Inspiration
Modern Large Language Models can audit complex contracts, surface hidden liability clauses, and flag regulatory risks in seconds—yet legal, financial, and enterprise teams are largely locked out of using them. Uploading an unredacted NDA, employment agreement, or vendor contract to a cloud API means transmitting Personally Identifiable Information (PII), tax IDs, bank details, and proprietary figures across external infrastructure.
GhostVault was inspired by a simple question: What if I could get frontier-level cloud AI reasoning on sensitive documents without ever letting raw PII leave the user's browser? Instead of forcing a binary choice between strict data privacy and cloud AI intelligence, I designed a zero-persistence, hybrid AI architecture that keeps sensitive data strictly in local browser RAM while routing only sanitized payloads to the cloud.
What It Does
GhostVault is a privacy-first hybrid AI contract-auditing and PII-redaction workbench. It extracts and scrubs sensitive documents locally on the client device, replaces identifying entities with deterministic semantic placeholders, lets the user inspect the exact outbound payload, runs deep compliance auditing in the cloud on the scrubbed text, and rehydrates the final report locally.
End-to-End Hybrid Workflow
Client-Side Multi-Format Ingestion: Users upload contracts directly into volatile browser memory via
parseLocalFile, supporting.pdf,.docx,.txt,.md,.csv, and.jsonfiles—or load built-in sample agreements. No backend database or browser storage (localStorage/sessionStorage) persists raw files.Local On-Device PII Scrubbing (
only_on_device): Before any network request is made, GhostVault runs a two-tier local sanitization engine in browser RAM:- Deterministic Regex Engine: Instantly catches structured identifiers such as Social Security Numbers, email addresses, phone numbers, dates, street addresses, and monetary values using strict word-boundary matching.
- On-Device Gemini Nano: Uses local browser AI inference to detect context-dependent entities like full names and organizations. If on-device weights are unavailable, GhostVault safely falls back to the local Regex engine without ever leaking unredacted text to the cloud.
- Every detected entity is mapped to a reversible semantic token (
[PERSON_1],[ORG_1],[ADDRESS_1],[SSN_1],[AMOUNT_1]).
Transparent Payload Inspection: Inside the Audit Workbench, users inspect the Token-Replaced Payload side-by-side before transmission, verifying with 100% certainty that zero raw PII is included in the outbound request.
Cloud Risk & Compliance Auditing (
only_in_cloud): Only the anonymized payload is transmitted via Firebase AI Logic togemini-3.5-flash-lite, which performs deep clause analysis, flags high-risk terms, and generates structured compliance findings.Local Token Rehydration: Once the cloud audit returns, GhostVault maps placeholders back to their original values strictly inside local browser memory—producing a complete, human-readable audit report without the cloud model ever seeing the underlying identities.
[Local Document (.pdf / .docx / .txt / .md / .csv / .json)]
|
v (100% In-Browser RAM — only_on_device)
[Regex Engine + On-Device Gemini Nano] --> Ephemeral Token Map (RAM Only)
|
v (Zero Raw PII — User-Verified Payload)
[Firebase AI Logic + App Check] ---------> Cloud Audit (gemini-3.5-flash-lite)
|
v (Local Rehydration in RAM)
[Complete Human-Readable Compliance Report]
Core Application Portals
- Audit Workbench: The primary split-pane workspace for ingesting documents, monitoring local redaction status, inspecting sanitized payloads, and reviewing rehydrated clause audits.
- Document Vault: A client-side session workspace for managing uploaded contracts, inspecting parsing states, and tracking redaction coverage across active files.
- Risk & Compliance: A structured breakdown of severity levels, Security Controls, active Token Maps, flagged clauses, and actionable remediation recommendations.
- Audit Logs: A transparent execution trace logging every hybrid routing decision (
only_on_devicevs.only_in_cloud), token count, and verification state for compliance accountability.
How I Built It & Tech Stack
I engineered GhostVault around a serverless, zero-persistence architecture so that user documents never touch cloud storage:
Frontend & Visual Craft: Built with React, TypeScript, Vite, and Tailwind CSS. I designed a dark-mode, high-contrast developer-tool interface inspired by Raycast and Finova—pairing custom glowing ghost-and-lock branding and a custom display title font with Space Grotesk, Inter, and JetBrains Mono so reviewers can inspect payload diffs and risk indicators without visual clutter.
Client-Side Document Parsing: Implemented in-browser extraction (
fileParser.ts) to parse.pdf,.docx,.txt,.md,.csv, and.jsonfiles directly in volatile memory, including automatic detection and clear warnings for scanned, image-only PDFs.Hybrid AI Orchestration: Powered by the Firebase AI Logic SDK, explicitly partitioning execution between on-device Gemini Nano (
only_on_device) for zero-egress PII redaction and cloudgemini-3.5-flash-lite(only_in_cloud) for high-context legal risk reasoning.Security & Abuse Protection: Secured client-to-cloud AI calls using Firebase App Check backed by reCAPTCHA Enterprise (with UUID debug tokens for local development), ensuring only verified app instances can invoke cloud inference without exposing privileged server-side keys.
Spec-Driven AI Development & Auditing: Built iteratively inside Kiro IDE using structured
tasks.mdspecifications alongside Google Antigravity and Kilo pre-judging security audits to eliminate stale pipeline states, enforce strict local-only privacy boundaries, and harden edge cases.
Challenges I Ran Into
Preventing Silent Cloud Fallback Leaks: Ensuring that selecting local-only redaction never silently falls back to a cloud model when Gemini Nano is unavailable required strict routing guards and pipeline state isolation so unredacted text can never cross the network boundary.
Word-Boundary & Address Redaction Precision: Naive regex patterns risked partial-word collisions or misclassifying multi-part street addresses. I refined boundary-aware matchers and sorted entity spans by length and offset so overlapping entities (such as
"Acme Corp"and"Acme") tokenize and rehydrate cleanly without corruption.Handling Scanned PDFs Without Server OCR: Because GhostVault avoids uploading raw files to a server, image-only PDFs yield empty text streams during standard client-side PDF parsing. I added explicit empty-text detection to alert users immediately instead of running an audit on blank content.
Client-Side Security Without a Custom Backend: Eliminating a traditional Node.js/Python proxy server kept the architecture lightweight and zero-persistence, while requiring careful configuration of Firebase App Check, reCAPTCHA Enterprise, and environment isolation across local and production builds.
Accomplishments That I'm Proud Of
True Zero-Persistence Privacy: GhostVault operates with zero backend databases and zero browser storage persistence—raw documents and token lookup maps live strictly in browser RAM and vanish when the tab closes.
Verifiable Trust Through Payload Inspection: Rather than asking users to blindly trust a "privacy-safe" badge, GhostVault shows the exact tokenized payload before any cloud request fires.
Cohesive Four-Portal Experience: Delivering a unified workflow across the Audit Workbench, Document Vault, Risk & Compliance, and Audit Logs portals with a crisp, distraction-free dark UI.
What I Learned & What's Next
Building GhostVault showed me how hybrid AI architectures solve real-world adoption blockers that neither on-device models nor cloud models can solve alone: small local models excel at fast, privacy-critical boundary tasks like PII redaction, while frontier cloud models excel at multi-clause legal reasoning once sensitive identities are stripped out.
Next, I plan to expand GhostVault with:
In-Browser WebAssembly / WebGPU OCR: Adding client-side optical character recognition so scanned, image-only PDFs and contract photos (
.png,.jpg) can be extracted and scrubbed entirely in browser RAM.Custom Compliance Rulebooks: Allowing teams to upload organization-specific policy checklists (GDPR, HIPAA, SOC 2) to tailor cloud audit criteria.
Offline Batch Redaction Mode: Enabling air-gapped PII scrubbing and exportable redacted documents even when completely disconnected from the internet.
Built With
- css3
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- gemini
- gemini-3.5-flash-lite
- gemini-nano
- github
- html5
- javascript
- jspdf
- kiro
- pdf.js
- react
- recaptcha
- regex
- tailwindcss
- typescript
- vite
- web-ai