# Yantrika — What We Built, and How *Comprehensive implementation reference — v0.12.1, 2026-09-03* This document is the single place to understand the whole platform: every component, why it exists, how it talks to the others, the security model, how it gets deployed, how it's tested, and how it was actually built. It is written for a technical reader (engineer, CTO, or a technical investor) who wants the real picture, not the pitch deck. For the pitch-deck version, see `docs/index.html`. For the day-to-day command reference, see the root `README.md` and `docs/RUNBOOK-WINDOWS.md`. For the security posture in isolation, see `docs/SECURITY.md` and `docs/COMPLIANCE.md`. --- ## 1. What Yantrika is Yantrika is an operations platform for **Physical AI** — specifically, fleets of autonomous mobile robots (AMRs) in warehouses and industrial sites. "Physical AI" is the umbrella the industry (NVIDIA, Amazon Robotics, Physical Intelligence, Google DeepMind and others) uses for AI systems that act in the physical world rather than just generate text or images: a warehouse AMR, a manipulator arm, a humanoid. Every one of those systems needs the same operational layer once you have more than a handful of them running: a place to see what they're doing, a way to catch problems before they become costly, a gate that keeps a human in the loop for anything consequential, and a way for new operators to learn the system quickly. Yantrika is that layer. Concretely, the platform is three things that share one backend and one identity system: 1. **The fleet-ops core** — simulator/connector → Supabase → console, detector, notifier, predictive maintenance, human-approval command gate. This is the part a real deployment runs continuously. 2. **Sarathi** — an AI copilot, embedded in the console, that answers questions about the fleet ("why is AMR-07 down?", "what's pending approval?") with cited evidence pulled live from the same database, never from imagination. 3. **Yantrika Academy** — a self-contained learning product, sharing the same login, that teaches two things: how to *operate* this specific platform (hands-on, against a live simulated fleet), and how Physical AI *actually works* as a field (perception, planning, robot learning, simulation, the 2026 industry landscape) — content built from web-verified 2026 industry facts, not platform marketing. All three run from one repository, one `yantraops` CLI, and (for the demo/local path) zero paid infrastructure — the loopback mode needs no Supabase account, no API keys, and no internet access at all. ## 2. System architecture ### 2.1 Data flow ``` ┌─────────────────────────────────────────┐ Real AMRs (any vendor) │ MQTT broker │ speaking VDA 5050 v2.1 │ (VDA 5050 v2.1 topics) │ ──────────────────▶ state / instantActions / actionStates │ └───────────────┬───────────────────────┬─┘ │ │ ┌─────────────────────▼───┐ ┌────────────▼────────┐ │ yantrabridge (connector) │ │ yantrasim (sim) │ │ VDA→row translation, │ │ 10-AMR deterministic │ │ alert dedup, batched sink │ │ simulator, same │ │ + CommandPublisher │ │ translation code │ └─────────────┬──────────────┘ └───────────┬─────────┘ │ │ └────────────────┬────────────────┘ ▼ ┌───────────────────────────┐ │ Supabase (PostgREST) │ │ robots · alerts · incidents │ │ commands · missions · │ │ robot_telemetry · │ │ maintenance_findings · │ │ fleet_meta · user_roles · │ │ academy_progress · │ │ certificates │ └──┬───────┬─────────┬───────┘ │ │ │ ┌────────────────┘ │ └───────────────┐ ▼ ▼ ▼ ┌──────────────────┐ ┌────────────────────┐ ┌──────────────────────┐ │ yantradetect │ │ yantranotify │ │ console / academy │ │ incidents + │ │ console/webhook/ │ │ (single-file apps, │ │ predictive │ │ WhatsApp fan-out, │ │ no build step) │ │ maintenance │ │ dedup + backoff │ │ ↕ Sarathi /ask │ └──────────────────┘ └────────────────────┘ └──────────────────────┘ ``` Every arrow above is a real, tested code path — not a diagram of an aspiration. The simulator and the real-robot connector deliberately share the same translation logic (`translate.py` in each package, kept in parity and covered by parallel test suites), so the console, copilot, detector, and notifier cannot tell a simulated fleet from a real one. That is the core design decision that let this whole platform be built and proven *before* a physical robot was ever involved: everything downstream of the `robots` table is validated against the simulator today and will not need to change when a real fleet is plugged in — only `yantrabridge`'s source changes, from JSONL replay to a live MQTT feed from the robots' own VDA 5050 stack. ### 2.2 Why VDA 5050 VDA 5050 is the real, published interoperability standard (maintained by the VDA — the German Association of the Automotive Industry — and the VDMA) for AMR fleets from *different vendors* to speak one protocol to a fleet-management layer. Building on a real standard rather than a bespoke schema means: (a) the platform is credible to anyone evaluating it against industrial requirements, (b) a real AMR vendor's existing VDA 5050 stack can plug into `yantrabridge` with translation work only, not a robot-side integration project, and (c) the "instantActions" / "actionStates" pattern gives the human-approval command gate (below) a standards-based mechanism for closing the loop, rather than an invented one. ### 2.3 Why Supabase Supabase was chosen deliberately for the reasons that matter to an early-stage platform: it is Postgres (so the schema, RLS policies, and SECURITY DEFINER functions are portable to any Postgres — no lock-in), it exposes PostgREST (a REST API generated from the schema — every component in this repo talks to the backend over plain HTTPS/JSON, no vendor SDK lock-in either), it has a real free tier sufficient for a genuine pilot, and it ships Auth (JWT issuance, refresh tokens) that the RBAC model in Section 5 builds directly on. Row Level Security is not a Supabase feature — it is Postgres's own security model — so the "hardened" and "RBAC" modes described below would work identically against self-hosted Postgres. ## 3. Components, one by one | Component | Package | Lines | What it does | |---|---|---|---| | `core/` | `yantracore` | ~110 | The contract every other component imports: the seven canonical robot statuses (`active · idle · charging · paused · estop · degraded · fault`), a `normalize()` for legacy spellings, the multi-site `site_id()` helper, and the single-sourced release `__version__`. | | `sim/` | `yantrasim` | ~1,590 | A deterministic, seeded 10-AMR warehouse simulator: 3 simulated vendors, an 8×5 waypoint grid, battery/charging physics, a scripted localization-fault incident (used pedagogically in the Academy), and mission-aware task assignment. Emits real VDA 5050 v2.1 `state` messages and publishes them via Supabase, MQTT, or stdout. | | `connector/` | `yantrabridge` | ~1,780 | The real-robot path: VDA 5050 → row translation (kept in lockstep with the simulator's), alert dedup with hysteresis, a batched PostgREST sink, sources for MQTT or recorded JSONL/MCAP files, and `CommandPublisher` — the piece that turns an approved command into a real VDA 5050 `instantAction` and watches for the robot's `actionState` acknowledgment. | | `detector/` | `yantradetect` | ~1,020 | Two engines in one package. `IncidentEngine`: PagerDuty-style incident lifecycle — flap-guarded fault/estop detection, one open incident per robot, deterministic idempotent `INC-XXXX` ids, auto-resolve with duration and impact. `MaintenanceEngine`: reads `robot_telemetry` trend windows and raises `maintenance_findings` (motor-temp trend, battery-drain anomaly) with a heuristic remaining-useful-life estimate and confidence score — this is the "predictive maintenance" story. | | `notifier/` | `yantranotify` | ~1,080 | Multi-channel alert fan-out for unacked critical/serious alerts and open incidents: console, webhook (Slack Block Kit / Discord embed shaped), WhatsApp via Twilio. Retry with backoff, a circuit breaker so a dead channel doesn't block the others, severity-grouped digests, HMAC-signed webhooks, multi-site filtering. | | `copilot/` | `sarathi` | ~1,760 | The AI copilot, "Sarathi" (Sanskrit for charioteer/guide — the one who drives with you). A FastAPI service exposing `POST /ask`; see Section 6. Also exposes the same fleet tools over MCP (Model Context Protocol) for external agents. | | `ops/` | `yantraops` | ~1,990 | The orchestrator CLI: `up` (loopback/Supabase/MQTT modes, auto-open browser, READY banner with timing), `migrate` (tracked, checksummed, OPT-IN-gated schema application), `doctor` (environment preflight), `status`, `audit-security` (live security-posture scan — see Section 5). | | `console/` | — | 2,161 (single file) | The operations console: live fleet map, robot detail, alerts, incidents with recorded-telemetry replay, missions, a Pending Approvals card (the human-in-the-loop gate), an Audit view, an SLA/uptime analytics card, the Sarathi Copilot chat panel, a command palette (Ctrl/Cmd+K), a first-run guided tour, a printable shift report, and sign-in/sign-up. Deliberately zero build step — one HTML file, one `