A distributed microservices system designed for user authentication, book management, favorites tracking, and email notifications. Built using modern Python frameworks and tools like FastAPI, gRPC, PostgreSQL, RabbitMQ, and deployed with Docker and Kubernetes.
Layer | Technologies |
---|---|
Backend | Python, FastAPI, SQLAlchemy, gRPC, JWT, Pydantic, Alembic |
Messaging | RabbitMQ (Publisher/Consumer) |
Database | PostgreSQL, Redis |
Container | Docker, Docker Compose |
Orchestration | Kubernetes (k3s), Ingress (Traefik or NGINX), Helm (optional) |
Others | Git, Uvicorn, Pydantic, AsyncIO |
- Handles user registration, login, JWT authentication.
- Technologies: FastAPI, Redis (refresh tokens), RabbitMQ (user registration events).
- gRPC Server: Provides user data to Favorites Service.
- Handles book listing and details.
- gRPC Server: Serves book details to Favorites Service.
- Allows users to mark books as favorites.
- gRPC Client: Fetches user and book data via Auth and Books services.
- Uses PostgreSQL for storage.
- Consumes user registration messages from RabbitMQ.
- Sends confirmation emails asynchronously.
books-microservices/ ├── 📁k8s/ │ └── ... # Kubernetes manifests ├── 📁services/ │ ├── 🔐auth_service/ # Authentication microservice │ ├── 📚books_service/ # Books management microservice │ ├── ❤️favorites_service/ # User favorites microservice │ └── 📧email_service/ # Email notifications microservice ├── docker-compose.yaml # Local development setup └── README.md
git clone https://github.com/your-username/books-microservices.git
cd books-microservices
docker build -t auth_service_image:latest ./services/auth_service docker build -t books_service_image:latest ./services/books_service docker build -t favorites_service_image:latest ./services/favorites_service docker build -t email_service_image:latest ./services/email_service
kubectl apply -f k8s/
Example endpoint: http://localhost/auth/health http://localhost/books http://localhost/favorites
🔌 API Endpoints
Service | Path | Method | Description |
---|---|---|---|
Auth Service | /auth/register |
POST | Register user |
/auth/login |
POST | Login user | |
Books Service | /books |
GET | List books |
Favorites | /favorites |
GET | Get favorites by user |
Email Service | (Internal, RabbitMQ) | — | Receives registration events |
📬 Message Flow Example User registers via Auth Service.
Auth publishes an event to RabbitMQ.
Email Service consumes the event and sends email.
Favorites Service pulls user info via gRPC from Auth Service.
🔐 Auth Flow JWT Access Token (short-lived)
Refresh Token stored in Redis
Built-in security utilities for route protection
🧪 Testing & Dev Run locally with Docker Compose (optional)
Unit tests via Pytest
Postman collection available soon
📘 Demo & Code Samples 📂 Check out sample code and mini version of this system [coming soon].
👨💻 Author Ali Sajadian 📧 [sajadian.ali@gmail.com] 🔗 GitHub 🧠 Python & Nest.js & .NET / Next.js Full-Stack Developer
📄 License This project is licensed under the MIT License - see the LICENSE file for details.
- Replace
https://github.com/your-username/books-microservices.git
with your real GitHub URL. - Add your contact info and links in the footer.
- (Optional) Include a diagram or architecture image (can generate if needed).
Would you like me to create a microservices architecture diagram to include in this README?