
This release takes Smart Clinical Copilot from a codebase that could not start to a fully working, verified full‑stack application that runs exactly as the README describes.
The core problem
The project had never been run end‑to‑end. The backend crashed on import, the frontend failed to build, the clinical rule engine didn't match its own rule format, and the test suite targeted an API that didn't exist. In short: nothing worked out of the box.
What's fixed
Backend (FastAPI) now boots and serves with zero configuration
Removed the experta dependency that made the app impossible to install on modern Python, and replaced it with a clean pure‑Python forward‑chaining rules engine.
Made the heavy AI/ML stack optional (PyTorch, Transformers, SHAP, OpenAI, Ollama). The app now starts and runs without them; they're isolated in requirements-ml.txt and imported lazily.
Fixed clinical rule matching. /match-rules now correctly evaluates the real rule schema (AND of all conditions, with observation/medication/condition matching) and returns valid, evidence‑bearing alerts e.g. "Avoid NSAIDs due to advanced CKD" firing on low eGFR + ibuprofen.
Fixed rule loading: handles the top‑level rules: list, allows the in operator, and accepts explanation‑only actions.
Updated the deprecated OpenAI v0 API to the v1 client; added deterministic, guideline‑based explanations and summaries as a fallback when no LLM is configured.
Graceful degradation everywhere SQLite by default, in‑memory Redis mock, and no requirement for FHIR/IRIS/LLM to run the demo.
Fixed the trie autocomplete engine, error handler, patients router, and cohort analytics endpoint.
Frontend (React + Vite) now builds cleanly
Added the missing src/lib/utils.ts and fixed the @/* path alias.
Resolved all TypeScript build errors; production build and typecheck pass with 0 errors.
API base URL is now configurable via VITE_API_BASE_URL; fixed patient‑detail rendering (name, gender, birth date) and the explain‑rule call.
Infrastructure, tests & docs
Clean, installable requirements.txt plus an optional requirements-ml.txt.
Fixed both Dockerfiles and docker-compose (Python 3.11, curl for healthchecks, non‑fatal C‑extension build, nginx aligned to port 3000).
Replaced the stale, never‑passing test suite with a real one — 14 passing tests covering rule loading, the trie engine, condition matching, and the public API.
Added backend/.env.example, removed a committed virtualenv and stray files, updated .gitignore, and corrected the README run instructions.
Quick start
python -m venv .venv && source .venv/bin/activate
pip install -r backend/requirements.txt
uvicorn backend.main:app --reload # http://localhost:8000/docs
No database, Redis, FHIR server, or API key required to run the demo.
Verified working
Backend boots · frontend builds · demo patients load · clinical alerts fire with evidence · healthy patients trigger none · all 14 tests pass.
An AI-powered clinical decision support system that helps healthcare providers make better decisions by providing real-time clinical insights and recommendations.
Features • Architecture • Quick Start • Development • Contributing
| Category | Features |
|---|---|
| 🏥 Clinical Support | • Real-time clinical decision support • Rule-based alerting system • Patient risk assessment • Medication safety checks |
| 🔄 Integration | • FHIR integration for healthcare data • IRIS for Healthcare integration • Multi-system interoperability • Real-time data synchronization |
| 💻 User Interface | • Modern, responsive web interface • Intuitive clinical dashboard • Real-time alerts and notifications • Customizable views |
| 🛠️ Technical | • Docker-based deployment • Scalable microservices architecture • High-performance data processing • Secure data handling |
The system consists of the following components:
graph TD A[User
External Actor] --> B[Web Frontend] B --> C[Copilot Backend
Python/FastAPI] B --> D[Django Admin & API
Python/Django]B -- "Requests data from" --> C D -- "Requests data from" --> E[Database APIs<br>PostgreSQL, Redis, etc.] D -- "Uses ORM for" --> E B -- "Initializes" --> F[UI Entry Point<br>TypeScript/React] F -- "Initializes" --> G[App Shell<br>TypeScript/React] G -- "Manages" --> H[UI Pages<br>TSX/React Directory] H -- "Uses" --> I[UI Components<br>TSX/React Directory] H -- "Calls" --> J[Frontend API Client<br>TypeScript] J -- "Requests data from" --> C C -- "Uses" --> K[Rules Engine<br>Python Code] C -- "Accesses" --> L[FHIR Client<br>Python Code] L -- "Communicates with" --> M[External Systems<br>FHIR APIs, InterSystems IRIS, etc.] C -- "Invokes" --> N[Monitoring Services<br>Python Code Directory] C -- "Reads config from" --> O[Configuration Management<br>Python Code Directory] O -- "Manages Uses" --> O C -- "Invokes" --> P[LLM Service<br>Python Code] P -- "Communicates with" --> Q[External Systems<br>OpenAI, Ollama, etc.] D -- "Handles commands &<br>delegates HTTP to" --> R[URL Configuration<br>Python/Django] R -- "Routes to" --> S[Core Business Logic<br>Python/Django Directory] D -- "Loads" --> T[Application Settings<br>Python/Django]
Clone the repository:
git clone https://github.com/kunal0297/SmartClinicalCopilot.git
cd SmartClinicalCopilot
Create a .env file in the backend directory with the following content:
# Environment ENVIRONMENT=developmentAPI Settings
HOST=0.0.0.0 PORT=8000
Database
DATABASE_URL=postgresql://postgres:postgres@db:5432/clinical_copilot
FHIR Server
FHIR_SERVER_URL=http://hapi.fhir.org/baseR4
LLM Settings
LLM_API_KEY=your-api-key-here LLM_MODEL=mistral
Redis Settings
REDIS_URL=redis://redis:6379/0
Security
SECRET_KEY=your-secret-key-here ACCESS_TOKEN_EXPIRE_MINUTES=11520 # 8 days
Monitoring
ENABLE_METRICS=true METRICS_PORT=9090
Logging
LOG_LEVEL=INFO
Build and start the Docker containers:
docker-compose build
docker-compose up
Access the services:
The backend runs out of the box with zero configuration — it defaults to a
local SQLite database, an in-memory Redis mock, and deterministic
guideline-based explanations, so no external services are required to run
the demo.
Set up the environment (from the project root):
python -m venv .venv
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
Install dependencies:
pip install -r backend/requirements.txt
Run the development server (from the project root):
uvicorn backend.main:app --reload
The application is
backend.main:appand must be launched from the
project root (not from insidebackend/) because it imports the
backendpackage.
(Optional) Configure environment variables:
cp backend/.env.example backend/.env # then edit as needed
(Optional) Enable AI features. The heavy AI/ML stack (SHAP, HuggingFace
Transformers, PyTorch, OpenAI, Ollama) is not required. Install it only
if you want SHAP feature-importance explanations or LLM-generated
narratives:
pip install -r backend/requirements-ml.txt
Then set OPENAI_API_KEY=... (or USE_LOCAL_LLM=true) in backend/.env.
Once running, explore the interactive API docs at
http://localhost:8000/docs, or try the core
clinical-decision-support flow from the command line:
curl http://localhost:8000/health curl http://localhost:8000/demo-patientsMatch the first demo patient against the clinical rules (fires the
"avoid NSAIDs in advanced CKD" alert):
curl -s http://localhost:8000/demo-patients
| python -c "import sys,json;print(json.dumps(json.load(sys.stdin)[0]))"
| curl -s -X POST http://localhost:8000/match-rules
-H 'Content-Type: application/json' -d @-
Run the tests:
cd backend && python -m pytest
Install dependencies:
cd frontend
npm install
Run the development server (expects the backend on http://localhost:8000):
npm run dev
The API base URL is configurable via VITE_API_BASE_URL.
Production build:
npm run build
We welcome contributions! Please follow these steps:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the https://github.com/kunal0297/SmartClinicalCopilot/blob/main/LICENSE file for details.
Team Kunal0297
After cloning the repository, you must set up the frontend dependencies to avoid common TypeScript and module errors:
Install Frontend Dependencies
cd frontend
npm install
Ensure TypeScript Type Definitions
If you encounter errors about missing type definitions for node or vite/client, run:
npm install --save-dev @types/node vite
Check for utils.ts
Make sure the file frontend/src/lib/utils.ts exists. If not, create it with the following content:
import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge";export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }
export function formatDate(date: Date): string { return new Intl.DateTimeFormat("en-US", { year: "numeric", month: "long", day: "numeric", }).format(date); }
export function debounce<T extends (...args: any[]) => any>( func: T, wait: number ): (...args: Parameters) => void { let timeout: NodeJS.Timeout;
return function executedFunction(...args: Parameters) { const later = () => { clearTimeout(timeout); func(...args); };
clearTimeout(timeout); timeout = setTimeout(later, wait);}; }
export function generateId(): string { return Math.random().toString(36).substring(2) + Date.now().toString(36); }
Troubleshooting
Cannot find module '@/lib/utils', check that the file above exists and is committed.Build the Frontend
npm run build
Made with ❤️ by Team Kunal0297