Skip to content

Drihmia/DoctorFlow

Repository files navigation

DoctorFlow API

DoctorFlow is an API designed to streamline the patient management process. It digitizes patient records and enhances communication between doctors and patients.

Table of Contents

Introduction

DoctorFlow is a clinic management system API built with Express.js and Node.js. It uses MongoDB for data storage and Redis for managing authentication tokens. The API provides a comprehensive solution for managing doctor and patient data, handling appointments, and improving clinic operations.

Features

For Doctors

  • Profile Management: Create and manage personal profiles.
  • Patient Management: Create and manage patient profiles, including general information and medical data.
  • Session Logging: Log patient sessions with detailed information such as session date, diagnosis, prescriptions.

For Patients

  • Profile Viewing: View their personal profiles.
  • Session History: Access their session history.
  • Doctor Information: View basic information about their doctor.

Special User: Dev

  • The "Dev" user cannot be created via the API. A special script createDev.js is used to create this user locally. This script requires two environment variables: EMAIL and PASSWORD.

Target Audience

The API is intended for other developers who want to integrate DoctorFlow into their websites or applications.

Tech Stack Used

  • Backend Framework: Express.js and Node.js for server-side logic and routing.
  • Database: MongoDB with Mongoose for data management and schema modeling.
  • Authentication: UUID4 tokens for user authentication, managed with Redis for efficient session handling.
  • Documentation: JSDoc and Swagger for generating and interacting with API documentation.
  • Testing: Postman for API testing and validation.
  • Redis: Used for managing authentication tokens and improving session management.

Installation, Setup, and Usage

Prerequisites

Before you begin, ensure you have the following installed on your machine:

Cloning the Repository

To get started with DoctorFlow, first clone the repository to your local machine:

git clone https://github.com/Drihmia/DoctorFlow.git

System Setup

  1. Update System and Install Dependencies:
    sudo apt update
    sudo apt install redis-server redis-tools
    sudo apt install mongodb
  1. Start Necessary Services:
    • Start Redis Server:
    sudo service redis-server start
  • Start MongoDB (if you are working on a local machine):
    sudo service mongod start

Installation

Once you have cloned the repository, navigate to the project directory and install the required dependencies:

cd DoctorFlow
npm install

Configuration

Create a .env file in the root directory of the project and include the following environment variables:

MONGO_URI=your-mongodb-uri
EMAIL=[email protected]
PASSWORD=your-dev-password

Note: You can use .env file to store environment variables or you can set them directly in the terminal using export command.

export MONGO_URI=your-mongodb-uri
export EMAIL=your-dev-email
export PASSWORD=your-dev-password
  • MONGO_URL: Replace your-mongodb-uri with the URI of your MongoDB instance. If you're using MongoDB Atlas, ensure your IP address is added to the database's access white list. Refer to Atlas documentation for more details.
  • EMAIL and PASSWORD: Use these for creating a dev account to access dev endpoints.

Usage

  1. Start Redis Server:

    • Ensure Redis is installed and running.
    • Start the Redis server with:
      redis-server
  2. Start the Express Application:

    • Start the Node.js application:
      npm start
  3. Create a Dev Account:

    • Run the script to create a dev account, which will allow access to the dev endpoints:
      npm run dev createDev.js
    • This script uses the EMAIL and PASSWORD you set in your .env file to create the dev account..

Note: Dev account can only access 3 endpoints: /doctors, /patients, and /sessions.

  1. Access the API Documentation:
    • Deployed Documentation: Visit the deployed API documentation at /api-docs.
    • Local Documentation: Access the Swagger UI locally at /api-docs to explore and interact with the API endpoints.

Automating the Installation

We’ve provided an automation script to simplify the installation process. This script handles the majority of the setup steps automatically.

If something doesn’t work during the installation, the script will display messages in different colors to help you troubleshoot and resolve any issues manually.

To run the script, execute the following command:

bash automate_setup_process.bash

Testing

Note: We wanted to make sure our project is well-structured and runs smoothly, so we adopted a Test-Driven Development (TDD) approach. By writing tests first, we set ourselves up to improve the code confidently. As the project grew, our tests grew with it, helping us refine both the code and the tests, making sure everything works together seamlessly.

The API can be tested using Postman. The collection and environment files are available in the postman directory. Click the button below to run the collection in Postman:

Run In Postman

Note: Basic environment variables are set in the Postman collection. Update the environment variables with your own values if necessary.

Environment Variables

  • BaseUrlDF: The base URL of the DoctorFlow API, e.g., https://drihmia.tech
  • DevEmail: The email address you've chosen to create the dev account using the script.
  • DevPassword: The password you've chosen to create the dev account using the script.

Contributors

License

This project is licensed under the Apache License - see the LICENSE file for details.

About

ALX's specialization portfolio Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published