Skip to content

HimathX/medsync-clinic-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

149 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ MedSync - Clinic Management System

MedSync Logo

A comprehensive, production-ready clinic management platform with FastAPI backend and React 19 frontend, featuring role-based portals for patients, doctors, and administrative staff.

FastAPI React TypeScript MySQL Tailwind CSS

Features β€’ Tech Stack β€’ Quick Start β€’ Architecture


πŸ“‹ Table of Contents


🌟 Overview

MedSync is a modern, scalable healthcare management platform built with cutting-edge technologies. It streamlines clinic operations through dedicated, role-specific portals that enable seamless appointment scheduling, comprehensive medical record management, integrated billing, and advanced analytics.

Why MedSync?

βœ… Full-Stack Healthcare Solution - Complete ecosystem from patient booking to billing
βœ… Role-Based Portals - Tailored interfaces for patients, doctors, and staff
βœ… Real-Time Data Sync - Live updates across all modules and user types
βœ… Production-Ready - Secure authentication, error handling, and comprehensive validation
βœ… Scalable Architecture - Connection pooling, stored procedures, and optimized queries
βœ… Type-Safe Frontend - React 19 with TypeScript and Zod validation
βœ… Multi-Branch Support - Manage multiple clinic locations seamlessly


✨ Features

πŸ‘₯ Patient Portal

  • πŸ“… Smart Appointment Booking - Search doctors by specialty, view real-time availability
  • πŸ“‹ Medical Records - Complete consultation history, prescriptions, lab results
  • πŸ’³ Billing & Payments - Invoice management, payment history, insurance tracking
  • πŸ“Š Health Dashboard - Personalized health score, metrics, and alerts
  • πŸ”” Smart Notifications - Real-time appointment reminders and status updates

πŸ‘¨β€βš•οΈ Doctor Portal

  • πŸ“Š Analytics Dashboard - Daily schedules, patient statistics, satisfaction metrics
  • 🩺 Consultation Management - Detailed patient consultations with diagnoses
  • πŸ’Š Digital Prescriptions - Write and manage medication prescriptions
  • πŸ“… Schedule Management - Set availability and manage time slots
  • πŸ“ˆ Patient Intelligence - Complete medical history and clinical insights

🏒 Staff/Admin Portal

  • πŸ‘€ Patient Management - Register patients, search by NIC, manage records
  • πŸ“† Appointment Operations - Book, reschedule, and manage appointments
  • πŸ’° Billing & Invoicing - Generate invoices, process payments, insurance claims
  • πŸ“Š Comprehensive Reporting - Revenue analytics, appointment trends, operational reports
  • πŸ‘¨β€βš•οΈ Resource Management - Doctor profiles, specializations, and scheduling

πŸ”’ Security & Authentication

  • πŸ” JWT + OAuth2 - Secure token-based authentication
  • πŸ›‘οΈ Role-Based Access Control - Granular authorization per user type
  • πŸ”‘ Bcrypt Password Hashing - Industry-standard password security
  • 🎯 Session Management - Persistent login with automatic cleanup

πŸ› οΈ Tech Stack

Backend (FastAPI + Python)

Component Version Purpose
FastAPI 0.115+ Modern async REST API framework
Python 3.10+ Backend runtime
MySQL 8.0+ Relational database
Pydantic 2.0+ Data validation & serialization
JWT + OAuth2 - Authentication & authorization
bcrypt - Password hashing
ReportLab - PDF generation

Frontend (React + TypeScript)

Component Version Purpose
React 19.2+ UI library with server components
TypeScript 5.0+ Type-safe development
React Router 7.x Client-side routing
Tailwind CSS 4.0+ Utility-first styling
React Hook Form - Efficient form management
Zod - Schema validation
Radix UI - Accessible component primitives
shadcn/ui - High-quality pre-built components
Axios - HTTP client with interceptors
Recharts - Data visualization
Framer Motion - Smooth animations

Database Architecture

  • Connection Pooling - 10 concurrent connections for optimal performance
  • Stored Procedures - Complex operations for consistency and security
  • Optimized Indexing - Fast query performance on 20+ tables
  • Backup System - Automated timestamped backups with DDL/DML separation

πŸš€ Quick Start

Prerequisites

  • Python 3.10+ (Backend)
  • Node.js 18+ (Frontend)
  • MySQL 8.0+
  • Git

1️⃣ Clone & Setup Database

git clone https://github.com/yourusername/medsync.git
cd medsync

# Create MySQL database
mysql -u root -p
CREATE DATABASE medsync_db;
USE medsync_db;
SOURCE database/schema.sql;  # If available

2️⃣ Backend Setup

cd backend

# Virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Dependencies
pip install -r requirements.txt

# Environment configuration
cp .env.example .env
# Edit .env with your database credentials

# Run server
uvicorn main:app --reload --host 0.0.0.0 --port 8000

Backend Available: http://localhost:8000

3️⃣ Frontend Setup

cd ../frontend

# Dependencies
npm install

# Environment configuration
cp .env.example .env
# Ensure VITE_API_URL=http://localhost:8000

# Development server
npm run dev

Frontend Available: http://localhost:5173

4️⃣ Access the System

  1. Navigate to http://localhost:5173
  2. Choose your portal: Patient β†’ Doctor β†’ Staff
  3. Login or register based on your role

βš™οΈ Configuration

Backend Environment (.env)

# Database
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=medsync_db

# Security
SECRET_KEY=your-secret-key-here-min-32-chars
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

# CORS (Production: restrict this)
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000

Frontend Environment (.env)

VITE_API_URL=http://localhost:8000
VITE_APP_NAME=MedSync

πŸ—οΈ Architecture

Backend Architecture

FastAPI Server
    ↓
CORS Middleware β†’ Auth Middleware
    ↓
22 API Routers β†’ Pydantic Schemas
    ↓
Business Logic β†’ Database Utils
    ↓
MySQL Database (Connection Pool)
    ↓
Stored Procedures

Key Design Patterns:

  • RESTful API - Standard HTTP methods and status codes
  • Dependency Injection - FastAPI's built-in DI for services
  • Connection Pooling - Efficient database resource management
  • Stored Procedures - Database-level transaction integrity

Frontend Architecture

React 19 + TypeScript
    ↓
React Router (Client-side routing)
    ↓
Portal Layouts (Patient/Doctor/Staff)
    ↓
Page Components β†’ Service Layer
    ↓
Axios API Client (with interceptors)
    ↓
FastAPI Backend

Key Patterns:

  • Layered Architecture - Separation of concerns (UI β†’ Services β†’ API)
  • Hook-Based State - React hooks for component state
  • Form Validation - Zod schemas with React Hook Form
  • HTTP Interceptors - Automatic token refresh, error handling
  • Component Reusability - 58+ modular UI components

πŸ“š API Documentation

Complete API documentation is auto-generated at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

πŸ‘₯ User Roles

Role Portal URL Key Permissions Features
Patient /patient/* Read own records, book appointments Appointments, Records, Billing
Doctor /doctor/* Manage consultations, write prescriptions Consultations, Prescriptions, Schedule
Staff /staff/* Full operational access Patient Mgmt, Appointments, Billing, Reports

Access Control

  • Enforced Route Protection - Automatic redirects for unauthorized access
  • Token Validation - JWT tokens verified on every request
  • Session Management - Automatic logout after inactivity
  • Audit Trail - Operations logged for compliance

πŸ”’ Security Features

βœ… Password Security - bcrypt hashing with salt
βœ… JWT Authentication - 30-minute token expiration
βœ… CORS Protection - Configurable origin restrictions
βœ… SQL Injection Prevention - Parameterized queries via ORM
βœ… HTTPS Ready - Configure for production SSL/TLS
βœ… Input Validation - Pydantic schemas validate all inputs
βœ… Role-Based Authorization - Fine-grained access control

⚠️ Production Checklist:

  • Update SECRET_KEY to a strong random value
  • Restrict ALLOWED_ORIGINS to your domain
  • Enable HTTPS in environment
  • Configure database backups
  • Set up monitoring and logging
  • Review and update CORS policy

🀝 Contributing

We welcome contributions! Follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes following existing patterns
  4. Commit clearly: git commit -m 'Add amazing feature'
  5. Push your branch: git push origin feature/amazing-feature
  6. Open a Pull Request

Development Guidelines

βœ… Follow existing code style and patterns
βœ… Write clear commit messages
βœ… Update documentation for new features
βœ… Test thoroughly before submitting
βœ… Use TypeScript for frontend, type hints for backend


πŸ“„ License

Licensed under the MIT License - see LICENSE file for details.


πŸ™ Acknowledgments

  • FastAPI - Modern Python web framework
  • React - Powerful UI library
  • Radix UI & shadcn/ui - Accessible components
  • Tailwind CSS - Utility-first styling
  • MySQL - Reliable database system

πŸ“ž Support & Documentation


Built with ❀️ for the healthcare community

⭐ Star on GitHub β€’ πŸ“§ Contact Us

About

Multi-branch clinic appointment and treatment management system with integrated billing and patient records

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors