Skip to content

Local Development

Prerequisites

  • Node.js 18+
  • Yarn
  • Wrangler CLI: npm install -g wrangler && wrangler login

First-time setup

  1. Install monorepo dependencies

    Terminal window
    # From enterprise/ root
    yarn install
  2. Initialize the local D1 database

    Terminal window
    cd apps/alokon
    yarn db:go

    This runs db:resetdb:migratedb:seed in sequence. After this you have a clean database with one user: rick@alokai.com / 123qwe.

  3. Start the dev servers

    Terminal window
    yarn dev
    ServerURLNotes
    Wrangler (Worker + API)http://localhost:8787Hot-reloads server code
    Vite (React SPA)http://localhost:5173HMR for frontend

    Open http://localhost:5173 to 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 config

Database commands

CommandDescription
yarn db:migrateRun any pending migrations
yarn db:seedInsert default user
yarn db:resetDelete all local D1 state
yarn db:goFull reset: reset → migrate → seed

Running tests

Terminal window
yarn test

Tests use Vitest.

Building

Terminal window
yarn build

Outputs:

  • 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"
}