Local Development
Prerequisites
- Node.js 18+
- Yarn
- Wrangler CLI:
npm install -g wrangler && wrangler login
First-time setup
-
Install monorepo dependencies
Terminal window # From enterprise/ rootyarn install -
Initialize the local D1 database
Terminal window cd apps/alokonyarn db:goThis runs
db:reset→db:migrate→db:seedin sequence. After this you have a clean database with one user:rick@alokai.com/123qwe. -
Start the dev servers
Terminal window yarn devServer URL Notes Wrangler (Worker + API) http://localhost:8787Hot-reloads server code Vite (React SPA) http://localhost:5173HMR for frontend Open
http://localhost:5173to use the UI.
Project structure
apps/alokon/├── src/│ ├── client/ # React SPA (Vite)│ │ ├── App.tsx # Router setup│ │ ├── pages/ # Page components│ │ ├── components/ # Reusable UI│ │ ├── stores/ # Zustand state│ │ └── lib/api.ts # HTTP client│ ├── server/ # Hono Worker│ │ ├── index.ts # App entrypoint│ │ ├── routes/ # API route handlers│ │ ├── middleware/ # Auth, space context│ │ └── utils/ # Business logic│ ├── shared/ # Types and schemas shared by client + server│ │ ├── types/│ │ └── schemas/ # Built-in component field definitions│ ├── db/│ │ └── migrations/ # SQL migration files│ └── cli/ # CLI tool source├── package.json├── vite.config.ts # Frontend build config└── wrangler.jsonc # Cloudflare Worker configDatabase commands
| Command | Description |
|---|---|
yarn db:migrate | Run any pending migrations |
yarn db:seed | Insert default user |
yarn db:reset | Delete all local D1 state |
yarn db:go | Full reset: reset → migrate → seed |
Running tests
yarn testTests use Vitest.
Building
yarn buildOutputs:
dist/— React SPA (served as static assets by the Worker)- Wrangler bundles the Worker from
src/server/index.ts
Environment variables for local dev
Set variables in wrangler.jsonc under the [vars] section:
"vars": { "ENVIRONMENT": "development", "AUTH_JWT_SECRET": "alokon-dev-secret-change-in-production", "AUTH_PROVIDER": "none"}