Modules
Module Organization
The Bun Core Platform uses a layered module architecture with three main layers:- Apps — Entry points and orchestration
- Packages — Shared code (domain, application, infrastructure)
- Config — Centralized configuration
Apps Layer
apps/monolith/
The main Hono application. Wires together:
- Server setup (Hono)
- Middleware registration (rate limiting, idempotency, i18n, logging)
- Route mounting (
/api/v1/...) - DI container setup
Packages Layer
packages/domain/
Pure TypeScript — zero framework dependencies.
Business entities and rules:
- No imports from
hono,mongodb, or any infrastructure - Pure TypeScript classes and interfaces only
- Business logic lives here, not in use cases
packages/application/
Use cases + port interfaces. Depends only on domain/.
packages/infrastructure/
Adapters implementing application ports. Depends on application/ + external libraries.
Modules Layer
Gateway Module (apps/monolith/src/modules/gateway/)
AI communication layer for OpenClaw integration.
Config Layer
config/MONOLITH_CONFIG.md
Centralized configuration reference for all environment variables.
Module Rules
| Layer | Can Depend On | Cannot Depend On |
|---|---|---|
domain/ | Nothing (pure) | Any framework or infra |
application/ | domain/ | infrastructure/, apps/ |
infrastructure/ | application/ | — |
apps/monolith/ | All layers | — |
Adding a New Module
- Create
apps/monolith/src/modules/<name>/ - Define domain entities in
domain/entities/ - Define ports in
domain/ports/ - Implement use cases in
application/use-cases/ - Implement adapters in
infrastructure/ - Add routes in
apps/monolith/src/api-gateway/routes/ - Register in DI container
See Also
- Architecture — System design
- File Structure — Project layout