The Distributed Microservices Platform is a scalable, modular system designed to showcase microservices architecture in action. It includes core services such as User Management, Inventory, Payments, and Notifications. These services communicate via gRPC and message queues, leveraging service discovery, circuit breakers, and distributed tracing for enhanced reliability and observability.
This project serves as a practical example for developers looking to understand and implement microservices using Node.js.
- Service Discovery: Automatically locate services via a central registry.
- Inter-Service Communication: gRPC and message queues for efficient communication.
- Resilience: Circuit breakers and retries for fault tolerance.
- Observability: Centralized logging, metrics, and distributed tracing.
- Extensibility: Modular design for adding new services.
The system consists of multiple independent services that communicate asynchronously through a message broker. Each service has its own database to ensure loose coupling and autonomy.
- API Gateway: Entry point for client requests, routes traffic to appropriate services.
- User Service: Manages user authentication, profiles, and roles.
- Inventory Service: Handles product catalog and stock levels.
- Payment Service: Processes transactions and handles payment gateways.
- Notification Service: Sends emails, SMS, or push notifications to users.
- Message Broker: Facilitates communication between services (e.g., RabbitMQ or Kafka).
- Service Discovery: Ensures that services can locate and communicate with each other dynamically.
Below is the suggested folder structure for the project:
distributed-microservices-platform/
├── api-gateway/
│ ├── src/
│ │ ├── routes/
│ │ ├── middlewares/
│ │ ├── controllers/
│ │ ├── services/
│ │ └── app.js
│ ├── package.json
│ └── README.md
├── user-service/
│ ├── src/
│ │ ├── controllers/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── services/
│ │ └── app.js
│ ├── package.json
│ └── README.md
├── inventory-service/
│ ├── src/
│ │ ├── controllers/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── services/
│ │ └── app.js
│ ├── package.json
│ └── README.md
├── payment-service/
│ ├── src/
│ │ ├── controllers/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── services/
│ │ └── app.js
│ ├── package.json
│ └── README.md
├── notification-service/
│ ├── src/
│ │ ├── controllers/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── services/
│ │ └── app.js
│ ├── package.json
│ └── README.md
├── shared/
│ ├── configs/
│ ├── middlewares/
│ ├── utils/
│ └── README.md
├── docker-compose.yml
├── .env
└── README.md
- Node.js (16.x or higher)
- Docker and Docker Compose
- RabbitMQ or Kafka for message brokering
- MongoDB/PostgreSQL (for service-specific databases)
- gRPC Tools (for generating service stubs)
-
Clone the Repository
git clone https://github.com/opensource-nodejs/distributed-microservices-platform.git cd distributed-microservices-platform
-
Install Dependencies Navigate to each service folder and install dependencies:
cd user-service npm install cd ../inventory-service npm install # Repeat for all services
-
Configure Environment Variables Create a
.env
file in the root directory and populate it with the required environment variables:NODE_ENV=development SERVICE_PORT=5000 DB_CONNECTION_STRING=mongodb://localhost:27017/user-service MESSAGE_BROKER_URL=amqp://localhost
-
Start Services Use Docker Compose to start all services together:
docker-compose up
-
Access the API Gateway The API Gateway will be available at
http://localhost:3000
.
We welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request with detailed changes.
This project is licensed under the GNU General Public License v3.0. Read more about the license here.
This project is maintained by Aditya Pratap Bhuyan.
This unified document includes all the necessary details about the project, from architecture to folder structure and setup instructions, while crediting the maintainer and providing relevant licensing information. Let me know if you’d like to enhance any section!