Skip to content
Aditya Pratap Bhuyan edited this page Jan 4, 2025 · 1 revision

Distributed Microservices Platform

Welcome to the Distributed Microservices Platform Wiki!

This Wiki serves as a comprehensive guide to understand, set up, and contribute to the Distributed Microservices Platform. It provides detailed information about the architecture, folder structure, setup, and functionality of the platform.


Table of Contents

  1. [Project Overview](#project-overview)
  2. [Architecture](#architecture)
  3. [Folder Structure](#folder-structure)
  4. [Setup Instructions](#setup-instructions)
  5. [Technology Stack](#technology-stack)
  6. [Features](#features)
  7. [Contributing](#contributing)
  8. [License](#license)

Project Overview

The Distributed Microservices Platform demonstrates a modular, scalable, and fault-tolerant architecture using microservices. It includes services for user management, inventory, payments, notifications, and more. These services communicate via gRPC and a message broker for asynchronous communication.

Key Highlights:

  • Scalable microservices architecture.
  • Resilient inter-service communication.
  • Centralized observability with logs and tracing.
  • Dockerized deployment for easy setup.

Architecture

High-Level Design

The system consists of the following key components:

  • API Gateway: Acts as the single entry point for all client requests.
  • User Service: Manages user-related functionalities like authentication and profile management.
  • Inventory Service: Manages product catalog and stock levels.
  • Payment Service: Handles financial transactions and payment gateway integrations.
  • Notification Service: Delivers notifications via email, SMS, or push notifications.
  • Message Broker (RabbitMQ/Kafka): Facilitates communication between services.
  • Service Discovery: Enables dynamic service registration and discovery.

Architecture Diagram

Communication:

  • gRPC: Used for synchronous communication between services.
  • Message Broker: Used for asynchronous communication (e.g., RabbitMQ, Kafka).

Folder Structure

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

Setup Instructions

Prerequisites

  • Node.js (16.x or higher)
  • Docker and Docker Compose
  • RabbitMQ or Kafka
  • MongoDB/PostgreSQL
  • gRPC Tools

Steps

  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:

    NODE_ENV=development
    SERVICE_PORT=5000
    DB_CONNECTION_STRING=mongodb://localhost:27017/service-name
    MESSAGE_BROKER_URL=amqp://localhost
    
  4. Run the Application Use Docker Compose to start all services:

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


Technology Stack

  • Node.js: Core runtime for services.
  • gRPC: Inter-service communication.
  • RabbitMQ/Kafka: Message brokering.
  • MongoDB/PostgreSQL: Database for individual services.
  • Docker: Containerization.
  • Docker Compose: Multi-container orchestration.

Features

  1. Service discovery for dynamic registration.
  2. Fault-tolerant communication using circuit breakers and retries.
  3. Centralized logging and tracing for observability.
  4. Modular design for easy extensibility.
  5. Asynchronous and synchronous communication models.

Contributing

We welcome contributions to improve this project! Follow these steps to contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with a clear description.

License

This project is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html).


Maintainer

This project is maintained by [Aditya Pratap Bhuyan](https://linkedin.com/in/adityabhuyan).