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,26 @@
|
||||
{
|
||||
"name": "@parking/devices",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc -b",
|
||||
"dev": "tsc -b --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@parking/shared": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "6.0.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Device-agnostic adapter interfaces.
|
||||
//
|
||||
// Business logic talks ONLY to these interfaces, never to a device SDK. Swapping
|
||||
// hardware means writing a new adapter that implements one of these — nothing
|
||||
// else changes. See wiki/concepts/device-adapter-pattern.md.
|
||||
//
|
||||
// SAFETY: a barrier is NOT a door. The relay interface expresses INTENT only
|
||||
// (`pulseOpen`); it never times or forces a close against a vehicle. Physical
|
||||
// safety (induction loops, anti-crush, auto-reverse) lives in the barrier
|
||||
// operator's own firmware. See wiki/concepts/barrier-not-a-door.md.
|
||||
|
||||
export interface CardReaderDevice {
|
||||
connect(): Promise<void>;
|
||||
onCardRead(cb: (cardNumber: string, door: number) => void): void;
|
||||
disconnect(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface TicketData {
|
||||
readonly ticketId: string;
|
||||
readonly lane: number;
|
||||
readonly issuedAt: string; // ISO-8601
|
||||
}
|
||||
|
||||
export interface PrinterDevice {
|
||||
printTicket(data: TicketData): Promise<void>;
|
||||
checkStatus(): Promise<"ready" | "offline" | "paper_out">;
|
||||
}
|
||||
|
||||
export interface RelayDevice {
|
||||
/** Express intent to open. NEVER timed/forced closed against a vehicle. */
|
||||
pulseOpen(doorId: number): Promise<void>;
|
||||
getDoorStatus(doorId: number): Promise<"open" | "closed">;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"composite": true
|
||||
},
|
||||
"references": [{ "path": "../shared" }],
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user