Project Structure
A Bun + Turbo monorepo: two Cloudflare Workers apps and the shared packages that tie them together.
text
Apps
apps/api: the Hono API worker. Routes live insrc/index.ts; business logic is exposed as oRPC procedures insrc/orpc. Data access uses Drizzle against D1.apps/web: the TanStack Start web app, also a Worker. File-based routes insrc/routesrender server-side and hydrate on the client.
Packages
@my-app/backend-contract: the oRPC contract. It declares procedure inputs and outputs with Zod, and both apps depend on it, so a change to the contract is a compile error on both sides until fixed.@my-app/ui: shared Base UI components, the global stylesheet, and yourConfig.brandsettings.@my-app/transactional: react-email templates, rendered to HTML by the email module.
Packages are namespaced under your project name. Import them with the alias, e.g. @my-app/ui/components/ui/button.
The oRPC contract flow
Adding an API endpoint touches three places, all fully typed:
- Declare the procedure in
packages/backend-contract(name, Zod input/output). - Implement it in
apps/api/src/orpc. - Call it from the web app through the typed
backendclient, autocomplete and type checking included.
Which folders exist depends on the modules you selected, see Modules.