Skip to content

About

A modern, full-stack clinic management system built with Next.js, TypeScript, PostgreSQL, and Prisma. Designed to streamline operations for healthcare professionals with features for role-based access control, patient & doctor management, appointment scheduling, billing, and electronic medical records.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

πŸ₯ MadanBhandariClinic β€” Clinic Management System

A modern, full-stack clinic management platform built for healthcare professionals in Nepal.

Next.js TypeScript PostgreSQL Prisma Tailwind CSS Vercel


πŸ“‹ Table of Contents


🌟 Overview

MadanBhandariClinic is a comprehensive clinic management system designed to streamline day-to-day operations of a modern healthcare facility. It provides role-based access for Admins, Doctors, and Receptionists to manage patients, appointments, billing, medical records, inventory, and ward beds β€” all from a single, intuitive dashboard.


✨ Features

Module Description
πŸ” Authentication Secure login with role-based access control (Admin, Doctor, Receptionist, Patient)
πŸ‘₯ Patient Management Add, view, and manage patient records with full medical history
πŸ“… Appointments Book, confirm, cancel, and track appointments with doctors
🩺 Doctor Management Manage doctor profiles, specializations, schedules, and fees
πŸ“‹ Medical Records Record diagnoses, prescriptions, lab results, and follow-up dates
πŸ’Š Prescriptions Link prescriptions directly to medical records
πŸ’³ Billing & Invoices Generate invoices with tax calculation and payment tracking
πŸ₯ Ward & Bed Management Monitor ward occupancy and assign patients to beds
πŸ“¦ Inventory Track medicines and medical supplies with reorder alerts
βš™οΈ Clinic Settings Update clinic name, contact info, and other configurations
πŸ“Š Dashboard Analytics Visual overview of key metrics with charts

πŸ› οΈ Tech Stack

Frontend

Technology Version Purpose
Next.js 16.2 React framework with App Router & Server Components
React 19 UI library
TypeScript 5 Type-safe development
Tailwind CSS 4 Utility-first CSS framework
shadcn/ui 4.10 Accessible, pre-built UI components
Radix UI 1.5 Headless UI primitives
Recharts 3.8 Charting & data visualization
React Hook Form 7.77 Performant form management
Zod 4.4 Schema validation
Lucide React 1.17 Icon library
Zustand 5.0 Global state management
date-fns 4.4 Date utility library
Sonner 2.0 Toast notifications

Backend & Database

Technology Version Purpose
Next.js API Routes 16.2 RESTful API endpoints
NextAuth.js 5.0 (beta) Authentication & session management
Prisma ORM 7.8 Type-safe database client & schema management
PostgreSQL 18 Primary relational database
bcryptjs 3.0 Password hashing

DevOps & Tooling

Technology Purpose
Vercel Hosting & deployment
ESLint Code linting
ts-node TypeScript execution for seeding
dotenv Environment variable management

πŸ“ Project Structure

smart-clinic/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma        # Database schema (models & relations)
β”‚   └── seed.ts              # Database seeding script
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ (auth)/          # Auth pages (login)
β”‚   β”‚   β”œβ”€β”€ api/             # REST API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ appointments/
β”‚   β”‚   β”‚   β”œβ”€β”€ billing/
β”‚   β”‚   β”‚   β”œβ”€β”€ doctors/
β”‚   β”‚   β”‚   β”œβ”€β”€ patients/
β”‚   β”‚   β”‚   β”œβ”€β”€ medical-records/
β”‚   β”‚   β”‚   β”œβ”€β”€ inventory/
β”‚   β”‚   β”‚   β”œβ”€β”€ wards/
β”‚   β”‚   β”‚   └── settings/
β”‚   β”‚   β”œβ”€β”€ dashboard/       # Protected dashboard pages
β”‚   β”‚   β”‚   β”œβ”€β”€ appointments/
β”‚   β”‚   β”‚   β”œβ”€β”€ billing/
β”‚   β”‚   β”‚   β”œβ”€β”€ doctors/
β”‚   β”‚   β”‚   β”œβ”€β”€ inventory/
β”‚   β”‚   β”‚   β”œβ”€β”€ medical-records/
β”‚   β”‚   β”‚   β”œβ”€β”€ patients/
β”‚   β”‚   β”‚   β”œβ”€β”€ settings/
β”‚   β”‚   β”‚   └── wards/
β”‚   β”‚   β”œβ”€β”€ globals.css
β”‚   β”‚   └── layout.tsx
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ dashboard/       # Dashboard-specific components
β”‚   β”‚   β”œβ”€β”€ shared/          # Reusable shared components
β”‚   β”‚   └── ui/              # shadcn/ui base components
β”‚   └── lib/
β”‚       β”œβ”€β”€ prisma.ts        # Prisma client instance
β”‚       └── utils.ts         # Utility functions
β”œβ”€β”€ .env.local               # Local environment variables (do NOT commit)
β”œβ”€β”€ next.config.ts           # Next.js configuration
β”œβ”€β”€ prisma.config.ts         # Prisma configuration
β”œβ”€β”€ tailwind.config.ts       # Tailwind CSS configuration
└── package.json

πŸš€ Getting Started

Prerequisites

Make sure you have the following installed on your machine:

  • βœ… Node.js v18 or higher β€” Download
  • βœ… npm v9 or higher (comes with Node.js)
  • βœ… PostgreSQL v14 or higher β€” Download
  • βœ… Git β€” Download

Installation

Step 1: Clone the repository

git clone https://github.com/YOUR_USERNAME/smart-clinic.git
cd smart-clinic

Step 2: Install dependencies

npm install

Step 3: Set up environment variables

Create a .env.local file in the root of the project:

cp .env.example .env.local

Then fill in your values (see Environment Variables section below).

Step 4: Set up the database

# Push the Prisma schema to your PostgreSQL database
npx prisma db push

# Seed the database with sample data
npm run seed

Step 5: Run the development server

npm run dev

Open http://localhost:3000 in your browser. πŸŽ‰


πŸ” Environment Variables

Create a .env.local file in the project root with the following variables:

# ─── Database ───────────────────────────────────────────────────
# PostgreSQL connection string
DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/smart_clinic"

# ─── NextAuth.js ────────────────────────────────────────────────
# A random secret string (generate one at: https://generate-secret.vercel.app/32)
NEXTAUTH_SECRET="your-super-secret-key-here"

# The base URL of your application
# Local development:
NEXTAUTH_URL="http://localhost:3000"
# Production (Vercel):
# NEXTAUTH_URL="https://your-app-name.vercel.app"

⚠️ Never commit .env.local to Git! It is already added to .gitignore.


πŸ—„οΈ Database Setup

This project uses Prisma ORM with PostgreSQL.

Local Setup

  1. Create a PostgreSQL database named smart_clinic
  2. Update the DATABASE_URL in your .env.local
  3. Run migrations:
    npx prisma db push
  4. Seed sample data:
    npm run seed
  5. (Optional) Open Prisma Studio to browse your database visually:
    npx prisma studio

Production Setup (Neon / Supabase)

For production, use a cloud PostgreSQL provider:

  • Neon (recommended for Vercel) β€” Free tier available
  • Supabase β€” Free tier available

☁️ Deployment (Vercel)

Step 1: Push code to GitHub

git init                          # (skip if already initialized)
git add .
git commit -m "πŸš€ Initial commit"
git remote add origin https://github.com/YOUR_USERNAME/smart-clinic.git
git push -u origin main

Step 2: Create a cloud PostgreSQL database

  1. Go to neon.tech β†’ Create free account
  2. Create a new project β†’ Copy the Connection String

Step 3: Deploy on Vercel

  1. Go to vercel.com β†’ Sign in with GitHub
  2. Click "Add New Project" β†’ Import your smart-clinic repository
  3. In the "Environment Variables" section, add:
    • DATABASE_URL β†’ Your Neon connection string
    • NEXTAUTH_SECRET β†’ A random secret (generate at generate-secret.vercel.app)
    • NEXTAUTH_URL β†’ https://your-app-name.vercel.app
  4. Click "Deploy" πŸš€

Step 4: Initialize the production database

After deployment, run in your local terminal:

# Push schema to production database
DATABASE_URL="your-neon-connection-string" npx prisma db push

# Seed production database with sample data
DATABASE_URL="your-neon-connection-string" npm run seed

πŸ‘€ Default Login Credentials

After seeding the database, use these credentials to log in:

Role Email Password
πŸ‘‘ Admin admin@clinic.com Admin@123
πŸ‘¨β€βš•οΈ Doctor ramesh@clinic.com Doctor@123
πŸ€’ Patient aarav@patient.com Patient@123

⚠️ Change these default passwords immediately in a production environment!


πŸ†• Recent Updates (June 2026)

  • Role-Based Access Control (RBAC): Added support for multi-role login (Admin, Doctor, Patient) using NextAuth credentials.
  • Dynamic UI: Dashboard statistics and UI elements (buttons, forms) dynamically hide/show based on the logged-in user's role.
  • Sidebar Navigation: Implemented a globally managed, collapsible desktop sidebar with smooth animations and default closed state on login.
  • Middleware Update: Fixed proxy routing logic to properly allow authorized non-admin users to access the dashboard securely.
  • Provider Fix: Added <SessionProvider> to the root layout to prevent client-side hook crashes (useSession()).

πŸ“œ License

This project is for educational and academic purposes.


Made with ❀️ in Nepal

About

A modern, full-stack clinic management system built with Next.js, TypeScript, PostgreSQL, and Prisma. Designed to streamline operations for healthcare professionals with features for role-based access control, patient & doctor management, appointment scheduling, billing, and electronic medical records.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages