Inspiration

Every day, people sign residential leases, freelance NDAs, employment agreements, and hospital billing statements filled with hidden auto-renewals, surprise surcharges, and aggressive penalty clauses. Modern AI can catch these traps in seconds—but pasting a real lease or medical bill into a cloud chatbot means uploading your Social Security number, home address, bank routing number, date of birth, and Medical Record Number (MRN) to third-party servers.

I built Redacta to break the false choice between privacy and intelligence. Redacta is a cross-platform (Android + Offline-First Web PWA) Hybrid AI contract and billing auditor that scrubs sensitive personal data strictly on your device before a single byte ever reaches the cloud—and still works even in Airplane Mode.

What it does

Redacta turns any phone or browser into a zero-trust document auditing studio across three tabs (Shield, Vault, and Engine):

  • 100% Offline Multi-Format Ingestion: Snap a photo with the camera, select from the gallery, or attach PDF, Word (.docx/.doc), RTF, or plain text documents. Text is extracted entirely on-device—including automatic OCR fallback for scanned image-only PDFs—working with zero internet connection.
  • Real-Time On-Device PII Firewall: Automatically detects and masks 8 toggleable PII categories (Names, SSN / Tax ID, Email, Phone, Card / Account, Street Address, Birth Date, and Medical ID) in milliseconds into deterministic tokens ([PARTY_1], [SSN_1], [ADDR_1], [MRN_1]). A live Verified Anonymized Payload inspector lets users verify exactly what leaves the device before calling AI.
  • Hybrid AI Routing (3 Modes):
    • Strict Offline: 100% on-device heuristic clause screening (and Chrome Built-in AI on Web when available) with zero network egress.
    • Smart Hybrid: Instant on-device screening paired with lightweight cloud triage on the redacted payload, automatically falling back to local execution when offline.
    • Deep Cloud Audit: Streams structured JSON risk reports from Cloud Gemini (gemini-3.8-flash with automatic gemini-3.5-flash-lite fallback) covering an overall 0–100 risk score, severity classification, executive summary, flagged clauses with verbatim quotes and fairer counter-clauses, hidden costs, and critical notice deadlines.
  • Streaming Negotiation & Billing Dispute Studio: Generates ready-to-send emails in three tones (Collaborative, Firm & Formal, Billing Dispute) while preserving anonymized tokens verbatim. A one-tap Local Re-Hydration switch restores the user's real details strictly on-device right before copying or sharing.
  • Offline-First Vault + Optional Cross-Platform Sync: Works immediately in Guest Mode with zero sign-in required—saving every audit locally (Room SQLite on Android, IndexedDB on Web). Signing in optionally with Google syncs anonymized audits across Android and Web via per-user isolated Firebase Firestore.
  • Personalization & Telemetry: Includes a 3-step onboarding flow, live Editorial Light / Cryptographic Dark / System theming with theme-adapted branding, and a live Hybrid AI Engine dashboard tracking PII blocked, on-device vs. cloud split, and millisecond latency.

How I built it

  • Android Native App (com.redacta.hybridai v2.0): Built in Kotlin and Jetpack Compose with Material Design 3, adaptive layouts (NavigationBar on phones, NavigationRail on tablets/foldables), DataStore Preferences for theme/onboarding state, and Room for offline audit storage.
    • Offline Extraction: Bundled Google ML Kit Text Recognition (zero cloud vision calls), PDFBox-Android + native PdfRenderer OCR fallback for scanned PDFs, and an XXE-hardened ZipInputStream + SAXParser pipeline for Word .docx files.
    • Cloud AI & Security: Firebase AI Logic (Firebase.ai) protected by Firebase App Check (no hardcoded API keys), Credential Manager Google Sign-In, and zero-trust Firestore Security Rules enforcing per-user UID isolation and strict schema validation.
  • Web App & Offline-First PWA: Built with Vanilla PHP, modular ES6 JavaScript, Service Workers (sw.js), and manifest.webmanifest.
    • On-Device Web Processing: Client-side Tesseract.js (WASM) for offline camera/image OCR, PDF.js + canvas OCR fallback for scanned PDFs, JSZip + DOMParser for local .docx extraction, IndexedDB offline vault, Chrome Built-in AI (LanguageModel) detection, and optional Firebase Web SDK sync sharing the exact same Firestore schema as Android.

Challenges I ran into

  • Cloud Latency & Model Configuration: Early deep cloud audits and negotiation drafts encountered 60-second stalls and unsupported thinking-level errors (ThinkingLevel.MINIMAL). We solved this by switching to streaming (generateContentStream), setting ThinkingLevel.LOW on gemini-3.8-flash, and engineering an automatic fast-tier fallback to gemini-3.5-flash-lite with explicit coroutine timeouts.
  • Offline Document Extraction Without Heavy Bloat: Standard desktop Office parsers crash or bloat Android APKs. We engineered a lightweight, XXE-hardened streaming XML extractor for .docx archives and paired PDFBox with an automatic PdfRenderer + bundled ML Kit OCR fallback for image-only scanned PDFs.
  • Zero-Friction Privacy UX: Requiring sign-in before testing a privacy app creates immediate friction. We re-architected the storage layer to be offline-first (Guest Mode by default) backed by Room/IndexedDB, layering optional Google Sign-In and Firestore cloud sync on top without locking users out of offline checks.

Accomplishments that I'm proud of

  • Zero Raw PII Egress: Users can inspect the exact tokenized payload leaving their device—and verify that local extraction, redaction, triage, and vault storage work even with Wi-Fi and cellular data completely turned off.
  • True Cross-Platform Parity: Both the Android app and Web PWA share the same deterministic PII firewall, 8 redaction categories, 3 routing policies, structured audit schema, dual-theme design system, and optional Firestore Vault.
  • Play-Policy-Compliant Zero-Permission Capture: Uses Android's zero-permission Photo Picker, System Camera TakePicture contract, and Storage Access Framework (OpenDocument)—requiring zero broad storage or camera runtime permissions.

What I learned

  • Hybrid AI shines when each tier does what it does best: deterministic on-device engines handle privacy-critical PII scrubbing, OCR, and instant offline triage in milliseconds, while cloud LLMs handle deep legal/financial reasoning strictly on anonymized text.
  • Designing offline-first from the ground up dramatically improves reliability, latency, and user trust—turning network errors into seamless local fallbacks instead of broken screens.

What's next for Redacta

  • On-Device Small Language Models (Gemini Nano / AICore & WebGPU) for richer fully offline clause rewrites and negotiation drafting.
  • Multi-Document Redline Diffing to compare an original landlord/vendor contract against a revised draft and verify every requested change was applied.
  • Exportable Redacted PDFs with visual black-bar overlays ready for legal review or medical billing appeals.

Built With

  • android
  • chrome-built-in-ai
  • css3
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-firestore
  • gemini-api
  • google-ml-kit
  • html5
  • indexeddb
  • javascript
  • jetpack-compose
  • jetpack-datastore
  • jszip
  • kotlin
  • material-design-3
  • pdf.js
  • pdfbox
  • php
  • pwa
  • room-database
  • service-workers
  • tesseract.js
  • webassembly
Share this project:

Updates

Submission history