Skip to content

arvindsis11/Ai-Healthcare-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

53 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ₯ AI Healthcare Platform

Enterprise-Grade AI Healthcare Assistant with Retrieval-Augmented Generation

Founded by: Arvind Sisodiya

FastAPI Next.js Python TypeScript Docker License

πŸ“– Documentation β€’ πŸš€ Quick Start β€’ πŸ—οΈ Architecture β€’ ✨ Features β€’ πŸ›£οΈ Roadmap


🎯 Overview

AI Healthcare Platform is a production-ready, enterprise-grade healthcare AI system that combines:

  • πŸ€– Intelligent RAG – Retrieval-Augmented Generation with semantic search, hybrid reranking, and clinical citations
  • βš•οΈ Medical Intelligence – Symptom extraction, triage risk scoring, specialist recommendations
  • πŸ”’ Enterprise Security – Prompt injection guards, rate limiting, input validation
  • πŸ“Š Observability – Structured logging, request tracing, latency tracking
  • 🌍 Multilingual – Automatic language detection for English, Hindi, Spanish, French

Medical Disclaimer: This system provides educational information only and is not a substitute for professional medical advice, diagnosis, or treatment.


πŸš€ Quick Start

Development Setup (3 minutes)

# Clone and install
git clone https://github.com/arvindsis11/Ai-Healthcare-Chatbot.git
cd Ai-Healthcare-Chatbot

# Configure environment
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY (required for LLM responses)

# Start backend
./setup.sh
./run_backend.sh        # Terminal 1: http://localhost:8000

# Start frontend (new terminal)
./run_frontend.sh       # Terminal 2: http://localhost:3000

Full Stack with Docker (1 command)

docker compose up --build

All services available at:


✨ Features

πŸ’¬ Intelligent Chat

  • Symptom Analysis – Automatic symptom extraction with keyword + ML-assisted detection
  • Risk Triage – Real-time risk scoring (low 🟒 | medium 🟑 | high πŸ”΄)
  • Source Citations – Every response includes clinical sources and evidence excerpts
  • Conversation History – Anonymous session persistence and easy restoration

πŸ” Security & Safety

  • Prompt Injection Guard – Blocks jailbreak and unsafe input patterns
  • Rate Limiting – Per-IP request throttling (configurable)
  • Input Validation – Pydantic-powered request validation
  • Medical Disclaimers – Automatic safety notices on all responses

⚑ Performance & Scalability

  • Smart Caching – Redis + in-memory TTL cache for frequent queries
  • Hybrid Retrieval – Vector similarity + lexical reranking for best results
  • Document Chunking – 120-word windows with 50% overlap for precise context
  • Session Abstraction – Ready for PostgreSQL with current in-memory fallback

πŸ› οΈ Enterprise Features

  • Structured Logging – JSON logs with request IDs and latency tracking
  • Admin Dashboard – Analytics, symptom trends, user activity
  • Multilingual Support – Language detection with translation scaffolding
  • API-First Design – Clean REST endpoints for health, chat, analysis, sessions
  • Docker Ready – Full containerization with nginx reverse proxy

πŸ—οΈ Architecture

graph TB
    User["πŸ‘€ User"] -->|Chat Input| FE["🌐 Next.js Frontend"]
    FE -->|HTTP/REST| API["⚑ FastAPI API"]
    API -->|Validate| Guard["πŸ” Prompt Guard"]
    API -->|Detect| Lang["🌍 Language Detection"]
    API -->|Extract| Symp["βš•οΈ Symptom Extraction"]
    API -->|Assess| Triage["πŸ“Š Triage Service"]
    API -->|Check| Cache["⚑ Redis Cache"]
    API -->|Retrieve| RAG["πŸ” RAG Pipeline"]
    RAG -->|Search| VDB["πŸ“š ChromaDB"]
    RAG -->|Rerank| Hybrid["πŸ”„ Hybrid Retrieval"]
    RAG -->|Generate| LLM["πŸ€– OpenAI LLM"]
    API -->|Persist| Session["πŸ’Ύ Session Store"]
    API -->|Response| FE
    FE -->|Display| User
Loading

Layered Architecture:

  • API Layer – Routing, validation, orchestration
  • Service Layer – Chat, RAG, medical intelligence, caching
  • Repository Layer – Vector DB, session persistence
  • AI Layer – Prompt guards, translation, medical analysis
  • Middleware – Request IDs, latency tracking, security headers

πŸ“Š Key Capabilities

Feature Details
RAG Pipeline Semantic search + lexical reranking + chunk-based citations
Triage System Rule-based risk detection (low/medium/high with severity scores)
Specialist Routing Automatic doctor type recommendations based on symptoms
Session Management Anonymous chat history with optional PostgreSQL backing
Caching Redis-first architecture with intelligent fallback
Logging Structured JSON logs with request IDs and latency metrics
Rate Limiting Per-IP throttling with configurable request windows
Multilingual Language detection + translation scaffolding

πŸ›£οΈ Roadmap

βœ… Phase 1 – AI Healthcare Assistant (Current)

  • Safe conversational healthcare guidance
  • RAG with clinical citations
  • Triage risk assessment
  • Enterprise infrastructure

πŸ“‹ Phase 2 – AI Healthcare API Platform

  • Multi-tenant API management
  • OAuth2/JWT authentication
  • Usage analytics & billing

πŸ₯ Phase 3 – AI Telemedicine Platform

  • Doctor network integration
  • Appointment scheduling
  • Longitudinal patient context

πŸ”¬ Phase 4 – AI Clinical Decision Support

  • Knowledge graph retrieval
  • Evidence-based care pathways
  • Clinician audit trails

πŸ“– Documentation

Document Purpose
PROJECT_STATE.md Readiness assessment, tech debt, component overview
ARCHITECTURE.md Layered design, request flow, observability
SETUP.md Development & Docker deployment guides
API.md REST endpoints with request/response examples
RAG_PIPELINE.md Retrieval strategy, safety measures
SECURITY.md Security controls & recommendations
DEPLOYMENT.md Production deployment & CI/CD
PRODUCT_ROADMAP.md 4-phase product evolution
KNOWLEDGE_GRAPH.md Future knowledge graph design
ENTERPRISE_UPGRADE_SUMMARY.md Complete upgrade details
EXECUTION_CHECKLIST.md All 18 implementation steps

πŸ§ͺ Testing & Validation

# Frontend
cd frontend
npm run lint      # ESLint checks
npm run build     # Production build
npm run test      # Jest unit tests

# Backend (requires dependencies)
pip install -r backend/requirements.txt
pytest tests/

# Full stack
docker compose up --build

Test Status

  • βœ… Frontend Build: Passing
  • βœ… Frontend Lint: Passing
  • βœ… Frontend Tests: Passing
  • βœ… Backend Compile: Passing
  • βœ… Docker Compose: Valid

🌟 Key Endpoints

GET  /api/v1/health               # Health check with features
POST /api/v1/chat                 # Main chat endpoint
POST /api/v1/analyze-symptoms     # Focused symptom analysis
GET  /api/v1/sessions/{id}        # Chat history retrieval

Example Request

curl -X POST http://localhost:8000/api/v1/chat \
  -H "Content-Type: application/json" \
  -d '{
    "message": "I have fever and headache",
    "symptoms": ["fever", "headache"]
  }'

Example Response

{
  "response": "Based on your symptoms...",
  "conversation_id": "abc-123",
  "symptom_analysis": {
    "symptoms": ["fever", "headache"],
    "severity_score": 5,
    "risk_level": "medium",
    "possible_conditions": ["General symptom cluster..."],
    "urgency_recommendation": "See doctor within 24-72 hours"
  },
  "recommended_specialist": "General Physician",
  "citations": [
    {
      "id": "fever.yml#chunk-1",
      "source": "fever.yml",
      "excerpt": "Fever is a common symptom..."
    }
  ],
  "sources": ["fever.yml"]
}

πŸ“ Project Structure

πŸ“¦ Ai-Healthcare-Chatbot
β”œβ”€β”€ πŸ”§ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/              # FastAPI routes
β”‚   β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”œβ”€β”€ repositories/     # Data access
β”‚   β”‚   β”œβ”€β”€ rag/              # RAG pipeline
β”‚   β”‚   β”œβ”€β”€ ai/               # Prompt guards, translation
β”‚   β”‚   β”œβ”€β”€ middleware/       # Security, tracing
β”‚   β”‚   β”œβ”€β”€ models/           # Pydantic schemas
β”‚   β”‚   └── core/             # Settings, logging, DI
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”œβ”€β”€ 🎨 frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/              # Routes
β”‚   β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/         # Chat workspace
β”‚   β”‚   β”‚   └── analytics/    # Admin dashboard
β”‚   β”‚   β”œβ”€β”€ components/       # Shared UI
β”‚   β”‚   β”œβ”€β”€ services/         # API clients
β”‚   β”‚   └── styles/           # Tailwind CSS
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ 🐳 docker-compose.yml    # Full stack orchestration
β”œβ”€β”€ πŸ“š docs/                 # Enterprise documentation
β”œβ”€β”€ βœ… tests/                # Test suites
└── πŸ“– README.md             # This file

πŸ’‘ Enterprise Readiness

Readiness Score: 72/100

Category Score Details
Architecture 82/100 Modular layered design βœ…
Safety 74/100 Prompt guards, disclaimers βœ…
Observability 70/100 Structured logging & tracing βœ…
Scalability 75/100 Caching, abstraction layers βœ…
Testing 58/100 Core tests passing, expandable
Operations 73/100 Docker & CI/CD ready βœ…

πŸ” Security Features

  • βœ… Prompt Injection Protection – Pattern-based guard against adversarial input
  • βœ… Rate Limiting – Per-IP request throttling
  • βœ… Input Validation – Pydantic schemas on all endpoints
  • βœ… Security Headers – X-Frame-Options, X-Content-Type-Options, Referrer-Policy
  • βœ… CORS Configuration – Configurable allow-list
  • βœ… Medical Disclaimers – Automatic safety notices
  • πŸ”œ JWT Authentication – Coming in Phase 2

🀝 Contributing

We welcome contributions! Please read our Contributing Guide and Code of Conduct before getting started.

To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Looking for something to work on? Check the open issues or the full list of proposed improvements in GITHUB_ISSUES.md.


πŸ“œ License

This project is licensed under the MIT License – see LICENSE file for details.


πŸ‘¨β€πŸ’Ό About Author

Arvind Sisodiya – Healthcare AI Architect & Full-Stack Engineer

Passionate about building enterprise-grade AI systems that make healthcare accessible and safe.


πŸš€ Ready to Get Started?

docker compose up --build

Questions? Check the πŸ“– documentation or open an issue!

Built with ❀️ for healthcare professionals and patients worldwide