Project Structure
How Bedstack organizes code for scalability.
Bedstack follows a Feature-Based folder structure. Instead of grouping files by their technical type (e.g., putting all controllers in one folder), we group them by the domain feature they belong to.
Monorepo Layout
Bedstack is designed as a monorepo using Bun Workspaces and Turborepo.
turbo.json
bun.lock
package.json
Feature Folders
Inside a Bedstack application (like apps/api), code is organized into self-contained feature modules. This makes the codebase easier to navigate and allows features to be moved or scaled independently.
A Typical Feature Structure
users.controller.ts
users.service.ts
users.repository.ts
users.mapper.ts
The shared Folder
Global utilities, shared middleware, and cross-cutting concerns live in the src/shared directory.
Tip: Avoid dumping everything into
shared. If a utility or constant is only used in one feature, keep it inside that feature's folder.
Entry Points
src/main.ts: The entry point of the application.src/app.module.ts: The "orchestrator" file that composes all individual feature controllers into a single Elysia instance. This pattern is inspired by NestJS to maintain a clean root application file.