A comprehensive Clinical Data Monitoring System with Supabase for clinical data storage and Firebase Authentication for secure user access.
A comprehensive platform for clinical trial data quality monitoring and risk management
Features • Demo • Quick Start • Documentation • Support
- Overview
- Features
- Demo
- Architecture
- Quick Start
- Detailed Setup
- Usage Guide
- API Documentation
- Security
- Troubleshooting
- Contributing
- License
The Clinical Data Monitoring System is an enterprise-grade platform designed to streamline clinical trial data quality management. It provides real-time insights into data quality metrics, risk assessment, and automated reporting for Clinical Research Associates (CRAs), Data Quality Teams (DQT), and site staff.
- 🎯 Real-time Monitoring: Track data quality metrics across multiple sites and patients
- 🤖 AI-Powered Insights: Leverage GPT-5.2 for intelligent analysis and recommendations
- 📊 Comprehensive Reporting: Generate automated reports for stakeholders
- 🔒 Secure & Compliant: HIPAA-ready with Firebase authentication and RLS policies
- 📈 Scalable Architecture: Built on modern cloud infrastructure (Supabase, Firebase, MongoDB)
- Real-time KPI Monitoring: Total sites, patients, risk scores, and clean patient percentages
- Interactive Visualizations: Risk distribution charts, regional analysis, and trend graphs
- Custom Filters: Filter by region, country, risk level, and time period
- Multi-level Data Quality Tracking: Monitor missing pages, open issues, uncoded terms, and lab discrepancies
- Risk Scoring Algorithm: Automated risk classification (High/Medium/Low)
- Patient-Level Insights: Individual DQI scores and clean status tracking
- Collaborative Features: Comments, tags, and team annotations
- Automated Alert System: Create and manage alerts for high-risk indicators
- Priority-Based Workflow: Organize tasks by urgency and impact
- Issue Resolution Tracking: Monitor resolution progress and timelines
- Escalation Protocols: Built-in workflows for critical issues
- Natural Language Queries: Ask questions about your clinical data in plain English
- Automated Report Generation:
- Site Performance Reports
- CRA Activity Reports
- Risk Analysis Summaries
- Intelligent Recommendations: AI-powered action items and insights
- Powered by OpenAI GPT-5.2: Advanced language understanding and generation
- Data Quality Index (DQI): Composite score based on multiple quality indicators
- Issue Categorization: Track by type (missing pages, uncoded terms, lab issues)
- Trend Analysis: Monitor data quality improvements over time
- Benchmark Comparisons: Compare sites against study averages
- CSV Export: Download filtered datasets for external analysis
- Executive Summaries: One-click generation of stakeholder reports
- Custom Report Templates: Tailor reports to specific audiences
- Scheduled Reports: Automated delivery to team members
- Multiple User Roles: CRA, DQT, Site Staff, Manager
- Granular Permissions: Control access to sensitive data
- Audit Trails: Track all user actions and data changes
Secure Login |
User Registration |
Comprehensive dashboard with real-time KPIs and visualizations
Sites Risk Analysis |
Patient-Level Analysis |
Data Quality Metrics |
AI-Powered Insights |
Automated report generation with customizable templates
┌─────────────────────────────────────────────────────────────┐
│ Client Layer │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ React 19 │ │ Firebase SDK │ │ Supabase JS │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ API Gateway Layer │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ FastAPI Backend (Python) │ │
│ │ • JWT Authentication │ │
│ │ • Firebase Admin Verification │ │
│ │ • RESTful API Endpoints │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌──────────────────┐ ┌──────────────┐ ┌──────────────┐
│ Supabase │ │ Firebase │ │ MongoDB │
│ (PostgreSQL) │ │ Authentication│ │ (Profiles) │
│ │ │ │ │ │
│ • Clinical Data │ │ • User Auth │ │ • Alerts │
│ • Sites │ │ • Tokens │ │ • Comments │
│ • Patients │ │ • Sessions │ │ • Tags │
└──────────────────┘ └──────────────┘ └──────────────┘
│
▼
┌──────────────────────────────────────┐
│ OpenAI GPT-5.2 API │
│ (AI Assistant & Analytics) │
└──────────────────────────────────────┘
Frontend:
- React 19 (Hooks, Context API)
- Material-UI / Custom CSS
- Chart.js / Recharts
- Axios for API calls
- Firebase SDK
Backend:
- FastAPI (Python 3.9+)
- Pydantic for data validation
- PyMongo for MongoDB
- Supabase Python Client
- Firebase Admin SDK
Databases:
- Supabase (PostgreSQL) - Clinical data storage
- MongoDB - User profiles, comments, alerts
- Firebase - Authentication state
AI & Analytics:
- OpenAI GPT-5.2
- Custom risk scoring algorithms
- Natural language processing
- Python 3.9+
- Node.js 16+ and npm/yarn
- MongoDB (local or Atlas)
- Supabase account
- Firebase account
- OpenAI API key (Emergent Universal Key configured)
# Clone the repository
git clone https://github.com/yourusername/clinical-data-monitoring.git
cd clinical-data-monitoring
# Backend setup
cd app/backend
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your credentials
# Frontend setup
cd ../frontend
npm install
cp .env.example .env
# Edit .env with your credentials
# Start services
# Backend (from app/backend)
uvicorn main:app --reload --port 8000
# Frontend (from app/frontend)
npm start# Build and run with Docker Compose
docker-compose up -d
# Access the application
# Frontend: http://localhost:3000
# Backend API: http://localhost:8000
# API Docs: http://localhost:8000/docs- Navigate to Firebase Console
- Click "Add project"
- Enter project name:
clinical-data-monitoring - Disable Google Analytics (optional)
- Click "Create project"
- Go to Authentication → Sign-in method
- Enable Email/Password authentication
- (Optional) Enable additional providers (Google, Microsoft)
- Go to Project Settings → General
- Under "Your apps", click Web icon (
</>) - Register app:
clinical-monitoring-web - Copy the configuration object
Update /app/frontend/.env:
REACT_APP_FIREBASE_API_KEY=AIzaSy...your-actual-key
REACT_APP_FIREBASE_AUTH_DOMAIN=your-project-id.firebaseapp.com
REACT_APP_FIREBASE_PROJECT_ID=your-project-id
REACT_APP_FIREBASE_STORAGE_BUCKET=your-project-id.appspot.com
REACT_APP_FIREBASE_APP_ID=1:123456789:web:abcdef...For backend verification:
- Project Settings → Service Accounts
- Click "Generate new private key"
- Save as
/app/backend/firebase-admin.json - Add to backend
.env:
FIREBASE_ADMIN_CONFIG_PATH=/app/backend/firebase-admin.jsonExecute the following SQL in your Supabase SQL Editor:
-- High Risk Sites Table
CREATE TABLE "High Risk Sites" (
"Study" TEXT,
"Region" TEXT,
"Country" TEXT,
"Site_ID" TEXT PRIMARY KEY,
"Total_Subjects" INTEGER,
"Total_Missing_Pages" INTEGER,
"Total_Open_Issues" INTEGER,
"Total_Uncoded_MedDRA" INTEGER,
"Total_Uncoded_WHODD" INTEGER,
"Total_Lab_Issues" INTEGER,
"Avg_DQI" DOUBLE PRECISION,
"Clean_Patients_Count" INTEGER,
"Clean_Patient_Percentage" DOUBLE PRECISION,
"Risk_Score" DOUBLE PRECISION,
"Risk_Level" TEXT,
"created_at" TIMESTAMP DEFAULT NOW()
);
-- Patient Data Table
CREATE TABLE "Patient Data" (
"Study" TEXT,
"Region" TEXT,
"Country" TEXT,
"Site_ID" TEXT,
"Subject_ID" TEXT PRIMARY KEY,
"missing_pages_count" INTEGER,
"total_open_issues" INTEGER,
"uncoded_meddra_terms" INTEGER,
"uncoded_whodd_terms" INTEGER,
"missing_lab_count" INTEGER,
"Clean_Patient_Status" TEXT,
"Data_Quality_Index" INTEGER,
"created_at" TIMESTAMP DEFAULT NOW()
);
-- Sites Data Table
CREATE TABLE "Sites Data" (
"Study" TEXT,
"Region" TEXT,
"Country" TEXT,
"Site_ID" TEXT PRIMARY KEY,
"Total_Subjects" INTEGER,
"Total_Missing_Pages" INTEGER,
"Total_Open_Issues" INTEGER,
"Total_Uncoded_MedDRA" INTEGER,
"Total_Uncoded_WHODD" INTEGER,
"Total_Lab_Issues" INTEGER,
"Avg_DQI" DOUBLE PRECISION,
"Clean_Patients_Count" INTEGER,
"Clean_Patient_Percentage" DOUBLE PRECISION,
"Risk_Score" DOUBLE PRECISION,
"Risk_Level" TEXT,
"created_at" TIMESTAMP DEFAULT NOW()
);- Navigate to Table Editor in Supabase Dashboard
- Select a table
- Click Insert → Import data from CSV
- Upload your CSV files:
Output_High_Risk_Sites.csv→ High Risk SitesOutput_Patient_Level_Unified_CLEAN.csv→ Patient DataOutput_Site_Level_Summary.csv→ Sites Data
-- Enable RLS
ALTER TABLE "High Risk Sites" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "Patient Data" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "Sites Data" ENABLE ROW LEVEL SECURITY;
-- Create policies (adjust based on your security requirements)
CREATE POLICY "Allow authenticated read access" ON "High Risk Sites"
FOR SELECT USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated read access" ON "Patient Data"
FOR SELECT USING (auth.role() = 'authenticated');
CREATE POLICY "Allow authenticated read access" ON "Sites Data"
FOR SELECT USING (auth.role() = 'authenticated');Update both frontend and backend .env files:
REACT_APP_SUPABASE_URL=https://your-project-ref.supabase.co
REACT_APP_SUPABASE_KEY=your-anon-public-key
SUPABASE_URL=https://your-project-ref.supabase.co
SUPABASE_KEY=your-service-role-key# Install MongoDB
# Ubuntu
sudo apt install mongodb
# Start MongoDB
sudo systemctl start mongodb- Create account at MongoDB Atlas
- Create a free cluster
- Get connection string
- Update backend
.env:
MONGO_URL=mongodb+srv://username:password@cluster.mongodb.net/
DB_NAME=clinical_monitoring# Backend API
REACT_APP_BACKEND_URL=http://localhost:8000
# Supabase
REACT_APP_SUPABASE_URL=https://your-project.supabase.co
REACT_APP_SUPABASE_KEY=your-anon-key
# Firebase
REACT_APP_FIREBASE_API_KEY=your-api-key
REACT_APP_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
REACT_APP_FIREBASE_PROJECT_ID=your-project-id
REACT_APP_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
REACT_APP_FIREBASE_APP_ID=your-app-id# MongoDB
MONGO_URL=mongodb://localhost:27017
DB_NAME=clinical_monitoring
# API Configuration
CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
JWT_SECRET=your-super-secret-jwt-key-change-this
# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-service-role-key
# Firebase (Optional)
FIREBASE_ADMIN_CONFIG_PATH=/app/backend/firebase-admin.json
# OpenAI
EMERGENT_LLM_KEY=your-openai-api-key- Navigate to
http://localhost:3000 - Click "Register" tab
- Fill in your details:
- Full Name: John Doe
- Email: john.doe@example.com
- Password: Minimum 6 characters
- Role: Select from dropdown (CRA, DQT, Site Staff, Manager)
- Click "Create Account"
- You'll be automatically logged in
- KPI Cards: View total sites, patients, high-risk sites, clean patient percentage
- Charts: Risk distribution pie chart, top 5 high-risk sites
- Filters: Filter by region, country, date range
Navigation: Dashboard → Site Analysis
- View all sites with risk scores
- Filter by risk level (High/Medium/Low)
- Search by Site ID, Country, or Region
- Click on a site to view detailed metrics
- Add comments and tags for collaboration
Navigation: Dashboard → Patient Analysis
- View patient-level data quality
- Filter by clean status (Clean/Not Clean)
- Search by Patient ID or Site ID
- View individual DQI scores
- Track missing pages, open issues, uncoded terms
Navigation: Dashboard → Risk Management
- View all high-risk sites in one place
- Create alerts for specific issues
- Assign priority levels (High/Medium/Low)
- Track resolution status
- Add resolution notes
Navigation: Dashboard → AI Assistant
Example Queries:
- "What are the top 5 sites with the highest risk scores?"
- "Show me patients with DQI below 70"
- "Generate a site performance report for Site 001"
- "What's the average clean patient percentage by region?"
Generate Reports:
- Select report type (Site Performance, CRA Report, Risk Analysis)
- Configure parameters (date range, site filter)
- Click "Generate Report"
- Download or email the report
Navigation: Dashboard → Data Quality
- Monitor open issues across all sites
- Track missing pages trends
- View uncoded term statistics
- Analyze lab issue patterns
- DQI distribution visualization
Navigation: Dashboard → Reports
- Export Data: Download filtered datasets as CSV
- Executive Summary: Generate high-level reports
- Custom Reports: Create tailored reports for stakeholders
- Schedule Reports: Set up automated report delivery
| Feature | CRA | DQT | Site Staff | Manager |
|---|---|---|---|---|
| View Dashboard | ✅ | ✅ | ✅ | ✅ |
| View Site Analysis | ✅ | ✅ | ✅ | ✅ |
| View Patient Data | ✅ | ✅ | ✅ | |
| Create Alerts | ✅ | ✅ | ❌ | ✅ |
| Resolve Issues | ✅ | ✅ | ✅ | |
| Generate Reports | ✅ | ✅ | ✅ | |
| Manage Users | ❌ | ❌ | ❌ | ✅ |
| AI Assistant | ✅ | ✅ | ✅ |
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword",
"full_name": "John Doe",
"role": "CRA"
}POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword"
}
Response:
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"token_type": "bearer",
"user": {
"email": "user@example.com",
"full_name": "John Doe",
"role": "CRA"
}
}GET /api/sites
Authorization: Bearer {token}
Query Parameters:
- risk_level: High|Medium|Low
- region: string
- country: stringGET /api/sites/{site_id}
Authorization: Bearer {token}GET /api/patients
Authorization: Bearer {token}
Query Parameters:
- site_id: string
- clean_status: Clean|Not Clean
- dqi_min: integer (0-100)POST /api/alerts
Authorization: Bearer {token}
Content-Type: application/json
{
"site_id": "001",
"issue_type": "High Missing Pages",
"priority": "High",
"description": "Site has 45 missing pages"
}PUT /api/alerts/{alert_id}
Authorization: Bearer {token}
Content-Type: application/json
{
"status": "Resolved",
"resolution_notes": "Issue addressed with site staff"
}POST /api/ai/query
Authorization: Bearer {token}
Content-Type: application/json
{
"query": "What are the top 5 highest risk sites?"
}POST /api/ai/generate-report
Authorization: Bearer {token}
Content-Type: application/json
{
"report_type": "site_performance",
"site_id": "001",
"date_range": {
"start": "2024-01-01",
"end": "2024-12-31"
}
}Once the backend is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
The system supports dual authentication:
-
Firebase Authentication (Recommended)
- Industry-standard security
- Automatic token refresh
- MFA support (optional)
- Secure session management
-
JWT Authentication (Fallback)
- Works without external dependencies
- MongoDB-backed user storage
- Manual token management
# Use environment variables
cp .env.example .env
# Never commit .env files
# Strong passwords
# Minimum 8 characters, mix of upper/lower/numbers/symbols- Enable HTTPS/SSL
server {
listen 443 ssl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
}- Configure CORS Properly
# backend/main.py
CORS_ORIGINS = [
"https://yourdomain.com",
"https://www.yourdomain.com"
]- Enable Supabase RLS
ALTER TABLE "Patient Data" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users can only see their assigned sites"
ON "Patient Data"
FOR SELECT
USING (
"Site_ID" IN (
SELECT site_id FROM user_site_assignments
WHERE user_id = auth.uid()
)
);- Rotate Secrets Regularly
- Firebase service account keys: Every 90 days
- JWT secrets: Every 30 days
- API keys: Every 60 days
- Monitor & Audit
- Enable Firebase audit logs
- Track API access patterns
- Monitor for suspicious activity
- Encryption at Rest: All data encrypted in Supabase/MongoDB
- Encryption in Transit: HTTPS/TLS for all API calls
- PHI/PII Handling: Follow HIPAA guidelines for patient data
- Access Logging: All data access logged for audit
Error: "Firebase not configured" or "API key invalid"
Solutions:
# Check environment variables
cat /app/frontend/.env | grep FIREBASE
# Verify no extra spaces or quotes
REACT_APP_FIREBASE_API_KEY=AIzaSy... # ✅ Correct
REACT_APP_FIREBASE_API_KEY="AIzaSy..." # ❌ Wrong
# Restart frontend
npm startError: Empty dashboard or "Failed to fetch data"
Solutions:
# Verify table names (exact match required)
Tables must be: "High Risk Sites", "Patient Data", "Sites Data"
# Check RLS policies
# In Supabase Dashboard → Authentication → Policies
# Ensure read access is granted
# Test connection
curl -X GET "https://your-project.supabase.co/rest/v1/Sites%20Data" \
-H "apikey: your-anon-key"Error: "ModuleNotFoundError" or "Connection refused"
Solutions:
# Check Python version
python --version # Should be 3.9+
# Reinstall dependencies
pip install -r requirements.txt --force-reinstall
# Check MongoDB connection
mongo --eval "db.runCommand({ ping: 1 })"
# View logs
tail -f /var/log/supervisor/backend.err.logError: "Access-Control-Allow-Origin" in browser console
Solutions:
# backend/.env
CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
# backend/main.py - verify CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # For development only!
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)Error: "OpenAI API error" or "Rate limit exceeded"
Solutions:
# Check API key
echo $EMERGENT_LLM_KEY
# Test OpenAI connection
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer $EMERGENT_LLM_KEY"
# Check rate limits in OpenAI dashboard
# Implement exponential backoff in code- Check Service Status
sudo supervisorctl status
# Should show: backend RUNNING, frontend RUNNING- View Logs
# Backend errors
tail -f /var/log/supervisor/backend.err.log
# Backend output
tail -f /var/log/supervisor/backend.out.log
# Frontend errors
tail -f /var/log/supervisor/frontend.err.log- Restart Services
# Restart individual services
sudo supervisorctl restart backend
sudo supervisorctl restart frontend
# Restart all
sudo supervisorctl restart all- Clear Cache
# Browser: Clear localStorage
localStorage.clear();
# Backend: Clear Python cache
find . -type d -name __pycache__ -exec rm -r {} +
# Frontend: Clear node modules
rm -rf node_modules package-lock.json
npm installIf you're still experiencing issues:
- Check Documentation: Review the relevant section in this README
- Search Issues: Look for similar issues in the GitHub Issues tab
- Enable Debug Mode:
# backend/.env DEBUG=True LOG_LEVEL=DEBUG
- Create an Issue: Include:
- Error message and stack trace
- Environment details (OS, Python/Node versions)
- Steps to reproduce
- Relevant logs
- GitHub Discussions - Ask questions and share ideas
- Stack Overflow - Technical questions
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/AmazingFeature - Commit your changes:
git commit -m 'Add some AmazingFeature' - Push to the branch:
git push origin feature/AmazingFeature - Open a Pull Request
- Follow PEP 8 for Python code
- Use ESLint for JavaScript/React
- Write unit tests for new features
- Update documentation for API changes
- Add comments for complex logic
- All PRs require at least one approval
- CI/CD checks must pass
- Code coverage should not decrease
- Documentation must be updated
This project is licensed under the MIT License - see the LICENSE file for details.
--
Made with ❤️ for Clinical Research Teams



