Cookbook (Patterns) π§βπ³¶
The Cookbook provides complete, end-to-end architectural patterns that show how pico-iocβs features compose in real-world systems.
π Patterns Overview¶
| Pattern | Description | File |
|---|---|---|
| Multi-Tenant Applications | Isolate tenants across configuration, scoped containers, and runtime boundaries. | pattern-multi-tenant.md |
| Hot Reload (Dev Server) | Dev-time module replacement with deterministic container rebuilds and safe teardown. | pattern-hot-reload.md |
| CLI Applications | Command registration, DI per invocation, and structured output. | pattern-cli-app.md |
| CQRS Command Bus | Segregated read/write models, command handlers, and middleware pipelines with AOP. | pattern-cqrs.md |
| Feature Toggles (AOP) | Cross-cutting feature flags via decorators and runtime config. | pattern-aop-feature-toggle.md |
| Structured Logging (AOP) | Enforced log context, correlation IDs, and function-level structured logs. | pattern-aop-structured-logging.md |
| Security Checks (AOP) | Permission/role gates, pre/post conditions, auditing hooks. | pattern-aop-security.md |
| Method Profiling (AOP) | Execution timing and performance insights for critical call paths. | pattern-aop-profiling.md |
| Configuration Overrides | Environment-driven overrides and deterministic container setup. | pattern-config-overrides.md |
π§ How to Use¶
- Pick a pattern that fits your scenario.
- Copy the module layout and minimal container scaffolding.
- Apply overrides / AOP / config depending on your environment.
- Combine patterns:
- The AOP patterns stack.
- Overrides apply everywhere.
- CQRS works well with profiling + structured logging.
π§© Pattern Categories¶
Application Architecture - Multi-Tenant Applications - CQRS Command Bus
Developer Experience - Hot Reload - Configuration Overrides & Deterministic Setup
Interfaces - CLI Applications
Cross-Cutting Concerns (AOP) - Feature Toggles - Structured Logging - Security Checks (@secured) - Method Profiling
AI / LLM Integration - Dynamic LangChain Model / Prompt Selection & Caching
π€ Contributing¶
- Propose a new pattern or improvement by keeping:
- Clear problem definition
- Reproducible steps and code snippets
- Dependency boundaries and lifecycle considerations
- Testing and observability guidance
- Aim for composability: demonstrate how the pattern integrates with existing patterns when relevant.