Skip to content

Commit ee60106

Browse files
committed
docs(readme.md): updated README.md to elaborate how the whole structure works for MicroStream
1 parent b0db1b6 commit ee60106

File tree

1 file changed

+66
-10
lines changed

1 file changed

+66
-10
lines changed

README.md

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ License: [MIT](./LICENSE)
4242

4343
## Table of Contents 📚
4444

45-
- [Features ✨](#features-✨)
46-
- [Installation 🛠️](#installation-🛠️)
47-
- [Usage 🚀](#usage-🚀)
48-
- [Configuration Options ⚙️](#configuration-options-⚙️)
49-
- [Log Levels 📊](#log-levels-📊)
50-
- [MicroStream Hub 🏢](#microstream-hub-🏢)
51-
- [Author 👨‍💻](#author-👨‍💻)
52-
- [Contributing 🤝](#contributing-🤝)
53-
- [License 📜](#license-📜)
45+
- [Features ✨](#features-)
46+
- [How Does It Work? 🌟](#how-does-it-work-)
47+
- [Installation 🛠️](#installation-)
48+
- [Usage 🚀](#usage-)
49+
- [Configuration Options ⚙️](#configuration-options-)
50+
- [Log Levels 📊](#log-levels-)
51+
- [MicroStream Hub 🏢](#microstream-hub-)
52+
- [Author 👨‍💻](#author-)
53+
- [Contributing 🤝](#contributing-)
54+
- [License 📜](#license-)
5455

5556
<hr>
5657

@@ -67,6 +68,61 @@ License: [MIT](./LICENSE)
6768

6869
<hr>
6970

71+
## How Does It Work? 🌟
72+
73+
**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.
74+
75+
Here's how it works:
76+
77+
### 🌟 The Star Network Concept
78+
79+
Imagine a star:
80+
81+
- The **center of the star** is the **[MicroStream Hub](https://github.com/arijitcodes/microstream-hub)**.
82+
- The **points of the star** are your **microservices** (each equipped with the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**).
83+
84+
![MicroStream Star Network Diagram](https://mermaid.ink/svg/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBIdWJbTWljcm9TdHJlYW0gSHViXSAtLT4gU2VydmljZTFbU2VydmljZSAxXVxuICAgIEh1YiAtLT4gU2VydmljZTJbU2VydmljZSAyXVxuICAgIEh1YiAtLT4gU2VydmljZTNbU2VydmljZSAzXVxuICAgIEh1YiAtLT4gU2VydmljZTRbU2VydmljZSA0XVxuICAgIEh1YiAtLT4gU2VydmljZTVbU2VydmljZSA1XVxuIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQiLCJsaW5lV2lkdGgiOiIzIn19)
85+
86+
In this setup:
87+
88+
- The **Hub** acts as the central communication point.
89+
- **Services** (nodes) connect to the Hub and communicate through it, **not directly with each other**.
90+
91+
### 🚀 How It Works in Practice
92+
93+
1. **Service Registration**:
94+
95+
- Each microservice connects to the Hub using the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**.
96+
- The **[Hub](https://github.com/arijitcodes/microstream-hub)** automatically detects and registers the service.
97+
98+
2. **Request-Response Communication in Real-Time**:
99+
100+
- When **Service A** needs to talk to **Service B**, it sends a request to the **[Hub](https://github.com/arijitcodes/microstream-hub)**.
101+
- The **[Hub](https://github.com/arijitcodes/microstream-hub)** routes the request to **Service B**.
102+
- **Service B** processes the request and sends a response back through the **[Hub](https://github.com/arijitcodes/microstream-hub)**.
103+
- All communication happens in **real-time** over WebSockets, ensuring fast and reliable data exchange.
104+
105+
3. **Auto-Discovery**:
106+
107+
- 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.
108+
109+
4. **Heartbeat Mechanism**:
110+
- Services send regular "heartbeats" to the **[Hub](https://github.com/arijitcodes/microstream-hub)** to confirm they’re active.
111+
- If a service stops sending heartbeats, the **[Hub](https://github.com/arijitcodes/microstream-hub)** removes it from the network.
112+
113+
### ✨ Why Choose MicroStream?
114+
115+
**MicroStream** is designed to make microservice communication **simple**, **efficient**, and **scalable**. Here’s why you’ll love it:
116+
117+
- **Easy Setup**: Minimal configuration required to get started.
118+
- **Real-Time Request-Response Communication**: Built on WebSockets for instant, reliable data exchange.
119+
- **Auto-Service-Management**: Once connected, the **[Hub](https://github.com/arijitcodes/microstream-hub)** keeps track of all services, simplifying network management.
120+
- **Scalable**: Easily add more services without reconfiguring the network.
121+
- **Lightweight**: Minimal overhead compared to traditional REST or gRPC.
122+
- **Flexible**: Works seamlessly with any microservice architecture.
123+
124+
<hr>
125+
70126
## Installation 🛠️
71127

72128
```bash
@@ -102,7 +158,7 @@ console.log("Received response:", response);
102158

103159
### Explanation
104160

105-
1. **Configuration**: The [`MicrostreamClient`](#microstreamclientoptions) is configured with the URL of the Microstream Hub, the name of your service, and the log level.
161+
1. **Configuration**: The [`MicrostreamClient`](#microstreamclientoptions) is configured with the URL of the [Microstream Hub](#microstream-hub-), the name of your service, and the log level.
106162
2. **Registering Handlers**: The `onRequest` method is used to register a handler for incoming requests. In this example, the handler responds to an "authenticate" event.
107163
- **Parameters**:
108164
- `event`: The event name to listen for.

0 commit comments

Comments
 (0)