Project structure¶
This starter kit is organized as a monorepo, with separate Bun workspaces for the client, server, and shared packages. This simplifies development by reducing context switching, eliminating redundant configuration, and keeping shared types in sync across the codebase. It also enables the Express API and React frontend to be served from a single deployment.
Workspace layout¶
.
├── apps/
│ ├── client/ # React + Vite client application
│ │ ├── src/
│ │ │ ├── components/ui/ # Reusable UI components
│ │ │ ├── lib/ # Client-side integrations
│ │ │ ├── pages/ # Standalone client pages, such as 404
│ │ │ ├── routes/ # TanStack Router file routes
│ │ │ ├── main.tsx # Browser entry point
│ │ │ ├── routeTree.gen.ts # Generated TanStack Router route tree
│ │ │ ├── router.tsx # Router setup
│ │ │ └── styles.css # Global styles and theme
│ │ ├── components.json # UI generator configuration
│ │ └── vite.config.ts
│ ├── server/ # Express + MongoDB API
│ │ ├── src/
│ │ │ ├── app.ts # Express app assembly and error handling
│ │ │ ├── auth.ts # Better Auth configuration
│ │ │ ├── config.ts # Environment validation
│ │ │ ├── database.ts # MongoDB connection
│ │ │ ├── index.ts # Server startup
│ │ │ ├── lib/ # Server integrations, such as email and storage
│ │ │ ├── middleware/ # Authentication and authorization guards
│ │ │ ├── models/ # Mongoose models
│ │ │ ├── routes/ # Feature routers mounted under /api
│ │ │ └── schemas/ # Request-validation schemas
│ │ └── tsconfig.json
├── packages/
│ ├── emails/ # React Email templates
│ ├── mail/ # Local MailDev service
│ └── shared/ # Types-only contracts shared by client and server
│ └── src/index.ts
├── .railway/ # Railway project and service definitions
├── .vscode/ # Workspace editor settings
├── .env.example # Local environment template
├── DESIGN.md # Product design direction
├── .oxfmtrc.json # Oxfmt configuration
├── .oxlintrc.json # Oxlint configuration
├── compose.db.yaml # Local MongoDB and RustFS services
├── compose.yaml # Full app + MongoDB stack
├── Dockerfile # Production image build
├── docs/ # Documentation site
├── package.json # Root scripts and workspace metadata
├── tsconfig.json # Shared TypeScript options for workspace packages
└── bun.lock # Locked dependency versions
The client and server packages are the runnable application. shared contains
types only, emails contains email templates, and mail runs the local development inbox.
Source path aliases¶
The client and server map @/* to their own src/ directories. Use @/ for
all app-local imports, including shadcn UI components:
TypeScript uses the paths mappings. Vite resolves the client mapping, and
apps/server/alias-runtime.js resolves server imports to src/ in development
and dist/ in production, including the Railway Docker deployment.
Root configuration files¶
Most root-level configuration is for development and deployment:
.env.examplelists the environment variables used by the server and Compose.package.jsondefines theapps/*andpackages/*workspaces and contains the commands for development, builds, checks, and Docker Compose.tsconfig.jsonholds the shared TypeScript options inherited by each workspace package..oxfmtrc.jsonand.oxlintrc.jsonconfigure formatting and linting.compose.db.yamlstarts MongoDB for local development;compose.yamlstarts the production-style app and MongoDB stack.Dockerfilebuilds the client and server into the production image..railway/defines the Railway project and its services.
Where to add code¶
Put new code in the package that owns it:
- Add feature routers under
apps/server/src/routes/, mount them inapps/server/src/app.ts, and add server integrations underapps/server/src/lib/. - Add authentication changes in
apps/server/src/auth.ts; keep environment validation inapps/server/src/config.ts. - Add request validation schemas under
apps/server/src/schemas/. - Add reusable Express guards under
apps/server/src/middleware/. - Add application models under
apps/server/src/models/. - Add routed browser pages under
apps/client/src/routes/, and reusable UI components toapps/client/src/components/ui/. - Add browser/server response contracts to
packages/shared/src/index.ts. Keep database and server-only code out of this package. - Add React Email templates to
packages/emails/.
Next step¶
Continue to Design and UI before adding screens.