Spaces:
Configuration error
Configuration error
|
Download docs/PROJECT_AUDIT.md from Sivaneshakumar/sanjeevani-api: direct link, hf CLI and curl.
- Browser
- Download file 9.75 kB
-
https://huggingface.co/spaces/Sivaneshakumar/sanjeevani-api/resolve/main/docs/PROJECT_AUDIT.md
- Command line
-
hf download hf://spaces/Sivaneshakumar/sanjeevani-api/docs/PROJECT_AUDIT.md
-
curl -L -o PROJECT_AUDIT.md https://huggingface.co/spaces/Sivaneshakumar/sanjeevani-api/resolve/main/docs/PROJECT_AUDIT.md
9.75 kB
| # SanjeevaniAI β Comprehensive Project Audit | |
| **Audit Date:** August 18, 2026 | |
| **Auditor:** Lead Software Architect & ML/DevOps Engineer | |
| **Project Path:** `D:\SanjeevaniAI` | |
| **Repository State:** Initialized with pretrained ML models and clinical datasets; core application layers (Frontend, FastAPI Backend, Database, Auth, APIs) require development. | |
| --- | |
| ## 1. Executive Summary | |
| SanjeevaniAI is an AI-powered healthcare intelligence and decision-support platform designed to assist clinicians and patients with biomedical named entity recognition (NER), medical document analysis, clinical summarization, health profiling, and interactive AI consultation. | |
| An in-depth audit of `D:\SanjeevaniAI` reveals high-value pretrained machine learning assetsβmost notably a locally verified `tner/roberta-large-bc5cdr` biomedical NER model and extensive clinical/pharmacological datasetsβalongside an empty application scaffold (`app/`, `clinical_engine/`, `rag/`, `evaluation/`). | |
| This document details the existing state, inventory of models and datasets, technical debt, and provides an actionable blueprint for constructing a production-grade, HIPAA/privacy-conscious, modular healthcare system. | |
| --- | |
| ## 2. Directory Structure & Asset Inventory | |
| ``` | |
| D:\SanjeevaniAI\ | |
| βββ .venv/ # Python 3.11.9 Virtual Environment with PyTorch & Transformers | |
| βββ checkpoints/ # TrOCR training checkpoints (epoch 1-3) | |
| βββ datasets/ # Rich clinical and NLP datasets | |
| β βββ clinical/ | |
| β β βββ ddi/ # Drug-Drug Interaction dataset (CSV) | |
| β β βββ ddi_severity/ # DDI Database with severity ratings (JSON) | |
| β β βββ medicines_250k/ # 250,000+ Medicine dataset (CSV) | |
| β β βββ mid/ # Medical Information Database & Therapeutic class counts (XLSX) | |
| β βββ intent/ # CLINC150 Intent Classification data | |
| β βββ ner/ | |
| β β βββ bc5cdr/ # BC5CDR BioCreative V CDR Corpus data & loader | |
| β βββ ocr/ # Prescription & medical text OCR samples | |
| β βββ speech/ # Audio speech samples for medical transcription | |
| β βββ translation/ # Parallel translation benchmarks | |
| βββ models/ # Pretrained & fine-tuned model store | |
| β βββ bc5cdr-ner/ # β Verified Local RoBERTa-large BC5CDR NER Model | |
| β β βββ config.json # RobertaForTokenClassification (Chemical & Disease tags) | |
| β β βββ pytorch_model.bin # Pretrained PyTorch weights (~1.4 GB) | |
| β β βββ merges.txt, vocab.json # BPE Tokenizer assets | |
| β β βββ tokenizer_config.json | |
| β β βββ eval/ # Metric files (F1: 88.4%, Chemical F1: 92.6%, Disease F1: 83.4%) | |
| β βββ gguf/ # Quantized LLM weights store | |
| β βββ pretrained/ # Base Hugging Face model repositories | |
| β β βββ biomedbert/ # Microsoft BiomedNLP-BiomedBERT-base-uncased | |
| β β βββ indictrans_en_indic/ # IndicTrans2 English to Indic translation | |
| β β βββ indictrans_indic_indic/# IndicTrans2 Indic to Indic translation | |
| β β βββ intent/ # DistilBERT for intent classification | |
| β β βββ sapbert/ # SapBERT biomedical entity representation | |
| β β βββ trocr/ # Microsoft TrOCR base printed | |
| β β βββ whisper/ # OpenAI Whisper base speech-to-text | |
| β βββ trained/ # Custom fine-tuned weights output directory | |
| βββ app/ # [EMPTY] Target directory for FastAPI modular backend | |
| βββ clinical_engine/ # [EMPTY] Clinical decision support engine | |
| βββ evaluation/ # [EMPTY] ML evaluation scripts | |
| βββ rag/ # [EMPTY] Retrieval-Augmented Generation subsystem | |
| βββ scripts/ # Maintenance & training utilities | |
| β βββ download_models.py # Hugging Face snapshot downloader | |
| β βββ prepare_mobile_ocr.py # Mobile OCR preprocessing pipeline | |
| β βββ test_models.py # Integrity checker for model weights | |
| β βββ test_trocr_load.py # TrOCR loading script | |
| β βββ train_trocr.py # TrOCR fine-tuning workflow | |
| βββ training/ # Training scripts | |
| β βββ intent/ # Intent classification fine-tuning | |
| β βββ ner/ # Token classification fine-tuning (train_ner.py) | |
| β βββ ocr/ # TrOCR training and evaluation | |
| βββ README.md # [EMPTY - 0 bytes] Needs comprehensive documentation | |
| βββ requirements.txt # [BASIC] Missing FastAPI, SQLAlchemy, Alembic, Pydantic, etc. | |
| ``` | |
| --- | |
| ## 3. Existing Machine Learning Models Verification | |
| ### 3.1 Local Biomedical NER Model (`models/bc5cdr-ner`) | |
| * **Architecture:** `RobertaForTokenClassification` fine-tuned on BioCreative V CDR (BC5CDR). | |
| * **Entity Classes:** | |
| * `0: O` (Outside) | |
| * `1: B-Chemical` (Beginning of Chemical/Drug name) | |
| * `2: B-Disease` (Beginning of Disease/Condition name) | |
| * `3: I-Disease` (Inside of Disease name) | |
| * `4: I-Chemical` (Inside of Chemical name) | |
| * **Performance:** Overall F1: `88.41%` (Chemical F1: `92.57%`, Disease F1: `83.38%`). | |
| * **Live Inference Verification:** | |
| * Successfully loaded onto CUDA (`cuda:0`) via HuggingFace `pipeline("ner")`. | |
| * Sample: *"The patient was prescribed metformin for type 2 diabetes mellitus."* | |
| * Result: `Chemical: metformin (confidence 0.9998)`, `Disease: type 2 diabetes mellitus (confidence 0.9985)`. | |
| * **Deployment Consideration:** The model weights are ~1.4GB. The FastAPI application must load the model once as a singleton during application startup (`lifespan` handler) to prevent latency penalties on individual requests. | |
| --- | |
| ## 4. Technology Stack & Environment Assessment | |
| | Subsystem | Existing State | Target Production Architecture | | |
| | :--- | :--- | :--- | | |
| | **Python Environment** | Python 3.11.9 with PyTorch 2.8.0 (CUDA 12.9), Transformers 4.57.1 | Extend `.venv` with FastAPI, Pydantic v2, SQLAlchemy 2.0, Alembic, python-jose, passlib, pypdf, httpx | | |
| | **Node.js Environment** | Node.js v22.17.0, npm 10.9.2 | Next.js 14+ (App Router), TypeScript, Tailwind CSS, Lucide Icons, Radix/shadcn UI, TanStack Query | | |
| | **Backend Framework** | None (Empty `app/` folder) | FastAPI with modular layered architecture (`api/v1`, `services`, `repositories`, `models`, `ml`) | | |
| | **Database** | None | PostgreSQL (production/docker) & SQLite (aiosqlite dev fallback) via SQLAlchemy async engine + Alembic | | |
| | **Authentication** | None | Secure JWT auth with refresh tokens, Argon2/Bcrypt password hashing, Role-Based Access Control (RBAC) | | |
| | **Document Processing** | None | Multi-format extraction pipeline (PDF via `pypdf`/`pdfplumber`, TXT, DOCX), sanitization, entity linking | | |
| | **AI LLM Provider** | None | Abstract `LLMProvider` with `GeminiProvider` (Google GenAI), `OpenAIProvider`, and `MockLLMProvider` | | |
| | **Task Queue / Cache** | None | Redis with Celery / FastAPI async background tasks fallback | | |
| | **Containerization** | None | Multi-stage `Dockerfile` (Backend & Frontend) + `docker-compose.yml` (App, DB, Redis, Worker) | | |
| --- | |
| ## 5. Identified Gaps & Technical Problems | |
| 1. **Missing Backend Application Layer:** The `app/` directory is completely empty. There are no API routers, service layers, Pydantic schemas, or data models. | |
| 2. **Missing Frontend Client:** No Next.js or React frontend exists. All UI interactions, dashboards, and visualizations must be built from scratch. | |
| 3. **Missing Database Schemas & Migrations:** No relational tables or Alembic migration environments are established. | |
| 4. **Missing Authentication & Authorization:** No user identity, session management, or RBAC controls exist. | |
| 5. **No Medical Safety Guards:** AI responses need guardrails distinguishing extracted facts from AI considerations, with clear disclaimers that SanjeevaniAI is not an autonomous diagnostic device. | |
| 6. **No API Documentation & Health Probes:** Missing OpenAPI schemas, `/health`, and `/ready` endpoints. | |
| 7. **No Automated Test Suites:** Missing unit, integration, and ML inference validation tests. | |
| --- | |
| ## 6. Recommended Migration & Architecture Plan | |
| 1. **Preserve High-Value Data & Models:** Retain all files under `models/` (especially `models/bc5cdr-ner`) and `datasets/`. | |
| 2. **Build Modular FastAPI Backend:** Implement clean separation of concerns: | |
| `Router -> Schema Validation -> Service Layer -> Repository / ML Engine -> Database`. | |
| 3. **Build Modern Next.js TypeScript Frontend:** Modern healthcare SaaS UI with responsive sidebar, dark/light clinical theme, accessible components, and interactive NER visualizer. | |
| 4. **Implement Local ML Adapter (`MLManager`):** Encapsulate `models/bc5cdr-ner` with cached singleton lifecycle, warm-up routines, and fallback error handling. | |
| 5. **Implement Resilient Document Pipeline:** Secure upload handler with MIME validation, SHA256 hashing, structured entity extraction, and clinical summarization. | |
| 6. **Implement Multi-Provider LLM Engine:** Pluggable AI Assistant supporting Google Gemini with fallback to MockLLM for offline development. | |
| 7. **Provide Complete DevOps & Testing Tooling:** Alembic migrations, Pytest suite, Jest/React testing, Docker Compose configurations, and comprehensive documentation. | |