-
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
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.
For a complete list of dependencies, refer to the package.json
file.