Skip to content

UtkarshAhuja2003/Synkro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservices Backend System

This system consists of three isolated microservices for user management, product management, and order processing. These services communicate asynchronously using a message queue for state management and are routed through Nginx to provide unified access to each microservice.

Open in Gitpod

Microservices:

System Features:

  • Event-Driven Architecture: Services communicate via events ("User Registered", "Order Placed").
  • JWT Authentication: Secure access to protected routes in the User and Order services.
  • Caching: Implemented for frequently queried data to optimize performance.
  • Asynchronous Communication: Queue-based event system ensures state consistency across services.
  • NGINX Reverse Proxy: NGINX is used to route requests to the appropriate microservice, providing a single access point for the User, Product, and Order services (/user, /product, /order).

Github Actions: This project uses GitHub Actions for continuous integration (CI) to automate project building with every commit.

Prerequisites:

  • Docker: Ensure Docker and Docker Compose are installed.

Installation

  1. Clone the repository:
git clone https://github.com/UtkarshAhuja2003/ecommerce.git
cd ecommerce
  1. Copy environment files: For each service, navigate to the service directory and copy the .env.sample to .env.
cd services/users
cp .env.sample .env

cd ../products
cp .env.sample .env

cd ../orders
cp .env.sample .env
  1. Set up Docker containers for services, databases, redis, proxy and message queue:
docker-compose up --build
  1. Access the services:

User Service: http://localhost/user
Product Service: http://localhost/product
Order Service: http://localhost/order

API Documentation

A Postman collection is provided to test the API endpoints for user, product, and order management.

Postman Collection: 🚀 Postman Collection

Tech Stack

  • Node.js: Backend services for user, product, and order management.
  • Apollo Server: GraphQL API implementation.
  • MongoDB: Database for managing persistent data.
  • Redis: Cache for optimized performance.
  • RabbitMQ: Messaging service for inter-service communication.
  • Nginx: Proxy server for routing requests.
  • Docker: Containerization of all services.
  • Gitpod: Cloud-based development environment.

Key Dependencies

  • Apollo Server: Implements a GraphQL API to handle queries and mutations across microservices.
  • Amqplib: Facilitates interaction with RabbitMQ for message queuing.
  • Bcrypt.js: Used for password hashing and security.
  • Express: Web framework for building APIs and handling HTTP requests.
  • JSON Web Token (JWT): Handles authentication and authorization.

Project Structure

├── .github/ # Github actions
├── docker-compose.yml 
├── proxy/ # Nginx proxy
│   ├── Dockerfile
├── services/
│   ├── users/
│   │   ├── src/
│   │   │   ├── config/ # Database, Message Queue, Redis connection
│   │   │   ├── middlewares/
│   │   │   ├── models/ # Database schema
│   │   │   ├── resolvers/ # Handles GraphQL queries and mutations.
│   │   │   ├── schemas/ GraphQL schemas
│   │   │   ├── utils/
│   │   │   ├── apollo.js # Apollo Server
│   │   │   ├── app.js
│   │   │   └── index.js
│   │   ├── tests/
│   │   ├── .env
│   │   ├── Dockerfile
│   │   └── package.json
│   ├── products/
│   │   ├── src/
│   │   │   ├── config/
│   │   │   ├── models/
│   │   │   ├── resolvers/
│   │   │   ├── schemas/
│   │   │   ├── utils/
│   │   │   ├── apollo.js
│   │   │   ├── app.js
│   │   │   └── index.js
│   │   ├── .env
│   │   ├── Dockerfile
│   │   └── package.json
│   ├── orders/
│   │   ├── src/
│   │   │   ├── config/
│   │   │   ├── models/
│   │   │   ├── resolvers/
│   │   │   ├── schemas/
│   │   │   ├── utils/
│   │   │   │   ├── cacheOrders.js
│   │   │   │   ├── getProducts.js
│   │   │   │   ├── inventoryUpdate.js
│   │   │   │   ├── orderStatus.js
│   │   │   │   └── verifyUser.js
│   │   │   ├── validator/
│   │   │   ├── apollo.js
│   │   │   ├── app.js
│   │   │   ├── constants.js
│   │   │   └── index.js
│   │   ├── .env
│   │   ├── Dockerfile
│   │   └── package.json
└── README.md

About

Microservices-based e-commerce system with GraphQL API and event-driven architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published