services/customer/
Purpose
Java + Spring Boot microservice that owns the Customer aggregate. Read-only in the checkout flow — the Ordering saga reads customer profile and contact info before starting saga steps. Conforms to the Ordering context as a Conformist in the DDD context map (Ordering reads data as-is, no translation). Port 5005.
Key Files
| File | Description |
|---|---|
Dockerfile | Multi-stage Maven build → minimal JRE runtime image |
pom.xml | Maven project descriptor with Spring Boot and swagger-request-validator |
readme.md | Service notes: customer schema, seeded test data, environment variables |
src/main/java/com/example/customer/CustomerApplication.java | Spring Boot entry point |
src/main/java/com/example/customer/HealthController.java | GET /health → {"status": "ok"} |
src/main/resources/application.properties | Server port, DB datasource settings |
For AI Agents
Working In This Directory
- Read-only in checkout flow —
GET /customers/{customerId}is the only endpoint called by Ordering - If a
customerIdis invalid, return 404; Ordering will abort the saga with a 422 before any stock is touched - Customer data is seeded via
init.sqlmounted into the Customer DB container — update seed data there, not in code - No write endpoints are required for the current assignment scope; if added later, require an
Idempotency-Key
Testing Requirements
docker compose build customer— verify Maven buildcurl http://localhost:5005/health→{"status": "ok"}GET /customers/{seeded-id}→ 200 with profile JSONGET /customers/nonexistent→ 404
Common Patterns
Customerentity:customerId,name,email,contactInfo,preferences@GetMapping("/customers/{id}")withOptional<Customer>→ 404 if empty- Environment variables:
DATABASE_URL,DATABASE_USERNAME,DATABASE_PASSWORD
Dependencies
Internal
docs/api-specs/customer.yaml— request validation contract- Ordering service — sole caller in checkout flow
External
- Spring Boot 3.x
swagger-request-validator(Atlassian)- PostgreSQL — Customer DB at port 5436
opentelemetry-spring-boot-starter— observability