This project is a microservices-based backend for an Android e-commerce store, built using Node.js and Express. It follows a distributed architecture with multiple services handling different business logic. An API Gateway is used to centralize requests, and RabbitMQ facilitates communication between services asynchronously.(Project is still under development)
- User Service: Manages user authentication, registration, and profile handling.
- Product Service: Handles product listing, details, and inventory management.
- API Gateway: Acts as the entry point, routing client requests to the respective services.
- RabbitMQ: Used as a message broker to enable event-driven communication between services.
- Node.js & Express – Backend framework for all microservices.
- RabbitMQ – Message broker for inter-service communication.
- MongoDB – Database for storing users and products.
- JWT (JSON Web Tokens) – Authentication and authorization.
- Docker – Containerization for easy deployment.
- Redis (Optional) – Can be used for caching user sessions or product data.
- User registration & authentication (JWT-based).
- Profile management (update user details, change password).
- Secure password hashing using bcrypt.
- Create, update, delete, and fetch products.
- Inventory management (track stock levels).
- Searching and filtering products.
- Centralized entry point for all client requests.
- Validates JWT tokens for authentication.
- Routes requests to the appropriate microservice.
- User Service → Product Service: Notify when a user registers.
- Product Service → User Service: Notify users about new product arrivals or stock updates.
- Node.js (>= 14.x)
- MongoDB (local or cloud)
- RabbitMQ (running locally or in Docker)
- Docker (optional)
-
Clone the repository
git clone https://github.com/yourusername/ecommerce-microservices.git cd ecommerce-microservices -
Set up environment variables
Create a.envfile for each service (user-service/.env,product-service/.env,api-gateway/.env) with the following keys:# Example for User Service PORT=5001 MONGODB_URI=mongodb://localhost:27017/users JWT_SECRET=your_jwt_secret RABBITMQ_URI=amqp://localhost
-
Install dependencies for each service
cd user-service && npm install cd ../product-service && npm install cd ../api-gateway && npm install
-
Start RabbitMQ (if using Docker)
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:management
-
Start the microservices
Open separate terminals and run:cd user-service && npm run dev cd ../product-service && npm run dev cd ../api-gateway && npm run dev
| Method | Endpoint | Description |
|---|---|---|
| POST | /register |
Register a new user |
| POST | /login |
Authenticate user and return JWT |
| GET | /profile |
Get user profile (Requires JWT) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /products |
Fetch all products |
| POST | /products |
Add a new product (Admin only) |
| GET | /products/:id |
Get product details |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/users/register |
Proxy to User Service |
| GET | /api/products |
Proxy to Product Service |
- Order & Payment Service: Handle checkout and payments.
- Admin Panel: Dashboard for managing products and users.
- Notifications Service: Send push notifications and emails.
This project is licensed under the MIT License.