Dual-Ecosystem Product: Native Android Production App + Cross-Platform Progressive Web App (PWA) + Firebase Cloud Sync & Auth + Production ASO & SEO Pack.
DocuSnap AI is an intelligent document vault engineered to solve the everyday chaos of lost medical prescriptions, pharmacy slips, electricity/gas utility bills, and grocery receipts.
Rather than forcing users to manually open a scanner app, DocuSnap AI introduces Zero-Click Media Ingestion:
ContentObserver monitors gallery additions (MediaStore.Images.Media.EXTERNAL_CONTENT_URI).FileProvider with automatic high-res capture and OCR. ββββββββββββββββββββββββββββββββββββββββββββββββ
β Android Gallery Photo / Snap β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β MediaObserverService β
β (ContentObserver) β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β MediaIngestionWorker β
β (WorkManager Coroutine) β
βββββββββ¬βββββββββββββββ¬βββββββ
β β
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
βΌ βΌ
βββββββββββββββββββββββββ ββββββββββββββββββββββββ
β Google ML Kit OCR β β Resolution & Hash β
β (100% On-Device) β β SHA-256 Dedupe β
ββββββββββββ¬βββββββββββββ ββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β Gemini Flash Reasoningβ ββββΊ Structured Entities: Doctor, Medicines, PKR Amounts, Vendor
ββββββββββββ¬βββββββββββββ
β
βΌ
βββββββββββββββββββββββββ ββββββββββββββββββββββββ
β Room DB (SQLite FTS5)β ββββββββββββββββββββββββββββββββββββββββββββ β Conversational UI β
β Offline Search Index β β "Ask Anything" Box β
ββββββββββββ¬βββββββββββββ ββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β Firebase Cloud Sync β βββββΊ Real-Time Firestore & Storage
ββββββββββββ¬βββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cross-Platform PWA (iOS Safari / Desktop / Mac / Win) β
β - HTML5 Canvas Downscaling β
β - Native iOS "Add to Home Screen" Bottom Sheet Modal β
β - Zero-Cost Static Hosting on GitHub Pages β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DocuSnapAI/
βββ android/ # Native Android Production Application
β βββ build.gradle.kts # Project build script
β βββ settings.gradle.kts # Gradle settings
β βββ gradle.properties # JVM & AndroidX properties
β βββ app/
β βββ build.gradle.kts # Compose, Room FTS5, ML Kit, Gemini, Firebase BOM
β βββ proguard-rules.pro # ProGuard rules for Room, ML Kit & Gemini
β βββ src/main/
β βββ AndroidManifest.xml # Permissions (READ_MEDIA_IMAGES, FOREGROUND_SERVICE)
β βββ java/com/docusnap/ai/
β β βββ DocuSnapApplication.kt
β β βββ ai/
β β β βββ GeminiReasoningEngine.kt # Structured JSON & Conversational Search
β β βββ data/
β β β βββ local/
β β β β βββ AppDatabase.kt # Room Database with FTS virtual table
β β β β βββ DocumentDao.kt # FTS5 MATCH queries & CRUD
β β β βββ model/
β β β βββ DocumentEntity.kt # Primary entity schema
β β β βββ DocumentFtsEntity.kt # Room FTS4/5 entity
β β β βββ DocumentDto.kt # DTOs & JSON serialization
β β βββ ocr/
β β β βββ OcrEngine.kt # Bundled Google ML Kit Text Recognition
β β βββ service/
β β β βββ BootReceiver.kt # Restarts observer service on device boot
β β β βββ MediaIngestionWorker.kt # CoroutineWorker with aspect ratio filter
β β β βββ MediaObserverService.kt # Foreground Service + ContentObserver
β β βββ sync/
β β β βββ FirebaseSyncRepository.kt # Auth, Firestore & Storage sync
β β βββ ui/
β β βββ MainActivity.kt # Compose activity & permissions launcher
β β βββ DocuSnapNavHost.kt # Navigation graph & bottom bar
β β βββ DocuSnapViewModel.kt # StateFlow & conversational orchestrator
β β βββ screens/
β β β βββ ConversationalSearchScreen.kt # "Ask Anything" (Roman Urdu/English)
β β β βββ DocumentInspectorScreen.kt # Deep-zoomable viewer & copyable tags
β β β βββ SettingsScreen.kt # On-Device vs Gemini & battery settings
β β β βββ SmartVaultScreen.kt # Categorized grid of documents
β β βββ theme/
β β βββ Color.kt
β β βββ Theme.kt
β β βββ Type.kt
β βββ res/ # Drawables, colors, strings, extraction rules
β
βββ web/ # Cross-Platform Progressive Web App (PWA)
β βββ package.json # React 18, Vite, Tailwind CSS, Lucide, Firebase JS
β βββ vite.config.ts # Vite + VitePWA configuration
β βββ tailwind.config.js # Theme colors matching Android Material 3
β βββ tsconfig.json # TypeScript bundler configuration
β βββ index.html # PWA meta tags & iOS Safari viewport fit
β βββ public/
β β βββ 404.html # GitHub Pages SPA routing fallback script
β β βββ manifest.json # Full PWA Web App Manifest
β β βββ favicon.svg # DocuSnap vector brand asset
β βββ src/
β βββ App.tsx # Main container, tabs, and real-time synchronization
β βββ firebase.ts # Firebase Auth, Storage, & Firestore snapshot listeners
β βββ gemini.ts # Gemini Flash multimodal vision & Roman Urdu reasoning
β βββ types.ts # TypeScript models matching Room Entity
β βββ components/
β βββ ConversationalSearch.tsx # "Ask Anything" search with animated AI answer
β βββ SmartVault.tsx # Categorized grid with filter chips & amounts
β βββ DocumentInspectorModal.tsx # Deep-zoom image inspector with one-click copy
β βββ UploadModal.tsx # Client-side HTML5 Canvas downscaler & camera intake
β βββ IosInstallPrompt.tsx # Native iOS Safari "Add to Home Screen" bottom sheet
β βββ Navbar.tsx # Brand header & navigation controls
β
βββ firebase/ # Cloud Backend Contracts & Rules
β βββ firebase.json # Hosting & Firestore configuration
β βββ firestore.rules # Security rules: users/{userId}/documents/{docId}
β βββ firestore.indexes.json # Composite query indexes
β βββ storage.rules # Rules for /images/ and /thumbs/
β
βββ play_store_assets/ # Google Play Store Production ASO
β βββ title.txt # Title (29/30 characters)
β βββ short_description.txt # Short Description (79/80 characters)
β βββ full_description.txt # Keyword-rich 4000-character description
β βββ listing_metadata.json # Categories, ratings, contact info
β βββ release_notes.txt # Release notes for v1.0.0
β
βββ web_seo/ # Web SEO & Search Engine Optimization Pack
β βββ index.html # Complete OpenGraph, Twitter Card & JSON-LD
β βββ robots.txt # Search engine crawler directives
β βββ sitemap.xml # XML Sitemap with daily change frequency
β
βββ README.md # Comprehensive product documentation
In android/.../service/MediaObserverService.kt:
ContentObserver on MediaStore.Images.Media.EXTERNAL_CONTENT_URI.MediaIngestionWorker via ExistingWorkPolicy.APPEND_OR_REPLACE.MediaIngestionWorker decodes image bounds first without loading full bitmaps into RAM:
width < 380 or height < 380, discards (small stickers, low-res thumbnails).aspectRatio > 4.5, discards (thin banners, dividers).When Gemini Deep Reasoning is active, extracted text is analyzed using the following structured schema:
{
"document_type": "Medical Prescription | Expense Receipt | Utility Bill | Bank Slip | General Document",
"title": "Short descriptive title (e.g., Blood Test Report - Chughtai Lab)",
"summary": "1-2 sentence conversational summary",
"key_entities": {
"doctor_name": "string or null",
"medicines": ["string"],
"total_amount": 1250.00,
"vendor_or_hospital": "string or null",
"date": "YYYY-MM-DD"
},
"searchable_tags": ["tag1", "tag2"]
}
documents_fts MATCH :query).display: "standalone", viewport-fit=cover, custom dark theme colors).IosInstallPrompt: step-by-step bottom sheet guiding the user to tap Share -> Add to Home Screen.android/ directory in Android Studio.GEMINI_API_KEY in android/app/build.gradle.kts or local.properties.google-services.json from the Firebase console in android/app/../gradlew assembleDebug
web/ directory:
cd web
npm install
npm run build
web/dist/.# Push dist directory to gh-pages branch
git subtree push --prefix web/dist origin gh-pages
Note: public/404.html ensures all deep SPA routes redirect seamlessly without 404 errors on GitHub Pages.
From the project root:
firebase deploy --only firestore:rules,storage:rules
DocuSnap AI is released under the MIT License.