Monorepo Architecture — Bun + Turborepo
A monorepo keeps all your apps and shared code in one repository. With Bun workspaces and Turborepo task orchestration, you get fast installs, parallel builds, and type-safe package sharing.badmin
Admin panel monorepo — web + server + docs + shared packages.
cyop
AI captioning monorepo — web + server + tRPC + auth + db packages.
fullstack
Template monorepo — web + docs + desktop + API + shared packages.
Standard Structure
All three projects follow the same pattern:Workspace Configuration
Bun Workspaces (package.json)
Turborepo Pipeline (turbo.json)
Biome (Lint + Format)
Biome replaces ESLint + Prettier with a single, faster tool:Shared Packages
contracts — Zod + tRPC
Shared schemas keep frontend and backend type-synced:LoginInput for form validation. The backend imports the same schema for request validation. One source of truth.
db — Drizzle Package
Isolate database logic in its own package:apps/server and apps/web (for server functions) import from @repo/db.
ui — shadcn/ui Package
Shared components built on shadcn/ui:Create a
components.json in both apps/web and packages/ui so shadcn add places components in the right location.Cross-App Type Safety
The key benefit of monorepo: runtime-free type sharing.Environment Variables
Each app reads its own env vars. Service URLs can be overridden:- Web:
3000 - Docs:
3001 - API:
3002 - Desktop:
1420
CI/CD with GitHub Actions
Turborepo caches build outputs, making CI fast:Database Workflow
Best Practices
apps/+packages/split — Apps are deployable units; packages are shared libraries- Contracts package — Zod schemas + tRPC routers = type safety without code generation
- Biome over ESLint+Prettier — One tool, 30× faster, fewer config files
- Turbo caching —
^builddependency graph + remote cache = fast CI - DB as a package — Schema, client, and migrations in one sharable package
- Environment overrides — Service URLs via
.env, not hardcoded - shadcn/ui in packages/ui — Share components across web and docs apps
- Tab indentation — Biome defaults to tabs — consistent, smaller diffs
References
- Turborepo Docs
- Bun Workspaces
- Biome
- badmin repo — Production monorepo example
- fullstack repo — Template monorepo
