A HIPAA-compliant, enterprise-grade healthcare support system powered by Multi-Agent RAG architecture, blockchain audit logging, and secure cloud infrastructure. Combines traditional Ayurvedic wisdom with modern AI technology.
- Safety Guardrails - Content filtering and PII protection
- Intent Classification - Smart routing to specialized agents
- Symptom Checker - Emergency detection with hospital routing
- RAG-Powered Recommendations:
- πΏ Ayurvedic remedies from curated knowledge base
- π§ Yoga therapy with video recommendations
- π‘ Wellness guidance
- Government Schemes - Health insurance and benefits search
- Mental Wellness - Support and resources with Sarvam AI Hindi TTS
- Hospital Locator - Find nearby facilities using Mapbox
- Voice Features - Speech-to-text (OpenAI Whisper) and multilingual TTS
- Firebase Authentication - Google OAuth & JWT tokens
- End-to-End Encryption - AES-256-GCM for PHI data
- Blockchain Audit Logging - PostgreSQL-based immutable audit trail
- DISHA Compliance - India's Digital Information Security in Healthcare Act
- Consent Management - Explicit user consent tracking
- Session Management - Secure session history with MongoDB
- Next.js 15 + React 19 frontend
- Real-time chat interface with i18n support (English/Hindi)
- Voice input support with language detection
- Text-to-speech responses (OpenAI + Sarvam AI for Hindi)
- Responsive design with Tailwind CSS
- Document upload and processing
.
βββ src/ # Backend Python modules
β βββ chains/ # LangChain agents
β β βββ base_chains.py # Core chains (safety, intent, fusion)
β β βββ specialized_chains.py # Domain agents (ayurveda, yoga, etc.)
β β βββ health_advisory_chain.py
β β βββ medical_reasoning_chain.py
β β βββ profile_chain.py
β β βββ document_qa_chain.py
β βββ auth/ # Authentication
β β βββ firebase_auth.py # Firebase Admin SDK
β β βββ security.py # JWT & password hashing
β β βββ deps.py # Auth dependencies
β βββ database/ # Database layer
β β βββ mongodb_manager.py # MongoDB connection
β β βββ mongodb_models.py # Pydantic models
β β βββ models.py # SQLAlchemy models (legacy)
β β βββ core.py # Database core
β βββ blockchain/ # Blockchain audit logging
β β βββ postgres_blockchain.py # Cloud PostgreSQL blockchain
β β βββ private_blockchain.py # Local SQLite blockchain
β β βββ audit_logger.py
β β βββ ledger.py
β βββ security/ # Security & encryption
β β βββ encryption.py # AES-256-GCM PHI encryption
β βββ compliance/ # Healthcare compliance
β β βββ disha_compliance.py # DISHA compliance manager
β βββ document_processor/ # RAG document ingestion
β β βββ chunker.py
β β βββ enrichment_manager.py
β β βββ pdf_processor.py
β βββ embeddings/ # Sentence transformers
β βββ retrieval/ # Vector search & reranking
β βββ vector_store/ # Pinecone/ChromaDB management
βββ frontend/ # Next.js application
β βββ src/
β β βββ app/ # Pages & API routes
β β β βββ [locale]/ # i18n routing (en/hi)
β β β βββ api/ # API endpoints (proxy)
β β βββ components/ # React components
β β β βββ ChatInterface.tsx
β β β βββ VoiceRecorder.tsx
β β β βββ DocumentUpload.tsx
β β βββ lib/
β β β βββ firebase.ts # Firebase client config
β β βββ i18n/ # Internationalization
β βββ messages/ # Translation files (en.json, hi.json)
βββ config/ # Configuration files
β βββ settings.py # Application settings
β βββ firebase-service-account.json # (not in git)
βββ data/ # RAG data
β βββ chroma_db/ # Local vector database
β βββ raw/ # Source documents
β βββ processed/ # Processed documents
βββ api_mongodb.py # FastAPI backend (MongoDB-based)
βββ ingest.py # RAG ingestion script
βββ cli.py # CLI interface
βββ requirements.txt # Python dependencies
- Python 3.11+
- Node.js 18+
- Firebase account
- OpenAI API keys (2 for load balancing)
- MongoDB Atlas account
- Pinecone account (for cloud vector store)
- Supabase PostgreSQL database (for blockchain)
- Tavily API key (for web search)
- YouTube Data API key
- Mapbox API key (for location services)
- Sarvam AI API key (for Hindi TTS)
# Clone repository
git clone <your-repo-url>
cd Pran-Protocol
# Install Python dependencies
pip install -r requirements.txt
# Install frontend dependencies
cd frontend
npm install
cd ...env file BEFORE running the application!
Create .env file from example:
cp .env.example .envEdit .env with your credentials:
# === OpenAI API Keys (Load Balanced) ===
OPENAI_API_KEY_1=sk-proj-your-primary-key
OPENAI_API_KEY_2=sk-proj-your-secondary-key
# === Tavily API Key ===
TAVILY_API_KEY=tvly-dev-your-key
# === YouTube API Key ===
YOUTUBE_API_KEY=your-youtube-key
YOUTUBE_SEARCH_MAX_RESULTS=3
VIDEO_CACHE_TTL_SECONDS=900
# === Mapbox API Key ===
MAPBOX_API_KEY=your-mapbox-key
# === Sarvam AI (Hindi TTS) ===
SARVAM_API_KEY=sk_your-sarvam-key
# Firebase Configuration (Shared between Frontend and Backend)
FIREBASE_API_KEY=your-firebase-api-key
FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_STORAGE_BUCKET=your-project.firebasestorage.app
FIREBASE_MESSAGING_SENDER_ID=123456789
FIREBASE_APP_ID=1:123456789:web:abcdef
FIREBASE_SERVICE_ACCOUNT_PATH=config/firebase-service-account.json
# Backend URL
BACKEND_URL=http://localhost:8000
# JWT Authentication Secret
SECRET_KEY=your-super-secret-key-generate-with-secrets
# MongoDB Configuration
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database?retryWrites=true&w=majority
MONGODB_DB_NAME=pran-protocol
# Encryption Key for PHI Data (DO NOT LOSE THIS!)
MASTER_ENCRYPTION_KEY=generate-64-char-hex-key
# Vector Store Configuration
VECTOR_STORE_TYPE=pinecone
PINECONE_API_KEY=your-pinecone-key
PINECONE_ENVIRONMENT=us-east-1
PINECONE_INDEX_NAME=pran-protocol
# Blockchain Configuration (PostgreSQL on Supabase)
BLOCKCHAIN_TYPE=private
BLOCKCHAIN_DATABASE_URL=postgresql://user:pass@host:5432/postgres
# News API (Optional)
NEWS_API_KEY=your-news-api-keyβ Common Error: If you see "Cannot read properties of undefined (reading 'app')" in the frontend, it means your .env file is missing or incomplete. Make sure ALL Firebase variables are filled in.
Download Service Account Key:
- Go to Firebase Console
- Select your project
- Go to Project Settings β Service Accounts
- Click Generate new private key
- Save as
config/firebase-service-account.json
Enable Google Sign-In:
- Go to Authentication β Sign-in method
- Enable Google provider
- Add your domain (localhost for development)
Detailed setup guide: See FIREBASE_SETUP.md
# Terminal 1: Start Backend (from root directory)
uvicorn api_mongodb:app --reload --host 0.0.0.0 --port 8000
# Terminal 2: Start Frontend (from root directory)
cd frontend
npm run devAccess the app: Open http://localhost:3000
Add your own Ayurveda/Yoga documents to enhance the knowledge base:
# Place documents in data/raw/
# Then run ingestion:
python ingest.py- Sign Up / Login with Google
- Start chatting with the healthcare assistant
- Ask questions about:
- Ayurvedic remedies
- Yoga poses and exercises
- Symptoms and health concerns
- Government health schemes
- Mental wellness support
- π€ Click microphone icon to speak your query (supports English/Hindi)
- π Click speaker icon on bot responses to hear them
- π Hindi TTS powered by Sarvam AI
- π English TTS powered by OpenAI
- π Upload medical documents, reports, and prescriptions
- π RAG-powered document Q&A
- π Encrypted storage and secure processing
"I have a backache for 2 days"
"What yoga poses help with anxiety?"
"Remedies for migraine?"
"Government health schemes in India"
"Meditation techniques for better sleep"
User Query
β
π‘οΈ Safety Guardrail (PII & Content Filter)
β
π― Intent Classification (8 specialized agents)
β
π Route to Agent
β
ββββββββββββββββββββββββββββ
β Symptom Checker β β Multi-Agent Response:
β β ββ Emergency? β Hospital Locator
β β ββ Non-Emergency:
β β ββ πΏ Ayurveda Agent (RAG)
β β ββ π§ Yoga Agent (RAG + YouTube)
β β ββ π‘ Wellness Agent
ββββββββββββββββββββββββββββ€
β Government Schemes β β Web Search + Recommendations
β Mental Wellness β β Support + Yoga Videos
β AYUSH Support β β Traditional Medicine (RAG)
β Hospital Locator β β Find Facilities
β Yoga Therapy β β Poses + Videos (RAG + YouTube)
β Ayurveda β β Remedies (RAG)
β General Wellness β β Guidance (RAG)
ββββββββββββββββββββββββββββ
β
π Response Fusion (Combines multi-agent outputs)
β
π€ Formatted Response to User
Backend:
- FastAPI - REST API
- LangChain - Agent orchestration
- Pinecone - Cloud vector database
- ChromaDB - Local vector database (fallback)
- MongoDB Atlas - User, session & message storage
- PostgreSQL (Supabase) - Blockchain audit logging
- Firebase Admin SDK - Authentication
- OpenAI GPT-4o-mini - LLM
- OpenAI Whisper - Speech-to-text
- Sentence Transformers - Embeddings
- AES-256-GCM - PHI encryption
Frontend:
- Next.js 15 - React framework
- TypeScript - Type safety
- Tailwind CSS - Styling
- Firebase Auth - Google OAuth
- next-intl - i18n support (English/Hindi)
Cloud Services:
- Firebase - Authentication & storage
- MongoDB Atlas - NoSQL database
- Supabase - PostgreSQL blockchain
- Pinecone - Vector database
- Mapbox - Location services
- Sarvam AI - Hindi text-to-speech
- β
All sensitive data in
.env(not committed to git) - β Firebase service account JSON excluded from git
- β JWT token authentication with secure rotation
- β AES-256-GCM encryption for PHI (Protected Health Information)
- β Master encryption key management
- β PII detection and filtering
- β Content safety guardrails
- β Emergency queries prioritized (never blocked)
- β DISHA compliance for Indian healthcare regulations
- β Blockchain audit trail (immutable logging)
- β Consent management with version tracking
- β Session security with MongoDB
- Encryption at Rest: All PHI encrypted with AES-256-GCM
- Encryption in Transit: HTTPS/TLS for all API calls
- Audit Logging: Immutable blockchain-based audit trail
- Access Controls: Role-based authentication with Firebase
- Consent Management: Explicit user consent tracking
- Data Integrity: PostgreSQL blockchain ensures data immutability
.env(all API keys and secrets)config/firebase-service-account.jsonhealthcare.db(legacy user database)data/chroma_db/(local vector database)data/blockchain.db(local blockchain database)audio_cache/,logs/,uploads/node_modules/,__pycache__/,.next/audit_ledger.json
Once backend is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /auth/signup- Create account (deprecated)POST /auth/login- Password login (deprecated)POST /auth/firebase-login- Google OAuth (primary)GET /auth/me- Get user profilePOST /chat- Send messageGET /sessions- List chat sessionsGET /sessions/{session_id}/messages- Get session messagesPOST /tts- Text-to-speech (OpenAI)POST /tts/sarvam- Hindi text-to-speech (Sarvam AI)POST /transcribe- Speech-to-text (OpenAI Whisper)POST /upload-document- Upload medical documentsPOST /consent/accept- Accept consent agreementGET /audit/user- Get user audit logs (blockchain)POST /nearby-places- Find nearby hospitals (Mapbox)
# Backend
uvicorn api_mongodb:app --reload # Start with auto-reload
python cli.py # CLI interface
python ingest.py # Ingest documents
python check_profile.py # Check user profiles
python clear_databases.py # Clear all databases (dev only)
python migrate_to_cloud_vectorstore.py # Migrate to Pinecone
# Frontend
cd frontend
npm run dev # Development server
npm run build # Production build
npm run start # Production server
npm run lint # Run ESLint- Create chain class in
src/chains/specialized_chains.py:
class MyNewChain(BaseChain):
def invoke(self, inputs: dict) -> dict:
# Your logic here
return {"output": "response"}- Initialize in workflow (
src/workflow.py):
self.my_chain = MyNewChain(config)- Add routing logic in
run()method
Add documents to data/raw/ then run:
python ingest.pySupported formats: .txt, .pdf, .docx, .md
MongoDB Collections:
users:
_id,email,firebase_uiddisplay_name,photo_urlcreated_at,last_loginprofile(encrypted PHI data)consent_agreements(DISHA compliance)
sessions:
_id,user_id,titlecreated_at,updated_atmessage_count
messages:
_id,session_id,user_idrole(user/assistant),content(encrypted)timestamp,metadata
audit_logs:
_id,user_id,action,resourcetimestamp,ip_address,user_agentblockchain_hash(reference to blockchain entry)
PostgreSQL Blockchain:
- Immutable audit trail
- Hash-chained blocks
- Tamper-evident logging
- HIPAA compliance
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ayurvedic knowledge base curated from traditional texts
- Yoga therapy based on authentic practices
- Built with LangChain, OpenAI, and Firebase
- UI inspired by traditional Indian aesthetics
For setup help or issues:
- Check
.env.examplefor required environment variables - Ensure Firebase service account JSON is properly configured
- Verify MongoDB Atlas connection string
- Check Pinecone API key and index configuration
- See API docs at
/docswhen backend is running - Check logs in
logs/directory - Open an issue on GitHub
MongoDB Connection Failed:
- Verify
MONGODB_URIin.env - Ensure IP whitelist in MongoDB Atlas includes your IP
- Check network connectivity
Pinecone Index Not Found:
- Create index with dimension 384 (for sentence-transformers)
- Verify
PINECONE_INDEX_NAMEmatches your index
Firebase Authentication Error:
- Ensure
firebase-service-account.jsonis inconfig/ - Verify all Firebase env variables are set
Blockchain Logging Failed:
- Check
BLOCKCHAIN_DATABASE_URLconnection - Verify PostgreSQL database is accessible
- Falls back to local SQLite if cloud fails
Made with πΏ for holistic healthcare | HIPAA Compliant | DISHA Certified