Skip to content

The central hub for MicroStream, a lightweight, real-time communication system for microservices. Routes messages between services, handles service discovery, and ensures seamless communication with WebSockets. Perfect for building scalable, event-driven architectures.

License

Notifications You must be signed in to change notification settings

arijitcodes/microstream-hub

Repository files navigation

MicroStream Hub 🏢

The central hub for Microstream, a lightweight, real-time communication system for microservices. Routes messages between services, handles service discovery, and ensures seamless communication with WebSockets. Perfect for building scalable, event-driven architectures.

Author: Arijit Banerjee
License: MIT

GitHub Repository Link   

GitHub License   GitHub language count   GitHub top language   GitHub last commit (branch)  

GitHub contributors   GitHub pull requests   GitHub issues   GitHub repo size   GitHub code size  

Semantic-Release Badge   Commitizen Friendly   Conventional Commits Badge  


Table of Contents 📚


Features ✨

  • 🏢 Central WebSocket server for real-time communication between microservices.
  • 🔗 Service discovery and registration.
  • 📡 Request routing and response handling.
  • ❤️ Heartbeat mechanism to detect and remove inactive services.
  • 📊 Configurable logging for better observability.
  • 🔄 Real-time inter-service communication using WebSockets.
  • ⚡ Synchronous request-response pattern without HTTP overhead.
  • 🔍 Auto-discovery and connection management.

How Does It Work? 🌟

MicroStream simplifies communication between microservices using a centralized hub-and-spoke architecture, also known as a star network. In this model, the MicroStream Hub acts as the central communication point, and your microservices, equipped with the MicroStream Client, connect to the Hub and communicate through it.

Here's how it works:

🌟 The Star Network Concept

Imagine a star:

MicroStream Star Network Diagram

In this setup:

  • The Hub acts as the central communication point.
  • Services (nodes) connect to the Hub and communicate through it, not directly with each other.

🚀 How It Works in Practice

  1. Service Registration:

    • Each microservice connects to the Hub using the MicroStream Client.
    • The Hub automatically detects and registers the service.
  2. Request-Response Communication in Real-Time:

    • When Service A needs to talk to Service B, it sends a request to the Hub.
    • The Hub routes the request to Service B.
    • Service B processes the request and sends a response back through the Hub.
    • All communication happens in real-time over WebSockets, ensuring fast and reliable data exchange.
  3. Auto-Discovery:

    • Once connected, the Hub keeps track of all connected services, so you don’t need to manually configure connections between services. However, you still need to specify the target service and method when sending a request.
  4. Heartbeat Mechanism:

    • Services send regular "heartbeats" to the Hub to confirm they’re active.
    • If a service stops sending heartbeats, the Hub removes it from the network.

✨ Why Choose MicroStream?

MicroStream is designed to make microservice communication simple, efficient, and scalable. Here’s why you’ll love it:

  • Easy Setup: Minimal configuration required to get started.
  • Real-Time Request-Response Communication: Built on WebSockets for instant, reliable data exchange.
  • Auto-Service-Management: Once connected, the Hub keeps track of all services, simplifying network management.
  • Scalable: Easily add more services without reconfiguring the network.
  • Lightweight: Minimal overhead compared to traditional REST or gRPC.
  • Flexible: Works seamlessly with any microservice architecture.

Deployment 🚀

Running via Docker 🐳

docker compose up --build

To change the port in Docker Compose, you can set the PORT environment variable in the docker-compose.yml file:

version: "3.8"
services:
  microstream-hub:
    build: .
    ports:
      - "${PORT:-3000}:3000"
    environment:
      - PORT=3000
    restart: unless-stopped

Running Locally 🏃‍♂️

Installation 🛠️

npm install

Running the Hub

node src/hub.js

Configuration Example

To change the port, you can set the PORT environment variable:

PORT=4000 node src/hub.js

Client SDK 🚀

We provide a client SDK for easy integration with the MicroStream Hub.


Author 👨‍💻

Author: Arijit Banerjee

About: Full Stack Web Developer | Cyber Security Enthusiast | Actor

Social Media:   Instagram Instagram   Linkedin LinkedIn   GitHub GitHub   Website Website

Email: arijit.codes@gmail.com


Contributing 🤝

We welcome contributions! Please see our CONTRIBUTING.md for guidelines on how to contribute to this project.


License 📜

This project is licensed under the MIT License. See the LICENSE file for details.


About

The central hub for MicroStream, a lightweight, real-time communication system for microservices. Routes messages between services, handles service discovery, and ensures seamless communication with WebSockets. Perfect for building scalable, event-driven architectures.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •