Skip to content

rajrasane/ClinicClerk

Repository files navigation

ClinicClerk

Note : This project is currently put on hold , as I need to improve it's security and make sure it follows med related approval or certs

A modern, secure digital patient records management system built for solo medical practitioners. Designed to replace handwritten patient notebooks with a comprehensive, searchable digital solution featuring multi-tenancy, authentication, and optimized performance.

✨ Features

πŸ₯ Core Medical Management

  • Patient Management - Complete CRUD operations with detailed patient profiles
  • Visit/Consultation Tracking - Comprehensive visit records with medical details
  • Medical History - Full patient history with visit timeline and medical data
  • Search & Filter - Advanced search by name, phone, date ranges, and medical criteria

πŸ” Security & Authentication

  • Supabase Authentication - Secure email/password authentication
  • Multi-Tenant Architecture - Doctor-based data isolation using Row Level Security (RLS)
  • Data Privacy - Each doctor only sees their own patients and visits
  • Secure API - Protected endpoints with authentication middleware

πŸš€ Performance & Optimization

  • Optimized Database Schema - 90% storage reduction with smart data types
  • Intelligent Caching - Optimized cache management for faster load times
  • Responsive Design - Mobile-first UI with modern glass morphism effects
  • Real-time Updates - Optimistic updates for seamless user experience

πŸ’» Modern UI/UX

  • Clean Interface - Modern, intuitive design with Tailwind CSS v4
  • Modal-based Forms - Streamlined patient and visit management
  • Toast Notifications - Real-time feedback for all operations
  • Date Pickers - Advanced date selection with auto-close functionality
  • Responsive Layout - Optimized for desktop, tablet, and mobile devices

πŸ›  Tech Stack

  • Framework: Next.js 15.2.8 with TypeScript & React 19
  • Database: Supabase (PostgreSQL) with Row Level Security
  • Authentication: Supabase Auth with custom forms
  • Styling: Tailwind CSS v4 with custom components
  • UI Components: Radix UI primitives + custom components
  • Forms: React Hook Form with validation
  • Animations: Framer Motion for smooth transitions
  • Icons: Heroicons & Lucide React
  • Date Handling: date-fns & React Day Picker
  • Notifications: React Hot Toast
  • Export: jspdf (PDF) & xlsx (Excel)

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Supabase account (free tier supported)

Setup

# Clone and install
git clone https://github.com/rajrasane/ClinicClerk.git
cd ClinicClerk
npm install

# Environment variables
cp .env.example .env.local
# Add your Supabase credentials

# Run development server
npm run dev

Environment Variables

# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

# Optional: PostgreSQL Database (if using direct connection)
DATABASE_URL=your_database_url

Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from /src/lib/schema.sql in your Supabase SQL editor
  3. Enable Row Level Security policies (included in schema)
  4. Update environment variables with your Supabase credentials

πŸ“ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/                    # API routes
β”‚   β”‚   β”œβ”€β”€ export/            # Data export operations
β”‚   β”‚   β”œβ”€β”€ patients/          # Patient CRUD operations
β”‚   β”‚   β”œβ”€β”€ visits/            # Visit CRUD operations  
β”‚   β”‚   └── profile/           # Doctor profile management
β”‚   β”œβ”€β”€ login/                 # Authentication pages
β”‚   β”œβ”€β”€ signup/                # User registration
β”‚   └── profile/               # Doctor profile page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ auth/                  # Authentication components
β”‚   β”‚   β”œβ”€β”€ LoginForm.tsx      # Login form with validation
β”‚   β”‚   └── SignupForm.tsx     # Signup form with doctor profile
β”‚   β”œβ”€β”€ ui/                    # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ button.tsx         # Custom button component
β”‚   β”‚   β”œβ”€β”€ calendar.tsx       # Date picker component
β”‚   β”‚   └── [other-ui].tsx     # Various UI primitives
β”‚   β”œβ”€β”€ AddPatientModalNew.tsx # Patient creation modal
β”‚   β”œβ”€β”€ AddVisitModal.tsx      # Visit creation modal
β”‚   β”œβ”€β”€ PatientDetailsModal.tsx# Patient details view
β”‚   β”œβ”€β”€ VisitDetailsModal.tsx  # Visit details view
β”‚   β”œβ”€β”€ Patients.tsx           # Patient management interface
β”‚   └── Visits.tsx             # Visit management interface
β”œβ”€β”€ contexts/
β”‚   └── AuthContext.tsx        # Authentication context provider
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ usePatients.ts         # Patient data management hooks
β”‚   └── useVisits.ts           # Visit data management hooks
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ supabase.ts            # Supabase client configuration
β”‚   β”œβ”€β”€ supabase-server.ts     # Server-side Supabase client
β”‚   β”œβ”€β”€ schema.sql             # Optimized database schema
β”‚   β”œβ”€β”€ cache.ts               # Cache management utilities
β”‚   └── utils.ts               # Utility functions
└── sections/
    └── Header.tsx             # Main navigation header

πŸ”Œ API Endpoints

Patients

  • GET /api/patients - Get all patients (filtered by doctor)
  • POST /api/patients - Create new patient
  • PUT /api/patients/[id] - Update patient
  • DELETE /api/patients/[id] - Delete patient

Visits

  • GET /api/visits - Get all visits (filtered by doctor)
  • POST /api/visits - Create new visit
  • PUT /api/visits/[id] - Update visit
  • DELETE /api/visits/[id] - Delete visit

Profile

  • GET /api/profile - Get doctor profile
  • PUT /api/profile - Update doctor profile

Export

  • GET /api/export/patients - Export patients to Excel/PDF
  • GET /api/export/visits - Export visits to Excel/PDF

πŸ₯ Usage

For Solo Practitioners

  1. Sign Up - Create your doctor account with clinic details
  2. Add Patients - Register new patients with comprehensive medical information
  3. Record Visits - Document consultations, diagnoses, and prescriptions
  4. Search & Filter - Quickly find patients and review medical history
  5. Manage Profile - Update your clinic information and preferences

Key Workflows

  • Patient Registration - Capture demographics, medical history, and emergency contacts
  • Visit Documentation - Record chief complaints, symptoms, diagnosis, and treatment plans
  • Medical History Review - Access complete patient timeline with all previous visits
  • Search Operations - Find patients by name, phone, or filter visits by date range

πŸ”’ Security Features

  • Row Level Security (RLS) - Database-level data isolation per doctor
  • Authentication Required - All routes protected with Supabase Auth
  • Data Validation - Comprehensive input validation and sanitization
  • Secure API - Protected endpoints with proper error handling
  • Privacy Compliance - Each doctor can only access their own data

πŸš€ Performance Optimizations

  • Database Schema - Optimized data types for 90% storage reduction
  • Smart Caching - Intelligent cache invalidation strategies
  • Optimistic Updates - Immediate UI updates with background sync
  • Connection Pooling - Efficient database connection management
  • Responsive Loading - Progressive loading with skeleton states

πŸ“Š Scale & Deployment

Designed for Production:

  • Supports 3K+ patients and 10K+ visits per doctor
  • Optimized for Vercel + Supabase free tiers
  • Ready for real-world medical practice deployment
  • Bandwidth-optimized for cost-effective scaling

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ†˜ Support

For issues, feature requests, or questions:

  1. Check existing GitHub issues
  2. Create a new issue with detailed description
  3. Include steps to reproduce for bugs

Built with ❀️ for modern medical practices

Releases

Packages

Contributors

Languages