Skip to content

amandeeep02/ClinicEase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ ClinicEase - Appointment Management System

A modern, full-stack hospital management system with AI-powered features built using the MERN stack (MongoDB, Express.js, React, Node.js).

✨ Overview

ClinicEase is a comprehensive healthcare management platform that streamlines hospital operations with role-based access control for patients, doctors, and administrators. The system features AI-powered chatbot assistance, automated patient summaries, and seamless appointment management.

πŸš€ Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (v4.4 or higher)
  • npm or yarn
  • Google Gemini API Key (for AI features)
  • AWS S3 (optional, for cloud file storage)

Installation

1. Clone the Repository

git clone <repository-url>
cd ClinicEase

2. Setup Backend

cd backend
npm install

# Create .env file from example
cp .env.example .env

# Edit .env and add your configuration
# Add GEMINI_API_KEY for AI features
# Add AWS credentials for S3 (optional)

# Seed database with demo data
npm run seed

# Start backend server
npm run dev

Backend will run on http://localhost:3000

3. Setup Frontend

cd frontend
npm install

# Create .env file from example
cp .env.example .env

# Start frontend development server
npm run dev

Frontend will run on http://localhost:5173

4. Start MongoDB

Ensure MongoDB is running on your system:

mongod

Or use MongoDB Atlas for cloud database.

πŸ” Demo Credentials

Role Email Password
Patient john@example.com patient123
Doctor dr.smith@clinicease.com doctor123
Admin admin@clinicease.com admin123

πŸ“‹ Features

πŸ‘€ For Patients

  • βœ… User Registration & Authentication - Secure signup and login
  • βœ… Appointment Booking - Schedule appointments with available doctors
  • βœ… Appointment Management - View, track, and cancel appointments
  • βœ… Medical Report Upload - Upload and store medical documents
  • βœ… Medical History - Access complete medical history and reports
  • βœ… AI Chatbot - Get instant health guidance and symptom analysis
  • βœ… Dashboard - View statistics and upcoming appointments
  • βœ… Profile Management - Update personal information

πŸ‘¨β€βš•οΈ For Doctors

  • βœ… Doctor Registration - Register with admin approval workflow
  • βœ… Appointment Management - View and manage patient appointments
  • βœ… Status Updates - Approve, reject, or complete appointments
  • βœ… Patient History Access - View complete patient medical records
  • βœ… Report Generation - Create and upload medical reports
  • βœ… File Attachments - Attach documents to patient reports
  • βœ… AI Patient Summaries - Generate AI-powered patient summaries
  • βœ… Dashboard - View appointment statistics and pending cases
  • βœ… Prescription Guidance - AI-assisted treatment recommendations

πŸ‘¨β€πŸ’Ό For Administrators

  • βœ… Doctor Approval System - Approve or reject doctor registrations
  • βœ… User Management - Manage all users (patients, doctors)
  • βœ… Appointment Oversight - View all appointments across departments
  • βœ… System Analytics - Comprehensive statistics and insights
  • βœ… Search Functionality - Search users and appointments
  • βœ… User Deletion - Remove users from the system
  • βœ… Status Management - Update doctor approval status
  • βœ… Dashboard - System-wide overview and metrics

πŸ€– AI-Powered Features

  • βœ… Medical Chatbot - Powered by Google Gemini 2.0 Flash
  • βœ… Symptom Analysis - AI-driven symptom evaluation
  • βœ… Patient Summaries - Automated patient history summaries
  • βœ… Prescription Guidance - Treatment recommendations for doctors
  • βœ… Conversation History - Persistent chat history with context
  • βœ… Fallback Responses - Rule-based responses when AI is unavailable

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT (JSON Web Tokens)
  • Password Security: bcryptjs
  • File Upload: Multer
  • Cloud Storage: AWS S3 SDK
  • AI Integration: Google Generative AI (Gemini)
  • CORS: Enabled for cross-origin requests
  • Environment: dotenv for configuration

Frontend

  • Framework: React 19
  • Routing: React Router DOM v7
  • Styling: Tailwind CSS with custom Neobrutalism theme
  • HTTP Client: Axios
  • Form Handling: React Hook Form
  • Validation: Zod
  • Charts: Recharts
  • Icons: Lucide React
  • Notifications: Sonner (toast notifications)
  • Build Tool: Vite

πŸ“ Project Structure

ClinicEase/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/       # Business logic & request handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ appointmentController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ authController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ chatbotController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ reportController.js
β”‚   β”‚   β”‚   └── userController.js
β”‚   β”‚   β”œβ”€β”€ models/            # MongoDB schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Appointment.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Report.js
β”‚   β”‚   β”‚   └── ChatHistory.js
β”‚   β”‚   β”œβ”€β”€ routes/            # API route definitions
β”‚   β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ appointmentRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ reportRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ userRoutes.js
β”‚   β”‚   β”‚   └── chatbotRoutes.js
β”‚   β”‚   β”œβ”€β”€ middleware/        # Custom middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js        # JWT authentication
β”‚   β”‚   β”‚   └── upload.js      # File upload handling
β”‚   β”‚   β”œβ”€β”€ services/          # External services
β”‚   β”‚   β”‚   β”œβ”€β”€ geminiService.js  # AI integration
β”‚   β”‚   β”‚   └── s3Service.js      # AWS S3 integration
β”‚   β”‚   β”œβ”€β”€ App.js            # Express app setup
β”‚   β”‚   └── seed.js           # Database seeding
β”‚   β”œβ”€β”€ uploads/              # Local file storage
β”‚   β”œβ”€β”€ .env                  # Environment variables
β”‚   β”œβ”€β”€ .env.example          # Environment template
β”‚   β”œβ”€β”€ package.json
β”‚   └── setup-s3-bucket.js    # S3 bucket setup script
β”‚
└── frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/       # Reusable UI components
    β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.jsx
    β”‚   β”‚   β”œβ”€β”€ ChatBotWindow.jsx
    β”‚   β”‚   β”œβ”€β”€ ReportCard.jsx
    β”‚   β”‚   └── ...
    β”‚   β”œβ”€β”€ contexts/         # React Context providers
    β”‚   β”‚   └── AuthContext.jsx
    β”‚   β”œβ”€β”€ hooks/            # Custom React hooks
    β”‚   β”‚   └── useTheme.js
    β”‚   β”œβ”€β”€ pages/            # Page components
    β”‚   β”‚   β”œβ”€β”€ auth/         # Login, Register
    β”‚   β”‚   β”œβ”€β”€ patient/      # Patient pages
    β”‚   β”‚   β”œβ”€β”€ Doctor/       # Doctor pages
    β”‚   β”‚   β”œβ”€β”€ admin/        # Admin pages
    β”‚   β”‚   └── shared/       # Shared pages
    β”‚   β”œβ”€β”€ services/         # API service layer
    β”‚   β”‚   β”œβ”€β”€ api.js
    β”‚   β”‚   β”œβ”€β”€ authService.js
    β”‚   β”‚   β”œβ”€β”€ appointmentService.js
    β”‚   β”‚   β”œβ”€β”€ reportService.js
    β”‚   β”‚   β”œβ”€β”€ chatbotService.js
    β”‚   β”‚   └── usersService.js
    β”‚   β”œβ”€β”€ config/           # Configuration files
    β”‚   β”‚   └── api.js
    β”‚   β”œβ”€β”€ App.jsx           # Main app component
    β”‚   β”œβ”€β”€ main.jsx          # Entry point
    β”‚   └── index.css         # Global styles
    β”œβ”€β”€ public/               # Static assets
    β”œβ”€β”€ .env                  # Environment variables
    β”œβ”€β”€ .env.example          # Environment template
    β”œβ”€β”€ index.html
    β”œβ”€β”€ package.json
    β”œβ”€β”€ tailwind.config.js    # Tailwind configuration
    └── vite.config.js        # Vite configuration

πŸ”Œ API Documentation

Authentication Endpoints

Method Endpoint Description Auth Required Role
POST /api/auth/register Register new user No -
POST /api/auth/login Login user No -
GET /api/auth/me Get current user Yes All
PUT /api/auth/profile Update user profile Yes All

Appointment Endpoints

Method Endpoint Description Auth Required Role
POST /api/appointments Create appointment Yes Patient
GET /api/appointments/my-appointments Get user appointments Yes All
GET /api/appointments/all Get all appointments Yes Doctor, Admin
GET /api/appointments/stats Get appointment stats Yes Admin
GET /api/appointments/:id Get appointment by ID Yes All
PUT /api/appointments/:id/status Update appointment status Yes Doctor, Admin
DELETE /api/appointments/:id Delete appointment Yes Patient, Admin

Report Endpoints

Method Endpoint Description Auth Required Role
POST /api/reports Create report (doctor) Yes Doctor
POST /api/reports/upload Upload report (patient) Yes Patient
GET /api/reports/my-reports Get user's reports Yes All
GET /api/reports/patient/:patientEmail Get patient reports Yes All
GET /api/reports/ai-summary/:patientEmail Generate AI patient summary Yes All
GET /api/reports/:id Get report by ID Yes All
GET /api/reports Get all reports Yes Admin
PUT /api/reports/:id Update report Yes Doctor, Admin
DELETE /api/reports/:id Delete report Yes Doctor, Admin

User Endpoints

Method Endpoint Description Auth Required Role
GET /api/users/doctors Get all doctors Yes All
GET /api/users/patients Get all patients Yes Doctor, Admin
GET /api/users/stats Get user statistics Yes Admin
GET /api/users/search Search users Yes All
GET /api/users/:id Get user by ID Yes All
PUT /api/users/doctors/:id/status Update doctor status Yes Admin
DELETE /api/users/:id Delete user Yes Admin

Chatbot Endpoints

Method Endpoint Description Auth Required Role
POST /api/chatbot/message Send chat message Yes All
GET /api/chatbot/history Get chat history Yes All
DELETE /api/chatbot/history Clear chat history Yes All

Health Check

Method Endpoint Description Auth Required
GET /api/health Health check No

πŸ“ Environment Variables

Backend (.env)

# Server Configuration
PORT=3000
NODE_ENV=development

# Database
MONGODB_URI=mongodb://localhost:27017/clinicease

# JWT Secret (Change in production!)
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production

# Frontend URL
FRONTEND_URL=http://localhost:5173

# Google Gemini AI
GEMINI_API_KEY=your-gemini-api-key

# AWS S3 (Optional)
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
AWS_REGION=us-east-1
AWS_S3_BUCKET_NAME=clinicease-uploads

Frontend (.env)

VITE_API_URL=http://localhost:3000/api

πŸ§ͺ Testing

The project includes several test scripts to verify functionality:

cd backend

# Test all endpoints
node test-all-endpoints.js

# Test AI features
node test-ai-features.js

# Test report creation
node test-report-creation.js

# Test Gemini API directly
node test-gemini-direct.js

# Simple API test
node test-simple.js

πŸ”’ Security Features

  • JWT Authentication - Secure token-based authentication
  • Password Hashing - bcryptjs with salt rounds
  • Role-Based Access Control (RBAC) - Granular permissions
  • Protected Routes - Frontend and backend route protection
  • CORS Configuration - Controlled cross-origin access
  • File Upload Validation - Secure file handling with Multer
  • Environment Variables - Sensitive data protection
  • Input Validation - Zod schema validation on frontend
  • MongoDB Injection Prevention - Mongoose sanitization

🎨 Design System

The frontend uses a custom Neobrutalism design system with:

  • Bold borders and shadows
  • Vibrant color palette
  • Rounded corners (1.25rem)
  • Custom shadow effects
  • Accessible color contrast
  • Responsive design

Color Palette

nb-bg: #F2F7F9        // Background
nb-ink: #0F172A       // Text/Borders
nb-accent: #A78BFA    // Primary accent (Purple)
nb-accent-2: #34D399  // Secondary accent (Green)
nb-warn: #FBBF24      // Warning (Yellow)
nb-error: #F43F5E     // Error (Red)
nb-ok: #22C55E        // Success (Green)
nb-card: #FFFFFF      // Card background

πŸ› Troubleshooting

MongoDB Connection Error

# Ensure MongoDB is running
mongod

# Or check if MongoDB service is active
sudo systemctl status mongod

Port Already in Use

# Backend: Change PORT in backend/.env
PORT=3001

# Frontend: Vite will auto-select next available port
# Or specify in package.json: "dev": "vite --port 5174"

CORS Errors

Verify FRONTEND_URL in backend/.env matches your frontend URL:

FRONTEND_URL=http://localhost:5173

AI Features Not Working

Ensure you have a valid Google Gemini API key:

GEMINI_API_KEY=your-actual-api-key

Get your API key from: https://makersuite.google.com/app/apikey

File Upload Issues

Check upload directory permissions:

cd backend
mkdir -p uploads
chmod 755 uploads

πŸ“¦ Deployment

Backend Deployment

  1. Set NODE_ENV=production in environment
  2. Use a process manager like PM2
  3. Configure MongoDB Atlas for cloud database
  4. Set up AWS S3 for file storage
  5. Use environment variables for all secrets

Frontend Deployment

  1. Build the production bundle:
npm run build
  1. Deploy the dist folder to:

    • Vercel
    • Netlify
    • AWS S3 + CloudFront
    • Any static hosting service
  2. Update VITE_API_URL to production backend URL

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License. See the LICENSE file for details.

πŸ‘₯ Authors

16010123036 - Amandeep Singh

16010123037 - Ambuj Rai

16010123035 - Alapan Barman

πŸ™ Acknowledgments

  • Google Gemini AI for chatbot capabilities
  • MongoDB for database solutions
  • React and Vite teams for excellent developer experience
  • Tailwind CSS for styling framework

Status: βœ… Production Ready - All features implemented and tested

Version: 1.0.0

For questions or support, please open an issue on GitHub.

About

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages