Layered Modular Layout
Quick start
Organize source code by role, not by framework-specific folder names. Dependencies flow downward only:
src/
bootstrap/
routes/
modules/
shared/
import { userSchema } from "@/modules/users"; // public API only
Before creating, moving, or importing a file, identify its role and keep dependencies flowing from outer entrypoints toward inner reusable code.
Workflows
- Identify the file's role (
bootstrap,routes,modules,shared, orglobals) - Place the file under the matching layer and smallest meaningful scope
- Import only downward —
bootstrapmay import fromroutes,modules,shared;routesfrommodules,shared;modulesfromsharedand other modules' public APIs;sharedonly fromshared - Use public APIs across module boundaries (e.g.,
modules/users/index.ts), never internal paths - Group by scope, not by type; add subfolders only when a scope becomes too large to scan
- Avoid red flags: never import from
bootstrapoutside bootstrap, never import internal module paths, never put domain logic inshared
Advanced features
See REFERENCE.md for the full role matrix, dependency rules, module boundaries, grouping guidance, example structure, and red flags.