https://github.com/the-sabra/addnet
addNet
https://github.com/the-sabra/addnet
distributed-systems grpc microservices rest-api rpc
Last synced: about 2 months ago
JSON representation
addNet
- Host: GitHub
- URL: https://github.com/the-sabra/addnet
- Owner: the-sabra
- Created: 2025-04-13T11:11:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-14T14:36:04.000Z (about 1 year ago)
- Last Synced: 2025-04-14T20:19:22.968Z (about 1 year ago)
- Topics: distributed-systems, grpc, microservices, rest-api, rpc
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AddNet - Distributed Microservice Application
[](https://golang.org/)
[](https://bun.sh/)
[](https://www.rabbitmq.com/)
[](https://prometheus.io/)
[](https://grafana.com/)
AddNet is a distributed microservice application demonstrating communication between services using gRPC and RabbitMQ message queuing, inspired by [Eng Ahmed El Taweel video](https://youtu.be/Ur6b1NWGbYE?si=54EkJ_Avy5QT-YGF).
## System Architecture

The application consists of two main services:
- **Service A** (Go): A gRPC server that provides an addition operation and forwards results to RabbitMQ
- **Service B** (TypeScript/Bun): A consumer that reads messages from RabbitMQ, adds the new value to an existing total, saves the updated value to a file, and exposes an HTTP endpoint to retrieve the latest result
### Communication Flow
1. Client makes gRPC request to Service A with two numbers
2. Service A adds numbers and returns result
3. Service A sends result to RabbitMQ queue
4. Service B consumes messages and persists results
5. Latest result available via Service B's HTTP endpoint
## Features
- **Reliable Messaging**: Outbox pattern ensures message delivery
- **Monitoring**: Prometheus metrics and Grafana dashboard
- **Load Testing**: k6 test scripts included
- **Containerized**: Docker Compose for easy deployment
- **Multi-language**: Go and TypeScript services
## Monitoring

## Prerequisites
- Docker and Docker Compose
- Go 1.24+
- Bun 1.2.9+ (for Service B)
- gRPC tools (for development)
## Getting Started
### Running with Docker Compose
```bash
docker-compose up --build
```
This will start:
- Service A (gRPC server on port 50051)
- Service B (HTTP server on port 2113)
- RabbitMQ (management UI on port 15672)
- PostgreSQL database
- Prometheus (on port 9090)
- Grafana (on port 3000)
### Accessing Services
- **Service A gRPC**: `localhost:50051`
- **Service B HTTP**: `http://localhost:2113/latest`
- **RabbitMQ Management**: `http://localhost:15672` (guest/guest)
- **Prometheus**: `http://localhost:9090`
- **Grafana**: `http://localhost:3000` (admin/grafana)
## Development
### Service A (Go)
```bash
cd service_a
go run cmd/server/main.go
```
### Service B (TypeScript)
```bash
cd service_b
bun install
bun run index.ts
```
### Regenerating gRPC Code
After modifying `addition.proto`:
```bash
cd service_a
protoc --go_out=. --go-grpc_out=. internal/proto/addition.proto
```
## Testing
### Load Testing with k6
**gRPC Test (Service A):**
```bash
k6 run service_a/k6_grpc_test.js
```
**REST Test (Service B):**
```bash
k6 run service_b/k6_rest_test.js
```
## Monitoring
The project includes preconfigured Grafana dashboards showing:
- Request latency
- Throughput
- Error rates
- Queue delivery metrics
## Project Structure
```
the-sabra-addnet/
├── service_a/ # Go gRPC service
│ ├── cmd/ # Application entry points
│ ├── internal/ # Internal application code
│ └── proto/ # Protocol Buffer definitions
├── service_b/ # TypeScript consumer service
├── prometheus/ # Prometheus configuration
└── grafana/ # Grafana dashboards and datasources
```
## Acknowledgments
This project was inspired by Eng Ahmed El Taweel excellent tutorial on building distributed systems. Check out his [original video](https://youtu.be/Ur6b1NWGbYE?si=54EkJ_Avy5QT-YGF) for more insights into microservice architecture.