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 Ariadne Screen
- Create
ariadne/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 ariadne/lib/models/navigation_data.dart with fromJson/toJson
Adding a New Tracking Algorithm
- Create
server/src/algs/tracking_alg_yourname.tsas a pure module: it default-exports anAlgorithm(seeserver/src/algs/tracking_alg_types.ts) and imports only that types file and other pure algorithm modules - Add a configured instance to
TRACKING_ALG_CATALOGinserver/src/algs/tracking_alg_catalog.ts; itsnameis the registry name - Add
tools/rtls-sim/algs/prod_yourname.tsso the simulator runs the same entry - Add
server/tests/tracking_alg_yourname.test.ts - It will automatically appear in
/api/v1/tracking/algorithmsand be selectable via/api/v1/tracking/start/yourname
See tracking for how the runner drives these modules.
Modifying the Navigation System
Server-side (graph storage)
- Floor/node/edge CRUD:
server/src/routes/http.ts(route declarations use/floor,/node,/edgebefore the/api/v1prefix is applied) - Navigation bundle: search for the
/navigation/projectroute declaration (served under/api/v1/navigation/project) - Pathfinding: search for the
/navigation/pathfindroute declaration (served under/api/v1/navigation/pathfind)
Web-side (graph editor)
- Editor UI:
web/src/pages/navigation.ts - Uses Pixi.js directly (not through
canvas.ts)
Ariadne-side (navigation)
- Graph:
ariadne/lib/core/navigation_graph.dart - Position:
ariadne/lib/core/positioning.dart - Renderer:
ariadne/lib/game/navigation_game.dart - Screen:
ariadne/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)
Ariadne build
- Entry:
scripts/build/ariadne.sh - Release pipeline:
scripts/release/ariadne.ts
Full build
- Entry:
scripts/build/all.sh(calls server + ariadne builds)
Running Tests
bash
# Everything (typecheck, unit tests, Playwright, contracts)
bun test:all
# Server tests
cd server && bun test
# Contract tests (server ↔ ariadne)
bun test:contracts
# Ariadne tests
cd ariadne && 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) - Ariadne:
ariadne/lib/screens/home_screen.dart(connection flow) - Lib:
lib/src/schemas.ts+lib/src/types/query.d.ts(data contracts) - Config:
config/main.config.json(legacy fallback: rootmain.config.json) + docs atdocs/guide/configuration.md