Architecture layers
The four layers of Baseleg and the direction of allowed dependencies.
UI
apps/web/src/pages/ · packages/ui/Renders views · handles user interaction · calls use cases · no business rule decisions
calls use cases
Application
packages/application/<context>/Use cases · orchestration · transaction boundaries · defines ports for infrastructure
owns model
calls ports
<!-- Domain -->
<div style="background:color-mix(in srgb,#22c55e 12%,#ffffff);border:2px solid #22c55e;border-radius:10px;padding:16px 20px">
<div style="font-weight:700;color:var(--docs-primary);margin-bottom:4px">Domain</div>
<div style="color:color-mix(in srgb,var(--docs-primary) 70%,transparent);font-size:0.8rem;margin-bottom:2px"><code style="background:color-mix(in srgb,#22c55e 10%,#ffffff);border:1px solid color-mix(in srgb,#22c55e 25%,#ffffff);padding:1px 5px;border-radius:4px">packages/domain/<context>/</code></div>
<div style="color:color-mix(in srgb,var(--docs-primary) 55%,transparent);font-size:0.75rem">Entities · value objects · domain rules · no infrastructure imports</div>
<div style="margin-top:10px;padding:6px 8px;background:color-mix(in srgb,#22c55e 8%,#ffffff);border-radius:6px;font-size:0.7rem;color:color-mix(in srgb,var(--docs-primary) 50%,transparent)">Only depends on <code style="background:transparent;border:none;padding:0">@baseleg/shared-*</code></div>
</div>
<!-- Infrastructure -->
<div style="background:var(--docs-surface-2);border:2px solid var(--docs-border);border-radius:10px;padding:16px 20px">
<div style="font-weight:700;color:var(--docs-primary);margin-bottom:4px">Infrastructure</div>
<div style="color:color-mix(in srgb,var(--docs-primary) 70%,transparent);font-size:0.8rem;margin-bottom:2px"><code style="background:var(--docs-surface-2);border:1px solid var(--docs-border);padding:1px 5px;border-radius:4px">packages/infrastructure/</code></div>
<div style="color:color-mix(in srgb,var(--docs-primary) 55%,transparent);font-size:0.75rem">D1/Drizzle · repository impls · auth · notification adapters</div>
<div style="margin-top:10px;padding:6px 8px;background:color-mix(in srgb,var(--docs-primary) 4%,#ffffff);border-radius:6px;font-size:0.7rem;color:color-mix(in srgb,var(--docs-primary) 50%,transparent)">Implements ports · depends on Domain + Shared</div>
</div>
Forbidden: UI → Infrastructure · Domain → Infrastructure · Application → Infrastructure implementations · UI → Drizzle schema
Dependency rules
| Layer | May import from |
|---|---|
| UI | Application, UI (shared), selected Domain types/value objects |
| Application | Domain, Shared |
| Domain | Shared only |
| Infrastructure | Domain, Shared |
See Package boundaries for the full import rules with code examples.