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.
- User Service: Handles user registration, authentication, and profile management. User Service README
- Product Service: Manages products, including creation, inventory updates, and deletion. Product Service README
- Order Service: Manages the creation and processing of orders. Order Service README
- 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.
- Docker: Ensure Docker and Docker Compose are installed.
- Clone the repository:
git clone https://github.com/UtkarshAhuja2003/ecommerce.git
cd ecommerce- 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- Set up Docker containers for services, databases, redis, proxy and message queue:
docker-compose up --build- Access the services:
User Service: http://localhost/user
Product Service: http://localhost/product
Order Service: http://localhost/order
A Postman collection is provided to test the API endpoints for user, product, and order management.
- 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.
- 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.
├── .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