Inspiration

Security architects check system designs against long public standards such as OWASP ASVS and NIST SP 800-63B. Two problems make cloud chatbots unusable for that work:

Confidentiality. I can't paste a proprietary architecture diagram, internal service names or production data flows into a cloud model. Invented rules. A chatbot that makes up or paraphrases a compliance requirement is worse than no tool at all. I built Cartridge to split the work along the privacy line. The cloud reads the public standard once. Everything that touches my confidential design runs on Gemini Nano, on my own device.

What it does

Compiles a public standard once (cloud Gemini through Firebase AI Logic). I upload an openly licensed standard as PDF, Markdown or text, or load the pre-compiled 74-rule OWASP ASVS 5.0 starter in one click. Cloud Gemini turns it into numbered rules (R001, R002, …), each with a quote copied from the source. Code on the device checks every quote against the stored text, after normalising whitespace, ligatures, dashes and hyphenation. Rules whose quote isn't found are left out, with the reason shown. Exam Day measures the small model honestly. Cloud Gemini writes an exam, including questions the rules don't cover, split 70/30 into practice and held-out sets. Gemini Nano takes the exam on the device. A cloud tutor rewords the titles and keywords of rules it missed in practice. It never sees the held-out 30%, which is asked once at the end. The report card shows the held-out test pass rate. An offline Blueprint canvas checks architecture diagrams on the device. I draw a diagram, or start from a template (Web service, Data pipeline, Auth & session flow), on an Excalidraw canvas whose fonts are served by the app itself. Gemini Nano checks every connection against the 5 closest rules. The inspector shows the quote checked against the source, and the header shows Diagram bytes sent: 0. The canvas stays in amber Advisory mode until the cartridge passes a hand-reviewed 30-connection test three times on that device. Until then it never shows green. An optional Ask the cloud (generalised)… button lets me rewrite a pattern without private names. It warns me if a private name is still in the text, and nothing leaves until I approve the exact bytes. Ask works offline, and the cartridge can grow in versions. Gemini Nano picks the rule, code builds the answer from it, checks the quote and does any arithmetic. A question the cartridge can't answer waits offline in Waiting for signal. It goes to cloud Gemini only after I approve the exact text. A rule suggested by the cloud joins the cartridge only if its quote verifies and I approve it, as a new version (v2, v3, …). Nothing is overwritten. Every request is auditable. Every request that leaves the device is listed in What left this device, with its exact content, and summed up on the Report card. Firebase Remote Config changes cloud models and quality thresholds without a redeploy. An optional Firestore public library (with Firebase Auth for publishing) shares compiled public standards. They're checked again on install: SHA-256 hash and every quote. How I built it Hybrid AI with Firebase AI Logic (firebase/ai). One SDK in two modes: InferenceMode.ONLY_IN_CLOUD ( cloud.ts ) for compiling standards, writing exams, tutoring, and approved questions. InferenceMode.ONLY_ON_DEVICE ( firebaseDevice.ts ) for diagram checks and offline answers on Chrome's Gemini Nano. A privacy boundary in the type system (src/privacy/). Anything the user types or draws is a Private value. Cloud calls and Firestore writes accept only Public, checked by the compiler and again at run time with assertPublic(). The only way across is declassify(), which needs my approval in a dialog that shows the exact text. Designed for a small model. Gemini Nano picks from 5 candidate slots (C1..C5 + NONE) instead of an enum of up to 120 rule IDs, so one model session serves every cartridge. It names an exception by number (matchedExceptionIndex) instead of copying its text. Firebase: App Check: reCAPTCHA Enterprise in production, the debug provider in development. Remote Config ( remoteConfig.ts , remote_config.json), with offline defaults. Firestore and Auth ( firestoreLibrary.ts , firestore.rules): owner-only updates and an 11-field schema whitelist. Hosting, with a hand-written service worker ( serviceWorker.ts ). It precaches the 20-file core app, including the Inter font and the OWASP starter, and saves the Blueprint canvas files the first time it opens. UI: light and dark mode with CSS color-scheme and light-dark(), matched by the Excalidraw canvas. Measured results Compiling OWASP ASVS 5.0 (chapters V7, V8, V12, V14 and V16, CC BY-SA 4.0): 5 cloud calls to gemini-3.5-flash-lite, 56,591 bytes sent, 96 seconds. 82 of 82 quotes verified on the device (1 after asking again). 74 rules kept: 19 critical, 55 major, 5 with stated exceptions. Automated tests: 424 unit and type tests in 46 files. TypeScript, ESLint (with a rule that bans calling the raw LanguageModel API), Prettier and the production build all pass. Real Gemini Nano in Chrome on a Windows VM (16 GB RAM, 4 vCPU, no GPU), using the live site: Blueprint, with DevTools set to Offline: no network calls, Diagram bytes sent: 0. It flagged Customer browser (HTTPS, user password) → API gateway as Possible violation, review R056, citing OWASP ASVS 14.3.2 with the quote verified against the source, in amber Advisory mode. Exam Day: Gemini Nano answered the practice questions on the device (20 of 25, 80%, part-way through the run). The cloud tutor ran two rounds; the failure list it received shrank from 12.8 KB to 4.5 KB. Approval before sending: when I chose to keep a question on the device, nothing was sent. When I approved, the dialog showed the exact 31-byte question (741 bytes with the instructions). The cloud answered "Not covered by this rulebook", and those 741 bytes appear in the receipt and in What left this device.

Challenges I ran into

A silent cloud fallback in @firebase/ai 13.3.0. Without Chrome's Prompt API, InferenceMode.ONLY_ON_DEVICE sent requests to the cloud instead of failing. Diagrams must never leave the device, so I added three guards in firebaseDevice.ts : The device counts as ready only if the SDK built its on-device adapter. The device model's cloud address points to https://on-device-only.invalid, which can't reach a server. Any reply whose inferenceSource isn't on_device is rejected and logged. Reliable structured output from a small model. Long rule-ID lists in the response schema, and copying exception text word for word, caused wrong and "uncertain" results. Five fixed slots and exception numbers fixed both. Firestore rules for a public library. While reviewing the rules, I found that sharing one rule for create and update let a user change ownership. I split them, locked the identity fields (id, publishedByUid, sourceHash), whitelisted 11 fields with limits on the nested cartridge, and stopped using email addresses as publisher names.

Accomplishments I'm proud of

A real security standard, OWASP ASVS 5.0, works in one click on the live site as an offline cartridge with every quote verified. Privacy is enforced in code, not just promised: Private/Public types an on-device guard that fails closed a log of every request with its exact bytes Diagram bytes sent: 0 A complete Firebase stack (AI Logic, App Check, Remote Config, Firestore, Auth, Hosting) with 424 automated tests, offline support, and light and dark mode.

What's next

More openly licensed standards in the public library (NIST SP 800-63B, CIS Benchmarks, EU AI Act excerpts). An Android companion app (Kotlin and Jetpack Compose with Firebase AI Logic) that uses the same Firestore cartridges for audits in airplane mode. Publishing with server timestamps in Firestore, and automated deploys through Firebase preview channels.

Built With

  • chrome-built-in-ai
  • cloud-firestore
  • excalidraw
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • gemini
  • gemini-nano
  • indexeddb
  • minisearch
  • motion
  • pdf.js
  • react
  • recaptcha-enterprise
  • service-worker
  • shadcn-ui
  • tailwindcss
  • typescript
  • vite
  • vitest
  • zod
Share this project:

Updates

Submission history