Skip to content

Shgit29/Curamind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Curamind

Curamind is a full-stack clinical AI assistant that helps answer doctor-facing medical questions using retrieved evidence from biomedical sources. It combines retrieval-augmented generation, patient context, session memory, and response evaluation in a single product.

What It Does

  • Accepts a clinical question from the frontend chat interface
  • Uses patient intake context such as name, age, sex, and conditions
  • Retrieves relevant medical evidence from stored biomedical data
  • Generates a grounded response with citations
  • Stores chat sessions and message history
  • Runs a post-response audit for faithfulness, relevance, and correctness
  • Surfaces trust and evaluation signals in the UI

Core Features

  • Full-stack application with a React frontend and FastAPI backend
  • Retrieval pipeline over medical content using embeddings and pgvector
  • MMR-style reranking to diversify retrieved evidence
  • Gemini-based clinical response generation with fallback model rotation
  • Background extraction of evolving patient facts into session state
  • Analytics page for response quality monitoring
  • JWT-based authentication and protected routes

Tech Stack

Frontend

  • React
  • Vite
  • React Router
  • Framer Motion
  • Recharts
  • React Markdown

Backend

  • FastAPI
  • SQLAlchemy
  • PostgreSQL
  • pgvector
  • Pydantic
  • JWT authentication

AI / Retrieval

  • Google Gemini
  • Sentence Transformers
  • PubMedBERT embeddings
  • FAISS and vector search tooling
  • Biomedical ingestion scripts for PubMed, DrugBank, and ClinicalTrials

Architecture Overview

Curamind follows a simple full-stack flow:

  1. A doctor signs in and opens a consultation session.
  2. The frontend sends a question plus patient context to the backend.
  3. The backend retrieves relevant medical chunks from stored biomedical data.
  4. The generation layer builds a grounded prompt and calls Gemini.
  5. The answer is stored with session history and returned with citations.
  6. A background evaluator scores the answer for quality and trust.
  7. The frontend polls for evaluation results and shows trust badges.

Project Structure

CURAMIND/
├── backend/
│   ├── app/
│   │   ├── core/                 # config, database, security, LLM client
│   │   ├── modules/
│   │   │   ├── auth/             # signup, login, password reset
│   │   │   ├── orchestrator/     # main chat flow
│   │   │   ├── search/           # retrieval logic
│   │   │   ├── generation/       # prompt building, LLM calls, evaluation
│   │   │   ├── ingestion/        # medical data pipeline
│   │   │   └── sessions/         # session history APIs
│   │   └── main.py
│   └── tests/
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── services/
│   │   └── utils/
│   └── public/
└── docker-compose.yml

Key Backend Modules

  • backend/app/modules/orchestrator/ Handles the main request flow for clinical Q&A, session creation, message storage, and background tasks.

  • backend/app/modules/search/ Encodes the query, searches vectorized medical records, and reranks results before generation.

  • backend/app/modules/generation/ Builds the clinical prompt, calls Gemini models, deduplicates citations, and updates patient state.

  • backend/app/modules/ingestion/ Contains scripts for fetching, cleaning, chunking, embedding, and storing biomedical data.

Running Locally

Option 1: Docker Compose

Start the full stack with:

docker compose up --build

This starts:

  • PostgreSQL with pgvector
  • pgAdmin
  • FastAPI backend
  • React frontend

Typical local ports:

  • Frontend: http://localhost:5174
  • Backend: http://localhost:8000
  • pgAdmin: http://localhost:5050

Option 2: Run Frontend and Backend Separately

Backend:

cd backend
pip install -r requirements.txt
cd app
uvicorn main:app --reload --host 0.0.0.0 --port 8000

Frontend:

cd frontend
npm install
npm run dev -- --host 0.0.0.0 --port 5174

Environment Variables

The backend expects a .env file with values similar to:

POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_SERVER=
POSTGRES_PORT=
POSTGRES_DB=

SECRET_KEY=
ALGORITHM=
ACCESS_TOKEN_EXPIRE_MINUTES=

GEMINI_API_KEY=
GEMINI_API_KEY_2=
GEMINI_API_KEY_3=

Data Pipeline

The repository includes a multi-step ingestion pipeline under:

backend/app/modules/ingestion/CURAMINDv2/scripts/

This pipeline is designed to:

  • fetch biomedical content
  • clean and normalize text
  • extract entities
  • chunk documents
  • filter noisy chunks
  • generate embeddings
  • store metadata for retrieval

The orchestration script is:

python backend/app/modules/ingestion/CURAMINDv2/scripts/run_pipeline.py

Testing

Backend tests are located in:

  • backend/tests/test_smoke.py
  • backend/tests/unit/

Run tests with:

cd backend
pytest

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages