https://github.com/arijitcodes/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.
https://github.com/arijitcodes/microstream-hub
ipc message-broker microservices microstream microstream-hub nodejs real-time service-discovery service-mesh service-registry socket-io typescript
Last synced: 12 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/arijitcodes/microstream-hub
- Owner: arijitcodes
- License: mit
- Created: 2025-02-27T18:43:32.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-25T19:41:21.000Z (2 months ago)
- Last Synced: 2025-03-25T20:36:25.369Z (2 months ago)
- Topics: ipc, message-broker, microservices, microstream, microstream-hub, nodejs, real-time, service-discovery, service-mesh, service-registry, socket-io, typescript
- Language: JavaScript
- Homepage:
- Size: 668 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](#author)
License: [MIT](./LICENSE)[](https://github.com/arijitcodes/microstream-hub) Β Β
[](https://github.com/arijitcodes/microstream-hub/blob/main/LICENSE) Β
[](https://github.com/arijitcodes/microstream-hub) Β
[](https://github.com/arijitcodes/microstream-hub) Β
[](https://github.com/arijitcodes/microstream-hub/commits/main) Β[](https://github.com/arijitcodes/microstream-hub/graphs/contributors) Β
[](https://github.com/arijitcodes/microstream-hub/pulls) Β
[](https://github.com/arijitcodes/microstream-hub/issues) Β
[](https://github.com/arijitcodes/microstream-hub) Β
[](https://github.com/arijitcodes/microstream-hub) Β[](https://github.com/semantic-release/semantic-release) Β
[](https://commitizen.github.io/cz-cli/) Β
[](https://www.conventionalcommits.org) Β
## Table of Contents π
- [Features β¨](#features-)
- [How Does It Work? π](#how-does-it-work-)
- [Deployment π](#deployment-)
- [Client SDK π](#client-sdk-)
- [Author π¨βπ»](#author-)
- [Contributing π€](#contributing-)
- [License π](#license-)
## 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](https://github.com/arijitcodes/microstream-hub)** acts as the central communication point, and your microservices, equipped with the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**, connect to the Hub and communicate through it.
Here's how it works:
### π The Star Network Concept
Imagine a star:
- The **center of the star** is the **[MicroStream Hub](https://github.com/arijitcodes/microstream-hub)**.
- The **points of the star** are your **microservices** (each equipped with the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**).
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](https://github.com/arijitcodes/microstream-client)**.
- The **[Hub](https://github.com/arijitcodes/microstream-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](https://github.com/arijitcodes/microstream-hub)**.
- The **[Hub](https://github.com/arijitcodes/microstream-hub)** routes the request to **Service B**.
- **Service B** processes the request and sends a response back through the **[Hub](https://github.com/arijitcodes/microstream-hub)**.
- All communication happens in **real-time** over WebSockets, ensuring fast and reliable data exchange.3. **Auto-Discovery**:
- Once connected, the **[Hub](https://github.com/arijitcodes/microstream-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](https://github.com/arijitcodes/microstream-hub)** to confirm theyβre active.
- If a service stops sending heartbeats, the **[Hub](https://github.com/arijitcodes/microstream-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](https://github.com/arijitcodes/microstream-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 π³
```bash
docker compose up --build
```To change the port in Docker Compose, you can set the `PORT` environment variable in the `docker-compose.yml` file:
```yaml
version: "3.8"
services:
microstream-hub:
build: .
ports:
- "${PORT:-3000}:3000"
environment:
- PORT=3000
restart: unless-stopped
```### Running Locally πββοΈ
#### Installation π οΈ
```bash
npm install
```#### Running the Hub
```bash
node src/hub.js
```#### Configuration Example
To change the port, you can set the `PORT` environment variable:
```bash
PORT=4000 node src/hub.js
```
## Client SDK π
We provide a client SDK for easy integration with the MicroStream Hub.
- [MicroStream Client SDK on npm](https://www.npmjs.com/package/microstream-client)
- [MicroStream Client SDK Repository](https://github.com/arijitcodes/microstream-client)
## Author π¨βπ»
Author: [Arijit Banerjee](https://www.github.com/arijitcodes)
About: Full Stack Web Developer | Cyber Security Enthusiast | Actor
Social Media: Β
[ Instagram](https://www.instagram.com/arijit.codes)
Β
[ LinkedIn](https://www.linkedin.com/in/arijitban)
Β
[ GitHub](https://github.com/arijitcodes)
Β
[ Website](https://iamarijit.dev)Email: [email protected]
## Contributing π€
We welcome contributions! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
## License π
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.