A modern, full-stack clinic management platform built for healthcare professionals in Nepal.
- Overview
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Database Setup
- Deployment (Vercel)
- Default Login Credentials
- License
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.
| 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 |
| 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 |
| 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 |
| Technology | Purpose |
|---|---|
| Vercel | Hosting & deployment |
| ESLint | Code linting |
| ts-node | TypeScript execution for seeding |
| dotenv | Environment variable management |
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
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
Step 1: Clone the repository
git clone https://github.com/YOUR_USERNAME/smart-clinic.git
cd smart-clinicStep 2: Install dependencies
npm installStep 3: Set up environment variables
Create a .env.local file in the root of the project:
cp .env.example .env.localThen 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 seedStep 5: Run the development server
npm run devOpen http://localhost:3000 in your browser. π
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.localto Git! It is already added to.gitignore.
This project uses Prisma ORM with PostgreSQL.
- Create a PostgreSQL database named
smart_clinic - Update the
DATABASE_URLin your.env.local - Run migrations:
npx prisma db push
- Seed sample data:
npm run seed
- (Optional) Open Prisma Studio to browse your database visually:
npx prisma studio
For production, use a cloud PostgreSQL provider:
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- Go to neon.tech β Create free account
- Create a new project β Copy the Connection String
- Go to vercel.com β Sign in with GitHub
- Click "Add New Project" β Import your
smart-clinicrepository - In the "Environment Variables" section, add:
DATABASE_URLβ Your Neon connection stringNEXTAUTH_SECRETβ A random secret (generate at generate-secret.vercel.app)NEXTAUTH_URLβhttps://your-app-name.vercel.app
- Click "Deploy" π
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 seedAfter seeding the database, use these credentials to log in:
| Role | 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!
- 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()).
This project is for educational and academic purposes.
Made with β€οΈ in Nepal