Skip to content

Repository files navigation

๐Ÿง  Chikitsฤmedhฤ โ€“ Transparent Intelligence for Safer Medicine

Offline ยท Explainable ยท Privacy-First
A rule-based medicine safety analyzer with a premium medical-tech UI


๐Ÿ“˜ Overview

Chikitsฤmedhฤ is an offline, explainable-AI web app with a FastAPI backend and React/Vite frontend, powered by rule-based logic rather than black-box machine learning.
It helps users โ€” especially pharmacy students and healthcare practitioners โ€” check drugโ€“drug interactions, disease conflicts, and side effects in clear, simple language.

The system does not collect or upload personal data. It focuses on transparency, education, and offline safety analysis.


๐Ÿš€ Quick Start

One-Click Launcher (Windows)

Simply double-click start_oneclick.bat in the project root. This will:

  • โœ… Automatically create and activate a Python virtual environment
  • โœ… Install all backend dependencies
  • โœ… Build the frontend (React/Vite)
  • โœ… Launch the FastAPI backend server
  • โœ… Run comprehensive smoke tests
  • โœ… Open your browser to http://127.0.0.1:8000/app

That's it! The entire application will be running end-to-end.

Manual Setup

If you prefer manual control:

  1. Backend Setup:

    cd chikitsamedha
    python -m venv .venv312
    .venv312\Scripts\activate
    pip install -r requirements.txt
  2. Frontend Setup:

    cd frontend
    npm install
    npm run build
  3. Run the Application:

    python -m uvicorn chikitsamedha.backend.app:app --host 127.0.0.1 --port 8000
  4. Access the App: Open http://127.0.0.1:8000/app in your browser


๐ŸŽฏ Core Features

๐Ÿ’Š Medicine Safety Analysis

  • Fuzzy search (RapidFuzz) for drug names with synonym recognition & spelling correction
  • Support for up to 5 medicines simultaneously
  • Drug-drug, drug-disease, drug-context, and age-based interaction detection
  • Multi-dimensional risk profiling with scores across 4 categories

๐Ÿ‘ค User Profile & Multi-Profile System

  • Inputs: name, age, weight, height, blood group, diseases
  • Age band selector (Infant โ†’ Senior) with emoji labels
  • Collapsible sidebar profile with save/load/delete support
  • Multiple named profiles stored in localStorage

๐Ÿ“ธ Prescription Scanner (OCR)

  • Drag-and-drop or click-to-upload image interface
  • Pytesseract OCR to extract medicine names from prescriptions
  • Detected medicines shown as clickable chips with confidence scores
  • One-click "Use All" to send detected medicines to analysis

๐ŸŒก๏ธ Context-Aware Analysis

  • Context chips: Alcohol ๐Ÿบ, Grapefruit ๐ŸŠ, With Food ๐Ÿฝ๏ธ
  • Context interactions modify risk scores dynamically
  • Age-band-specific contraindications (e.g., Aspirin + Children)

๐Ÿ“Š Visual Dashboards & Charts

  • Animated meters with count-up numbers and gradient fill bars
  • Donut charts for context risk visualization
  • Risk breakdown bar charts by category
  • Alternatives bar chart for safer medicine suggestions
  • Risk indicator cards with color-coded severity (green โ†’ red)

๐Ÿ“„ Report Generator

  • Exports analysis as downloadable PDF (via ReportLab)
  • Includes user profile, medicines, risk scores, and explanations
  • Color-coded risk status card with large score display

๐ŸŒ Bilingual Support

  • Full English and Marathi (เคฎเคฐเคพเค เฅ€) interfaces
  • One-click language switching in the navbar
  • Bilingual explanations in analysis results

โ™ฟ Accessibility & Motion

  • Reduced motion toggle for users who prefer less animation
  • Keyboard-navigable UI elements
  • ARIA labels on all interactive components
  • Proper focus states and screen reader support

๐ŸŽจ Design System

Premium Medical-Tech Aesthetic

Chikitsฤmedhฤ features a Royal Futurism design language:

Element Details
Theme Dark mode with emerald/teal accent palette
Cards Gradient backgrounds, inner shadows, hover shimmer effect
Buttons 4 variants (Primary, Secondary, Ghost, Danger) with ripple effects
Inputs Enhanced focus rings, subtle glow on focus
Meters Animated width + count-up numbers (0% โ†’ 98%)
Toasts Type-specific icons, colored accent borders, backdrop blur
Modals Centered, backdrop blur, scale animation

Component Architecture

frontend/src/
โ”œโ”€โ”€ components/           # 14 reusable components
โ”‚   โ”œโ”€โ”€ AdvancedButton    โ€” State-aware button (5 states, ripple, loading, success)
โ”‚   โ”œโ”€โ”€ Navbar            โ€” Fixed nav with search, lang toggle, theme, mobile menu
โ”‚   โ”œโ”€โ”€ Modal             โ€” Centered overlay with backdrop blur
โ”‚   โ”œโ”€โ”€ SearchBar         โ€” Expandable search with focus animation
โ”‚   โ”œโ”€โ”€ Meter             โ€” Animated progress bar with count-up
โ”‚   โ”œโ”€โ”€ RiskIndicator     โ€” Color-coded risk display card
โ”‚   โ”œโ”€โ”€ SkeletonLoader    โ€” Loading placeholder animations
โ”‚   โ”œโ”€โ”€ ContextChips      โ€” Interactive context toggles
โ”‚   โ”œโ”€โ”€ StickyBar         โ€” Mobile bottom action bar
โ”‚   โ”œโ”€โ”€ ToastStack        โ€” Notification system with icons
โ”‚   โ”œโ”€โ”€ MedicineCard3D    โ€” 3D card with tilt effect
โ”‚   โ”œโ”€โ”€ AltCarousel       โ€” Safer alternatives carousel
โ”‚   โ”œโ”€โ”€ Loader            โ€” Full-page loading animation
โ”‚   โ””โ”€โ”€ Seo               โ€” Dynamic meta tags
โ”‚
โ”œโ”€โ”€ pages/                # 5 pages
โ”‚   โ”œโ”€โ”€ Home              โ€” Hero section, how-it-works steps, CTA
โ”‚   โ”œโ”€โ”€ Check             โ€” Main analysis page (medicines + profile sidebar)
โ”‚   โ”œโ”€โ”€ Scan              โ€” OCR prescription scanner
โ”‚   โ”œโ”€โ”€ Report            โ€” Analysis results with export
โ”‚   โ””โ”€โ”€ About             โ€” Feature cards with gradient icons
โ”‚
โ”œโ”€โ”€ charts/               # 3 visualization components
โ”‚   โ”œโ”€โ”€ RiskBreakdown     โ€” Category-based risk bar chart
โ”‚   โ”œโ”€โ”€ AlternativesBar   โ€” Safer alternatives comparison
โ”‚   โ””โ”€โ”€ DonutSingle       โ€” SVG donut chart
โ”‚
โ”œโ”€โ”€ context/              # 4 React contexts
โ”‚   โ”œโ”€โ”€ ThemeContext       โ€” Dark/light mode management
โ”‚   โ”œโ”€โ”€ LangContext        โ€” English/Marathi language state
โ”‚   โ”œโ”€โ”€ MotionContext      โ€” Reduced motion preferences
โ”‚   โ””โ”€โ”€ ToastContext       โ€” Notification queue management
โ”‚
โ”œโ”€โ”€ index.css             โ€” Complete design system (1000+ lines)
โ””โ”€โ”€ App.tsx               โ€” Router & layout wrapper

๐Ÿงฌ Example Medicines in Database

Medicine Purpose Common Risks Notes
Paracetamol Fever, Pain relief Liver strain at high dose, Alcohol interaction Safe in BP/Diabetes
Ibuprofen Pain, Inflammation Raises BP, irritates stomach, Ulcer risk Caution in BP, elderly
Atenolol Blood pressure control Lowers HR, fatigue Avoid with other BP drugs
Cetirizine Allergy relief Drowsiness Safe with Paracetamol
Metformin Diabetes control Contraindicated in CKD Monitor kidney function
Atorvastatin Cholesterol management Grapefruit interaction Muscle pain risk
Aspirin Blood thinner, Pain Contraindicated in children, Alcohol interaction GI bleeding risk

โš–๏ธ Example Interactions

Combo Risk Description
Paracetamol + Alcohol โš ๏ธ High (85%) Severe liver toxicity risk
Ibuprofen + Atenolol โŒ Moderate Ibuprofen may reduce BP medicine effect
Metformin + CKD โŒ Contraindicated Lactic acidosis risk
Atorvastatin + Grapefruit โš ๏ธ High (70%) Increases statin blood levels
Aspirin + Child (age < 12) โŒ Contraindicated Reye's syndrome risk
Paracetamol (alone, adult) โœ… Low (15%) Safe when used as directed

๐Ÿ’ป Technology Stack

Layer Tools
Backend FastAPI, Python 3.11+, Uvicorn (ASGI)
Frontend React 18, TypeScript, Vite 7
Styling CSS3 (1000+ line design system), Tailwind CSS utilities
Animations Framer Motion, CSS transitions
Icons Lucide React
Fuzzy Matching RapidFuzz
PDF Generation ReportLab
OCR Pytesseract (optional)
TTS pyttsx3 (Text-to-Speech)
Data Pandas, CSV-based knowledge base

โš™๏ธ Application Workflow

graph LR
    A[Enter Profile] --> B[Select Medicines]
    B --> C[Add Contexts]
    C --> D[Analyze Safety]
    D --> E{Risk Level}
    E -->|Low| F[โœ… Safe - Confetti]
    E -->|Moderate| G[โš ๏ธ Caution - Explanation]
    E -->|High| H[๐Ÿ”ด Warning - Shake]
    E -->|Contraindicated| I[โŒ Do Not Use]
    D --> J[Export PDF]
    D --> K[View Charts]
Loading
  1. User enters personal info (age, weight, height, diseases)
  2. User searches and selects up to 5 medicines
  3. User optionally adds contexts (Alcohol, Food, Grapefruit)
  4. App normalizes names โ†’ finds matches โ†’ applies rule-based logic
  5. App displays:
    • Overall Risk Level (Low / Moderate / High / Contraindicated)
    • Multi-dimensional risk profile (Drug-Drug, Drug-Disease, Context, Age)
    • Animated effectiveness & safety meters
    • Plain-language explanations (English + Marathi)
    • Interactive visualizations & charts
    • Safer alternative suggestions
  6. User can export full PDF report

๐Ÿง  Explainable AI Principle

Chikitsฤmedhฤ is designed around transparent reasoning, where every result includes a "Why":

"Ibuprofen reduces the BP-lowering effect of Atenolol by affecting kidney-mediated sodium retention."

"Paracetamol with Alcohol: High risk (85%) - Alcohol significantly increases the risk of liver damage when combined with paracetamol."

No black-box ML โ€” every step is rule-based and explainable.


๐Ÿ‘ฉโ€๐Ÿ’ป Project Architecture

chikitsamedha/
โ”‚
โ”œโ”€โ”€ start_oneclick.bat          # One-click launcher (Windows)
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ README.md                   # This file
โ”‚
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ smoke_test.py           # Automated smoke testing suite
โ”‚
โ”œโ”€โ”€ chikitsamedha/
โ”‚   โ”œโ”€โ”€ backend/
โ”‚   โ”‚   โ”œโ”€โ”€ app.py              # FastAPI main application + static file serving
โ”‚   โ”‚   โ”œโ”€โ”€ interaction_engine.py  # Core risk calculation engine
โ”‚   โ”‚   โ”œโ”€โ”€ data_loader.py      # Medicine database loader (CSV โ†’ Pandas)
โ”‚   โ”‚   โ”œโ”€โ”€ pdf_engine.py       # PDF report generator (ReportLab)
โ”‚   โ”‚   โ””โ”€โ”€ tts_engine.py       # Text-to-speech engine (pyttsx3)
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ frontend/
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx         # Main React app with routing
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx        # Entry point
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.css       # Design system (1000+ lines)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ i18n.ts         # Translations (EN + MR)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ components/     # 14 reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pages/          # 5 pages (Home, Check, Scan, Report, About)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ charts/         # 3 chart components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ context/        # 4 React context providers
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ lib/            # Utility functions & theme config
โ”‚   โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”‚   โ””โ”€โ”€ vite.config.ts
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ data/
โ”‚       โ”œโ”€โ”€ medicines.csv       # Medicine database
โ”‚       โ”œโ”€โ”€ interactions.csv    # Drug-drug interaction rules
โ”‚       โ”œโ”€โ”€ diseases.csv        # Disease database
โ”‚       โ”œโ”€โ”€ contexts.csv        # Context interaction rules
โ”‚       โ””โ”€โ”€ age_rules.csv       # Age-based contraindications
โ”‚
โ””โ”€โ”€ tesseract/                  # OCR engine (optional)

๐Ÿ“‹ API Endpoints

Endpoint Method Description
/api/health GET Health check
/api/list GET List all medicines in database
/api/suggest GET Fuzzy search suggestions (?type=medicine&q=para)
/api/check POST Analyze medicine interactions (main endpoint)
/api/compare POST Compare multiple medicine sets
/api/pdf POST Generate & download PDF report
/api/scan POST OCR prescription scanning (multipart upload)
/app GET Serve frontend application

๐Ÿงช Testing

The application includes comprehensive smoke tests that verify:

  • โœ… API health endpoint
  • โœ… Medicine search and suggestions
  • โœ… Risk calculation accuracy
  • โœ… Context-based interactions (Alcohol, Grapefruit, etc.)
  • โœ… Disease-based contraindications
  • โœ… Age-based restrictions
  • โœ… PDF generation
  • โœ… Frontend UI loading
  • โœ… Comparative analysis
  • โœ… v15 and v18 regression tests

Run tests manually:

python scripts/smoke_test.py

โš™๏ธ Dependencies

Backend:

fastapi
uvicorn
pandas
rapidfuzz
reportlab
pillow
pytesseract
pyttsx3
python-multipart

Frontend:

{
  "react": "^18.x",
  "react-dom": "^18.x",
  "react-router-dom": "^7.x",
  "typescript": "^5.x",
  "vite": "^7.x",
  "framer-motion": "^11.x",
  "lucide-react": "^0.x",
  "recharts": "^2.x"
}

๐Ÿ”ฎ Future Enhancements

  • โœ… Marathi + English bilingual support (Implemented)
  • โœ… Multi-medicine comparative analysis (Implemented)
  • โœ… Context-based risk analysis (Implemented)
  • โœ… Age band contraindications (Implemented)
  • โœ… OCR prescription scanning (Implemented)
  • โœ… Premium UI redesign (Implemented)
  • โœ… Multi-profile management (Implemented)
  • โœ… Animated meters & visualizations (Implemented)
  • ๐Ÿ”Š Voice narration for accessibility
  • ๐ŸŒ Interactive graph of drugโ€“enzymeโ€“effect relationships
  • ๐Ÿ—ƒ๏ธ SQLite database for faster queries
  • ๐ŸŽ“ Educational mode for pharmacy students
  • ๐Ÿ“ฑ Mobile app version (React Native)

๐Ÿ‘ฅ Contributing

This is an educational project. Contributions are welcome for:

  • Adding more medicines to the database
  • Improving interaction rules
  • Enhancing UI/UX design
  • Adding new features
  • Bug fixes and optimizations
  • Translating to additional languages

๐Ÿงพ License

Open educational prototype โ€“ for learning and research purposes only.

โš ๏ธ Medical Disclaimer: This application is for educational purposes only. No medical claims are made. Always consult a qualified healthcare professional before taking any medication. Pediatric medication should only be given under medical supervision.


Built with โค๏ธ for safer healthcare

About

Privacy-first medicine safety analyzer with explainable interaction checks, profile-based risk scoring, and an offline-capable FastAPI plus React experience.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages