Skip to content

Backend REST API for booking appointments with doctors. Built with JavaScript, Node.js, MongoDB, and Docker

Notifications You must be signed in to change notification settings

swhasans/appointment-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Appointment - API

Table of Contents

  1. Introduction
  2. Technologies Used
  3. Authentication & Authorization
  4. API Overview
  5. Endpoints & Routes
  6. JSON Structure
  7. Installation
  8. Usage
  9. Error Handling
  10. Pending Tasks
  11. License
  12. Acknowledgements

Introduction

Appointment - API is a backend REST API that enables users to book, update, retrieve, and delete appointments with doctors. Users need to be authenticated to access these features, ensuring that all appointment routes are secure.

Technologies Used

- JavaScript
- Node.js (Runtime Environment)
- Express (Node.js web application framework)
- MongoDB (Database)
- Mongoose (MongoDB Object Data Modeling library)
- Docker*
- Postman (API Platform for designing, building, testing, and iterating APIs)
- JSON Web Token (authentication)
- bcrypt (password hashing)
- validator (email validation)

Authentication & Authorization

Appointment - API uses JWT (JSON Web Tokens) for user authentication. Users need to be logged in to get a JWT token, which then allows them to access the appointment routes. If not logged in, users will need to sign up, after which a JWT token will be assigned to them.

Passwords stored in MongoDB are encrypted using the bcrypt library.A salt is generated and then passed, along with the original password, to produce a hashed version, ensuring the safety of user passwords.

Emails are validated during sign - up using the validator library, ensuring that users provide valid email addresses.

API Overview

This API follows a RESTful approach, providing endpoints for the standard CRUD operations: create, read, update, and delete.The API is versioned with "/api/v1" as the prefix, and the resource being accessed is "appointments". By adhering to a well - defined URL structure, developers can easily interact with the API and build applications that consume it.

Endpoints & Routes

Appointment Endpoints

The following URL endpoints are available for the Appointment-API:

User Authentication Routes

The AuthRoutes provide the following functionalities:

JSON Structure

Each appointment record in the API follows the structure defined by the Mongoose schema:

{
    appointment_sl_id: Number,
    doctor_id: Number,
    patient_id: Number,
    duration: Number,
    reason: String,
    status: String,
    createdAt: Date,
    updatedAt: Date
}

Each user record in the API follows the structure defined by the Mongoose schema:

{
    email: String,
    password: String
}

Installation

To use this project, follow these steps:

  1. Clone the repository: git clone https://github.com/your-username/appointment-api.git
  2. Install the dependencies: npm install
  3. Set up the MongoDB database and configure the connection in the code.
  4. Run the server: npm start

Usage

Once the server is running, you can make HTTP requests to the defined endpoints using tools like Postman. The API allows you to manage appointments with doctors, including creating new appointments, updating existing ones, retrieving appointment details, and deleting appointments.

Error Handling

The API is equipped with a handleErrors function that provides detailed error messages for specific error types, aiding in a smoother developer experience and efficient debugging.

Pending Tasks

As the application continues to evolve, there are several tasks that are currently pending completion:

Docker Integration

  • Dockerfile Creation: Develop a Dockerfile to containerize the application.
  • Docker Image Building: Build the Docker image from the created Dockerfile.
  • Local Docker Image Testing: Ensure the Docker image runs correctly when executed locally.
  • Pushing Docker Image: Push the built Docker image to a container registry (e.g., Docker Hub).
  • Docker Compose Integration: Develop a docker-compose.yml file to orchestrate the application along with its dependencies, such as MongoDB.
  • Docker Compose Testing: Validate the application's functionality using the docker-compose setup.
  • README.md Update: Augment this README.md with instructions detailing how users can run the application using Docker and docker-compose.

License

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

Acknowledgements

Note : The features or components marked with an asterisk (*) are currently in development and will be available in future iterations of the API.

About

Backend REST API for booking appointments with doctors. Built with JavaScript, Node.js, MongoDB, and Docker

Topics

Resources

Stars

Watchers

Forks