Appearance
Architecture
Monorepo Layout
.
├── apps/
│ ├── web/ # Frontend (React + Vite → Cloudflare Pages)
│ ├── api/ # Backend API (oRPC → Cloudflare Worker)
│ └── docs/ # Documentation site (VitePress → Cloudflare Pages)
├── packages/
│ ├── db/ # Drizzle ORM + D1 schema + migrations
│ ├── auth/ # better-auth configuration + helpers
│ ├── email/ # Resend email sender
│ ├── payment/ # Doku payment gateway integration
│ └── shared/ # Shared types, utilities, constants
├── pnpm-workspace.yaml # Workspace definitions + dependency catalogs
├── package.json
├── turbo.json # Build orchestration
├── biome.json # Formatter + linter config
└── lefthook.yml # Pre-commit hooksNamespaces
| Directory | Package Namespace | Example |
|---|---|---|
apps/* | @apps/* | @apps/web, @apps/api |
packages/* | @packages/* | @packages/db, @packages/auth |
Data Flow
User → Cloudflare Pages (apps/web)
↓
oRPC API (apps/api)
↓
D1 Database (packages/db)
↓
Auth (packages/auth) → better-auth + Google OAuth + Email/Password
Email (packages/email) → Resend
Payment (packages/payment) → DokuPackage Boundaries
@packages/dbexports schema, migrations, and acreateDb(env)factory.@packages/authexportsauthinstance andgetSessionhelpers.@packages/emailexportssendEmailfunction.@packages/paymentexports Doku client and checkout helpers.@packages/sharedexports TypeScript types and utilities used by both frontend and backend.
API Architecture (oRPC)
Contract (apps/api/src/contract/) → Route definitions, input/output schemas
Middleware (apps/api/src/middleware/) → Auth chain, role checks, context builders
Routes (apps/api/src/routes/) → Route handlers (guard + governance + service call)
Services (apps/api/src/services/) → Pure business logic, no auth awarenessThe API entrypoint is a pure Cloudflare Workers fetch handler. No additional HTTP framework (like Hono) is used — oRPC's OpenAPIHandler from @orpc/openapi/fetch handles request routing directly.
base44.com Migration
base44.comwas previously the backend (functions + entities).- All secrets previously stored in frontend now live in
apps/apienv bindings. - "Whoami" and non-AI data endpoints move from base44 to
apps/api. - AI features may still use base44.com directly; everything else goes through the new API.
Deployment Model
apps/webdeploys to Cloudflare Pages.apps/apideploys to Cloudflare Workers.apps/docsdeploys to Cloudflare Pages (separate site fromapps/web).apps/webandapps/apishare the same D1 database binding per environment.apps/docsis a static site with no backend dependency.
Workers vs Pages
| App | Platform | Wrangler Config |
|---|---|---|
apps/api | Workers | Supports env.development and env.production keys |
apps/web | Pages | No env keys — env vars dashboard-managed or via --branch CLI |
apps/docs | Pages | No env keys — static site |
Documentation Architecture
- Human docs:
apps/docs(VitePress) — overview, tech stack, architecture, user flows. - API docs: Auto-generated OpenAPI spec served by
apps/apiat/api/openapi.jsonwith Scalar UI at/api/docs. - AI rules:
.agents/knowledge system — hard rules and conventions for code generation. - No duplication: API endpoint docs live only in OpenAPI. Human docs link to it.
- Hot deploy:
apps/docsdeploys on every push to main. Keep it in sync with codebase changes.
README.md
The root README.md is minimal. It contains:
- One-line project description
- Link to
apps/docs/index.mdfor full documentation - Link to
/api/docsfor API reference - Quick setup instructions (pnpm install, dev commands)
Do NOT duplicate apps/docs content in README.md.
apps/docs/
The documentation site is built with VitePress and deployed to Cloudflare Pages. It is divided into two sections:
- overview/ — Non-technical docs: project goals, product features, getting started.
- technical/ — Technical docs: architecture, tech stack, auth, database, deployment, user flows.
API endpoint documentation is NOT in VitePress. It is auto-generated from the oRPC contract and served by apps/api at /api/openapi.json with Scalar UI at /api/docs. The docs site only links to it.
For docs conventions and update rules, see .agents/rules/docs.md.