Skip to content

KiranKishore05/Health-Plus-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Health Plus - Healthcare Appointment System πŸ₯

A comprehensive healthcare appointment booking system built with React frontend and Node.js/Express backend with MongoDB database.

πŸš€ Project Overview

Health Plus is a modern web application that allows patients to:

  • πŸ” Browse healthcare services and doctors
  • πŸ“… Book appointments online (voice/video consultations)
  • πŸ’¬ Live Chat Bot with intelligent AI responses
  • πŸ“§ Receive automated email confirmations
  • πŸ‘€ User authentication (Login/Signup)
  • πŸ”” Admin notifications for new appointments
  • πŸ“± Fully responsive mobile-friendly design

οΏ½ Table of Contents

οΏ½πŸ› οΈ Technologies Used

Frontend

  • React.js - UI framework
  • React Router - Navigation
  • React Toastify - Notifications
  • CSS3 - Styling
  • Font Awesome - Icons

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • MongoDB - Database
  • Mongoose - ODM for MongoDB
  • Nodemailer - Email service
  • JWT - Authentication tokens
  • bcryptjs - Password hashing

πŸ“‹ Prerequisites

Before running this project, ensure you have:

  • Node.js (v14 or higher)
  • npm (Node Package Manager)
  • MongoDB (local installation or MongoDB Atlas account)
  • Gmail account (for email notifications)

πŸ“‚ Project Structure

Health-Plus-main/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── chat.js            # Live chat API routes
β”‚   β”œβ”€β”€ server.js              # Main backend server
β”‚   β”œβ”€β”€ authMiddleware.js      # JWT authentication middleware
β”‚   β”œβ”€β”€ emailService.js        # Email sending service
β”‚   β”œβ”€β”€ .env                   # Environment variables (not in git)
β”‚   β”œβ”€β”€ .env.example           # Example environment file
β”‚   └── package.json           # Backend dependencies
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Components/        # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ AppointmentForm.js
β”‚   β”‚   β”‚   β”œβ”€β”€ LiveChat.js    # Live chat component
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Signup.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.js
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ Styles/            # CSS files
β”‚   β”‚   β”‚   β”œβ”€β”€ LiveChat.css   # Chat component styles
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ Pages/             # Page components
β”‚   β”‚   └── Assets/            # Images and media
β”‚   β”œβ”€β”€ public/                # Static files
β”‚   └── package.json           # Frontend dependencies
β”œβ”€β”€ .gitignore                 # Git ignore rules
└── README.md                  # This file

⚑ Quick Start Guide

For experienced developers who want to get started immediately:

# 1. Clone repository
git clone https://github.com/kishore0000123/Health-Plus-main.git
cd Health-Plus-main

# 2. Install backend dependencies
cd backend
npm install

# 3. Create .env file (copy from .env.example)
copy .env.example .env  # Windows
# cp .env.example .env  # Mac/Linux

# 4. Edit .env with your Gmail credentials and MongoDB URI

# 5. Start backend (in backend directory)
npm start

# 6. Open new terminal - Install frontend dependencies
cd ../frontend
npm install

# 7. Start frontend
npm start

# βœ… App opens at http://localhost:3000
# βœ… Backend runs at http://localhost:5001

βš™οΈ Installation & Setup

1. Clone the Repository

git clone https://github.com/kishore0000123/Health-Plus-main.git
cd Health-Plus-main

2. Install Dependencies

Frontend:

cd frontend
npm install

Backend:

cd backend
npm install

3. MongoDB Setup

Option A: Local MongoDB

  1. Download and install MongoDB from: https://www.mongodb.com/try/download/community
  2. Start MongoDB service
  3. Database will be created automatically at: mongodb://localhost:27017/healthplus

Option B: MongoDB Atlas (Cloud - Recommended)

  1. Create free account at: https://www.mongodb.com/cloud/atlas
  2. Create a cluster
  3. Get connection string
  4. Update in .env file

4. Configure Environment Variables

Create a .env file in the backend folder:

cd backend
copy .env.example .env    # On Windows
# or
cp .env.example .env      # On Mac/Linux

Edit backend/.env with your credentials:

PORT=5001
MONGODB_URI=mongodb://localhost:27017/healthplus
EMAIL_SERVICE=gmail
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-16-char-app-password
ADMIN_EMAIL=your-admin-email@gmail.com
JWT_SECRET=your-secret-key-here

⚠️ Important: Never commit the .env file to GitHub. It's already in .gitignore.

5. Gmail App Password Setup

For email notifications to work:

  1. Enable 2-Factor Authentication on your Gmail account
  2. Go to: https://myaccount.google.com/apppasswords
  3. Generate App Password for "Health Plus"
  4. Copy the 16-character password
  5. Paste it in EMAIL_PASSWORD in .env file

πŸš€ Running the Project

Start Backend Server

cd backend
node server.js

Backend will run on: http://localhost:5001

You should see:

πŸš€ Server running on port 5001
βœ… MongoDB Connected Successfully
βœ… Email server is ready to send messages

Start Frontend Application

Open a new terminal and run:

cd frontend
npm start

Frontend will run on: http://localhost:3000

The browser will automatically open the application.

πŸ—„οΈ Data Storage

Database: MongoDB

Database Name: healthplus

Collections:

1. Appointments Collection

Stores all patient appointment data:

{
  _id: ObjectId,                    // Auto-generated unique ID
  patientName: String,              // Min 8 characters
  patientNumber: String,            // 10 digits
  patientEmail: String,             // Optional, for confirmations
  patientGender: String,            // 'male', 'female', or 'private'
  appointmentTime: Date,            // Future date/time
  preferredMode: String,            // 'voice' or 'video'
  status: String,                   // 'pending', 'confirmed', 'cancelled', 'completed'
  createdAt: Date                   // Auto-generated timestamp
}

2. Users Collection

Stores registered user accounts:

{
  _id: ObjectId,
  name: String,                     // User full name
  email: String,                    // Unique email address
  password: String,                 // Hashed with bcrypt
  phone: String,                    // Optional phone number
  role: String,                     // 'patient', 'doctor', 'admin'
  createdAt: Date
}

Data Location:

  • Local MongoDB: C:\Program Files\MongoDB\Server\{version}\data\ (Windows)
  • MongoDB Atlas: Cloud storage (accessible from anywhere)

πŸ”„ How It Works

Complete Workflow

1. User Registration/Login

User visits site β†’ Clicks "Sign up" β†’ Fills registration form β†’ 
Backend validates data β†’ Password hashed β†’ User saved to MongoDB β†’ 
JWT token generated β†’ User logged in

2. Appointment Booking Process

User clicks "Book Appointment" β†’
Fills appointment form (name, phone, email, gender, date/time, mode) β†’
Frontend validates inputs β†’
Sends POST request to backend API β†’
Backend validates data β†’
Appointment saved to MongoDB (status: 'confirmed') β†’
Email sent to patient (if email provided) β†’
Email notification sent to admin β†’
Success response to frontend β†’
Toast notification shown β†’
Form reset

3. Email Notification Flow

Appointment created β†’
emailService.js triggered β†’
Connects to Gmail via SMTP β†’
Generates HTML email with appointment details β†’
Sends confirmation email to patient (if email provided) β†’
Sends notification email to admin/doctor β†’
Emails include: patient name, date/time, mode, contact info β†’
Confirmations logged in backend

4. Live Chat Bot Interaction

User clicks "Live Chat" button β†’
Chat window opens (bottom-right corner) β†’
User types message β†’
Frontend sends POST to /api/chat β†’
Backend processes message with AI logic β†’
Smart response generated based on keywords β†’
Response sent back to frontend β†’
Chat displays bot reply with animation

5. Data Retrieval

Admin/Doctor requests appointments β†’
GET /api/appointments called β†’
Backend queries MongoDB β†’
Returns sorted appointments (newest first) β†’
Frontend displays in dashboard

πŸ”Œ API Endpoints

Health Check

GET http://localhost:5001/api/health
Response: { success: true, message: "Server is running" }

Authentication

Register User

POST /api/auth/register
Body: { name, email, password, phone }
Response: { success, token, user }

Login User

POST /api/auth/login
Body: { email, password }
Response: { success, token, user }

Get Current User (Protected)

GET /api/auth/me
Headers: { Authorization: Bearer <token> }
Response: { success, user }

Live Chat Bot

Send Chat Message

POST /api/chat
Body: { message: "your message here" }
Response: { 
  success: true, 
  reply: "bot response",
  timestamp: "2026-02-21T10:30:00Z"
}

Supported Queries:

  • Appointment booking
  • Doctor information
  • Services offered
  • Contact details
  • Operating hours
  • Emergencies
  • Pricing information

Appointments

Get All Appointments

GET /api/appointments
Response: { success, data: [...appointments] }

Get Single Appointment

GET /api/appointments/:id
Response: { success, data: {...appointment} }

Create Appointment

POST /api/appointments
Body: {
  patientName,
  patientNumber,
  patientEmail (optional),
  patientGender,
  appointmentTime,
  preferredMode
}
Response: { 
  success, 
  data, 
  emailSent: boolean,
  adminNotified: boolean 
}

Update Appointment Status

PATCH /api/appointments/:id
Body: { status: "confirmed" | "cancelled" | "completed" }
Response: { success, data }

Delete Appointment

DELETE /api/appointments/:id
Response: { success, message }

πŸ“§ Email Features

Patient Confirmation Emails

When a patient provides an email during appointment booking:

βœ… Automatic confirmation email sent βœ… Professional HTML template βœ… Includes:

  • Patient name
  • Appointment date & time (formatted)
  • Preferred consultation mode (Voice/Video)
  • Contact information
  • Status confirmation

Admin Notification Emails

For every new appointment created:

βœ… Instant notification to admin βœ… Detailed patient information βœ… Includes:

  • Full patient details (name, email, phone, gender)
  • Appointment date & time
  • Preferred consultation mode
  • Action required alert
  • Timestamp of registration

Email sent via:

  • Gmail SMTP server
  • Nodemailer library
  • Secure app password authentication

πŸ”’ Security Features

  • Password Hashing: bcryptjs (10 salt rounds)
  • JWT Tokens: 7-day expiration
  • Environment Variables: Sensitive data not in code
  • Input Validation: Both frontend and backend
  • CORS Enabled: Controlled cross-origin requests
  • .gitignore: Prevents .env from being pushed to GitHub

πŸ› Troubleshooting

Backend won't start

# Check if port 5001 is already in use
netstat -ano | findstr :5001

# Kill the process (Windows)
taskkill /PID <process_id> /F

# Or change port in backend/.env
PORT=5002

# Restart backend
cd backend
node server.js

MongoDB connection error

  • Ensure MongoDB service is running
  • Check MONGODB_URI in .env file
  • Verify MongoDB is installed correctly
  • For Atlas: Check IP whitelist and credentials

Email not sending

  • Verify Gmail app password (16 characters, no spaces)
  • Check 2FA is enabled on Gmail account
  • Ensure EMAIL_USER and EMAIL_PASSWORD are correct in .env
  • Ensure ADMIN_EMAIL is set in .env
  • Check Gmail security settings

Frontend can't connect to backend

  • Ensure backend is running on port 5001
  • Check browser console (F12) for CORS errors
  • Verify API URLs use correct port (5001) in React components
  • Clear browser cache and restart

Live Chat not working

  • Verify backend is running
  • Check /api/chat endpoint is accessible
  • Open browser console for error messages
  • Ensure port 5001 is used in LiveChat.js
  • Try refreshing the page

πŸ§ͺ Testing the Application

Test Appointment Booking

  1. Start both backend and frontend servers
  2. Navigate to homepage
  3. Click "Book Appointment" button
  4. Fill in the form:
    • Patient Name (min 8 characters)
    • Phone Number (10 digits)
    • Email (optional, for confirmations)
    • Select gender
    • Choose date/time (future date)
    • Select voice or video mode
  5. Submit and check:
    • Success toast notification appears
    • Email received (if email provided)
    • Admin receives notification email
    • Check MongoDB for saved appointment

Test Live Chat

  1. Click "Live Chat" button in navbar
  2. Chat window opens bottom-right
  3. Try these test messages:
    • "How do I book an appointment?"
    • "What doctors are available?"
    • "Contact information"
    • "What are your services?"
  4. Verify bot responds instantly
  5. Check browser console for any errors

Test Authentication

  1. Click "Login" or "Signup"
  2. Register new account:
    • Provide name, email, password, phone
    • Verify success message
    • Check you're redirected and logged in
  3. Logout and login again
  4. Verify JWT token in localStorage

API Testing with Postman/curl

# Test Health Check
curl http://localhost:5001/api/health

# Test Chat Endpoint
curl -X POST http://localhost:5001/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"doctor"}'

# Test Appointments
curl http://localhost:5001/api/appointments

οΏ½ Live Chat Bot Features

Intelligent Responses

The live chat bot provides smart, context-aware responses for common queries:

  • Appointments: "How do I book an appointment?"
  • Doctors: "What specialists are available?"
  • Services: "What services do you offer?"
  • Contact: "How can I reach you?"
  • Emergencies: "I have a medical emergency"
  • Hours: "When are you available?"
  • Pricing: "How much does a consultation cost?"

Chat UI Features

  • 🎨 Beautiful animated interface
  • πŸ“± Fully responsive on mobile devices
  • ⚑ Real-time message delivery
  • πŸ€– Typing indicators
  • ⏱️ Message timestamps
  • πŸ”˜ Quick question buttons
  • 🎯 Auto-scroll to latest message
  • ❌ Easy close/open functionality

User Experience

  • Click "Live Chat" button in navigation bar
  • Chat window appears in bottom-right corner
  • Type message or click quick questions
  • Instant AI-powered responses
  • Helpful guidance for all queries

πŸ“ Development Notes

  • Backend automatically creates database and collections
  • First appointment booking creates the appointments collection
  • First user registration creates the users collection
  • All timestamps are stored in UTC
  • Passwords are never stored in plain text
  • Live chat responses are processed server-side
  • Email templates use HTML for professional formatting

πŸ‘₯ Contributors

  • Kishore Kiran - Full Stack Developer

πŸ“± Contact & Social Links

πŸ“„ License

Β© 2026 Health+. All rights reserved.

πŸ™ Acknowledgments

  • React community for excellent documentation and support
  • MongoDB for robust database solutions
  • Nodemailer for reliable email service integration
  • Font Awesome for beautiful icons
  • Express.js for powerful backend framework

🌟 Key Features Summary

βœ… User Authentication (JWT-based)
βœ… Appointment Booking System
βœ… Live Chat Bot with AI responses
βœ… Email Notifications (Patient + Admin)
βœ… Responsive Mobile Design
βœ… Real-time Data Management
βœ… Secure Password Hashing
βœ… MongoDB Database Integration
βœ… Professional UI/UX Design
βœ… CORS-enabled API

Built with ❀️ by Kishore Kiran

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors