A comprehensive hospital management system with NFC card integration, featuring a desktop client application for hospital staff (receptionists and doctors) and a robust backend API server.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Running the Project
- Project Structure
- API Documentation
- Database Schema
- Development
- Commands Reference
- Patient registration with unique 10-digit patient numbers
- Patient search and lookup (by patient number, NFC card, or name)
- Appointment scheduling
- Patient profile management
- View today's and tomorrow's appointments
- Patient consultation with voice input support
- Medical history viewing
- Prescription and diagnosis management
- Visit records management
- JWT-based authentication
- Role-based access control (Receptionist, Doctor)
- NFC card integration support
- Real-time appointment management
- Medical history tracking
- Appointment status management (Scheduled, Completed, Cancelled)
- Visit records linked to appointments
- Framework: React 18 with TypeScript
- UI Library: Shadcn UI (Radix UI components)
- Styling: Tailwind CSS
- State Management: Zustand, React Query
- Routing: React Router
- Desktop: Electron
- Build Tool: Vite
- Notifications: Sonner
- Runtime: Node.js with TypeScript
- Framework: Express.js
- Database: PostgreSQL with Prisma ORM (v7)
- Authentication: JWT (Access & Refresh tokens)
- Validation: Zod
- Password Hashing: bcryptjs
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- pnpm (v9 or higher) -
npm install -g pnpm - PostgreSQL (v14 or higher) - or use Neon DB (remote)
- Git
git clone <repository-url>
cd finalYearProjectpnpm installThis installs dependencies for both client and server using pnpm workspaces.
- Navigate to the
serverdirectory - Create a
.envfile:
cd server
cp .env.example .env- Configure the following environment variables in
server/.env:
# Database (local PostgreSQL or Neon DB)
DATABASE_URL="postgresql://username:password@localhost:5432/hospital_db?schema=public"
# Or for Neon DB:
# DATABASE_URL="postgresql://user:pass@host.neon.tech/db?sslmode=require"
# JWT Secrets
JWT_ACCESS_SECRET=your_access_secret_here
JWT_REFRESH_SECRET=your_refresh_secret_here
JWT_ACCESS_EXPIRES_IN=15m
JWT_REFRESH_EXPIRES_IN=7d
# Server
PORT=4000
NODE_ENV=development
# Frontend URL (for CORS)
FRONTEND_URL=http://localhost:5173- Navigate to the
desktop-clientdirectory - Create a
.envfile (if needed):
VITE_API_BASE_URL=http://localhost:4000/api# Start both server and client (web mode)
pnpm dev
# Or start server + Electron desktop app
pnpm electron# Backend only (port 4000)
pnpm dev:server
# Frontend only (port 5173)
pnpm dev:client
# Electron desktop app (requires server running separately)
pnpm --filter client electron:devIf using a new database, run migrations:
# Create tables (only for new databases)
pnpm db:migrate
# Generate Prisma client (required on new machines)
pnpm db:generate
# Seed with test data (optional)
pnpm db:seedIf connecting to an existing Neon DB with tables already created:
# Just generate the client
pnpm db:generate
# Then start the app
pnpm electronfinalYearProject/
βββ package.json # Root workspace config (pnpm)
βββ pnpm-workspace.yaml # Workspace definition
βββ .npmrc # pnpm configuration
βββ server/ # Backend API server
β βββ src/
β β βββ app/
β β β βββ config/ # Configuration files
β β β βββ constants/ # Constants and enums
β β β βββ middlewares/# Express middlewares
β β β βββ modules/ # Feature modules (auth, patient, etc.)
β β β βββ types/ # TypeScript type definitions
β β β βββ utils/ # Utility functions
β β βββ main.ts # Application entry point
β βββ prisma/
β β βββ schema.prisma # Database schema
β β βββ migrations/ # Database migrations
β βββ tests/ # Test scripts
β βββ package.json
β
βββ client/ # React + Electron frontend
β βββ src/
β β βββ api/ # API client functions
β β βββ components/ # React components
β β βββ contexts/ # React contexts
β β βββ hooks/ # Custom React hooks
β β βββ pages/ # Page components
β β βββ router/ # Routing configuration
β β βββ utils/ # Utility functions
β βββ electron/ # Electron configuration
β βββ package.json
β
βββ commands.md # Commands reference
βββ todo.md # Project todos and notes
βββ README.md # This file
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/logout- Logout user
POST /api/patients- Register a new patientGET /api/patients/:id- Get patient by IDGET /api/patients?q=...- Search patients
POST /api/appointments- Create appointmentGET /api/appointments- Get appointments (with filters)GET /api/appointments/:id- Get appointment by IDGET /api/appointments/doctor/:doctor_id/today- Get today's appointmentsGET /api/appointments/doctor/:doctor_id/tomorrow- Get tomorrow's appointmentsPUT /api/appointments/:id- Update appointmentPATCH /api/appointments/:id/cancel- Cancel appointment
POST /api/visits- Create visitGET /api/visits/:id- Get visit by IDGET /api/visits?patient_id=...- Get patient visitsPUT /api/visits/:id- Update visit
For detailed API documentation, see server/docs/backend-api.md
The database uses PostgreSQL with Prisma ORM. Key entities include:
- Users - Hospital staff (receptionists, doctors)
- Patients - Patient records with unique 10-digit numbers
- Appointments - Scheduled appointments
- Visits - Medical visit records linked to appointments
- Hospitals - Hospital information
- Allergies - Patient allergies
- ChronicConditions - Patient chronic conditions
For detailed schema information, see:
server/prisma/schema.prismaserver/docs/database-design.mdserver/ER.md
- TypeScript strict mode enabled
- ESLint for code linting
- Prettier for code formatting (if configured)
- Backend: Create a new module in
server/src/app/modules/ - Frontend: Create components in
client/src/components/or pages inclient/src/pages/ - Database: Update
server/prisma/schema.prismaand run migrations
# Create a new migration
pnpm db:migrate
# Apply migrations (production)
cd server && npx prisma migrate deploy
# Push schema changes (development only)
cd server && npx prisma db push# Backend tests (if available)
pnpm --filter server test
# Frontend tests (if available)
pnpm --filter client test
# All tests
pnpm testThis project uses pnpm workspaces for monorepo management.
pnpm dev # Start server + client (web mode)
pnpm electron # Start server + Electron desktop app
pnpm dev:server # Backend only (port 4000)
pnpm dev:client # Frontend only (port 5173)pnpm build # Build both client and server
pnpm build:server # Build backend only
pnpm build:client # Build frontend onlypnpm db:migrate # Run Prisma migrations
pnpm db:generate # Generate Prisma client
pnpm db:studio # Open Prisma Studio
pnpm db:seed # Seed database with test datapnpm lint # Run ESLint on all packages
pnpm clean # Remove all node_modules and builds
pnpm clean:install # Fresh install (clean + install)# Add dependency to server only
pnpm --filter server add express
# Add dev dependency to client only
pnpm --filter client add -D @types/react
# Run command in specific package
pnpm --filter server exec prisma migrate devFor more commands, see commands.md
The system uses JWT-based authentication with access and refresh tokens:
- Access Token: Short-lived (15 minutes), used for API requests
- Refresh Token: Long-lived (7 days), used to obtain new access tokens
Tokens are stored in HTTP-only cookies for security.
- Receptionist: Patient registration, appointment scheduling
- Doctor: Patient consultation, medical history viewing, prescription management
- Patient numbers are automatically generated as 10-digit sequential IDs
- Appointments can be linked to visits (when consultation is completed)
- Visit creation automatically updates appointment status to "completed"
- NFC card integration is supported for patient identification
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See LICENSE for details.
For issues and questions, please open an issue in the repository.
Built with β€οΈ for efficient hospital management