Inspiration

On a sheet-metal shop floor, defects are usually written down late — at the end of the shift, from memory, on a long form. The notes that matter most also contain things that must not leave the plant: customer names, drawing numbers, unit prices. Many factories simply forbid pasting such notes into cloud AI tools, so the people who would benefit most from AI never get to use it. And floor PCs are mixed: some can run a local model, many cannot.

I wanted an assistant where where the AI runs is decided by the data itself.

What it does

LineNote turns a short note (and optionally a photo) into a structured defect record — defect type, part, location, quantity, severity, suspected cause, immediate action — and later turns many records into a Pareto chart, root-cause hypotheses and an 8D report draft.

The core idea: hybrid inference as a data-governance policy, decided per request.

  • Confidential note (customer / drawing no. / price detected, or Confidential Lock on) -> ONLY_ON_DEVICE. If no on-device model: blocked — saved locally without AI, nothing is sent.
  • Non-sensitive note -> PREFER_ON_DEVICE. If no on-device model: falls back to cloud Gemini.
  • Multi-record root-cause analysis & 8D draft -> ONLY_IN_CLOUD, on masked records only.

Privacy features

  • Masking with a device-wide token map — ACME-77 is always [CUSTOMER_1], EN-2231 is [DRAWING_1]. The map lives only in IndexedDB on the device.
  • Fail-closed guard — before any cloud call or Firestore sync, every string field of every record is re-scanned; if anything sensitive remains, the request is blocked and logged.
  • Local restore — cloud answers come back with tokens; the UI can restore real names on this device only, clearly labeled.
  • Payload inspector — the exact JSON sent to Gemini is shown, so anyone can verify that no raw value left the device.
  • Hybrid Governance Log — every call records requested mode, actual inferenceSource (on-device / cloud), latency, cloud bytes and blocked status.
  • Human-in-the-loop — the worker reviews and edits each AI record before saving; a deterministic post-processor corrects quantities the model gets wrong (e.g. "M8 x4" -> 4).
  • Offline-first — records are saved to IndexedDB and synced (masked) to Firestore when the network returns.

How I built it (how Firebase AI Logic is used)

  • firebase/ai with GoogleAIBackend and getGenerativeModel(...), choosing InferenceMode per task from the routing policy above. Mode defaults and the cloud model name are controlled by Remote Config.
  • On-device: Gemini Nano in Chrome through Firebase AI Logic hybrid inference, with onDeviceParams.createOptions (system prompt, expected inputs/outputs) and structured JSON output with enums. initializeDeviceModel() is called on a user gesture and the model instance is reused.
  • Cloud: gemini-3.5-flash-lite (Firebase AI Logic default) for multi-record analysis on masked data.
  • response.inferenceSource drives the On-device / Cloud badge on every result and the governance log — the app never sets this label itself.
  • App Check with reCAPTCHA Enterprise (debug provider only in development), Anonymous Auth, Firestore with uid-scoped security rules (masked records only), Hosting.
  • React + TypeScript + Vite, Dexie (IndexedDB), Recharts; router and masking logic covered by Vitest unit tests.

Challenges I ran into

  • Overlapping sensitive spans. Dictionary hits, regex hits and the model's own sensitiveSpans overlapped and corrupted the note. I rebuilt masking as span collection -> overlap resolution (dictionary > regex > model) -> single-pass replacement, with tests for the exact failing input.
  • Small models and numbers. Nano sometimes returned quantity 1 for "x4", so a deterministic post-processor validates quantities and flags corrections.
  • Real-world latency. On my low-tier GPU PC, on-device structuring takes about 30 s, while cloud fallback takes about 2-3 s. This is exactly why the routing exists: confidential notes accept the wait, ordinary notes can use whatever is fastest.
  • App Check setup across localhost (debug tokens) and production (reCAPTCHA Enterprise).

Accomplishments that I'm proud of

  • The same deployed URL behaves correctly on both kinds of device: with Gemini Nano everything sensitive stays local; without it, ordinary notes fall back to the cloud while confidential notes are blocked with 0 bytes sent (visible in the log).
  • A judge can verify the privacy claim in the UI itself — payload inspector plus governance log — instead of trusting a README.

What I learned

Hybrid inference is more than a fallback for missing hardware: an explicit InferenceMode per request is a simple, auditable way to encode a company's data policy in the app.

What's next for LineNote

  • Photo-first capture for torque-mark and paint checks with on-device image input.
  • Customer/drawing dictionaries managed centrally via Remote Config per plant.
  • Android build with Gemini Nano for tablets on the line; export of 8D drafts to existing QMS tools.

Built during the submission period

LineNote is a new project created for #BuildHybridAI (started Nov 22, 2026). No pre-existing project code was reused; standard open-source libraries and AI coding assistants were used. All sample data is fictional.

Try it

Built With

  • chrome
  • cloud-firestore
  • dexie
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • gemini
  • gemini-nano
  • indexeddb
  • react
  • recaptcha-enterprise
  • recharts
  • typescript
  • vite
  • vitest
Share this project:

Updates

Submission history