# Nitdaa Sibling Project - Architecture Design **Version 1.0 Public Release** ## 1. System Overview Nitdaa is the mobile-friendly MVP sibling to the full HealthExpert enterprise platform. It removes administrative overhead, heavy RBAC UI components, and complex multi-pane layouts in favor of a lean, mobile-first edge interface. ## 2. Core Differences from Base HealthExpert - **UI/UX**: Transitioned from a 3-pane desktop layout to a single-pane vertical mobile layout. - **Admin Constraints**: Admin controls (Kill Switch, DB Purge) are entirely hidden in the HTML to prevent public tampering. - **Session Audit**: Uses `nitdaa_sessions.json` and `nitdaa_summary.json` for granular system telemetry rather than database-backed logs. ## 3. Data Flow 1. **Startup & Sync**: Flask initializes. `sync_he_data()` runs asynchronously to pull the latest dataset from `Sam-max1/he-data`. If differences are found, it gracefully purges vector/graph databases and rebuilds. Concurrently, it performs a 2-way remote synchronization of logs with `Sam-max1/mat_data`. 2. **Security & Connection**: Client connections face an immediate Math CAPTCHA. All API calls pass through `Flask-Limiter` and Strict HTTP Content Security Policies. 3. **Ingestion**: If new files are detected, `process_document_pipeline` splits them into 512-token chunks, vectorizes them into ChromaDB, and extracts graph entities locally using `spaCy`. 4. **Retrieval**: When a query hits `/api/query`, it triggers Tri-modal Hybrid Retrieval (Vector + BM25 + Graph). 5. **Synthesis**: A Cross-Encoder reranks the chunks, and the context is fed into a reasoning-distilled tiny model (e.g., `Jackrong/Qwen3.5-2B-Claude-4.6-Opus-Reasoning-Distilled-GGUF`) running on `llama-cpp-python`. ## 4. Resource Allocation Nitdaa is tuned for the HuggingFace Spaces free tier: - **vCPU constraints**: Threads are explicitly clamped to prevent CPU thrashing. - **Vector Limit**: A hard limit of 10,000 chunks is enforced globally to prevent `OutOfMemory` crashes. - **Session Quotas**: Max 5 file uploads per session to prevent abuse.