Skip to content

This is an API created for an Appointments website. You can book an appointment with a teacher to learn a course or topic.

License

Notifications You must be signed in to change notification settings

sergiomauz/RoR-Personal-Teaching

Repository files navigation

PERSONAL TEACHING - ROR BACKEND

This project implements a simple API for an Appointments Book System using Ruby on Rails, as part of my final project at Microverse.

Data Model

screenshot-data-model

Built With

  • Ruby on Rails
  • PostgreSQL as database
  • Doorkeeper for Sign In tokens
  • Rubocop as linter
  • Rspec for testing
  • Apipie for API documentation
  • Cloudinary for image storage

Features

  • Sign In with tokens managed by Doorkeeper.
  • Model and controller for Users.
  • Model and controller for Teachers.
  • Model and controller for Appointments.
  • Documentation using Apipie for Rails.

Live Demo

How to Install

  • Install Ruby in your system. To install Ruby, you can read the Documentation.
  • Install Rails. You can read this page.
  • Clone it using git clone command.
  • Run in your terminal bundle install.
  • Run in your terminal rails db:create.
  • Run in your terminal rails db:migrate.
  • Run in your terminal rails db:seed.
  • Create an account (it is for free) in Cloudinary, confirm your e-mail and sign in.
  • Go to Cloudinary Account Settings and change the default name of your cloud (try to use a very long random string, more than 30 characters).
  • Copy your cloud_name in config/application.rb (replace the value in config.x.cloudinary.cloud_name)
  • Go to your Cloudinary Upload Settings.
  • Move to Upload presets and create new strong Unsigned preset. Try to use a long string (more than 60 characters).
  • Copy your upload_preset in config/application.rb (replace the value in config.x.cloudinary.upload_preset)
  • Run in your terminal rails s.

Automated Test

  • This project uses RSpec for unit and integration testing.
  • All files are in spec directory.
  • In order to run the tests, in terminal, type: rspec, it should return 71 examples and 0 failures.

API Documentation

  • This project uses Apipie Gem for API documentation.
  • After run rails s, go to http://localhost:3000/apipiedoc in your favorite browser to see the API documentation.
  • Also, you can go to https://ror-personal-teaching-backend.herokuapp.com/apipiedoc for online documentation, but you will need to sign in as an admin user (see the db/seeds.rb file to know the admin user example).
  • This API uses Doorkeeper to Sign In with JWT.
  • To sign in and use the API (at least if it is required), you must create an access_token using /api/v1/oauth/token sending a POST request:
{
  "grant_type": "password",
  "username": "anyuser",
  "password": "som3StrongPassw0rd"
}
  • API will return something like this:
{
    "access_token": "7p-ol7DSFL8pyFx_a1McTQQq9fIWEgYTSCSCg8DQEhw",
    "token_type": "Bearer",
    "expires_in": 3600,
    "refresh_token": "kcu0UysdF-bZcOi_xYcAvSkIfvejggcW_O3AGgdYPug",
    "created_at": 1609000354
}
  • You must use access_token as Authorization parameter (prefixed by the word Bearer) in the Header of every request to API (if it is required, according to API documentation).
  • Also, you can use refresh_token to renew your access_token without passing username and password again. For that, you must send a POST request:
{
  "grant_type": "refresh_token",
  "refresh_token": "kcu0UysdF-bZcOi_xYcAvSkIfvejggcW_O3AGgdYPug"
}
  • API will return something similar when you pass username and password:
{
    "access_token": "HA2P1ZKKJZJ4SajKrjSTX9R4DydNlXQhi5QyFVTuF08",
    "token_type": "Bearer",
    "expires_in": 3600,
    "refresh_token": "s6eBdXEb0mnc4AzVgVzAgyC-owhmww4LNP2dIn3Dk9Q",
    "created_at": 1609003229
}

Author

👤 Sergio Zambrano

🤝 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!

Credits

📝 License

This project is MIT licensed.

About

This is an API created for an Appointments website. You can book an appointment with a teacher to learn a course or topic.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published