AI Skill Report Card
Architecting Microservices
Quick Start
Bash# 1. Domain discovery mkdir microservices-project && cd microservices-project mkdir -p docs/{domain-model,bounded-contexts,services} # 2. Create initial domain map cat > docs/domain-model/core-domains.md << EOF # Core Domains - User Management (Core) - Order Processing (Core) - Inventory Management (Supporting) - Notification Service (Generic) EOF
Recommendation▾
Add specific performance metrics and SLA targets in the optimization step (e.g., 'maintain 99.9% uptime, <100ms p50 latency')
Workflow
Progress:
- Domain Discovery & Event Storming
- Bounded Context Identification
- Service Boundary Definition
- Data Architecture Planning
- API Contract Design
- Implementation Strategy
- Deployment Architecture
- Monitoring & Observability Setup
- Verification & Testing
- Performance Optimization
Step 1: Domain Discovery & Event Storming
- Map business processes as domain events
- Identify aggregates and entities
- Document ubiquitous language
- Verification: Validate with domain experts
Step 2: Bounded Context Identification
Context Map Template:
- Context Name: [UserManagement]
- Core Domain: [Yes/No]
- Upstream/Downstream: [Relationships]
- Integration Pattern: [Shared DB/API/Events]
Step 3: Service Boundary Definition
- One service per bounded context
- Define service responsibilities
- Identify cross-cutting concerns
- Self-check: Each service should be independently deployable
Step 4: Data Architecture Planning
YAML# data-strategy.yml services: user-service: database: postgresql schema: users ownership: exclusive order-service: database: postgresql schema: orders ownership: exclusive shared_data: none # Avoid shared databases
Step 5: API Contract Design
YAML# user-service-api.yml openapi: 3.0.0 paths: /users: post: summary: Create user requestBody: $ref: '#/components/schemas/CreateUserRequest'
Step 6: Implementation Strategy
- Start with walking skeleton
- Implement one service completely
- Add services incrementally
- Verification: Each service passes health checks independently
Step 7: Deployment Architecture
YAML# docker-compose.yml version: '3.8' services: user-service: build: ./user-service ports: ["8081:8080"] environment: - DATABASE_URL=postgres://... order-service: build: ./order-service ports: ["8082:8080"]
Step 8: Monitoring & Observability
YAML# monitoring-stack.yml - Distributed tracing: Jaeger - Metrics: Prometheus + Grafana - Logs: ELK Stack - Health checks: Spring Actuator
Step 9: Verification & Testing
Bash# Service-level tests ./gradlew test # Contract tests ./gradlew contractTest # End-to-end tests ./gradlew e2eTest # Performance tests k6 run load-test.js
Step 10: Performance Optimization
- Profile service interactions
- Implement caching strategies
- Optimize database queries
- Self-check: Response times < 200ms for 95th percentile
Recommendation▾
Include more concrete domain event examples in the Event Storming section (e.g., 'UserRegistered', 'OrderPlaced', 'PaymentProcessed')
Examples
Example 1: E-commerce Domain Decomposition Input: Monolithic e-commerce application Output:
- User Service (authentication, profiles)
- Product Catalog Service (inventory, pricing)
- Order Service (cart, checkout, fulfillment)
- Payment Service (transactions, billing)
- Notification Service (emails, SMS)
Example 2: Service API Contract Input: User registration requirement Output:
YAMLPOST /api/v1/users { "email": "user@example.com", "name": "John Doe" } Response: 201 Created { "id": "user-123", "email": "user@example.com", "created_at": "2024-01-01T00:00:00Z" }
Recommendation▾
Expand the walking skeleton example with actual code structure and deployment commands
Best Practices
- Database per Service: Never share databases between services
- API-First Design: Define contracts before implementation
- Eventual Consistency: Embrace async communication via events
- Bulkhead Pattern: Isolate failures between services
- Circuit Breaker: Implement resilience patterns
- Versioning Strategy: Use semantic versioning for APIs
- Idempotency: Ensure operations can be safely retried
Common Pitfalls
- Distributed Monolith: Services too tightly coupled
- Chatty Interfaces: Too many service calls for single operation
- Shared Database: Coupling services through shared data
- Premature Optimization: Building complex architecture before understanding domain
- Missing Monitoring: No visibility into service health and performance
- Ignoring Network Failures: Not handling partial failures gracefully
- Over-Engineering: Creating services that are too granular
- Synchronous Communication: Using REST for everything instead of events