MicroBooks v2.0 is a production-grade, event-driven microservices system built with FastAPI, Next.js, and Apache Kafka. It features an automated CI/CD pipeline via GitHub Actions and a comprehensive observability stack. Containerized with Docker and Kubernetes-ready, it provides a robust, scalable environment for modern software development.
Modern Microservices-based bookstore management system using Apache Kafka for asynchronous communication, MongoDB Atlas for cloud storage, and integrated automated CI/CD pipelines for local deployment.
βββββββββββββββ REST API βββββββββββββββββββ
β Frontend βββββββββββββββββββΊβ order_service β
β (Next.js) β β (FastAPI:3001) β
β :3000 β REST API β β
β βββββββββ ββββββββββ¬ββββββββββ
βββββββββββββββ β β Publish
β βΌ
ββββββββ΄βββββββββ ββββββββββββββββ
β inventory_ ββββ€ Apache Kafka β
β service β β :9092 β
β (FastAPI:3002)β ββββββββ¬ββββββββ
βββββββββ¬ββββββββ β Monitor
β ββββββββΌββββββββ
β β Kafka UI β
β β :8080 β
βΌ ββββββββββββββββ
ββββββββββββββββ
β MongoDB Atlasβ
ββββββββββββββββ
Below is a detailed diagram of the operational flow, from code push to user interaction and automated monitoring:
graph TD
subgraph "1. Development & CI/CD (Automation)"
Dev[Developer] -- "Push Code" --> GH[GitHub Repository]
GH -- "Trigger" --> GHA[GitHub Actions]
GHA -- "Deploy" --> SHR[Self-hosted Runner]
SHR -- "docker-compose up" --> Docker[Docker Engine]
end
subgraph "2. Business Logic (Application Logic)"
User[User] -- "Place Order" --> Frontend[Next.js Frontend]
Frontend -- "POST /api/orders" --> OS[Order Service]
OS -- "Save Order" --> DB[(MongoDB Atlas)]
OS -- "Publish 'order_created'" --> Kafka{Apache Kafka}
Kafka -- "Receive Event" --> IS[Inventory Service]
IS -- "Update Stock" --> DB
end
subgraph "3. Monitoring & Observability"
OS & IS & Frontend -- "Metrics/Traces" --> OTel[OpenTelemetry Collector]
OTel -- "Metrics" --> Prom[Prometheus]
OTel -- "Traces" --> Tempo[Tempo]
Docker -- "Logs" --> Promtail[Promtail]
Promtail -- "Logs" --> Loki[Loki]
Prom & Loki & Tempo -- "Dashboard" --> Grafana[Grafana]
Kafka -- "Monitor" --> KUI[Kafka UI]
end
%% Styling
style GH fill:#24292e,color:#fff
style Docker fill:#2496ed,color:#fff
style Kafka fill:#000,color:#fff
style DB fill:#47a248,color:#fff
style Grafana fill:#f46800,color:#fff
style GHA fill:#2088ff,color:#fff
| Component | Technology |
|---|---|
| Frontend | Next.js 15 (App Router), Tailwind CSS |
| Backend | Python 3.10+, FastAPI |
| Database | MongoDB Atlas (Cloud) |
| Message Broker | Apache Kafka & Zookeeper |
| Monitoring | Kafka UI (provectuslabs) |
| Infrastructure | Docker & Docker Compose |
| CI/CD | GitHub Actions (Self-hosted Runner) |
| Observability | OpenTelemetry + Prometheus + Grafana + Loki + Tempo |
For a comprehensive overview, detailed project reports, and presentation slides, please access our dedicated resources folder:
This folder contains:
- π Detailed Project Report (Architecture, Design Decisions, Implementation).
- π Presentation Slides for project demonstrations.
- π High-Resolution Diagrams of the system workflow and database schema.
- π Supplementary Technical Documentation.
MicroBooks/
βββ .github/workflows/ # CI/CD Workflows (Local Deployment)
βββ frontend/ # Next.js Frontend Application
βββ order_service/ # Order Management Service (Python)
βββ inventory_service/ # Inventory Management Service (Python)
βββ tests/ # Integration Tests
βββ docs/ # Design Documentation (PRD, Design)
βββ docs_self_host_runner/ # CI/CD Runner Configuration Docs
βββ k8s/ # Kubernetes Manifests (Kustomize)
β βββ base/ # Base configuration
βββ .env # Environment Variables
βββ README.mdThe system is integrated with a complete Automation workflow:
- Continuous Integration (CI): Automatically validates code and runs unit tests upon Pull Request or push to the
mainbranch. - Continuous Deployment (CD): Uses a GitHub Actions Self-hosted Runner installed directly on the local server.
- Upon successful CI, the Runner automatically executes
docker-compose pullanddocker-compose up -d. - Ensures the local environment is always synchronized with the latest code on GitHub without manual intervention.
- Upon successful CI, the Runner automatically executes
View details at: local-deploy.yml
# 1. Clone repo
git clone https://github.com/phatle224/micro_books.git
cd micro_books
# 2. Environment Configuration
cp .env.example .env
# Update MONGO_URI and DOCKER_HUB_USERNAME in .env
# 3. Launch
docker-compose up --build -dEnsure Kubernetes is enabled in Docker Desktop or Minikube.
# 1. Deploy the entire system
kubectl apply -k k8s/base
# 2. Wait until all Pods are in Running state
kubectl get pods -n microbooks -w
<p align="center">
<img src="image/readme/demo_k8s.png" width="49%" alt="Kubernetes Deployment Demo"/>
<img src="image/readme/k8s_pods.png" width="49%" alt="Kubernetes Pods Status"/>
</p>
# 3. Port-forward to access the Frontend (run in a separate terminal)
kubectl port-forward svc/frontend 3000:3000 -n microbooks
# 4. Stop and remove all resources
kubectl delete -k k8s/base| Service | URL | Description |
|---|---|---|
| Storefront | http://localhost:3000 | Shopping Interface |
| Admin Portal | http://localhost:3000/admin | System Administration |
| Kafka UI | http://localhost:8080 | Message Queue Monitoring |
| Order API Docs | http://localhost:3001/docs | Swagger UI (Order Service) |
| Inventory API Docs | http://localhost:3002/docs | Swagger UI (Inventory Service) |
# Terminal 1: Order Service
cd order-service
pip install -r requirements.txt
uvicorn app.main:app --port 3001 --reload
# Terminal 2: Inventory Service
cd inventory-service
pip install -r requirements.txt
uvicorn app.main:app --port 3002 --reload
# Terminal 3: Frontend
cd frontend
npm install
npm run devThe observability stack is pre-configured using OpenTelemetry + Prometheus + Grafana + Loki + Tempo.
- Order/Inventory services have OpenTelemetry enabled when running via Docker Compose.
- Metrics are pushed through the OpenTelemetry Collector and scraped by Prometheus.
- Logs are collected using Promtail (docker logs) and displayed via Loki.
- Traces are stored in Tempo and can be viewed in Grafana Explore..
You can access the admin portal to manage the bookstore, orders, and monitor Kafka:
- URL:
http://localhost:3000/admin/login - Username:
[email protected] - Password:
admin123
| Page | Description |
|---|---|
/admin |
General Dashboard |
/admin/books |
Book Inventory Management |
/admin/orders |
Order Management |
/admin/kafka |
Kafka Monitor (embedded Kafka UI) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/orders |
Get all orders |
| GET | /api/orders/{id} |
Get order details |
| POST | /api/orders |
Create new order |
| PATCH | /api/orders/{id} |
Update status |
| GET | /api/orders/stats/summary |
Order statistics (Admin) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
Get all books |
| GET | /api/books/{id} |
Get book details |
| POST | /api/books |
Add new book |
| PUT | /api/books/{id} |
Update book |
| DELETE | /api/books/{id} |
Delete book |
| GET | /api/books/categories |
Get book categories |
| GET | /api/books/stats/summary |
Inventory statistics (Admin) |
- Client creates an order β Order Service saves it to MongoDB Atlas.
- Order Service publishes an
order_createdevent to the Kafka topic. - Inventory Service subscribes to the topic and receives the event.
- Inventory Service automatically deducts stock for the corresponding book in MongoDB Atlas.
- All broker activity can be monitored real-time via Kafka UI at
localhost:8080or the/admin/kafkapage.
The system integrates Kafka UI for message flow observation:
- Brokers β View broker status, replicas, and partitions.
- Topics β Browse messages in the
order_createdtopic. - Consumer Groups β Monitor lag for the
inventory-service-group. - Schema Registry β Manage schemas (if applicable).
Kafka UI is embedded directly into the Admin page at
/admin/kafkaand can also be opened separately athttp://localhost:8080.
We provide an intuitive interface for users and developers to track event-driven flows:
- Kafka UI: Access at http://localhost:8080.
- Here you can view topics like
order_created, inspect message payloads, and monitor the status of Consumers (Inventory Service).
![]() |
![]() |
| Kiet Truong | Phat Le |
| Fullstack Dev & DevOps | Data Engineer & Backend |
Thank you for stopping by! Donβt forget to give this repo a βοΈ Star if you find it useful.















