Skip to content

A microservices-based system with services for user management, inventory, payments, and notifications. Includes service discovery, circuit breakers, and gRPC communication.

License

Notifications You must be signed in to change notification settings

opensource-nodejs/distributed-microservices-platform

Repository files navigation

Distributed Microservices Platform

Project Overview

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.


Features

  • 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.

Architecture

High-Level Architecture

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.

Folder Structure

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

Prerequisites

  • 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)

Setup Instructions

  1. Clone the Repository

    git clone https://github.com/opensource-nodejs/distributed-microservices-platform.git
    cd distributed-microservices-platform
    
  2. Install Dependencies Navigate to each service folder and install dependencies:

    cd user-service
    npm install
    cd ../inventory-service
    npm install
    # Repeat for all services
    
  3. 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
    
  4. Start Services Use Docker Compose to start all services together:

    docker-compose up
    
  5. Access the API Gateway The API Gateway will be available at http://localhost:3000.


Contributing

We welcome contributions! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with detailed changes.

License

This project is licensed under the GNU General Public License v3.0. Read more about the license here.


Maintainer

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!

About

A microservices-based system with services for user management, inventory, payments, and notifications. Includes service discovery, circuit breakers, and gRPC communication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published