Workspace Structure
The project is organized into three main workspace categories:Workspace Configuration
Workspaces are defined in the rootpackage.json:
package.json
workspace:* protocol:
api/hono/package.json
Turborepo Configuration
Turborepo manages task execution with intelligent caching and dependency awareness.Build Pipeline
Theturbo.json configuration defines task dependencies:
turbo.json
The
^build syntax means “build all dependencies first” before building the current package.Global Environment Variables
Turborepo is aware of environment variables that affect builds:turbo.json
Package Organization
API Packages
@api/hono - The main API server built with Honoapi/hono/package.json
Shared Packages
@packages/auth - Better Auth configuration and typespackages/auth/package.json
packages/db/package.json
Web Packages
@web/next - Next.js frontend applicationweb/next/package.json
Common Tasks
Running Development Servers
Start all workspaces in development mode:- Next.js dev server (port 3000)
- Hono API server (port 4000)
Building for Production
Build all packages in the correct order:- Builds
@packages/envfirst - Builds
@packages/dband@packages/auth - Builds
@api/honoand@web/next
Database Commands
Database tasks are scoped to the@packages/db workspace:
@packages/env is built first before running database operations.
Dependency Management
Catalog Pattern
ZeroStarter uses Bun’s catalog feature to centralize dependency versions:package.json
Installing Dependencies
Install dependencies from the root:Type Safety Across Workspaces
The monorepo enables end-to-end type safety:api/hono/src/index.ts
web/next/src/lib/api/client.ts
AppType from the API server provides full type safety in the frontend with zero code generation.
Benefits
Code Sharing
Share types, utilities, and configurations across frontend and backend
Incremental Builds
Turborepo only rebuilds changed packages and their dependents
Type Safety
End-to-end TypeScript types from database to API to frontend
Single Version Control
One repository, one version, easier collaboration
Best Practices
- Keep packages focused - Each package should have a single responsibility
- Use workspace protocol - Always use
workspace:*for internal dependencies - Leverage caching - Turborepo caches task outputs for faster subsequent runs
- Build before dev - The
^builddependency ensures packages are ready before dev mode - Centralize configs - Use
@packages/tsconfigfor shared TypeScript settings