Clinical Insight Engine is a full-stack clinical decision support system designed to surface early diabetes risk signals from routine patient data.
It combines a Python-based interpretable machine learning model with a modern React frontend, presenting results differently for clinicians and patients.
🎯 The project emphasizes interpretability, confidence-aware predictions, and ethical ML, rather than black-box diagnosis.
This system is intended for educational and research purposes only and does not provide medical diagnoses.
Inputs include:
- Age, gender
- Hypertension and heart disease status
- Smoking history
- BMI
- HbA1c level
- Blood glucose level
Clinician View
- Exact risk percentage (0–100%)
- Top contributing factors with impact analysis
- Model confidence indicators
- Suggested follow-up actions
Patient View
- Simplified risk category (LOW / MODERATE / HIGH)
- Plain-language explanation of risk factors
- Preventive lifestyle recommendations
- Stores previous assessments with timestamps
- Enables longitudinal tracking of patient risk
- Interactive bar charts showing factor contributions
- Available in clinician view for transparency
- React + TypeScript
- Vite for fast development
- Tailwind CSS with dark mode support
- TanStack Query for server state management
- React Hook Form + Zod validation
- Recharts for data visualization
- Framer Motion for animations
- Express.js REST API
- PostgreSQL database via Drizzle ORM
- Python integration for ML inference
- Zod-based route and schema validation
- Logistic Regression (scikit-learn)
- Feature engineering and preprocessing
- StandardScaler for normalization
- Node.js 18+ (LTS) + npm
- Python 3.10+
- PostgreSQL 14+ (local)
- Git
git clone https://github.com/gopaljilab/Clinical-Insight-Engine.git
cd Clinical-Insight-Enginenpm installCreate a .env file in the project root:
# Linux/macOS
cp .env.example .env
# Windows (PowerShell)
Copy-Item .env.example .envIf .env.example doesn't exist, create .env manually:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/clinical_insight_engine# Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib
# Start service
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
sudo -u postgres psql -c "CREATE DATABASE clinical_insight_engine;"# Install PostgreSQL
brew install postgresql
# Start service
brew services start postgresql
# Create database
psql postgres -c "ALTER USER postgres WITH PASSWORD 'postgres';"
psql postgres -c "CREATE DATABASE clinical_insight_engine;"- Download PostgreSQL from postgresql.org
- Install with default settings (remember the password for
postgresuser) - Open SQL Shell (psql) or pgAdmin and run:
-- If password is different, update .env accordingly
CREATE DATABASE clinical_insight_engine;Or via PowerShell (if psql is in PATH):
psql -U postgres -d postgres -c "CREATE DATABASE clinical_insight_engine;"Create the required tables:
npm run db:pushIf the above doesn't work, try:
npm run migrate
# or
npm run db:migrate# Create virtual environment
python3 -m venv .venv
# Activate environment
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# If requirements.txt doesn't exist, install manually:
# pip install numpy pandas scikit-learn# Create virtual environment
py -m venv .venv
# Activate environment
.\.venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt
# If requirements.txt doesn't exist, install manually:
# pip install numpy pandas scikit-learnIf dataset exists in project:
# Linux/macOS
cp attached_assets/diabetes_dataset.csv ./diabetes_dataset.csv
# Windows (PowerShell)
Copy-Item attached_assets/diabetes_dataset.csv ./diabetes_dataset.csvIf dataset is missing, generate synthetic data:
# Linux/macOS
python3 -c "from analyze import create_synthetic_data; create_synthetic_data()"
# Windows
py -c "from analyze import create_synthetic_data; create_synthetic_data()"npm run devFrontend runs at: http://localhost:5173
# Linux/macOS
python3 analyze.py
# Windows
py analyze.py# Linux/macOS
python3 main.py
# Windows
py main.pyCreate a patient JSON file:
cat > patient.json << 'EOF'
{
"gender": "Female",
"age": 52,
"hypertension": true,
"heartDisease": false,
"smokingHistory": "former",
"bmi": 30.1,
"hba1cLevel": 6.4,
"bloodGlucoseLevel": 148
}
EOF@'
{
"gender": "Female",
"age": 52,
"hypertension": true,
"heartDisease": false,
"smokingHistory": "former",
"bmi": 30.1,
"hba1cLevel": 6.4,
"bloodGlucoseLevel": 148
}
'@ | Out-File -FilePath patient.json -Encoding utf8Run prediction:
# Linux/macOS
python3 analyze.py predict_file patient.json
# Windows
py analyze.py predict_file patient.jsonPress Ctrl + C in the terminal running npm run dev
# Linux/macOS
deactivate
# Windows
deactivate- Longitudinal patient risk tracking
- Counterfactual reasoning ("What change reduces risk most?")
- Cohort discovery and population-level insights
- Integration with Electronic Health Records (EHR)
- Advanced bias detection and fairness metrics
- Cloud deployment (Vercel / Render)
Gopal Gupta
Computer Science Engineer
Full-Stack Developer | Data Science & ML Enthusiast