# Layer 2 Second layer of the chain. This file is imported by layer1.md and imports layer3.md in turn, forming a 3-deep @import chain that the TOK scanner should flag. ## Architecture Notes The ficticious project uses a layered architecture split across: - Application layer (HTTP adapters, CLI adapters) - Domain layer (pure business logic) - Infrastructure layer (databases, caches, external APIs) ## Dependency Rules - Application depends on domain but not infrastructure. - Infrastructure implements ports defined in the domain. - Domain never imports from application or infrastructure. - Cross-cutting concerns (logging, tracing) live as ports. ## Observability - Structured logs with correlation ids. - Metrics scraped from a `/metrics` endpoint. - Trace spans around domain service boundaries. - Health checks separate from metrics endpoints. ## Data Access - Repositories return domain objects, never ORM entities. - Database migrations numbered sequentially. - Idempotent migrations where feasible. - Readonly replicas for analytical queries. ## Caching - Read-through cache for hot entities. - TTL chosen per entity class. - Invalidate on write, not on read miss. - Measure hit-rate per cache bucket. @layer3.md