You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A production-grade microservice quiz platform that probes your knowledge in Django, Microservices, Redis, RabbitMQ, Docker, Kubernetes, and Terraform.
Why this project? Most microservice tutorials stop at "two services talking over HTTP." This project implements the patterns you'd actually encounter in production: event-driven communication via RabbitMQ, database-per-service isolation, Redis-backed leaderboards with sorted sets, Celery task queues, Kubernetes orchestration with HPAs, and Terraform-managed AWS infrastructure — all wired together end-to-end.
Services communicate asynchronously through RabbitMQ using a topic exchange (knowledge_probe):
Event
Publisher
Consumer
Action
user.registered
User Service
Evaluation Service
Create user stats record
quiz.completed
Quiz Service
Evaluation Service
Score attempt, update leaderboard
score.calculated
Evaluation Service
User Service
Update user profile stats
leaderboard.updated
Evaluation Service
Quiz Service
Invalidate caches
Tech Stack
Layer
Technology
Backend
Python 3.11, Django 5.0, Django REST Framework
Auth
JWT (djangorestframework-simplejwt)
Database
PostgreSQL 15 (database-per-service)
Cache
Redis 7 (django-redis)
Message Broker
RabbitMQ 3.12 (pika)
Task Queue
Celery 5.3
API Gateway
Nginx 1.25
Containerization
Docker + Docker Compose
Orchestration
Kubernetes (Deployments, HPAs, Ingress)
Infrastructure
Terraform (AWS: EKS, RDS, ElastiCache, Amazon MQ)
Design Decisions
Decision
Alternatives Considered
Why This Approach
RabbitMQ for inter-service messaging
REST calls, gRPC, Kafka
Decouples services temporally — a service being down doesn't break others. Topic exchange enables flexible routing without point-to-point coupling. Kafka would be overkill for this event volume.
Database-per-service (3 PostgreSQL databases)
Shared database, schema-per-service
True data isolation — services can't accidentally couple through shared tables. Mirrors real production microservice boundaries and allows independent schema evolution.
Redis sorted sets for leaderboards
SQL ORDER BY queries, application-level sorting
O(log N) insert + O(log N + M) range queries vs O(N log N) for SQL. Leaderboard reads vastly outnumber writes — Redis gives sub-millisecond response times at scale.
JWT over session-based auth
Server-side sessions, OAuth2, API keys
Stateless authentication works across services without a shared session store. Each service independently validates tokens using the shared secret — no inter-service call needed for auth.
Celery for async task processing
Django signals, threading, Dramatiq
Production-grade task queue with retry logic, rate limiting, and monitoring. RabbitMQ broker already in the stack, so no additional infrastructure required.
Terraform modules per resource
Monolithic Terraform, CloudFormation, Pulumi
Module-per-resource enables reuse across environments. dev/ and prod/ use the same modules with different variable values, avoiding config drift.
Nginx API Gateway
Kong, Traefik, AWS ALB
Lightweight, battle-tested, and sufficient for path-based routing + rate limiting. No need for a full-featured API gateway at this scale.
# Run all tests
./scripts/run_tests.sh
# Run specific service tests
./scripts/run_tests.sh quiz
./scripts/run_tests.sh user
./scripts/run_tests.sh eval# Run tests directly
docker-compose exec quiz_service python manage.py test --verbosity=2
Kubernetes Deployment
# Deploy to cluster
./scripts/deploy_k8s.sh
# Check status
kubectl -n knowledge-probe get pods
kubectl -n knowledge-probe get services
# Delete everything
./scripts/deploy_k8s.sh --delete
Before deploying, update:
k8s/secrets.yaml — Replace base64 placeholders with real secrets
k8s/ingress.yaml — Update hostname and enable TLS
Build and push Docker images to your container registry
Terraform (AWS Infrastructure)
cd terraform/environments/dev
# Configure
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars# Deploy
terraform init
terraform plan
terraform apply
Infrastructure provisions:
VPC with public/private subnets, NAT Gateways, VPC endpoints
EKS cluster with managed node groups and IRSA
RDS PostgreSQL with encryption, backups, monitoring
ElastiCache Redis with encryption in transit/at rest
Amazon MQ RabbitMQ broker
Key Patterns Demonstrated
Microservice Patterns
Database per Service — Each service owns its data, enabling independent deployment and scaling
API Gateway — Single entry point with rate limiting, routing, and TLS termination
Event-Driven Architecture — Async communication via RabbitMQ prevents temporal coupling
CQRS-lite — Quiz service writes, Evaluation service reads/aggregates
A production-grade microservice quiz platform built with Django, PostgreSQL, Redis, RabbitMQ, Kubernetes, and Terraform — demonstrating real-world patterns like event-driven architecture, database-per-service isolation, and Infrastructure as Code.