Microservices Design
SpecKit’s microservices architecture divides the ticketing platform into seven independent services, each responsible for a specific business capability. This design enables independent deployment, scaling, and development.Service Catalog
Catalog Service
Port: 5001
Responsibility: Event browsing and seat informationCapabilities:
Responsibility: Event browsing and seat informationCapabilities:
- List all events
- Get event details
- Retrieve seat maps with real-time availability
- PostgreSQL (schema:
bc_catalog) - Kafka consumer (updates seat status from inventory)
Inventory Service
Port: 5002
Responsibility: Seat reservations and availability managementCapabilities:
Responsibility: Seat reservations and availability managementCapabilities:
- Create seat reservations with distributed locking
- Manage reservation expiry (15-minute TTL)
- Publish reservation lifecycle events
- PostgreSQL (schema:
bc_inventory) - Redis (distributed locks)
- Kafka producer/consumer
Ordering Service
Port: 5003
Responsibility: Shopping cart and order managementCapabilities:
Responsibility: Shopping cart and order managementCapabilities:
- Maintain draft orders (cart)
- Checkout and order finalization
- Validate reservations before purchase
- PostgreSQL (schema:
bc_ordering) - Kafka consumer (reservation events)
- In-memory
ReservationStore
Payment Service
Port: 5004
Responsibility: Payment processing and validationCapabilities:
Responsibility: Payment processing and validationCapabilities:
- Process payments (simulated gateway)
- Validate order and reservation states
- Publish payment success/failure events
- PostgreSQL (schema:
bc_payment) - Kafka producer/consumer
- Event-based validation
Fulfillment Service
Port: 5005
Responsibility: Ticket generation and deliveryCapabilities:
Responsibility: Ticket generation and deliveryCapabilities:
- Generate digital tickets
- Link tickets to completed payments
- Publish ticket-issued events
- PostgreSQL (schema:
bc_fulfillment) - Kafka consumer
Identity Service
Port: 5000
Responsibility: User authentication and authorizationCapabilities:
Responsibility: User authentication and authorizationCapabilities:
- User registration and login
- JWT token generation
- Guest token management
- PostgreSQL (schema:
bc_identity) - BCrypt password hashing
Notification Service
Port: 5006
Responsibility: Customer notificationsCapabilities:
Responsibility: Customer notificationsCapabilities:
- Send ticket delivery emails
- Track notification history
- SMTP integration
- PostgreSQL (schema:
bc_notification) - Kafka consumer
- SMTP client
Service Boundaries
Boundary Principles
- Data Ownership
- Communication Contracts
- Autonomy
Rule: Each service exclusively owns its data schemaBenefits:
- No cross-schema foreign keys
- Independent schema evolution
- Clear data boundaries
Communication Patterns
1. Synchronous REST Communication
Request-Response Pattern
Request-Response Pattern
Use Case: Frontend queries Catalog Service for eventsHandler Implementation:When to Use:
- User-initiated queries requiring immediate response
- Operations within a single bounded context
- Simple CRUD operations
2. Asynchronous Event-Driven Communication
Event Choreography Pattern
Event Choreography Pattern
Use Case: Reservation lifecycle across multiple servicesStep 1: Inventory publishes reservation-created eventStep 2: Ordering consumes event and updates local stateWhen to Use:
- Cross-service workflows (checkout → payment → fulfillment)
- Long-running processes
- Services should remain decoupled
Service Independence Strategies
- Data Isolation
- Circuit Breaker (Future)
- Distributed Transactions
Strategy: Each service maintains its own projection of shared dataExample: Ordering service needs reservation dataBenefits:
- No direct database queries to Inventory service
- Eventually consistent read model
- Ordering service remains operational even if Inventory is down
Service Discovery & Configuration
Docker Compose Setup
Docker Compose Setup
- Docker Compose provides internal DNS (e.g.,
kafka,postgres,redis) - Services reference each other by container name
- For Kubernetes deployment, consider using service mesh (Istio, Linkerd)
Deployment Strategies
Independent Deployment
Each service has its own:
- Dockerfile
- Build pipeline
- Versioning
- Rollback capability
Database Migrations
Each service manages its own migrations:Uses EF Core schema-specific migrations:
Anti-Patterns to Avoid
Related Concepts
Event-Driven Architecture
Learn how Kafka enables service choreography
Hexagonal Architecture
Understand the internal structure of each service
CQRS Pattern
See how commands and queries are separated
System Architecture
View the complete architecture overview
