This document separates the architecture that runs today from the components planned for heavier solvers. That distinction is intentional: an alpha should be easy to reproduce without pretending that future infrastructure already exists.
- Scientific code is usable without React or HTTP.
- Canonical geometry uses meters; SVG pixels are only a view transform.
- Every public payload and project file has an explicit version.
- A failed or rejected solve never becomes a successful-looking scientific result.
- Identical valid inputs and settings produce equivalent outputs.
- The application remains useful locally without accounts, a database, or telemetry upload.
flowchart TB
subgraph Web["apps/web"]
Editor["SVG track editor"]
Form["Kart + solver inputs"]
Adapter["Versioned API adapter"]
BrowserSolver["Ported browser engine (TS)"]
Viewer["Line + charts + references"]
Project[".okl.json reader/writer"]
end
subgraph API["services/api"]
HTTP["FastAPI / OpenAPI"]
end
subgraph Core["engine"]
Contract["Strict Pydantic contracts"]
Geometry["Validation + metric geometry"]
Path["Minimum-bending baseline"]
Physics["Cyclic point-mass speed profile"]
Explain["Diagnostics + markers"]
end
Editor --> Adapter
Form --> Adapter
Adapter -->|API available| HTTP
Adapter -->|network unavailable| BrowserSolver
HTTP --> Contract --> Geometry --> Path --> Physics --> Explain
Explain --> Viewer
BrowserSolver --> Viewer
Project <--> Editor
Project <--> Form
The Vite development server proxies /api to a loopback-only FastAPI service. The endpoint runs a bounded synchronous MVP calculation. The static GitHub Pages demo cannot host Python, so it runs a TypeScript port of the engine (apps/web/src/domain/engine/): the same corridor preparation, minimum-bending optimizer, and iterative speed solver, held to roundoff-level parity with the Python engine by a committed fixture gate that runs in both directions (engineParity.test.ts checks the port against the fixtures, tests/python/test_parity_fixtures.py checks the engine against the same ones, and scripts/export_parity_fixtures.py regenerates them). The original anchor heuristic survives only as a defensive fallback so the demo never breaks.
GET /health
POST /v1/tracks/validate
POST /v1/simulations
GET /docs
GET /openapi.json
POST /v1/simulations accepts explicit left/right boundaries, kart parameters, and solver settings. A syntactically valid request returns one structured state: success, invalid_input, or numerical_failure. Validation and scientific failures are returned to the UI; only transport unavailability permits browser fallback.
engine/openkartline_enginedepends on Pydantic and NumPy, never FastAPI or React.services/apitranslates HTTP requests to engine calls.apps/webowns presentation and maps its centerline/width editor model to explicit boundaries..okl.jsonis a local user-project format; API request/result schemas are separate contracts.
- Length: meters.
- Time: seconds.
- Speed: meters per second inside the engine; km/h only for display/input fields that say so.
- Angles: radians.
- Mass: kilograms.
- Local frame: right-handed Cartesian
(x, y). - Distance
s: meters from the start sample in driving direction. - Boundaries:
left_boundaryandright_boundaryas seen while travelling in the declared direction.
The API accepts power_hp because it is familiar in karting and converts it immediately to mechanical watts. Raw project centerline coordinates remain metric and are independent of viewport size.
- Validate size, finite numeric range, closure, self-intersections, nesting, side semantics, and usable width.
- Normalize direction and align the two boundaries.
- Produce a periodic smooth representation and resample it by arc length.
- Search for a corridor-constrained, deterministic minimum-bending baseline.
- Derive station, heading, signed curvature, and segment lengths.
- Apply lateral speed limits and cyclic forward-acceleration/backward-braking passes under a combined friction envelope.
- Return samples, assumptions, warnings, solver/path diagnostics, and reproducible driving references.
The path is a local baseline, not proof of global minimum curvature and not a joint minimum-time solution.
- HTML limits improve input ergonomics but domain validation remains authoritative.
- Project imports have byte, point-count, numeric-range, and schema-version limits.
- API request collections and solver iterations are bounded.
- Domain rejection is shown to the user and is never silently replaced by fallback output.
- Numeric arrays are returned only for a successful state.
- Localhost CORS is explicit and credentials are disabled.
Joint path/control optimization may take seconds or minutes and must not run inside FastAPI background tasks. When that backend lands, an ADR must introduce a supervised process and a lifecycle such as:
queued -> validating -> running -> succeeded
\-> failed
\------------> cancelled
That future API would add job submission, progress, timeout, cancellation, restart recovery, and immutable input/result hashes. None of those endpoints are claimed by the current alpha.
- Static demo: GitHub Pages plus the ported TypeScript engine; no Python engine.
- Developer/local: Vite plus loopback FastAPI; current complete alpha workflow.
- Future local release: one launcher serving the built UI and supervised solver process.
- Future container/desktop: evaluated only after the physics MVP and cross-platform packaging tests.
- Future hosted service: requires authentication, quotas, durable jobs, privacy review, and abuse controls.