Appearance
Component Quick-Start Guides
Concise guides for AI assistants working on specific components. Each section tells you exactly where to look and what patterns to follow.
Adding a New HTTP Route
- Open
server/src/routes/http.ts - Find the section matching your domain (auth, beacons, gateways, etc.)
- Add your route following this pattern:
typescript
if (url === "/your-endpoint" && method === "GET") {
const g = guard_auth(req); // or guard_admin for admin-only
if (g instanceof Response) return g;
const { db } = g;
// Your logic here
return rs_res_ok({ data: result });
}- If you need a new Valibot schema, add it to
server/src/schemas.ts - If the web frontend needs to call this route, add schemas to
web/src/lib/contracts.ts
Adding a New Web Page
- Create the page function in
web/src/pages/your_page.ts - Create HTML templates in
web/src/templates/your_page/ - Register the menu handler in
web/src/pages/dashboard.ts - Export the page function and import it in
dashboard.ts - Add any needed API schemas to
web/src/lib/contracts.ts
Adding a New Mobile Screen
- Create
mobile/lib/screens/your_screen.dartas aStatefulWidget - Navigate to it from an existing screen using
Navigator.push() - Use
ApiClientfor server communication - If it needs BLE data, take
BleScanneras a constructor parameter
Adding a New Database Table
- Create migration file
server/migrations/NNN_description.ts:
typescript
import { Database } from "bun:sqlite";
export default function(db: Database) {
db.run(`CREATE TABLE IF NOT EXISTS your_table (...)`);
}- Add query result type to
lib/src/types/query.d.ts - Add Valibot schema to
server/src/schemas.ts - Rebuild migration embeds for production:
bun scripts/build/generators/embeds.ts
Adding a New Valibot Schema
For MQTT/external data (shared)
Add to lib/src/schemas.ts
For DB query results (server)
Add to server/src/schemas.ts
For API contracts (web)
Add to web/src/lib/contracts.ts
For mobile models
Add to mobile/lib/models/navigation_data.dart with fromJson/toJson
Adding a New Tracking Algorithm
- Create
server/src/algs/tracking_alg_yourname.ts - Export a function matching the algorithm interface
- Register it in
server/src/tracking.tsin the algorithm map - It will automatically appear in
/tracking/algorithmsand be selectable via/tracking/start/yourname
Modifying the Navigation System
Server-side (graph storage)
- Floor/node/edge CRUD:
server/src/routes/http.ts(search for/floor,/node,/edge) - Navigation bundle: search for
/navigation/project - Pathfinding: search for
/navigation/pathfind
Web-side (graph editor)
- Editor UI:
web/src/pages/navigation.ts - Uses Pixi.js directly (not through
canvas.ts)
Mobile-side (navigation)
- Graph:
mobile/lib/core/navigation_graph.dart - Position:
mobile/lib/core/positioning.dart - Renderer:
mobile/lib/game/navigation_game.dart - Screen:
mobile/lib/screens/navigation_screen.dart
Modifying the Build Process
Server build
- Entry:
scripts/build/server.sh - Embeds web UI:
scripts/build/generators/embeds.ts→server/src/static_embeds.ts
Web build
- Entry:
web/build.ts - Config injection happens here (define constants)
Mobile build
- Entry:
scripts/build/mobile.sh - Release pipeline:
scripts/release/mobile.ts
Full build
- Entry:
scripts/build/all.sh(calls server + mobile builds)
Running Tests
bash
# Server tests
cd server && bun test
# Contract tests (server ↔ mobile)
bun test:contracts
# Mobile tests
cd mobile && flutter test
# Web type checking
cd web && bun run typecheckKey Files to Read First
When starting work on any component, read these files first:
- Server:
server/src/server.ts(entry point, all exports) - Web:
web/src/web.ts+web/src/pages/dashboard.ts(router + main page) - Mobile:
mobile/lib/screens/home_screen.dart(connection flow) - Lib:
lib/src/schemas.ts+lib/src/types/query.d.ts(data contracts) - Config:
main.config.json+ docs atdocs/guide/configuration.md