Skip to main content

πŸ“š Advanced Microservices Architecture - Practical Assignments

E-Commerce Platform Migration Project​

Course: Advanced Microservices Architecture
Version: 1.1.0
Last Updated: 2026-01-13
Prerequisite: Completed mono-src (Building High-Performance APIs with FastAPI)


🎯 Project Overview​

Migration Journey​

You will migrate mono-src (monolithic Product Catalog Service) to a complete Microservices architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ β”‚ MICROSERVICES PLATFORM β”‚
β”‚ mono-src β”‚ β”‚ β”‚
β”‚ (Monolithic) β”‚ ──────► β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ β”‚ β”‚ User β”‚ β”‚ Product β”‚ β”‚ Order β”‚ β”‚
β”‚ β€’ User Auth β”‚ β”‚ β”‚ Service β”‚ β”‚ Service β”‚ β”‚ Service β”‚ β”‚
β”‚ β€’ Product CRUD β”‚ β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
β”‚ β€’ Single DB β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ DB β”‚ β”‚ DB β”‚ β”‚ DB β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ + API Gateway (Kong) β”‚
β”‚ + Message Broker (RabbitMQ) β”‚
β”‚ + Cache (Redis) β”‚
β”‚ + Observability Stack β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack​

ComponentTechnologyPort
User ServiceFastAPI + PostgreSQL8001
Product ServiceFastAPI + PostgreSQL + Redis8002
Order ServiceFastAPI + PostgreSQL + RabbitMQ8003
Notification ServiceFastAPI + RabbitMQ8004
API GatewayKong8000
CacheRedis6379
Message BrokerRabbitMQ5672, 15672
TracingJaeger16686
MetricsPrometheus9090
LoggingLoki + Promtail3100
VisualizationGrafana3000

Target Architecture​

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Svelte SPA β”‚
β”‚ (Port 5173) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Kong Gateway β”‚
β”‚ (Port 8000) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ User Service │◄────────│ Product Service β”‚ β”‚ Order Service β”‚
β”‚ (Port 8001) β”‚ Token β”‚ (Port 8002) β”‚ β”‚ (Port 8003) β”‚
β”‚ β”‚ Verify β”‚ β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚PostgreSQLβ”‚ β”‚ β”‚ β”‚PostgreSQLβ”‚ β”‚ β”‚ β”‚PostgreSQLβ”‚ β”‚
β”‚ β”‚ user_db β”‚ β”‚ β”‚ β”‚product_dbβ”‚ β”‚ β”‚ β”‚ order_db β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ Redis β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ Cache β”‚ β”‚ β”‚ β–Ό β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ RabbitMQ β”‚ β”‚
β”‚ β”‚ Publisherβ”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Notification β”‚
β”‚ Service β”‚
β”‚ (Port 8004) β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ RabbitMQ β”‚ β”‚
β”‚ β”‚ Consumer β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Assignment 01: User Service Extraction​

Unit 1 - Microservices Fundamentals & Refactoring​

🎯 Learning Objectives​

  • Understand Bounded Context and Database per Service concepts
  • Apply the Strangler Fig Pattern to migrate services
  • Set up an independent microservice with FastAPI

πŸ“– Business Requirements​

Scenario​

The company has decided to transition from a monolithic to a microservices architecture to:

  • Scale components independently
  • Deploy features without affecting the entire system
  • Allow teams to work in parallel

User Service is selected first because:

  • It has a clear Bounded Context (Authentication domain)
  • It has few dependencies on other domains
  • It is a critical component - needs stability and independent scaling

βœ… Required Tasks​

Task 1.1: Project Structure Setup (15 points)​

Requirements:

Create the directory structure for User Service following clean architecture pattern:

micro-src/
└── server/
└── user-service/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ main.py # FastAPI app entry
β”‚ β”œβ”€β”€ api/ # API endpoints layer
β”‚ β”œβ”€β”€ config/ # Configuration management
β”‚ β”œβ”€β”€ database/ # Database connection
β”‚ β”œβ”€β”€ models/ # SQLAlchemy models
β”‚ β”œβ”€β”€ repositories/ # Data access layer
β”‚ β”œβ”€β”€ schemas/ # Pydantic schemas
β”‚ β”œβ”€β”€ services/ # Business logic layer
β”‚ └── utils/ # Utilities (security, etc.)
β”œβ”€β”€ alembic/
β”œβ”€β”€ tests/
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ alembic.ini
└── start.sh

Acceptance Criteria:

  • Correct directory structure with all layers
  • All __init__.py files exist
  • Code from mono-src migrated and refactored

Task 1.2: Database per Service (20 points)​

Business Logic:

User Service requires a separate, completely isolated database:

  • Do not share schema with other services
  • Independent DB scaling
  • Independent migration

Technical Requirements:

SettingValue
DatabasePostgreSQL 15
DB Nameuser_service_db
Port (external)5433
Port (internal)5432

Requirements:

  1. Create Docker Compose configuration for PostgreSQL container
  2. Configure environment variables for database credentials
  3. Set up volume for data persistence
  4. Implement healthcheck for container readiness

Acceptance Criteria:

  • Database container runs successfully
  • Connection from service to DB works
  • Healthcheck passes
  • Data persists across container restarts

Task 1.3: User Model & Migrations (15 points)​

Business Logic:

Migrate the User model from mono-src, ensuring:

  • Preserve schema structure
  • Alembic migrations work
  • Auto-migration when the container starts

Model Definition:

ColumnTypeConstraints
idIntegerPK, auto-increment
usernameString(50)Unique, Not Null, Indexed
hashed_passwordString(255)Not Null
is_activeBooleanDefault True
created_atDateTimeServer default now()
updated_atDateTimeAuto-update

Requirements:

  1. Initialize Alembic for migrations
  2. Create initial migration script
  3. Implement start.sh that runs migrations before starting the service

Acceptance Criteria:

  • Alembic initialized
  • Initial migration generated
  • start.sh runs migrations automatically

Task 1.4: Authentication Endpoints (25 points)​

Business Logic:

Migrate and enhance authentication endpoints from mono-src:

EndpointMethodDescription
/registerPOSTUser registration
/loginPOSTOAuth2 Password Flow
/validate-tokenPOSTNEW - Token validation for other services
/healthGETHealth check

Token Validation Endpoint (Important):

This is a NEW endpoint, not present in mono-src. Other services (Product, Order) will call this endpoint to validate JWT tokens instead of decoding the token directly.

Request/Response Format:

  • Request: JSON body with token field containing the JWT
  • Response (Valid): { "valid": true, "user_id": <id>, "username": "<name>", "message": "Token is valid" }
  • Response (Invalid): { "valid": false, "user_id": null, "username": null, "message": "Token is invalid or expired" }

Why not share the JWT secret?

  • Security: Each service does not need to know the secret key
  • Centralized auth: User Service is the Single Source of Truth
  • Rotation: Keys can be rotated without updating other services

Acceptance Criteria:

  • POST /register creates user successfully
  • POST /login returns JWT token
  • POST /validate-token validates and returns user info
  • GET /health returns status

Task 1.5: Dockerization (15 points)​

Business Logic:

The Service needs to be containerized for easy deployment:

  • Multi-stage build (optional) to reduce image size
  • Non-root user for security
  • Auto-migration on startup

Requirements:

  1. Create Dockerfile with Python 3.11 base image
  2. Install dependencies efficiently (layer caching)
  3. Create non-root user for security
  4. Configure healthcheck
  5. Use start.sh as entrypoint

Acceptance Criteria:

  • Docker build successful
  • Container starts and is healthy
  • Migrations run automatically
  • API accessible at port 8001

🌟 Bonus Tasks​

Bonus 1.1: User Events Publishing (15 points)​

Implement event publishing when a user registers. Publish a user.created event to RabbitMQ containing user_id, username, and created_at.

Bonus 1.2: Password Policy (10 points)​

Implement password policy validation: min 8 chars, 1 uppercase, 1 lowercase, 1 digit, 1 special char. Return specific error messages for each failed rule.

Bonus 1.3: Rate Limiting (10 points)​

Implement rate limiting for the login endpoint: max 5 attempts per minute per IP. Use in-memory storage or Redis.


πŸ“Š Rubric - Assignment 01​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Project Structure (15pts)Perfect structure, all filesMinor issuesBasic structureIncorrect structure
Database Setup (20pts)Isolated DB, healthcheck, volumesWorks, minor config issuesBasic setupCannot connect
Model & Migrations (15pts)Alembic works, auto-migrateWorks manuallyPartialNot working
Auth Endpoints (25pts)All 4 endpoints, validate-token worksMissing 1 endpoint2 endpoints workMost broken
Dockerization (15pts)Multi-stage, non-root, healthcheckBasic Dockerfile worksContainer runsBuild fails
Code Quality (10pts)Clean, documented, type hintsGood codeAcceptablePoor quality

Total: 100 points | Bonus: 35 points


πŸ“ Assignment 02: Product Service & API Gateway​

Unit 2 - API Gateway (Kong)​

🎯 Learning Objectives​

  • Extract Product Service into an independent microservice
  • Implement inter-service authentication
  • Setup and configure Kong API Gateway
  • Understand routing and rate limiting concepts

πŸ“– Business Requirements​

Scenario​

After the User Service is stable, the team continues to migrate the Product Service. At the same time, an API Gateway is needed to:

  • Provide a single entry point for all API calls
  • Centralize routing and security
  • Implement rate limiting to protect services
  • Handle logging and monitoring

βœ… Required Tasks​

Task 2.1: Product Service Extraction (25 points)​

Business Logic:

Migrate the Product domain from mono-src into an independent service. Product Service:

  • Has a separate database (product_service_db)
  • Does NOT decode JWT tokens directly
  • Calls User Service to validate tokens

Project Structure:

product-service/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ main.py
β”‚ β”œβ”€β”€ api/
β”‚ β”‚ β”œβ”€β”€ products.py # CRUD endpoints
β”‚ β”‚ └── deps.py # Auth dependency
β”‚ β”œβ”€β”€ config/
β”‚ β”œβ”€β”€ database/
β”‚ β”œβ”€β”€ models/
β”‚ β”œβ”€β”€ repositories/
β”‚ β”œβ”€β”€ schemas/
β”‚ β”œβ”€β”€ services/
β”‚ └── utils/
β”‚ └── auth_client.py # HTTP client to User Service
β”œβ”€β”€ alembic/
β”œβ”€β”€ Dockerfile
└── requirements.txt

Acceptance Criteria:

  • Service runs on port 8002
  • Separate database (product_service_db, port 5434)
  • CRUD endpoints functional

Task 2.2: Inter-Service Authentication (25 points)​

Business Logic:

Product Service needs to authenticate the user but does NOT have access to the JWT secret.

Authentication Flow:

  1. Client sends request with Authorization: Bearer <token> to Product Service
  2. Product Service extracts token and calls User Service's /validate-token endpoint
  3. User Service validates token and returns user info or error
  4. Product Service allows/denies request based on validation result

Requirements:

  1. Create AuthClient class to communicate with User Service
  2. Implement get_current_user dependency for protected routes
  3. Return 401 Unauthorized when token is invalid/missing
  4. Make user info available in route handlers

Acceptance Criteria:

  • Auth client calls User Service successfully
  • Protected endpoints require valid token
  • 401 returned when token is invalid/missing
  • User info available in route handlers

Task 2.3: Kong API Gateway Setup (30 points)​

Business Logic:

Kong Gateway provides:

  • Routing: Direct requests to correct service
  • Rate Limiting: Protect services from abuse
  • Logging: Centralized access logs
  • Authentication (optional): Can add JWT plugin

Requirements:

  1. Set up Kong with PostgreSQL database using Docker Compose
  2. Run Kong migrations
  3. Configure Kong services and routes via Admin API:
    • Register User Service: /api/users/* β†’ user-service:8001
    • Register Product Service: /api/products/* β†’ product-service:8002

Routing Table:

Client RequestKong RouteUpstream
POST /api/users/register/api/users/*user-service:8001/register
POST /api/users/login/api/users/*user-service:8001/login
GET /api/products/api/products/*product-service:8002/products
POST /api/products/api/products/*product-service:8002/products

Acceptance Criteria:

  • Kong container running healthy
  • User Service accessible via Kong
  • Product Service accessible via Kong
  • Direct service access still works (for internal calls)

Task 2.4: Rate Limiting Plugin (10 points)​

Business Logic:

Protect API from abuse with rate limiting:

  • Login endpoint: 5 requests/minute (prevent brute force)
  • Product listing: 100 requests/minute
  • Product creation: 20 requests/minute

Requirements:

  1. Configure global rate limiting plugin
  2. Configure service-specific rate limiting
  3. Verify rate limit headers in responses

Acceptance Criteria:

  • Rate limiting plugin enabled
  • Exceeded requests return 429 Too Many Requests
  • Headers show rate limit info (X-RateLimit-*)

🌟 Bonus Tasks​

Bonus 2.1: Kong Declarative Config (15 points)​

Create a kong.yml declarative config file instead of using Admin API calls. Mount it to the container with KONG_DECLARATIVE_CONFIG.

Bonus 2.2: JWT Plugin (15 points)​

Configure Kong JWT plugin to validate tokens at the gateway level. Requires registering consumer and credentials.

Bonus 2.3: Request/Response Transformation (10 points)​

Add a transformation plugin to add custom headers (X-Request-ID, X-Service-Name) into responses.


πŸ“Š Rubric - Assignment 02​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Product Service (25pts)Complete CRUD, isolated DBMissing 1 featureBasic CRUD worksService broken
Inter-Service Auth (25pts)Auth client works, proper errorsWorks, error handling weakBasic validationNot implemented
Kong Setup (30pts)Full routing, both servicesOne service worksKong runs, partial routingKong not working
Rate Limiting (10pts)Multiple limits configuredBasic limit worksPlugin enabledNot configured
Code Quality (10pts)Clean, async, documentedGood codeAcceptablePoor quality

Total: 100 points | Bonus: 40 points


πŸ“ Assignment 03: Async Communication (RabbitMQ)​

Unit 3 - Async Communication​

🎯 Learning Objectives​

  • Understand the difference between Sync vs Async communication
  • Setup RabbitMQ with Exchange, Queue, Binding
  • Implement Producer/Consumer pattern with aio-pika
  • Handle message acknowledgment and error cases

πŸ“– Business Requirements​

Scenario​

When a user registers, the system needs to send a welcome email. If the email API is called synchronously:

  • User must wait for email sending to complete (slow response)
  • If the email service is down β†’ registration fails (not acceptable)

Solution: Async communication via message queue.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  1.Register   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Client β”‚ ────────────► β”‚ User Service β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β–² β”‚ 2. Create β”‚
β”‚ β”‚ User β”‚
β”‚ 3. Return β”‚ β”‚
β”‚ 201 Created β”‚ 4. Publish β”‚
β”‚ (immediate) β”‚ Event β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
β”‚ RabbitMQ β”‚
β”‚ user.createdβ”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
β”‚ Notification β”‚
β”‚ Service β”‚
β”‚ β”‚
β”‚ 5. Send Emailβ”‚
β”‚ (async) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βœ… Required Tasks​

Task 3.1: RabbitMQ Setup (15 points)​

Requirements:

  1. Configure RabbitMQ container with management UI
  2. Set up healthcheck
  3. Configure data persistence with volumes

Concepts to Understand:

ConceptDescription
ExchangeRouter that receives messages and routes them to queues
QueueBuffer that stores messages waiting to be consumed
BindingRule connecting exchange to queue
Routing KeyPattern to route message to correct queue

Exchange Types:

TypeBehavior
directRoute by exact routing key match
topicRoute by pattern matching (*.created, order.#)
fanoutBroadcast to all bound queues
headersRoute based on headers

Acceptance Criteria:

  • RabbitMQ container healthy
  • Management UI accessible at :15672
  • Can create exchange/queue via UI

Task 3.2: Event Publisher - User Service (25 points)​

Business Logic:

After user registers successfully, publish event to RabbitMQ.

Event Structure:

{
"event": "user.created",
"timestamp": "2025-12-24T10:00:00Z",
"data": {
"user_id": 1,
"username": "john_doe",
"email": "john@example.com",
"created_at": "2025-12-24T10:00:00Z"
}
}

Requirements:

  1. Create RabbitMQPublisher class with async connection handling
  2. Declare user_events exchange (topic, durable)
  3. Publish event after successful user registration
  4. Use persistent delivery mode for messages

Acceptance Criteria:

  • Exchange user_events created (durable)
  • Event published when user registers
  • Message visible in RabbitMQ Management UI
  • Registration is still fast (async publish)

Task 3.3: Event Consumer - Notification Service (30 points)​

Business Logic:

Notification Service consumes events and sends notifications:

  • Welcome email when user registers
  • Order confirmation when order created (future)

Project Structure:

notification-service/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ main.py
β”‚ β”œβ”€β”€ config/
β”‚ └── utils/
β”‚ β”œβ”€β”€ rabbitmq.py # Consumer
β”‚ └── notifications.py # Email/SMS handlers
β”œβ”€β”€ Dockerfile
└── requirements.txt

Requirements:

  1. Create RabbitMQConsumer class with proper connection handling
  2. Set QoS (prefetch_count) for controlled consumption
  3. Declare queue user_notifications and bind to exchange
  4. Implement message handling with proper acknowledgment
  5. Start consumer as background task on application startup

Acceptance Criteria:

  • Queue user_notifications created
  • Queue bound to exchange with routing key
  • Consumer receives messages
  • Message acknowledged after processing
  • Failed messages handled (DLQ or retry)

Task 3.4: Error Handling & Reliability (20 points)​

Business Logic:

Message queue needs to be reliable:

  • Messages must not be lost if consumer crashes
  • Failed messages need to be retried or moved to DLQ
  • Consumer crash should not block other messages

Reliability Patterns to Implement:

PatternDescription
Persistent MessagesMessages saved to disk
Manual AcknowledgmentAck after processing, nack on failure
Dead Letter QueueFailed messages moved to separate queue
Automatic ReconnectionConsumer reconnects after connection loss

Acceptance Criteria:

  • Messages persistent (survive broker restart)
  • Failed messages requeued or sent to DLQ
  • Consumer reconnects after connection loss
  • No message loss in failure scenarios

🌟 Bonus Tasks​

Bonus 3.1: Retry with Exponential Backoff (15 points)​

Implement retry mechanism with exponential backoff: 1s β†’ 2s β†’ 4s β†’ 8s β†’ DLQ. Track retry count in message headers.

Bonus 3.2: Multiple Consumers (10 points)​

Scale consumer horizontally by running multiple instances. Test with 3 consumer instances using competing consumers pattern.

Bonus 3.3: Event Schema Registry (10 points)​

Create shared event schemas package. Define JSON Schema for each event type. Validate messages against schema before publish/consume.


πŸ“Š Rubric - Assignment 03​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
RabbitMQ Setup (15pts)Healthy, UI works, concepts clearWorks, minor issuesBasic setupNot running
Publisher (25pts)Events published, persistent, asyncWorks, missing persistenceBasic publishNot implemented
Consumer (30pts)Consumes, processes, acknowledgesWorks, ack issuesReceives messagesNot working
Error Handling (20pts)DLQ, retry, reconnectionPartial error handlingBasic try/catchNo error handling
Code Quality (10pts)Clean async code, documentedGood codeAcceptablePoor quality

Total: 100 points | Bonus: 35 points


πŸ“ Assignment 04: SAGA Pattern - Order Service​

Unit 4 & 5 - SAGA Pattern (Happy Path & Failure Path)​

🎯 Learning Objectives​

  • Understand Distributed Transactions issues (ACID vs BASE)
  • Implement SAGA Pattern with Choreography
  • Handle Compensating Transactions on failure
  • Build Order Service with multi-service coordination

πŸ“– Business Requirements​

Scenario​

Order creation involves multiple services:

  1. User Service: Verify user exists and authenticated
  2. Product Service: Check stock availability, deduct stock
  3. Order Service: Create order record
  4. Notification Service: Send order confirmation

Problem: Distributed Transaction

In a monolith, database transactions ensure atomicity. In microservices, each service has its own DB β†’ Cannot use single transaction.

Solution: SAGA Pattern

SAGA is a sequence of local transactions, where each transaction updates a service and publishes an event to trigger the next transaction.

Happy Path Flow:

Order Service β†’ (order.created) β†’ Product Service β†’ (stock.reserved) β†’
Order Service β†’ (order.confirmed) β†’ Notification Service β†’ Send Email

Failure Path (Compensating Transaction):

Order Service β†’ (order.created) β†’ Product Service β†’ Stock INSUFFICIENT! β†’
(stock.failed) β†’ Order Service β†’ CANCEL Order β†’ (order.cancelled)

βœ… Required Tasks​

Task 4.1: Order Service Setup (20 points)​

Project Structure:

order-service/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ main.py
β”‚ β”œβ”€β”€ api/
β”‚ β”‚ β”œβ”€β”€ orders.py
β”‚ β”‚ └── deps.py
β”‚ β”œβ”€β”€ config/
β”‚ β”œβ”€β”€ database/
β”‚ β”œβ”€β”€ models/
β”‚ β”‚ β”œβ”€β”€ order.py
β”‚ β”‚ └── order_item.py
β”‚ β”œβ”€β”€ repositories/
β”‚ β”œβ”€β”€ schemas/
β”‚ β”œβ”€β”€ services/
β”‚ └── utils/
β”‚ β”œβ”€β”€ auth_client.py # Call User Service
β”‚ β”œβ”€β”€ product_client.py # Call Product Service
β”‚ └── rabbitmq.py # Event publisher
β”œβ”€β”€ alembic/
β”œβ”€β”€ Dockerfile
└── requirements.txt

Order Model:

ColumnTypeDescription
idIntegerPK
user_idIntegerUser who placed order
statusEnumPENDING, CONFIRMED, CANCELLED, SHIPPED, DELIVERED
total_amountDecimalTotal order value
created_atDateTimeOrder creation time
updated_atDateTimeLast update time

OrderItem Model:

ColumnTypeDescription
idIntegerPK
order_idIntegerFK to Order
product_idIntegerProduct ID
product_nameStringSnapshot of product name
quantityIntegerQuantity ordered
unit_priceDecimalPrice at order time

Why snapshot product data? Product name/price can change, but order needs to preserve information at the time of ordering.

Acceptance Criteria:

  • Order Service runs on port 8003
  • Order and OrderItem models created
  • Migrations work

Task 4.2: Order Creation API (25 points)​

Business Logic:

Create order endpoint needs to:

  1. Validate user (via User Service)
  2. Validate products exist (via Product Service)
  3. Create order with status PENDING
  4. Publish order.created event
  5. Return order (do not wait for stock reservation)

API Endpoint:

POST /orders
Authorization: Bearer <token>
Content-Type: application/json

Request Body:
{
"items": [
{ "product_id": 1, "quantity": 2 },
{ "product_id": 3, "quantity": 1 }
]
}

Response (201 Created):
{
"id": 1,
"user_id": 5,
"status": "PENDING",
"total_amount": 299.97,
"items": [...],
"created_at": "2025-12-24T10:00:00Z"
}

Acceptance Criteria:

  • Order created with status PENDING
  • Products fetched from Product Service
  • Total calculated correctly
  • Event published to RabbitMQ
  • Response immediate (not waiting for stock)

Task 4.3: Stock Reservation - Product Service (25 points)​

Business Logic:

Product Service consumes order.created event and reserves stock.

Requirements:

  1. Add RabbitMQ consumer to Product Service
  2. Handle order.created event:
    • Extract order_id and items from event
    • Check stock availability for ALL items first
    • If all available: deduct stock, publish stock.reserved
    • If any insufficient: publish stock.failed with reason
  3. Invalidate product cache after stock changes

Events:

EventRouting KeyWhen
stock.reservedstock.reservedAll items reserved successfully
stock.failedstock.failedInsufficient stock

Acceptance Criteria:

  • Product Service consumes order.created
  • Stock deducted when sufficient
  • stock.reserved event published on success
  • stock.failed event published on failure
  • Cache invalidated after stock change

Task 4.4: Order Status Update & Compensation (20 points)​

Business Logic:

Order Service consumes stock events to update order status.

Requirements:

  1. Handle stock.reserved event β†’ Update order to CONFIRMED, publish order.confirmed
  2. Handle stock.failed event β†’ Update order to CANCELLED, record reason, publish order.cancelled

Order Status Flow:

PENDING ──────► CONFIRMED ──────► SHIPPED ──────► DELIVERED
β”‚
└──────────► CANCELLED (compensation)

Acceptance Criteria:

  • Order updated to CONFIRMED on success
  • Order updated to CANCELLED on failure
  • Cancellation reason recorded
  • Appropriate events published

🌟 Bonus Tasks​

Bonus 4.1: Orchestration Pattern (20 points)​

Implement SAGA Orchestrator service instead of Choreography. Orchestrator coordinates steps and handles rollbacks centrally.

Bonus 4.2: Partial Failure Handling (15 points)​

Handle case: Order has 3 items, 2 items have stock, 1 item out of stock. Implement configurable behavior (cancel all vs partial fulfillment).

Bonus 4.3: Order Status WebSocket (10 points)​

Implement WebSocket endpoint /orders/{id}/status for real-time status updates.


πŸ“Š Rubric - Assignment 04​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Order Service Setup (20pts)Complete with items modelBasic order modelPartialNot working
Order Creation (25pts)Full validation, event publishedWorks, minor issuesBasic creationBroken
Stock Reservation (25pts)Reserve + events for both pathsSuccess path onlyBasic consumerNot implemented
Compensation (20pts)Full compensation, status flowBasic cancellationPartialNo compensation
Code Quality (10pts)Clean, documented, proper asyncGoodAcceptablePoor

Total: 100 points | Bonus: 45 points


πŸ“ Assignment 05: Performance - Redis Caching​

Unit 6 - Performance Patterns (Redis)​

🎯 Learning Objectives​

  • Understand caching strategies (Cache-aside, Read-through, Write-through)
  • Implement Cache-aside pattern with Redis
  • Handle Cache Invalidation correctly
  • Measure performance improvement

πŸ“– Business Requirements​

Scenario​

Product Service receives many read requests for product details:

  • 80% requests are GET operations
  • Same products are queried multiple times
  • Database queries take ~50-100ms

Problem: Database bottleneck with high traffic.

Solution: Redis caching to:

  • Reduce DB load
  • Improve response time (<10ms from cache)
  • Handle traffic spikes

βœ… Required Tasks​

Task 5.1: Redis Setup (15 points)​

Requirements:

  1. Configure Redis container with Alpine image
  2. Enable data persistence (AOF)
  3. Set memory limit and eviction policy (LRU)
  4. Configure healthcheck

Configuration Options:

OptionValuePurpose
appendonly yesEnable AOFData persistence
maxmemory 256mbMemory limitPrevent OOM
maxmemory-policy allkeys-lruEviction policyLRU when memory full

Acceptance Criteria:

  • Redis container healthy
  • redis-cli ping responds PONG
  • Persistence enabled

Task 5.2: Cache Manager Implementation (25 points)​

Business Logic:

Create CacheManager class to handle all cache operations.

Cache Key Strategy:

product:{product_id}         # Single product
products:list:{skip}:{limit} # Product list (paginated)
products:search:{query} # Search results

Requirements:

  1. Create CacheManager class with get, set, delete, delete_pattern methods
  2. Implement error handling (cache failures should not crash the application)
  3. Use JSON serialization for complex objects
  4. Make TTL configurable with default from settings
  5. Implement healthcheck method

Acceptance Criteria:

  • CacheManager with get/set/delete methods
  • Error handling does not crash application
  • TTL configurable
  • Pattern-based deletion

Task 5.3: Cache-Aside Pattern for Get Product (30 points)​

Business Logic:

Cache-Aside (Lazy Loading) Pattern:

  1. Check cache first
  2. If HIT β†’ return cached data
  3. If MISS β†’ query DB β†’ store in cache β†’ return

Requirements:

  1. Implement cache-aside pattern in ProductService.get_product()
  2. Add logging for cache hit/miss
  3. Configure TTL (default 300 seconds)
  4. Serialize/deserialize product data correctly

Acceptance Criteria:

  • First request queries DB and caches data
  • Subsequent requests hit cache
  • Response time <10ms for cache hits
  • Cache expires after TTL

Task 5.4: Cache Invalidation (20 points)​

Business Logic:

Cache must be invalidated when data changes:

  • Product updated β†’ delete product:{id}
  • Product deleted β†’ delete product:{id}
  • Stock changed β†’ delete product:{id}

Invalidation Strategies:

StrategyWhenImplementation
Write-invalidateUpdate/DeleteDelete cache key
TTL expirationAutoRedis handles
Pattern invalidationBulk updatesDelete matching keys

Acceptance Criteria:

  • Cache invalidated on update
  • Cache invalidated on delete
  • Cache invalidated on stock change
  • List caches also invalidated

🌟 Bonus Tasks​

Bonus 5.1: User Profile Caching (15 points)​

Apply caching for User Service's "Get User Profile" API. Track cache hit rate metrics.

Bonus 5.2: Cache Warming (10 points)​

On service startup, pre-populate cache with frequently accessed products (top 100 by views).

Bonus 5.3: Distributed Locking (15 points)​

Implement distributed lock with Redis to prevent "thundering herd" on cache miss. Use Redis SETNX for locking.


πŸ“Š Rubric - Assignment 05​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Redis Setup (15pts)Full config, persistence, healthcheckWorks, basic configContainer runsNot running
Cache Manager (25pts)All methods, error handling, patternsBasic get/set/deletePartial implementationNot working
Cache-Aside (30pts)Full pattern, logging, metricsWorks correctlyBasic cachingBroken
Invalidation (20pts)All cases handled, patternsMost casesBasic invalidationMissing
Performance (10pts)Measured improvement, <10msImproved responseSome improvementNo change

Total: 100 points | Bonus: 40 points


πŸ“ Assignment 06: Observability - Tracing (Jaeger/OTel)​

Unit 6 - Observability (Tracing)​

🎯 Learning Objectives​

  • Understand concepts: Trace, Span, Context Propagation
  • Setup OpenTelemetry instrumentation
  • Integrate Jaeger for distributed tracing
  • Debug cross-service requests

πŸ“– Business Requirements​

Scenario​

When order creation fails, we need to trace the request across services:

  • How long does it take in each service?
  • Which service failed?
  • Which database query was slow?

Without tracing: Check logs of each service, difficult to correlate.

With tracing: Single view of the entire request journey.


βœ… Required Tasks​

Task 6.1: Jaeger Setup (15 points)​

Requirements:

  1. Configure Jaeger all-in-one container
  2. Enable OTLP endpoint
  3. Expose UI port (16686)

Key Concepts:

ConceptDescription
TraceEnd-to-end journey of a request
SpanSingle operation in a trace (e.g., DB query, HTTP call)
ContextMetadata propagated across services (trace ID, span ID)
InstrumentationCode that creates and manages spans

Acceptance Criteria:

  • Jaeger UI accessible at :16686
  • OTLP endpoint available at :4317

Task 6.2: OpenTelemetry Setup (25 points)​

Dependencies Required:

  • opentelemetry-api
  • opentelemetry-sdk
  • opentelemetry-instrumentation-fastapi
  • opentelemetry-instrumentation-sqlalchemy
  • opentelemetry-instrumentation-httpx
  • opentelemetry-instrumentation-redis
  • opentelemetry-exporter-otlp

Requirements:

  1. Create setup_tracing() function for each service
  2. Configure Resource with service identity (name, version, environment)
  3. Create TracerProvider with OTLP exporter
  4. Add BatchSpanProcessor for performance
  5. Auto-instrument: FastAPI, SQLAlchemy, HTTPX, Redis

Required Instrumentations per Service:

ServiceFastAPISQLAlchemyHTTPXRedisRabbitMQ
Userβœ“βœ“--Manual
Productβœ“βœ“βœ“βœ“-
Orderβœ“βœ“βœ“-Manual
Notificationβœ“---Manual

Acceptance Criteria:

  • Tracing configured in all services
  • Auto-instrumentation for FastAPI, SQLAlchemy, HTTPX, Redis
  • Spans exported to Jaeger

Task 6.3: Instrument All Services (30 points)​

Requirements:

  1. Apply tracing setup to all 4 services
  2. Create manual spans for RabbitMQ message handlers
  3. Include relevant attributes (order_id, user_id, etc.)
  4. Record exceptions in spans

Acceptance Criteria:

  • User Service traced
  • Product Service traced (including Redis)
  • Order Service traced (including HTTPX calls)
  • Manual spans for RabbitMQ handlers

Task 6.4: Trace Analysis (20 points)​

Test Scenarios:

  1. Happy Path: Create order successful - trace shows full flow
  2. Failure Path: Insufficient stock - trace shows error span
  3. Cache Hit vs Miss: Cache HIT shows short span, MISS shows DB span

Jaeger UI Features to Use:

FeatureUsage
Service dropdownFilter by service
Operation dropdownFilter by endpoint
Tags searchFind by order_id, user_id
Compare tracesCompare slow vs fast
DependenciesService dependency graph

Acceptance Criteria:

  • Can find traces by service
  • Can filter by operation
  • Can see full trace across services
  • Can identify slow spans

🌟 Bonus Tasks​

Bonus 6.1: Custom Spans & Attributes (10 points)​

Add custom spans for business-critical operations with custom attributes.

Bonus 6.2: Trace Context in Messages (15 points)​

Propagate trace context via RabbitMQ messages using traceparent header.

Bonus 6.3: Sampling Strategy (10 points)​

Configure trace sampling (probabilistic 10% or rate limiting 100 traces/sec).


πŸ“Š Rubric - Assignment 06​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Jaeger Setup (15pts)UI works, OTLP enabledBasic setupContainer runsNot running
OTel Setup (25pts)All instrumentationsMissing 1-2Basic FastAPI onlyNot working
All Services (30pts)All 4 services traced3 services2 services1 or none
Trace Analysis (20pts)Full analysis, can debugBasic viewingCan find tracesCannot use UI
Code Quality (10pts)Clean, configurableGoodAcceptablePoor

Total: 100 points | Bonus: 35 points


πŸ“ Assignment 07: Observability - Logging (Loki)​

Unit 7 - Observability (Logging)​

🎯 Learning Objectives​

  • Understand centralized logging concepts
  • Setup Loki + Promtail for log aggregation
  • Implement structured logging
  • Query and analyze logs effectively

πŸ“– Business Requirements​

Scenario​

With multiple services, logs are scattered:

  • User Service logs β†’ container A
  • Product Service logs β†’ container B
  • Order Service logs β†’ container C

Problem: Difficult to correlate logs when debugging.

Solution: Centralized logging with Loki.

  • All logs β†’ Loki
  • Query from Grafana
  • Correlate with trace_id

βœ… Required Tasks​

Task 7.1: Loki + Promtail Setup (20 points)​

Requirements:

  1. Configure Loki with filesystem storage
  2. Configure Promtail to collect Docker container logs
  3. Set up Docker Compose for both services
  4. Add service labels for filtering

Acceptance Criteria:

  • Loki running at :3100
  • Promtail collecting Docker logs
  • Logs visible in Grafana

Task 7.2: Structured Logging (25 points)​

Business Logic:

JSON structured logs for easy parsing and querying.

Log Format:

{
"timestamp": "2025-12-24T10:00:00.000Z",
"level": "INFO",
"service": "order-service",
"trace_id": "abc123...",
"span_id": "def456...",
"message": "Order created successfully",
"order_id": 1,
"user_id": 5,
"total_amount": 299.97
}

Requirements:

  1. Create custom JSON formatter with trace context
  2. Configure logging to stdout
  3. Support extra fields in log messages
  4. Reduce noise from uvicorn, httpx

Acceptance Criteria:

  • Logs in JSON format
  • trace_id included (for correlation)
  • Custom fields supported
  • Log levels appropriate

Task 7.3: Log Aggregation Verification (25 points)​

Test Scenarios:

  1. All Services Logging: Start all services, make API requests, verify logs appear in Loki
  2. Cross-Service Correlation: Create order, find logs by trace_id across services
  3. Error Logging: Trigger error, search for ERROR level logs, verify stack trace

LogQL Queries to Implement:

Query PurposeDescription
All logs from a serviceFilter by container name
Error logs onlyFilter by level
Filter by trace_idCorrelate across services
Search for specific orderFilter by custom field
Rate of errorsCalculate error rate over time

Acceptance Criteria:

  • Logs from all services visible
  • Can filter by service
  • Can search by trace_id
  • Can search by custom fields

Task 7.4: Log-based Alerting (20 points)​

Requirements:

  1. Create Grafana alert rule for high error rate
  2. Configure alert condition (e.g., >10 errors in 5 minutes)
  3. Test alert firing and resolution

Acceptance Criteria:

  • Alert rule created in Grafana
  • Alert fires on error spike (test)
  • Alert resolves when errors decrease

🌟 Bonus Tasks​

Bonus 7.1: ELK Stack Alternative (20 points)​

Setup ELK Stack (Elasticsearch, Logstash, Kibana) instead of Loki. Create Kibana dashboard.

Bonus 7.2: Log Retention Policy (10 points)​

Configure log retention: keep 7 days detailed, 30 days aggregated.

Bonus 7.3: Audit Logging (10 points)​

Separate audit logs for security events (login, permission changes). Never delete.


πŸ“Š Rubric - Assignment 07​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Loki Setup (20pts)Full config, Promtail worksBasic setupContainer runsNot running
Structured Logging (25pts)JSON, trace_id, custom fieldsJSON, missing trace_idBasic JSONUnstructured
Aggregation (25pts)All services, can queryMost servicesSome logs visibleCannot query
Alerting (20pts)Alert works, testedAlert configuredPartialNo alerting
Code Quality (10pts)Clean, reusableGoodAcceptablePoor

Total: 100 points | Bonus: 40 points


πŸ“ Assignment 08: Observability - Metrics (Prometheus/Grafana)​

Unit 9 - Observability (Metrics)​

🎯 Learning Objectives​

  • Understand metrics types: Counter, Gauge, Histogram, Summary
  • Setup Prometheus for metrics collection
  • Build Grafana dashboards
  • Implement custom application metrics
  • Setup alerting based on metrics

πŸ“– Business Requirements​

Scenario​

The Operations team needs to monitor the system:

  • Request rate (requests per second)
  • Error rate (% of failed requests)
  • Response latency (p50, p90, p99)
  • Resource usage (CPU, memory)
  • Business metrics (orders/hour, revenue)

Goal: Real-time visibility into system health.


βœ… Required Tasks​

Task 8.1: Prometheus Setup (20 points)​

Requirements:

  1. Configure Prometheus with scrape configs for all services
  2. Set up service discovery for each microservice
  3. Configure data retention and storage
  4. Enable web UI

Scrape Targets:

Job NameTarget
prometheuslocalhost:9090
user-serviceuser-service:8001
product-serviceproduct-service:8002
order-serviceorder-service:8003
redisredis-exporter:9121
postgrespostgres-exporter:9187

Acceptance Criteria:

  • Prometheus UI accessible at :9090
  • All services discovered in Targets
  • Metrics being scraped

Task 8.2: Application Metrics (25 points)​

Metrics Types:

TypeUse CaseExample
CounterMonotonically increasingTotal requests, errors
GaugeCan go up/downActive connections, queue size
HistogramDistribution of valuesRequest latency, order value
SummarySimilar to histogramResponse size percentiles

Requirements:

  1. Setup prometheus-fastapi-instrumentator for each service
  2. Expose /metrics endpoint (exclude from tracing)
  3. Add default HTTP metrics (latency, request count)
  4. Create custom business metrics:
    • orders_created_total (Counter with status label)
    • order_value_dollars (Histogram with buckets)
    • http_requests_in_progress (Gauge)

Acceptance Criteria:

  • /metrics endpoint returns Prometheus format
  • Default HTTP metrics (latency, count)
  • Custom business metrics recording

Task 8.3: Grafana Dashboards (30 points)​

Requirements:

  1. Configure Grafana with Prometheus data source
  2. Set up dashboard provisioning
  3. Create overview dashboard with key metrics

Required Dashboard Panels:

PanelMetricType
Request Ratesum(rate(http_requests_total[5m])) by (service)Graph
Error Rate5xx requests / total requests * 100Graph
P99 Latencyhistogram_quantile(0.99, ...)Graph
Active Requestshttp_requests_in_progressGauge
Orders/Hourincrease(orders_created_total[1h])Stat

Acceptance Criteria:

  • Grafana UI accessible at :3000
  • Prometheus data source configured
  • Overview dashboard with key metrics
  • Service-specific dashboard

Task 8.4: Alerting Rules (15 points)​

Required Alert Rules:

AlertConditionSeverity
HighErrorRateError rate > 5% for 5mincritical
HighLatencyP99 > 2s for 5minwarning
ServiceDownup == 0 for 1mincritical
HighMemoryUsageMemory > 512MB for 5minwarning

Acceptance Criteria:

  • Alert rules loaded in Prometheus
  • Alerts fire correctly when triggered
  • Alerts visible in Grafana

🌟 Bonus Tasks​

Bonus 8.1: Custom Grafana Dashboard (15 points)​

Create business dashboard showing: orders per hour, revenue, top products, user signups.

Bonus 8.2: Alertmanager Integration (15 points)​

Setup Alertmanager to route alerts via Slack/Email/Discord.

Bonus 8.3: SLI/SLO Dashboard (15 points)​

Define SLOs (99.9% availability, p99 < 500ms). Create error budget dashboard.


πŸ“Š Rubric - Assignment 08​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Prometheus Setup (20pts)Full config, all targetsMost targetsBasic setupNot working
App Metrics (25pts)Default + custom businessDefault metricsPartialNo metrics
Dashboards (30pts)Multiple dashboards, polishedOverview dashboardBasic panelsNo dashboards
Alerting (15pts)Rules work, testedRules configuredPartialNo alerts
Code Quality (10pts)Clean, documentedGoodAcceptablePoor

Total: 100 points | Bonus: 45 points


πŸŽ“ Final Project: End-to-End Integration & Demo​

🎯 Objectives​

  • Deploy the entire microservices stack
  • Demonstrate the E2E user journey
  • Verify observability stack
  • Present architecture decisions

πŸ“‹ Final Project Requirements​

Part 1: Complete Deployment (30 points)​

Checklist:

ComponentRequirement
User ServiceRunning, healthy
Product ServiceRunning, cached
Order ServiceRunning, messaging
Notification ServiceConsuming messages
PostgreSQL (3 instances)Data persisted
RedisCaching working
RabbitMQQueues active
PrometheusScraping all services
GrafanaDashboards visible
LokiLogs aggregated
JaegerTraces visible

Part 2: E2E User Journey Demo (40 points)​

Demo Steps:

  1. Register User β†’ User created, 201 response
  2. Login β†’ Token returned
  3. Browse Products β†’ Products listed, cache metrics change
  4. Create Order β†’ Order created, stock reduced
  5. Notification β†’ Consumer log shows processing
  6. Tracing β†’ Full trace visible in Jaeger
  7. Metrics β†’ Dashboard shows request spike
  8. Logs β†’ Logs searchable by trace_id

Part 3: Failure Scenarios (20 points)​

Test Resilience:

ScenarioExpected Behavior
Kill Product ServiceOrder Service returns 503, auto-recovers
Kill RedisProduct Service fallback to DB (slower)
Kill RabbitMQOrder created, notification delayed
Invalid Token401 Unauthorized
Insufficient StockOrder fails gracefully

Part 4: Architecture Presentation (10 points)​

Topics to Present:

  1. Architecture Overview: Service boundaries, communication patterns, database per service
  2. Key Design Decisions: Why separate Auth service? Why RabbitMQ for notifications? Why Redis for products?
  3. Trade-offs: Consistency vs Availability, Complexity vs Simplicity, Performance vs Cost
  4. Future Improvements: API Gateway (Kong), Service Mesh (Istio), CI/CD Pipeline

πŸ“Š Final Project Rubric​

CriteriaExcellent (100%)Good (80%)Satisfactory (60%)Needs Improvement (40%)
Deployment (30pts)All components runningMissing 1-2Core services onlyMultiple failures
E2E Demo (40pts)Full journey, all verificationsMost steps workCore flow worksBroken flow
Failure Handling (20pts)Graceful degradationMost scenariosSome handlingCrashes
Presentation (10pts)Clear, insightfulGood explanationBasicPoor

Total: 100 points


πŸ“š Course Summary & Grading​

Overall Progress Tracking​

AssignmentTopicPointsBonus
01User Service Extraction10035
02Product Service & API Gateway10040
03Async Communication10035
04SAGA Pattern - Order Service10045
05Performance - Redis Caching10040
06Observability - Tracing10035
07Observability - Logging10040
08Observability - Metrics10045
FinalE2E Integration100-
Total900315

Grading Scale​

GradePercentagePoints (of 900)
A+95-100%855-900
A90-94%810-854
B+85-89%765-809
B80-84%720-764
C+75-79%675-719
C70-74%630-674
D60-69%540-629
F< 60%< 540

Bonus Points: Can increase grade (max +10%)


πŸ“– Additional Resources​

Documentation​

Architecture Patterns​


Last Updated: 2026-01-13
Version: 1.1.0
Syllabus Reference: Advanced Microservices Architecture


Note: This document provides requirements and descriptions only. Students are expected to research and implement the solutions independently. Refer to the provided resources and course materials for implementation guidance.