Skip to content

rajan-goswami/cloud-audition-project

Repository files navigation

Cloud Audition Project

Introduction

In this project, a sample microservice is developed in Node.JS, which manages messages and provides details about those messages, specifically whether or not a message is a palindrome. This microservice uses MongoDB database for storing messages and it is packaged using docker.

Table of Contents

High-level features

Architecture

Architecture image created using https://c4model.com/

Prerequisites

  • Node.JS > 12.0.0
  • Docker Desktop (for Mac and Windows) / Docker Engine (for Linux)

Commands

Testing:

# run all tests
npm run docker:test

To run locally:

npm run docker:dev

Linting:

# run ESLint
npm run lint

# fix ESLint errors
npm run lint:fix

Cleanup:

docker-compose down

Environment Variables

The environment variables can be found in the .env file. Following environment variables are defined:

# Port number
PORT=3000

Project Structure

src\
 |--config\         # configurations
 |--controllers\    # Route controllers (controller layer)
 |--docs\           # Swagger files
 |--middlewares\    # Custom express middlewares
 |--models\         # Mongoose models (data layer)
 |--routes\         # Routes
 |--services\       # Business logic (service layer)
 |--utils\          # Utility classes and functions
 |--validations\    # Request data validation schemas
 |--app.js          # Express app
 |--server.js       # App entry point

API Documentation

To view the list of available APIs and their specifications, run the server and go to http://localhost:3000/v1/docs in your browser. This documentation page is automatically generated using the swagger definitions written as comments in the route files.

API Endpoints

POST /v1/messages - create a message
GET /v1/messages - get all messages and associated information about messages
GET /v1/messages/:messageId - get a message
PATCH /v1/messages/:messageId - update a message
DELETE /v1/messages/:messageId - delete a message

Future scope

  • Deployment on minikube for local testing
  • CD pipeline
  • Setup monitoring and alerting of service using prometheus and grafana
  • API security
  • Load testing using k6