Coder Social home page Coder Social logo

medibook-api's Introduction

medibook-api

Backend API for the Medi-Book health appointment platform

This app uses a Rails back-end as an API to send doctor details and appointment data to the frontend for scheduling appointments

Table of Contents

Link to Kanban

Link to REACT FRONTEND

REACT FRONTEND

Built With

  • Ruby
  • Ruby on Rails
  • PostgreSQL
  • Heroku
  • Rspec
  • Rswag

Getting Started

To get a local copy up and running follow these simple example steps. In your terminal, navigate to your current directory and run this code

git clone https://github.com/medi-book/medibook-api

Then run:

cd medibook-api

Open in your preferred text editor. Run code . to open VScode.

Setup

This guide assumes you have already installed the necessary dependencies to use a postgreSQL database and Ruby on Rails.

  • Add all ruby gems to your Gemfile (bundle install)
  • Create a .env file in the root of your project and add the following lines: PASSWORD_DB = your_password
  • Run rails db:create db:migrate db:seed to create the database and run migrations.

Usage

  • Run rails s to start the server.
  • To create a new user, send a POST request to http://localhost:3000/signup with the following body:
{
  "user": {
    "username": "John Doe",
    "password": "password",
    "password_confirmation": "password"
  }
}
  • To create an admin user use the rails console and run:
User.create(username: "admin", password: "password", password_confirmation: "password", role: "admin")
  • To login, send a POST request to http://localhost:3000/authenticate with the following body:
{
  "user": {
    "username": "John Doe",
    "password": "password"
  }
}

Response: The token would be used in the Authorization header for all subsequent requests.

{
  "username": "John Doe",
  "token" : "token",
  "role": "regular"
}
  • To create a new appointment, send a POST request to http://localhost:3000/appointments with the following body:
{
  "appointment": {
    "doctor_id": 1,
    "date": "2023-01-01 00:00:00",
    "duration": 5,
  }
}

headers:

{
  "Authorization": "token"
}

Response:

{
  "message": "appointment added", 
  "status": "created",
}
  • To get all appointments, send a GET request to http://localhost:3000/appointments with the following headers:
{
  "Authorization": "token"
}

Response:

{
  [
    {
      "id": 1,
      "name": "John Doe",
      "total": "000",
      "duration": 5,
      "date": "2023-01-01 00:00:00",
    },
    {
      "id": 2,
      "name": "John Doe",
      "total": "000",
      "duration": 5,
      "date": "2023-01-01 00:00:00",
    }
  ]
}
  • To cancel an appointment, send a DELETE request to http://localhost:3000/appointments/1 with the following headers:
{
  "Authorization": "token"
}

Response:

{
  "message": "appointment deleted",
  "status": "ok"
}
  • To get all doctors, send a GET request to http://localhost:3000/doctors with the following headers:
{
  "Authorization": "token"
}

Response:

{
  [
    {
      "id": 1,
      "name": "John Doe",
      "specialization": "specialty",
      "hourly_rate": "$$",
      "picture": "image.png",
      "created_at": "created_at",
      "updated_at": "updated_at"
    },
    {
      "id": 2,
      "name": "John Doe",
      "specialization": "specialty",
      "hourly_rate": "$$",
      "picture": "image.png",
      "created_at": "created_at",
      "updated_at": "updated_at"
    }
  ]
}

Testing

Run Test for models and api requests:

Run migrations for test database: rails db:migrate RAILS_ENV=test

rspec spec/models rspec spec/requests

Link to documentation

docs link

Authors

๐Ÿ‘ค Sodiq Aderibigbe

๐Ÿ‘ค Anicet Murhula

๐Ÿ‘ค Ifza Rasool

๐Ÿ‘ค Oybek Kayumov

๐Ÿ‘ค Saningo Lekalantula

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a โญ๏ธ if you like this project!

๐Ÿ“ License

This project is MIT licensed.

medibook-api's People

Contributors

deyemiobaa avatar oybekkayumov avatar sainingo avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.