Python Architecture
Priority: P0 (CRITICAL)
Rules
- Keep domain decisions independent from HTTP, DB, env, and queue clients.
- Define ports where callers need substitution; implement adapters at the edge.
- Compose runtime dependencies in startup or wiring modules.
- Treat contracts, policy, and normalization helpers as standalone modules.
Recipe
- Place pure contracts and policy in domain/application modules.
- Keep adapters thin: DB, HTTP, bot, MCP, subprocess, storage.
- Push workflow orchestration into services that call contracts and ports.
- Separate report formatting from fact gathering.
- Add focused regression tests before moving boundary code.
Anti-Patterns
- No fake clean architecture theatre: folders must match real ownership.
- No DB imports in domain policy.
- No startup wiring hidden in module globals.
- No one-function runtime blobs spanning parse, dispatch, verify, and notify.
References
- Framework Map
- Clean Architecture
Canonical response anchors
When this skill applies, preserve the following domain terminology or equivalent concrete examples in the answer when relevant:
- inject