Clean Architecture in TypeScript
When implementing clean architecture patterns in TypeScript, read and follow the policy guide:
Policy: docs/policies/clean-architecture-typescript.md
When This Applies
- •Creating
*.system.tsfiles wrapping Azure SDK, Cloudflare API, or other external calls - •Defining
{name}-interface.tscontracts withI{Name}interfaces - •Refactoring mixed business logic and system interaction code
- •Setting up dependency injection via function/constructor parameters
- •Using the namespace API pattern (classes with static methods)
- •Configuring
bunfig.tomlcoverage exclusions for**/*.system.ts - •Creating module folder structures with
index.tsbarrel exports
File Naming Convention
| File Type | Pattern | Example |
|---|---|---|
| Interface | {domain}-interface.ts | blob-interface.ts |
| System wrapper | {domain}.system.ts | blob.system.ts |
| Mock | tests/mocks/{domain}-mock.ts | blob-mock.ts |
| Business logic | {domain}.ts or descriptive name | handler.ts |
Key Patterns
- •System files: thin wrappers, no business logic, excluded from coverage
- •Interfaces:
Iprefix, minimal surface area, platform-agnostic - •DI: accept deps object with interface types, provide defaults via
?.?? ?? - •Namespace API:
Secrets.parse()instead ofparseSecretReference()
Read the full guide for step-by-step refactoring process and examples.