Inspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for LineSide

Inspiration

When a CNC machining center or hydraulic workcell throws an alarm on the night shift, the technician on duty is often standing inside a steel enclosure with weak or no signal, wearing oily gloves, facing an urgent fault screen and a 300-page equipment manual. According to Siemens' industry benchmark report The True Cost of Downtime, Fortune Global 500 industrial manufacturers lose $1.4 trillion annually (roughly 11% of revenue) to unplanned downtime — reaching $2.3 million per hour in automotive plants (Siemens: The True Cost of Downtime). Pure cloud chatbots fail when Wi-Fi drops, shop-floor photos and PLC telemetry are sensitive plant data, and an unchecked hallucination ("just bypass the door interlock") risks severe injury.

What it does

LineSide turns a technician's plain-language report ("e101 again, oil is really hot, cooler feels weak") or an HMI alarm screen photo into a draft maintenance work order where every step cites an exact manual page.

  • 100% Firebase AI Logic — On-Device First: Gemini Nano in Chrome (through the Firebase AI Logic Web SDK) extracts alarm codes, reads HMI alarm images locally, and drafts cited steps. The manual knowledge base, BM25 retrieval, PLC readings, and repair history all run locally; the app reloads completely offline as a PWA.
  • Deterministic Validated Escalation (Single-Roundtrip Cloud Fallback): Every on-device output is checked deterministically before it is shown: strict JSON schema, page numbers restricted to the retrieved-page enum, step-to-page lexical grounding, and zero invented/missing alarm codes. Only failing answers escalate to Gemini in the cloud (gemini-3.5-flash-lite) via InferenceMode.ONLY_IN_CLOUD — with failure reasons attached, machine IDs and numeric PLC readings redacted, and shop-floor images stripped (0 bytes of HMI imagery sent to cloud). A 0 ms deterministic alarm-code fast-path plus skipCloud: true speculative intent guarantees at most 1 cloud round-trip on escalation. When offline or when cloud is toggled off, LineSide falls back verbatim to the cited manual steps and queues the report in retryQueue.ts for automatic re-verification upon reconnect.
  • Rails Before Models (Physical Safety Gates): Requests to bypass safety interlocks or modify alarm limits, unknown alarm codes, and physically impossible transducer readings (e.g., 150 °C on a 0–120 °C PT100 oil sensor = open-circuit / sensor fault, not a hydraulic overheat) are refused deterministically before any AI model runs, citing the authoritative manual page.
  • Public Industrial Standards + Browser-Local PDF Manual Ingestion (IndexedDB): Default equipment pages are grounded in real public standards: Haas VF-Series CNC Mill Operator's Manual (Pub. 96-8000, NGC Alarms 106/108/116/139), ISO 4413:2010 hydraulic safety, ISO 14119:2013 guard interlocks, IEC 60204-1, and U.S. OSHA 29 CFR 1910.147 Lockout/Tagout (LOTO). Technicians can also upload any multi-page equipment PDF offline; LineSide parses ISO 32000-1 /FlateDecode streams and /ToUnicode CMaps in pure browser code (src/core/pdfManual.ts), persists the chunked manual into IndexedDB (lineside-manuals-v1), and rebuilds the BM25 index offline.
  • Multimodal HMI Alarm Vision (0 bytes to Cloud): Captures HMI alarm snapshots via Chrome Prompt API multimodal expectedInputs: [{ type: "image" }] through Firebase AI Logic ONLY_ON_DEVICE, with a deterministic local fallback (TextDetector + PNG tEXt metadata + filename parser).
  • OSHA LOTO Human-in-the-Loop & Redacted Hand-Over: High-risk cabinet/accumulator work requires explicit LOTO confirmation. Live readings are verified against manual thresholds quoted on the cited page (CW_FLOW ≥ 15 L/min, p.12). Work orders share via compressed URL fragment (#share=..., no server), Web Share API, printable PDF, or QR code — always redacted first.

How we built it

  • Firebase AI Logic Web SDK (firebase 13.2): All AI inference uses getAI() + GoogleAIBackend exclusively. We run two fixed-mode model instances per request: InferenceMode.ONLY_ON_DEVICE (with initialPrompts + dynamic retrieved-page-enum responseConstraint) and InferenceMode.ONLY_IN_CLOUD (gemini-3.5-flash-lite, responseMimeType: "application/json" + responseJsonSchema, temperature: 0).
  • Why not PREFER_ON_DEVICE? In the SDK, PREFER_ON_DEVICE falls back only when the local model is unavailable — not when a small model returns invalid JSON, an unretrieved page, or an ungrounded step. HybridRouter.generateValidated() (src/inference/router.ts) enforces deterministic verification first and drives the tier badges directly from response.inferenceSource.
  • Mandatory Firebase App Check: ensureAppCheck() initializes ReCaptchaEnterpriseProvider (Fraud Defense) synchronously before getAI() so cloud calls never hit cached null App Check tokens. Real mode enforces VITE_RECAPTCHA_SITE_KEY and supports VITE_APPCHECK_DEBUG for judging.
  • Zero-Third-Party-API Build Guard (tests/no_direct_model_api.test.ts): Builds the real Vite production bundle and asserts that only Firebase / App Check / reCAPTCHA endpoints exist in the output, firebasevertexai.googleapis.com is present, and zero other model APIs appear anywhere in source or bundle.
  • UI & Accessibility: Vanilla TypeScript + Vite PWA (dist/assets/index-*.js 75.81 kB gzip), self-hosted Inter font, Phosphor icons, English & Spanish UI, high-contrast industrial stone-amber palette (21/21 WCAG 2.1 AA pairs pass, 0 failures; cloud badge #78350f / #f5ebe0 at 7.71:1), responsive from 390 px to desktop.

Verified Engineering & Evaluation Results

All results below are directly reproducible from the public repository (https://github.com/Qidianyan/lineside-firebase-hybrid-ai):

  • Automated Unit & Integration Tests (npm test): 17/17 test files, 160/160 Vitest tests PASS (including real Firebase AI Logic SDK on-device code path against mock window.LanguageModel, multimodal image path, ISO 32000-1 PDF FlateDecode/CMap parser + IndexedDB store, single-roundtrip cloud fallback, redacted sharing, and zero-third-party-API production-bundle guard).
  • Headless Chrome E2E & Accessibility (npm run e2e): 25/25 scenarios PASS, 0 console errors, 0 axe-core WCAG 2.1 A/AA violations across every UI state (including offline Nano, cloud escalation, PDF manual upload, multimodal HMI vision, LOTO confirmation, redacted share/print/QR, and 390 px mobile).
  • 62-Case × 8-Config Routing Benchmark (npm run eval → results/eval.md):
    • 100% refusal recall and 100% status+reason accuracy across all 8 routing configurations — even when 100% of on-device responses are fault-injected as wrong;
    • 100% citation validity (every accepted step cites an actually retrieved manual page);
    • Under 30% flaky on-device fault injection, 76.3% of work orders finish on-device and hybrid makes 9 cloud calls vs. 38 cloud-only (−76.3%, down from 98 prior to single-roundtrip intent optimization).
  • Live Firebase Spark Cloud Smoke (results/live_cloud_smoke.md): Verified against Spark project lineside-hybrid with gemini-3.5-flash-lite + App Check Fraud Defense (4/4 live cloud smoke checks PASS; work-order UI latency 16,697 ms).
  • Cross-Platform Shared Core (LinesideCore Swift package): 11/11 XCTest cases PASS, verifying identical tokenization, BM25 retrieval, and routing rules across the 62-case specification.

Challenges we ran into

  • On-device Gemini Nano is single-turn, token-bounded (≤ 9,216 tokens), and language-scoped (en/es/ja/de/fr) — requiring compact retrieved-excerpt prompts and bilingual EN/ES UX.
  • GenerativeModel schemas are bound at instance creation while our retrieved page enum changes per query, so we construct per-request model instances dynamically.
  • Initializing getAI() before initializeAppCheck() cached a null App Check reference and caused 401 errors on cloud escalation; synchronizing ensureAppCheck() prior to getAI() eliminated the failure.

What we learned

Hybrid AI is not "run the small model whenever installed" — it is "run the small model whenever deterministic verification can prove the output is safe and grounded." Rails before models plus validated escalation turn cloud fallback into a measurable, auditable, privacy-preserving event.

What's next

Cloud Firestore offline persistence for cross-shift redacted work-order sync; Firebase Remote Config for fleet-wide grounding thresholds; native Android AICore and iOS Foundation Models clients sharing our verified LinesideCore spec.


3. Prior-Work Disclosure (Paste into Devpost "New & Existing Work" / Notes)

Full commit-level disclosure with Pacific Time timestamps is published at PRIOR_WORK_DISCLOSURE.md.

  • Pre-Submission Baseline (pre-hackathon-baseline-20261110): An earlier offline Python prototype inspired the domain idea (none of that Python code is shipped). The LineSide TypeScript/PWA baseline (v1–v7) was created on 2026-11-10 prior to the Submission Period start (2026-11-11 13:30 PT) and is explicitly tagged pre-hackathon-baseline-20261110 in git.
  • Significant Updates Built During the Submission Period (git log pre-hackathon-baseline-20261110..HEAD):
    1. Live Firebase project lineside-hybrid (Spark) + Firebase AI Logic (gemini-3.5-flash-lite) + App Check Fraud Defense integration and synchronous ensureAppCheck() fix (4/4 live cloud smoke PASS);
    2. Full replacement of synthetic sample manuals with real public industrial standards (Haas VF-Series CNC Pub. 96-8000, ISO 4413:2010, ISO 14119:2013, IEC 60204-1, OSHA 29 CFR 1910.147);
    3. Zero-network browser-local ISO 32000-1 PDF manual parser (FlateDecode + /ToUnicode CMap) + IndexedDB BM25 manual store;
    4. Chrome Prompt API multimodal HMI alarm screen vision via Firebase AI Logic ONLY_ON_DEVICE (0 bytes imagery sent to cloud);
    5. Single-roundtrip cloud fallback optimization (cutting cloud-only calls from 98 to 38 and flaky-30% hybrid calls to 9);
    6. Strict zero-third-party-API build guard (tests/no_direct_model_api.test.ts), WCAG 2.1 AA high-contrast stone-amber palette (21/21 pass), and expansion to 160 Vitest tests + 25 headless-Chrome E2E/axe scenarios.
  • Honesty Statement: Default demo mode (VITE_AI_MODE=mock) uses a simulated window.LanguageModel and deterministic cloud stand-in (clearly labelled on screen) while exercising the real Firebase AI Logic on-device SDK path; results/eval.md measures pipeline routing and safety rails rather than live model quality. Real-device Chrome 139+ Gemini Nano hardware timing can be captured on any Nano-enabled desktop via npm run bench:real.

4. Try It Locally (Copy into Devpost "Try It Out" / Testing Instructions)

git clone https://github.com/Qidianyan/lineside-firebase-hybrid-ai.git
cd lineside-firebase-hybrid-ai
npm ci
npm test                 # 17 files, 160/160 tests PASS (incl. no_direct_model_api build guard)
npm run build && npm run preview   # Open http://127.0.0.1:4173/ (zero-account demo mode)
# Optional URL switches: ?nano=bad (inspect validated cloud escalation), ?offline=1, ?lang=es
# Real Firebase AI Logic mode: cp .env.example .env.local -> set VITE_FIREBASE_*, VITE_RECAPTCHA_SITE_KEY, VITE_AI_MODE=firebase

Built With

Share this project:

Updates

Submission history