Here is the Project Story formatted for Devpost. It highlights the hybrid architecture, the specific constraints of Gemini Nano, and the business value of the cloud audit.
Inspiration
Ports and container yards are chaotic environments. Surveyors and inspectors spend their days walking through aisles of stacked steel, often in dead zones with zero cellular connectivity. They take photos of dents, holes, rust, and broken door seals, and later they have to manually transcribe those photos into terminal operating systems or repair estimators.
We noticed a massive flaw in existing AI solutions: they all rely on the cloud. Uploading raw, high-resolution container photos over a congested port network is slow, expensive, and often impossible.
We were inspired by the idea of a "Local Witness, Cloud Auditor" architecture. What if the laptop in the port office could do the heavy lifting of visual inspection completely offline, fingerprint the image for tamper-proofing, and only sync the lightweight JSON data when the surveyor finally gets back to a stable Wi-Fi connection?
What it does
ContainerProof is a laptop-based, offline-first inspection tool.
- On-Device Analysis: The surveyor drops container photos and a short note into the app. Using Firebase AI Logic in
PREFER_ON_DEVICEmode, Gemini Nano analyzes the image and text together to produce a structured JSON record (Damage Type, Location, Severity). - Cryptographic Integrity: The app uses the Web Crypto API to generate a SHA-256 hash of the source image locally. This mathematically binds the AI's JSON output to the exact bytes of the photo, preventing tampering.
- Cloud Audit & Risk: When connectivity returns, the app syncs only the JSON and the hash (never the raw photos) to a larger cloud Gemini model in
ONLY_IN_CLOUDmode. The cloud model verifies the hash, cross-references the container ID against a mock manifest, calculates an estimated repair cost using a mock tariff table, and flags "detention risk" for severely damaged containers.
How we built it
We built a Vite + TypeScript single-page application.
- Firebase AI Logic: We initialized the
GoogleAIBackendand configured two distinct models. The first usedInferenceMode.PREFER_ON_DEVICEandonDeviceParams: { responseConstraint: DAMAGE_SCHEMA }to force the local model to output strict, parseable JSON. - Security: We used Firebase App Check with the debug provider to secure the AI Logic endpoints.
- Integrity: We used the native
crypto.subtle.digest('SHA-256', arrayBuffer)API to generate the cryptographic fingerprint locally. - State & Sync: We used IndexedDB to queue the JSON records when offline. When the user clicks "Sync & Audit," we send the array of JSON records to the
ONLY_IN_CLOUDmodel, which returns a detailed audit report.
Challenges we ran into
The biggest challenge was adapting to the physical constraints of a 4B-parameter on-device model (Gemini Nano).
- The 9K Context Window: We couldn't ask the model to read a container's serial number (OCR) and classify the damage in one pass—the context window would overflow. We had to design the UX so the human types the container ID in a note, and the AI focuses purely on the coarse visual damage features.
- Structured Output Failures: Early on, the on-device model would occasionally hallucinate extra fields or break the JSON format. We solved this by using a strict JSON schema with
additionalProperties: falseand passing it viaresponseConstraint. - Chrome Hardware Checks: Getting the multimodal Prompt API to run on an M4 MacBook Air required ensuring the correct Chrome flags were enabled and waiting for the local model to download and pass the hardware VRAM benchmark.
Accomplishments that we're proud of
- Zero Image Egress: Opening the DevTools Network tab during the on-device analysis confirms that zero image data leaves the laptop. The privacy and bandwidth savings are provable.
- The "Disagreement" Demo: We are most proud of how the hybrid split actually improves accuracy. In our demo, the on-device model correctly identifies a dent but understates the severity. The cloud model catches this discrepancy, flags it, and updates the repair estimate. It proves why both halves of the AI logic are necessary.
- Tamper-Proofing: Implementing SHA-256 hashing in just a few lines of code added a massive amount of technical polish to the project. If the JSON doesn't match the hash, the cloud rejects the record.
What we learned
We learned that hybrid AI isn't just about saving money on cloud tokens—it's a design constraint that unlocks new product categories. By forcing the initial analysis to happen on-device, we designed a tool that works in a basement, respects the privacy of sensitive port infrastructure, and minimizes network dependency.
We also learned that small models are incredibly capable at classification and structured extraction if you constrain them properly with JSON schemas, but they should never be trusted for complex, multi-step reasoning.
What's next for ContainerProof
- Cryptographic Signatures: Moving beyond simple hashing to PKI (Public Key Infrastructure) signing, so the cloud model can cryptographically verify which specific surveyor took the photo.
- Live API Integration: Exploring the Gemini Live API so surveyors can wear a headset and verbally dictate notes hands-free while juggling a clipboard and camera.
- Real Tariff Integration: Replacing our mock tariff data with real IICL (Institute of International Container Lessors) repair cost APIs.
- PWA Support: Turning the web app into a fully installable Progressive Web App so it behaves like native desktop software without the need to keep Chrome open.
Built With
- chrome-built-in-ai
- css3
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- firebase-remote-config
- gemini
- gemini-2.5-flash
- gemini-nano
- html5
- hybrid-ai
- idb-keyval
- indexeddb
- prompt-api
- sha-256
- typescript
- vite
- web-crypto-api