📢 Important Note: Video Call Functionality Limitations in Deployed Environment
🚀 Why is it not working on the deployed version? To establish a seamless peer-to-peer connection for video calling, the Node.js server and the Peer server need to run on different ports. However, hosting service providers like Render and Railway typically allow running only a single server or process on a specific port. As a result, when the application is deployed, only one person's video will be rendered during the video call.
💡 How to make it work perfectly? To fully experience the video call functionality and enable proper communication between the doctor and patient, I encourage you to follow these steps:
- Clone the repository:
https://github.com/Jishnuraj2001/doctor_patient_appointment_booking_system_pococare.git
- Install dependencies:
cd backend && npm install
- Start the Node.js server:
npm run server
- Start the Peer server on a separate port:
peerjs --port 3001
- Access the application locally: Open your browser and visit
http://localhost:<your-port>
By running the application locally, you can ensure that the Node.js server and the Peer server operate on different ports, enabling successful peer-to-peer communication during video calls.
🔍 Need assistance or have questions? If you encounter any issues or have questions regarding the video call functionality, please don't hesitate to reach out.
-
Patient Login
- Email: jishnurajkarockal@gmail.com
- Password: 123
-
Doctor Login
- Email: kuttu@gmail.com
- Password: 123
The system has been deployed with the following configurations:
-
Frontend
-
Backend
This documentation provides an overview of the MediConnect API, including its endpoints, request/response formats, authentication, and authorization requirements.
- Introduction
- Getting Started
- API Endpoints
- Middleware Functions
- Installation
- Environment Variables
- Dependencies
- Video Calling API Documentation
The MediConnect API is a backend service for managing appointments between doctors and patients. It provides functionalities for user registration, login, appointment creation, appointment retrieval, and appointment cancellation.
To get started with the MediConnect API, follow the installation instructions provided in the Installation section. Make sure to set up the required environment variables as mentioned in the Environment Variables section.
Register a new user with the specified information.
-
Request body:
name
: Name of the user (string, required).email
: Email address of the user (string, required).password
: Password for the user (string, required).role
: Role of the user (string, required). Possible values: "patient", "doctor", "admin".specialization
: Specialization of the user (string, required for doctors).gender
: Gender of the user.
-
Authentication: Not required.
-
Authorization: Not required.
-
Response:
- Status: 201
- Body: None
Authenticate user credentials and generate a JSON Web Token (JWT) for authorization.
-
Request body:
email
: Email address of the user (string, required).password
: Password for the user (string, required).
-
Authentication: Not required.
-
Authorization: Not required.
-
Response:
- Status: 201
- Body:
token
: JWT token for authorization (string).
Fetch all users from the database.
-
Request body: None
-
Authentication: Required (JWT token).
-
Authorization: Required (role: admin).
-
Response:
- Status: 200
- Body:
- Array of user objects:
name
: Name of the user (string).email
: Email address of the user (string).role
: Role of the user (string).specialization
: Specialization of the user (string, only for doctors).gender
: Gender of user.
- Array of user objects:
Fetch all doctors from the database.
-
Request body: None
-
Authentication: Required (JWT token).
-
Authorization: Not required.
-
Response:
- Status: 200
- Body:
- Array of doctor objects:
name
: Name of the doctor (string).email
: Email address of the doctor (string).specialization
: Specialization of the doctor (string).role
: Role of the user (string).specialization
: Specialization of the user (string, only for doctors).gender
: Gender of doctor.
- Array of doctor objects:
Create a new appointment with the specified details.
-
Request body:
patientId
: ID of the patient (string, required).doctorId
: ID of the doctor (string, required).date
: Date of the appointment (string, required). Format: "YYYY-MM-DD".time
: Time of the appointment (string, required). Format: "HH:MM AM/PM".
-
Authentication: Required (JWT token).
-
Authorization: Required (role: patient).
-
Response:
- Status: 201
- Body: None
Fetch appointments based on the user role (patient or doctor).
-
Request body: None
-
Authentication: Required (JWT token).
-
Authorization: Required (role: patient or doctor).
-
Response:
- Status: 200
- Body:
- Array of appointment objects:
patientId
: ID of the patient (string).doctorId
: ID of the doctor (string).date
: Date of the appointment (string).time
: Time of the appointment (string).
- Array of appointment objects:
Cancel an appointment with the specified ID.
-
Request parameters:
id
: ID of the appointment (string, required).
-
Authentication: Required (JWT token).
-
Authorization: Required (role: patient).
-
Response:
- Status: 200
- Body: None
The authenticator
middleware function is used to authenticate requests using JWT. It verifies the presence and validity of the JWT token in the request headers.
The authorizer
middleware function is used to authorize requests based on user roles. It checks if the user's role is included in the specified role array.
To install and run the MediConnect API locally, follow these steps:
-
Clone the repository:
git clone https://github.com/Jishnuraj2001/doctor_patient_appointment_booking_system_pococare.git
-
Navigate to the project directory:
cd backend
-
Install the dependencies:
npm install
-
Set up the required environment variables as mentioned in the Environment Variables section.
-
Start the server:
npm run server
-
The server will start running at
http://localhost:<port>
, where<port>
is the value of theprocess.env.port
environment variable.
The MediConnect API requires the following environment variables to be set:
port
: The port number on which the server should run.key
: Secret key used for JWT signing.email_password
: The Secret key used to send mail to the user when an appointment is booked or cancelled.db_url
: MongoDB Atlas cluster URL where you are storing the data.
You can set these variables in a .env
file in the root directory of the project.
Example .env
file:
port=3000
key=your-secret-key
email_password=your-email-password
db_url=your-mongodb-url
The MediConnect API relies on the following dependencies:
- express: Fast, unopinionated, minimalist
web framework for Node.js.
- dotenv: Loads environment variables from a
.env
file intoprocess.env
. - cors: Middleware for enabling Cross-Origin Resource Sharing (CORS) in Express.
- bcrypt: Library for hashing passwords.
- jsonwebtoken: Library for generating and verifying JSON Web Tokens (JWT).
- mongoose: MongoDB object modeling tool.
- nodemailer: Library for sending emails.
- nodemon: For running the server.
- socket.io: for real-time communication and event handling.
- peerjs: for establishing peer-to-peer connections between the doctor and patient.
- ejs: A simple and flexible templating engine that enables generating HTML markup with embedded JavaScript code.
For a complete list of dependencies, refer to the package.json
file.
This documentation provides information about the video calling functionality in the MediConnect appointment booking system. The video calling feature allows doctors and patients to join a video call when they have the same appointment ID.
To start a video call, follow the steps below:
-
The doctor/patient can initiates the video call by clicking on the "Video Consultation" button for a specific appointment.
This endpoint redirects the doctor to a new URL with the appointment ID as the endpoint.
:appointmentId
- Replace with the actual appointment ID.
Example:
http://localhost:<port>/<specific appointmentId>
-
The doctor/patient will be redirected to a video consultation page where they can interact with the other person.
To join a video call as a patient/doctor, follow the steps below:
-
By clicking the above same btn the doctor/patient can join the video call.
Example URL:
http://localhost:<port>/<specific appointmentId>
-
The patient/doctor will be redirected to the video consultation page where they can interact with the doctor.
This endpoint renders an EJS template for the video consultation page.
:appointmentId
- Replace with the actual appointment ID.
The video consultation page allows doctors and patients to interact during the video call. It includes the following features:
- Video Grid: Displays the video streams of both the doctor and the patient.
- Toggle Audio: Button to mute/unmute the audio during the video call.
- Toggle Camera: Button to turn on/off the camera during the video call.
Note: The video consultation page uses the following JavaScript libraries:
socket.io
for real-time communication and event handling.peerjs
for establishing peer-to-peer connections between the doctor and patient.ejs
A simple and flexible templating engine that enables generating HTML markup with embedded JavaScript code.script.js
contains the JavaScript code for handling audio and video toggles, connecting to the video call, and managing user streams.
To disconnect from a video call, simply close the video consultation page or navigate away from the page. The connection will be automatically terminated, and the doctor and patient will be disconnected.