Team FAT32
A highly scalable, event-driven donation platform built for the CUET API Avengers Microservice Hackathon 2025
- Overview
- Architecture
- Technologies Used
- Microservices
- Infrastructure Components
- Observability Stack
- Getting Started
- Kubernetes Deployment
- CI/CD Pipeline
- Demo Screenshots
- API Documentation
- System Features
CareForAll is a production-ready, cloud-native donation platform designed to handle:
- β High Traffic: 1000+ requests/second capacity
- β Event-Driven Architecture: Kafka-based asynchronous communication
- β Idempotent Operations: Reliable payment processing with webhook handling
- β Complete Observability: Distributed tracing, log aggregation, and metrics
- β Transparent Donation Tracking: Full donation lifecycle management
- β Scalable Design: Independent microservices with dedicated databases
βββββββββββββββ
β Frontend β
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway (8000) β
β β’ Authentication & Authorization (JWT) β
β β’ Rate Limiting & Circuit Breaking β
β β’ Request Routing & Load Balancing β
β β’ Distributed Tracing β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
βUser Service β β Campaign β β Donation β
β (8001) β β Service β β Service β
β β β (8002) β β (8004) β
β β’ Auth/JWT β β β β β
β β’ Profiles β β β’ CRUD ββββββ€ β’ Pledges β
β β’ Roles β β β’ gRPC βgRPCβ β’ FSM β
βββββββββββββββ βββββββββββββββ ββββββββ¬βββββββ
β
ββββββββββββββββββββββββββββ€
β β
βΌ βΌ
βββββββββββββββ βββββββββββββββ
β Payment β β Notificationβ
β Service β β Service β
β (8003) β β (8005) β
β β β β
β β’ Webhooks ββββββββββββΊβ β’ Events β
β β’ Banking β Kafka β β’ Alerts β
ββββββββ¬βββββββ βββββββββββββββ
β
βΌ
βββββββββββββββ
β Banking β
β Service β
β (8006) β
β β
β β’ Accounts β
β β’ Verify β
βββββββββββββββ
βββββββββββββββββββββββββββ
β Infrastructure β
βββββββββββββββββββββββββββ€
β Kafka + Zookeeper β
β PostgreSQL (per service)β
β Redis (caching) β
β Jaeger (tracing) β
β Loki + Promtail (logs) β
β Grafana (visualization) β
βββββββββββββββββββββββββββ
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Primary programming language |
| FastAPI | 0.104+ | High-performance async web framework |
| Uvicorn | Latest | ASGI server for production |
| Pydantic | 2.x | Data validation and settings management |
| Technology | Usage |
|---|---|
| PostgreSQL | 15-alpine - Dedicated database per service |
| Redis | 7-alpine - Caching, rate limiting, session storage |
| Technology | Purpose |
|---|---|
| Apache Kafka | Event streaming, async communication |
| Zookeeper | Kafka cluster coordination |
| Kafka UI | Web-based Kafka management |
- REST API: HTTP/JSON for synchronous communication
- gRPC: High-performance RPC between donation-service β campaign-service
- Kafka Events: Asynchronous event-driven messaging
| Tool | Purpose | Port |
|---|---|---|
| Jaeger | Distributed tracing | 16686 |
| Loki | Log aggregation | 3100 |
| Promtail | Log collection agent | - |
| Grafana | Metrics & logs visualization | 3000 |
| OpenTelemetry | Instrumentation SDK | - |
- Docker - Containerization
- Docker Compose - Multi-container orchestration
- GitHub Actions - CI/CD (future)
Role: Single entry point for all client requests
Responsibilities:
- π Authentication: JWT token validation
- π¦ Rate Limiting: Redis-based request throttling
- β‘ Circuit Breaking: Fault tolerance for downstream services
- π Load Balancing: Intelligent request distribution
- π Request Tracing: Distributed tracing with Jaeger
- ποΈ Service Registry: Dynamic service discovery
Tech Stack:
- FastAPI, Redis, OpenTelemetry, JWT
Key Features:
- Configurable rate limits per endpoint
- Automatic circuit breaking on service failures
- Request/Response logging with correlation IDs
- Health check aggregation
Role: User authentication and profile management
Database: userdb (PostgreSQL)
Responsibilities:
- π€ User Management: Registration, login, profile updates
- π Authentication: JWT token generation and validation
- π Role-Based Access: DONOR, CAMPAIGN_OWNER, ADMIN roles
- π User Profiles: Donor and campaign owner information
Tech Stack:
- FastAPI, SQLAlchemy, PostgreSQL, JWT, Bcrypt
API Endpoints:
POST /register - Create new user account
POST /login - Authenticate and get JWT token
GET /users/me - Get current user profile
PUT /users/me - Update user profile
GET /users/{id} - Get user by ID (admin)
Key Features:
- Password hashing with bcrypt
- JWT token with expiry
- Role-based authorization
- User session management
Role: Fundraising campaign management
Database: campaigndb (PostgreSQL)
Responsibilities:
- π’ Campaign CRUD: Create, read, update, delete campaigns
- π― Goal Tracking: Monitor fundraising goals and progress
- β Status Management: ACTIVE, PAUSED, COMPLETED, CANCELLED
- π gRPC Server: High-performance RPC endpoint for donation-service
Tech Stack:
- FastAPI, SQLAlchemy, PostgreSQL, gRPC, Redis (caching)
API Endpoints:
POST /campaigns - Create new campaign
GET /campaigns - List all campaigns (paginated)
GET /campaigns/{id} - Get campaign details
PUT /campaigns/{id} - Update campaign
DELETE /campaigns/{id} - Delete campaign
gRPC Methods:
rpc GetCampaign(CampaignRequest) returns (CampaignResponse);
rpc UpdateCampaignTotal(UpdateTotalRequest) returns (UpdateTotalResponse);Key Features:
- Redis caching for frequently accessed campaigns
- Real-time goal progress updates via gRPC
- Campaign owner verification
- Media attachments support
Role: Donation pledge and lifecycle management
Database: donation_db (PostgreSQL)
Responsibilities:
- π Donation Creation: Handle donation intents
- π State Machine: INITIATED β PENDING β AUTHORIZED β CAPTURED β COMPLETED/FAILED/REFUNDED
- π€ Event Publishing: Emit donation events to Kafka
- π₯ Event Consumption: Listen to payment events
- π gRPC Client: Communicate with campaign-service
Tech Stack:
- FastAPI, SQLAlchemy, PostgreSQL, AIOKafka, gRPC client
Kafka Topics:
- Produces:
donation_created- When new donation is initiated - Consumes:
payment.events- Payment verification results
API Endpoints:
POST /donations - Create new donation
GET /donations/{id} - Get donation details
GET /donations - List user donations
GET /campaigns/{id}/donations - List campaign donations
State Machine Flow:
INITIATED β payment verification request
β
PENDING β awaiting payment service
β
AUTHORIZED β payment verified
β
CAPTURED β funds debited
β
COMPLETED β
Key Features:
- Comprehensive emoji-based logging
- Automatic campaign total updates via gRPC
- Kafka-based async payment processing
- Donation history tracking
Role: Payment processing and banking integration
Database: payment_db (PostgreSQL)
Responsibilities:
- π³ Payment Verification: Validate payment requests
- π¦ Banking Integration: Communicate with banking-service
- π Idempotent Webhooks: Handle duplicate webhook deliveries
- π€ Event Publishing: Emit payment success/failure events
Tech Stack:
- FastAPI, SQLAlchemy, PostgreSQL, Confluent Kafka, HTTPx
Kafka Topics:
- Consumes:
donation_created- New donation events - Produces:
payment.events- Payment verification results
Payment Flow:
1. Consume donation_created event
2. Call banking-service to verify funds
3. Debit user account if sufficient balance
4. Publish payment.verified or payment.failed event
5. Update donation-service via Kafka
Key Features:
- Async payment processing
- Fund verification before debit
- Detailed transaction logging
- Webhook signature verification (future)
Role: Mock banking system for account operations
Database: banking_db (PostgreSQL)
Responsibilities:
- π° Account Management: Create and manage user accounts
- π΅ Balance Operations: Check balance, debit, credit
- β Transaction Validation: Verify sufficient funds
- π Transaction History: Track all account operations
Tech Stack:
- FastAPI, SQLAlchemy, PostgreSQL
API Endpoints:
POST /accounts - Create new account
GET /accounts/{id} - Get account details
POST /verify - Verify sufficient funds
POST /debit - Debit from account
POST /credit - Credit to account
GET /transactions/{account_id} - Get transaction history
Key Features:
- Thread-safe balance operations
- Transaction atomicity
- Audit trail for all operations
- Negative balance prevention
Role: Event-driven notification system
Database: notification_db (PostgreSQL)
Responsibilities:
- π§ Email Notifications: Send donation receipts (mocked)
- π± In-app Alerts: Store notifications for users
- π₯ Event Listening: Consume Kafka events
- π Real-time Updates: WebSocket support (future)
Tech Stack:
- FastAPI, SQLAlchemy, PostgreSQL, Confluent Kafka
Kafka Topics:
- Consumes:
payment.events- Payment verification results
Notification Types:
- Donation success confirmation
- Payment failure alerts
- Campaign milestone reached
- Campaign owner updates
Key Features:
- Async event processing
- Template-based notifications
- Notification history
- User preference management (future)
| Component | Purpose | Port |
|---|---|---|
| Zookeeper | Kafka cluster coordination | 2181 |
| Kafka Broker | Message streaming | 9092 |
| Kafka UI | Web-based management | 8080 |
Topics:
donation_created- New donation eventspayment.events- Payment verification results
Consumer Groups:
payment-service-group- Payment processingdonation-service-group- Donation status updatesnotification-service-group- Notification delivery
Each service has a dedicated PostgreSQL database for data isolation:
| Service | Database | Port |
|---|---|---|
| User | userdb |
5433 |
| Campaign | campaigndb |
5434 |
| Notification | notification_db |
5435 |
| Payment | payment_db |
5436 |
| Donation | donation_db |
5437 |
| Banking | banking_db |
5438 |
Benefits:
- Service autonomy
- Independent scaling
- Failure isolation
- Schema evolution flexibility
Purpose: Distributed caching and session management
Port: 6379
Use Cases:
- API Gateway rate limiting
- Campaign data caching
- Session storage
- Distributed locks
Port: 16686
Features:
- End-to-end request tracing
- Service dependency visualization
- Performance bottleneck identification
- gRPC call tracing
Access: http://localhost:16686
Loki Port: 3100
Features:
- Centralized log collection from all containers
- Label-based log filtering
- Real-time log streaming
- Long-term log retention (31 days)
Log Labels:
container_name- Service identifierservice- Service nameversion- Service versionlevel- Log level (INFO, ERROR, etc.)
Port: 3000
Credentials: admin/admin
Dashboards:
- CareForAll Logs Dashboard - Service-specific log panels
- Error Monitoring - Platform-wide error aggregation
- Trace-to-Log Correlation - Jump from traces to logs
Datasources:
- Loki (logs)
- Jaeger (traces)
Access: http://localhost:3000
- Docker Desktop (latest)
- Docker Compose (latest)
- 8GB+ RAM
- 20GB+ disk space
- Clone the repository
git clone https://github.com/sleepytmzd/fat32-api-avengers.git
cd fat32-api-avengers- Start all services
docker-compose up -d- Verify services are healthy
docker-compose ps- Access the platform
- API Gateway: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Jaeger UI: http://localhost:16686
- Kafka UI: http://localhost:8080
- Grafana: http://localhost:3000
For individual service development:
# User Service
cd user-service
pip install -r requirements.txt
uvicorn main:app --reload --port 8001
# Similar for other services...docker-compose downdocker-compose down -v
rm -rf data/The CareForAll platform is deployed on a production-grade Kubernetes cluster with enterprise features:
π― Key Features:
- β Horizontal Pod Autoscaling (HPA): Automatic scaling based on CPU/Memory utilization
- β TLS Termination: HTTPS encryption with Let's Encrypt certificates
- β Ingress Controller: NGINX ingress for intelligent routing
- β StatefulSets: For Kafka, Zookeeper, and PostgreSQL databases
- β Persistent Volumes: Durable storage for databases and logs
- β Resource Limits: CPU/Memory limits per service
- β Health Checks: Liveness and readiness probes
- β Rolling Updates: Zero-downtime deployments
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DigitalOcean Kubernetes β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β NGINX Ingress Controller β β
β β (teamfat32.duckdns.org) β β
β β TLS/HTTPS Enabled β β
β ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ β
β β API Gateway (LoadBalancer) β β
β β Port 8000 (HTTPS) β β
β ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ β
β β Microservices Layer β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β β β User β β Campaign β β Donation β β β
β β β Service β β Service β β Service β β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β β β Payment β β Banking β β Notify β β β
β β β Service β β Service β β Service β β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Infrastructure Services β β
β β β’ Kafka (StatefulSet) β β
β β β’ PostgreSQL Databases (StatefulSet x6) β β
β β β’ Redis (Deployment) β β
β β β’ Prometheus (StatefulSet) β β
β β β’ Grafana (Deployment) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
All Kubernetes manifests are located in the /k8s folder:
All microservices are configured with HPA for automatic scaling:
Scaling Behavior:
- API Gateway: 2-10 replicas (scales at 70% CPU)
- Microservices: 2-8 replicas (scales at 70% CPU)
- Scale-up: 1 pod every 30 seconds
- Scale-down: 1 pod every 5 minutes (stabilization)
TLS termination is handled by cert-manager with Let's Encrypt:
Features:
- Automatic certificate generation and renewal
- HTTP to HTTPS redirect
- TLS 1.2+ only
- Production-grade Let's Encrypt certificates
# Apply all manifests
kubectl apply -f k8s/
# Check deployment status
kubectl get pods -n default
# View HPA status
kubectl get hpa
# Check ingress
kubectl get ingress
# View logs
kubectl logs -f deployment/api-gateway
# Scale manually (if needed)
kubectl scale deployment/api-gateway --replicas=5- Frontend: https://teamfat32.duckdns.org
- API Gateway: https://teamfat32.duckdns.org/api
The project uses GitHub Actions for intelligent CI/CD with change detection:
π¦ Pipeline Features:
- β
Change Detection: Only build/test modified services using
dorny/paths-filter - β Parallel Testing: 8 concurrent test jobs for each service
- β Docker Multi-arch Builds: AMD64 and ARM64 support
- β Image Tagging: Semantic versioning with Git SHA tags
- β Automated Deployment: Push to DigitalOcean Kubernetes
- β Rollout Verification: Ensures successful deployment
- β Rollback on Failure: Automatic rollback if deployment fails
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GitHub Actions Workflow β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
βΌ βΌ
Detect Changes Run Tests (Parallel)
(dorny/paths-filter) β
β βββββββββββββββΌββββββββββββββ
β βΌ βΌ βΌ
β test-user test-campaign test-donation
β test-payment test-banking test-notify
β test-api-gw test-frontend
β β
ββββββββββββββββββββββ΄ββββββββββββββ
βΌ
Build Docker Images
(only changed services)
β
βΌ
Push to DockerHub
β
βΌ
Deploy to Kubernetes
β
βΌ
Verify Rollout Status
Workflow files are in the /.github/workflows directory:
Trigger Conditions:
- Push to
mainordevelopbranches - Pull requests to
main - Manual workflow dispatch
Pipeline Stages:
-
Detect Changes (30s)
- Uses
dorny/paths-filter@v2 - Outputs boolean flags for each service
- Uses
-
Run Tests (2-5 minutes per service)
- Parallel execution (8 jobs)
- Only runs if service changed
- Runs unit + integration tests
- Generates coverage reports
-
Build Docker Images (5-10 minutes)
- Only builds changed services
- Multi-stage builds for optimization
- Tags:
latest,v{version},sha-{git-sha} - Caches layers for faster builds
-
Push to Registry (2-3 minutes)
- Pushes to DockerHub
- Credentials from GitHub Secrets
- Retries on failure (3 attempts)
-
Deploy to Kubernetes (3-5 minutes)
- Updates deployment with new image
- Rolling update strategy
- Waits for rollout completion
- Automatic rollback on failure
For production deployments, branch protection is configured:
- β Require pull request reviews (1 reviewer)
- β Require status checks to pass (all test jobs)
- β Require branches to be up to date
- β Require conversation resolution
- β Enforce for administrators
See BRANCH_PROTECTION_SETUP.md for detailed setup instructions.
# Docker Hub credentials
DOCKERHUB_USERNAME=sleepytmzd
DOCKERHUB_TOKEN=<your-token>
# DigitalOcean credentials
DIGITALOCEAN_ACCESS_TOKEN=<your-token>
DO_CLUSTER_NAME=careforall-clusterEach service exposes Swagger UI documentation:
- API Gateway: http://localhost:8000/docs
- User Service: http://localhost:8001/docs
- Campaign Service: http://localhost:8002/docs
- Donation Service: http://localhost:8004/docs
- Payment Service: http://localhost:8003/docs
- Banking Service: http://localhost:8006/docs
- Notification Service: http://localhost:8005/docs
curl -X POST http://localhost:8000/api/users/register \
-H "Content-Type: application/json" \
-d '{
"email": "donor@example.com",
"password": "securepass123",
"name": "John Doe",
"role": "DONOR"
}'curl -X POST http://localhost:8000/api/users/login \
-H "Content-Type: application/json" \
-d '{
"email": "donor@example.com",
"password": "securepass123"
}'curl -X POST http://localhost:8000/api/campaigns \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"title": "Help Build School",
"description": "Building school in rural area",
"goal_amount": 50000,
"category": "EDUCATION"
}'curl -X POST http://localhost:8000/api/donations \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"campaign_id": 1,
"amount": 1000,
"is_anonymous": false
}'- β Health checks for all services
- β Automatic container restart
- β Circuit breaking for fault tolerance
- β Database connection pooling
- β JWT-based authentication
- β Role-based authorization
- β Password hashing (bcrypt)
- β Rate limiting per user/IP
- β CORS configuration
- β SQL injection prevention (ORM)
- β Async I/O with FastAPI
- β Redis caching
- β Database indexing
- β Connection pooling
- β gRPC for internal communication
- β Kafka for async operations
- β Distributed tracing (Jaeger)
- β Centralized logging (Loki)
- β Metrics visualization (Grafana)
- β Correlation IDs
- β Structured logging
- β Health check endpoints
- β Microservices architecture
- β Database per service
- β Stateless services
- β Event-driven communication
- β Horizontal scaling ready
- β Load balancing support
Each service can be configured via environment variables in docker-compose.yml:
# Example: User Service
environment:
DATABASE_URL: postgresql+asyncpg://user:password@postgres-user:5432/userdb
JWT_SECRET: your-secret-key
JWT_EXPIRY_HOURS: 24
JAEGER_ENDPOINT: http://jaeger:14268/api/traces
TRACING_ENABLED: "true"Topics are auto-created, but you can pre-create them:
docker exec -it kafka-demo kafka-topics --create \
--bootstrap-server localhost:9092 \
--topic donation_created \
--partitions 3 \
--replication-factor 1# All services
curl http://localhost:8000/health
# Individual service
curl http://localhost:8001/health# All services
docker-compose logs -f
# Specific service
docker-compose logs -f user-service
# Last 100 lines
docker-compose logs --tail=100 donation-service- Open http://localhost:16686
- Select service (e.g., "api-gateway")
- Click "Find Traces"
- Explore request flows
- Open http://localhost:3000
- Import
careforall-logs-dashboard.json - Filter by service:
{container_name="user-service-demo"}
- Open http://localhost:8080
- View topics, consumers, and message flow
./scripts/health-check.shpytest tests/integration/# Using Apache Bench
ab -n 1000 -c 10 http://localhost:8000/api/campaigns
# Using Locust
locust -f tests/load/locustfile.pyWe welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Project Lead: CareForAll Platform Development
- Hackathon: CUET API Avengers Microservice Hackathon 2025
- Date: November 21, 2025
- FastAPI community for excellent documentation
- CUET for organizing the hackathon
- Open source contributors
For issues and questions:
- GitHub Issues: Report Bug
- Documentation: Check service-specific READMEs
- Logs: Use Grafana dashboard for debugging
Built with β€οΈ by Team FAT32
Making donations transparent and accessible








