Skip to content

KitheK/MediFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mediflow Medical Platform

A comprehensive, production-ready medical workflow management system with a modern React frontend and FastAPI backend. Built for healthcare professionals to manage patients, resources, appointments, and analytics with enterprise-grade security and performance.

πŸš€ Quick Start

Prerequisites

  • Python 3.13+
  • Node.js (v14 or higher)
  • Docker & Docker Compose (recommended)
  • SQLite/PostgreSQL

πŸ› οΈ Technology Stack

Backend (FastAPI/Python)

  • FastAPI - Modern Python web framework with automatic API docs
  • SQLAlchemy - Database ORM with relationship management
  • SQLite/PostgreSQL - Database storage with migration support
  • JWT Authentication - Secure token-based authentication
  • bcrypt - Password hashing and security
  • Pydantic - Data validation and serialization
  • uvicorn - ASGI server for production deployment
  • Docker - Containerization and deployment

Frontend (React.js)

  • React 18+ - Modern UI framework with hooks
  • React Query (@tanstack/react-query) - Server state management
  • Chart.js - Advanced data visualization and analytics
  • Styled Components - CSS-in-JS styling solution
  • Axios - HTTP client for API communication
  • React Router - Client-side routing
  • Jest & Testing Library - Comprehensive testing suite
  • Webpack - Module bundling and optimization

Database & Security

  • SQLAlchemy Models - Relational data modeling
  • JWT Tokens - Secure API authentication
  • Password Hashing - bcrypt security implementation
  • CORS Support - Cross-origin resource sharing
  • Input Validation - Pydantic schema validation

πŸ“Š Core Features

Patient Management System

  • Comprehensive Patient Profiles - Demographics, medical history, insurance
  • Medical Records - EHR-compliant record keeping with audit trails
  • Patient Search & Filtering - Advanced search capabilities
  • Document Management - Upload and manage patient documents
  • Insurance Verification - Real-time coverage checking

Resource Management

  • Medical Equipment Tracking - Availability, maintenance, allocation
  • Staff Scheduling - Doctor availability and appointment management
  • Inventory Management - Medical supplies and medication tracking
  • Room Management - Facility scheduling and utilization

Analytics & Reporting

  • Real-time Dashboard - Live metrics and KPIs
  • Patient Analytics - Demographics, visit patterns, outcomes
  • Resource Utilization - Equipment usage, staff efficiency
  • Financial Reports - Revenue tracking, billing analytics
  • Custom Reports - Exportable data analysis

Authentication & Security

  • JWT-based Authentication - Secure token management
  • Role-based Access Control - Fine-grained permissions
  • Password Security - bcrypt hashing with salt
  • Session Management - Secure user sessions
  • API Rate Limiting - Protection against abuse

Installation & Running

Option 1: Docker (Recommended)

# Clone the repository
git clone <your-repo-url>
cd mediflow

# Start the entire application with Docker
docker-compose up --build

Option 2: Manual Setup

Backend Setup:

# Navigate to backend
cd backend

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows: venv\Scripts\activate
# On macOS/Linux: source venv/bin/activate

# Install Python dependencies
pip install -r requirements.txt

# Initialize database
python -c "from app.database import init_db; init_db()"

# Start the FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Frontend Setup:

# In a new terminal, navigate to frontend
cd frontend

# Install dependencies
npm install

# Start React development server
npm start

Access the platform:

  • Frontend: http://localhost:3000
  • Backend API: http://localhost:8000
  • API Documentation: http://localhost:8000/docs

πŸ“ Complete Project Structure

mediflow/
β”œβ”€β”€ backend/                       # FastAPI Backend
β”‚   β”œβ”€β”€ app/                       # Main application package
β”‚   β”‚   β”œβ”€β”€ api/                   # API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ analytics.py       # Analytics endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py           # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ patients.py       # Patient management endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ resources.py      # Resource management endpoints
β”‚   β”‚   β”‚   └── __init__.py
β”‚   β”‚   β”œβ”€β”€ core/                 # Core configuration and security
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py         # Application configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ security.py       # Security utilities (JWT, password hashing)
β”‚   β”‚   β”‚   └── __init__.py
β”‚   β”‚   β”œβ”€β”€ models/               # SQLAlchemy database models
β”‚   β”‚   β”‚   β”œβ”€β”€ base.py           # Base model class
β”‚   β”‚   β”‚   β”œβ”€β”€ patient.py        # Patient model
β”‚   β”‚   β”‚   β”œβ”€β”€ outcome.py        # Medical outcome model
β”‚   β”‚   β”‚   β”œβ”€β”€ resource.py       # Resource model
β”‚   β”‚   β”‚   β”œβ”€β”€ analytics.py      # Analytics data model
β”‚   β”‚   β”‚   └── __init__.py
β”‚   β”‚   β”œβ”€β”€ schemas/              # Pydantic schemas for validation
β”‚   β”‚   β”‚   β”œβ”€β”€ patient.py        # Patient schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ outcome.py        # Outcome schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ resource.py       # Resource schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ user.py           # User schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ analytics.py      # Analytics schemas
β”‚   β”‚   β”‚   └── __init__.py
β”‚   β”‚   β”œβ”€β”€ database.py           # Database configuration and connection
β”‚   β”‚   β”œβ”€β”€ main.py               # FastAPI application entry point
β”‚   β”‚   └── __init__.py
β”‚   β”œβ”€β”€ venv/                     # Python virtual environment
β”‚   β”œβ”€β”€ docker-compose.yml        # Docker Compose configuration
β”‚   β”œβ”€β”€ Dockerfile               # Docker image definition
β”‚   β”œβ”€β”€ init.sql                 # Database initialization script
β”‚   β”œβ”€β”€ mediflow.db              # SQLite database file
β”‚   └── requirements.txt         # Python dependencies
β”œβ”€β”€ frontend/                     # React Frontend
β”‚   β”œβ”€β”€ public/                   # Static public assets
β”‚   β”œβ”€β”€ src/                     # React application source code
β”‚   β”œβ”€β”€ build/                   # Production build output
β”‚   β”‚   └── static/
β”‚   β”‚       β”œβ”€β”€ css/            # Compiled CSS stylesheets
β”‚   β”‚       └── js/             # Bundled JavaScript files
β”‚   β”œβ”€β”€ node_modules/            # Project dependencies (auto-generated)
β”‚   └── package.json            # Project configuration and dependencies
└── README.md                    # Project documentation

πŸ”§ API Endpoints

Authentication

  • POST /api/auth/login - User login with JWT token
  • POST /api/auth/register - New user registration
  • POST /api/auth/refresh - Refresh access token
  • POST /api/auth/logout - Secure logout

Patient Management

  • GET /api/patients - List all patients with pagination
  • POST /api/patients - Create new patient record
  • GET /api/patients/{id} - Get detailed patient information
  • PUT /api/patients/{id} - Update patient details
  • DELETE /api/patients/{id} - Archive patient record
  • GET /api/patients/{id}/history - Patient medical history

Resource Management

  • GET /api/resources - List medical resources
  • POST /api/resources - Add new resource
  • PUT /api/resources/{id} - Update resource availability
  • GET /api/resources/availability - Check resource availability
  • POST /api/resources/{id}/allocate - Allocate resource

Analytics & Reporting

  • GET /api/analytics/overview - System overview statistics
  • GET /api/analytics/patient-stats - Patient demographic analytics
  • GET /api/analytics/resource-usage - Resource utilization metrics
  • GET /api/analytics/financial - Revenue and billing reports

πŸš€ Deployment

Docker Deployment (Production)

# Build and start all services
docker-compose -f docker-compose.prod.yml up --build -d

# View logs
docker-compose logs -f

# Scale backend services
docker-compose up --scale backend=3

Manual Production Deployment

Backend:

# Install dependencies
pip install -r requirements.txt

# Set production environment
export ENVIRONMENT=production
export DATABASE_URL=postgresql://user:pass@localhost/mediflow

# Start with gunicorn
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker

Frontend:

# Build for production
npm run build

# Serve with nginx or static server
serve -s build -l 3000

πŸ§ͺ Testing & Development

Backend Testing

cd backend
pytest tests/ -v

Frontend Testing

cd frontend
npm test

Development Scripts

# Backend development server
uvicorn app.main:app --reload

# Frontend development server
npm start

# Run linting
npm run lint

# Build production bundle
npm run build

βš™οΈ Configuration

Environment Variables

# Backend Configuration
DATABASE_URL=sqlite:///./mediflow.db
SECRET_KEY=your-super-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
ENVIRONMENT=development

# Optional: External API Keys
INSURANCE_API_KEY=your-insurance-api-key
LAB_API_KEY=your-lab-integration-key

Frontend Configuration

The React app automatically connects to the backend API and includes:

  • Responsive design for all screen sizes
  • Progressive Web App (PWA) capabilities
  • Optimized bundle splitting
  • Service worker for offline functionality

πŸ“ˆ Performance & Monitoring

Backend Performance

  • Async/Await: FastAPI's asynchronous request handling
  • Database Connection Pooling: Efficient database connections
  • Caching: Redis integration for frequent queries
  • Background Tasks: Celery for heavy operations

Frontend Performance

  • Code Splitting: Automatic bundle optimization
  • Lazy Loading: Component-level code splitting
  • Memoization: React.memo and useMemo optimizations
  • Service Worker: Caching and offline functionality

πŸ”’ Security Features

Data Protection

  • HIPAA Compliance - Healthcare data protection standards
  • Encryption at Rest - Database encryption for sensitive data
  • SSL/TLS - Secure data transmission
  • Input Sanitization - Protection against injection attacks

Access Control

  • JWT Authentication - Stateless token-based auth
  • Role-based Permissions - Granular access control
  • Session Management - Secure user sessions
  • Audit Logging - Complete activity tracking

πŸ“‹ Future Roadmap

High Priority

  • PostgreSQL Migration - Production database upgrade
  • Enhanced API Documentation - Comprehensive Swagger docs
  • Unit Test Coverage - 90%+ test coverage
  • Real-time Updates - WebSocket integration
  • Advanced Analytics - Machine learning insights

Medium Priority

  • Mobile App - React Native companion app
  • Microservices Architecture - Service decomposition
  • Advanced Search - Elasticsearch integration
  • Backup & Recovery - Automated backup system
  • Multi-tenant Support - Multiple facility management

Security & Compliance

  • Two-factor Authentication - Enhanced security
  • Data Encryption - End-to-end encryption
  • Compliance Auditing - HIPAA audit trails
  • Penetration Testing - Regular security assessments

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-feature
  3. Make your changes with proper tests
  4. Run tests: npm test (frontend) and pytest (backend)
  5. Commit changes: git commit -am 'Add new feature'
  6. Push to branch: git push origin feature/new-feature
  7. Submit a pull request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use ESLint and Prettier for JavaScript
  • Write tests for new features
  • Update documentation for API changes
  • Use conventional commit messages

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support & Troubleshooting

Common Issues

  • Docker Build Failures: Check Docker version and available memory
  • API Connection Issues: Verify backend is running on port 8000
  • Database Errors: Check database initialization and permissions
  • Frontend Build Issues: Clear node_modules and reinstall

Built with ❀️ for healthcare professionals

Simple, clean, and easy to run - perfect for medical practice management!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors