Initial scaffold: Turborepo monorepo + design wiki
Turborepo (pnpm workspaces) with all dependencies pinned to latest mutually-compatible versions: turbo 2.9, TypeScript 6, Fastify 5, React 19, Vite 8, better-sqlite3 12 + Drizzle ORM 0.45. Layout: - apps/server Fastify backend (local JWT auth + role guard, /health) - apps/web React 19 + Vite 8 operator SPA - packages/db Drizzle schema on SQLite/WAL; append-only events + users - packages/devices reader/printer/relay adapter interfaces (intent-only relay) - packages/shared shared domain types Architecture constraints from the design wiki are encoded in the scaffold: append-only hash-chained + signed event log, device-agnostic adapters, "a barrier is not a door" (relay expresses intent only), fully-local offline-first auth. wiki/ is an LLM-maintained Obsidian knowledge base (28 pages) ingested from the architecture & design notes, with its own maintenance schema. Verified: pnpm install, full turbo build (5/5), server boots and serves /health, drizzle-kit generates the initial migration.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// Shared types and utilities across the parking system.
|
||||
//
|
||||
// The domain is offline-first and threat-model driven. The central integrity
|
||||
// primitive is an append-only, hash-chained, ATECC608-signed event log: entry
|
||||
// and exit events are never edited or deleted — a "void" is itself an appended
|
||||
// event. See wiki/concepts/append-only-event-chain.md.
|
||||
|
||||
export type Role = "admin" | "operator" | "cashier" | "readonly";
|
||||
|
||||
export type Direction = "entry" | "exit";
|
||||
|
||||
/** What kind of identity source produced a read. */
|
||||
export type IdentitySource = "wiegand" | "lpr" | "qr" | "ticket" | "manual";
|
||||
|
||||
/**
|
||||
* An append-only parking event. Records are never mutated; corrections are new
|
||||
* events. `prevHash` chains each event to the previous one; `signature` is the
|
||||
* ATECC608 signature over the event contents. See wiki/append-only-event-chain.
|
||||
*/
|
||||
export interface ParkingEvent {
|
||||
readonly id: string;
|
||||
readonly index: number;
|
||||
readonly type: ParkingEventType;
|
||||
readonly direction: Direction | null;
|
||||
readonly lane: number;
|
||||
readonly source: IdentitySource | null;
|
||||
/** Card number, plate, ticket id, etc. — depends on `source`. */
|
||||
readonly identity: string | null;
|
||||
readonly occurredAt: string; // ISO-8601
|
||||
/** Hash of the previous event in the chain (hex). Null only for genesis. */
|
||||
readonly prevHash: string | null;
|
||||
/** ATECC608 signature over the canonical event payload (hex). */
|
||||
readonly signature: string;
|
||||
}
|
||||
|
||||
export type ParkingEventType =
|
||||
| "vehicle_entry"
|
||||
| "vehicle_exit"
|
||||
| "void"
|
||||
| "barrier_open_command"
|
||||
| "barrier_open_observed"
|
||||
| "shift_z_report"
|
||||
| "anomaly";
|
||||
|
||||
export const ROLES: readonly Role[] = [
|
||||
"admin",
|
||||
"operator",
|
||||
"cashier",
|
||||
"readonly",
|
||||
] as const;
|
||||
Reference in New Issue
Block a user