GithubHelp home page GithubHelp logo

starsheriff2 / expert-class Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 2.0 7.36 MB

This app allows users to sign up for a class taught by experts and gurus. This is the back-end, a RESTful API hosted in Railway. The front-end is hosted in Netlify.

Home Page: https://expert-class-frontend-v2.netlify.app

License: MIT License

Ruby 98.27% HTML 0.27% Dockerfile 1.26% Shell 0.19%
react ruby-on-rails full-stack docker docker-compose railway-deployment

expert-class's Introduction


This RESTFUL API works as the backend for a React web app. The dockerized container of the app is currently hosted on Railway. All images are hosted in Cloudinary.


app screenshot mobile app screenshot mobile app screenshot mobile app screenshot mobile app screenshot mobile

Table of Contents

About

Expert Class API is the backend for a fully responsive web app that I built with a team of 4 members. The front end of the app is handled separately by another app. The repo for the front-end is here. The API documentation of this project was generated with the 'rswag' gem. We built request and integration tests, achieving a 95% coverage. We use cross-site session cookies to handle user authentication. We use PostgreSQL as the database and Cloudinary to store all images in the cloud.

API Documentation

We used Rswag to generate all the API documentation directly from our tests. You will find all the endpoints necessary to use our API here: Documentation

Features

  • authenticate user
  • create new user
  • create and delete a class
  • show all classes
  • show all reserved classes
  • reserve a class

Front-end React app

  • The front-end associated with this app is here.

  • The Github repo of the front-end is here.

Live Demo

Deployed to Railway: Live Demo

Video Presentation

Watch a quick demo and walk-through of this project:

Expert Class - 13 January 2022 - Watch Video

Built With

  • Ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
  • Rails 6.1.4.1
  • PostgreSQL 14
  • Cloudinary (for image storing)
  • Rspec (testing)
  • Faker gem
  • Factory bot
  • Docker 20.10.22
  • Docker compose v2.15.1

Project Management

We used an agile methodology to manage all the tasks in this project. This project's tasks are described in this kanban board.

We used GitHub's built-in Kanban board: kanban

Setup and Installation

To get a local copy up and running, follow these simple example steps.

Get files

  1. Open your terminal or command prompt.
  2. If you do not have git installed in your system, skip this step and go to step 3; otherwise, go to the directory where you want to copy the project files and clone it by copying this text into your command prompt/terminal:
  git clone [email protected]:StarSheriff2/expert-class.git

Now go to either the "Docker Deploy" or the "Local Deployt" section, depending on how you wish to deploy the API in your system.


  1. Download the program files by clicking on the green button that says β€œCode” on the upper right side of the project frame.
  2. You will see a dropdown menu. Click on β€œDownload ZIP.”
  3. Go to the directory where you downloaded the ZIP file and open it. Extract its contents to any directory you want in your system.

Cloudinary Setup

You will need a Cloudinary account to be able to deploy this app locally or through Docker. If you already have one, look for the API Environment variable, which you will find in your cloudinary dashboard:

  • for a Docker deployment, copy the API Environment variable into your .env file:
CLOUDINARY_URL=<your_unique_cloudinary_url>
  • for a local deployment, copy the API Environment variable into your config/cloudinary.rb file, by replacing the text "<cloudinary_url_here>" with the respective value of your API Environment variable

; otherwise, create a new account by going to Cloudinary and sign up for a free account: https://cloudinary.com/.

Once you have your new Cloudinary account set up, follow these steps:

  1. Login with your new account
  2. Go to your Cloudinary dashboard
  3. Look for the API Environment variable cloudinary_yml_file
  4. Do the following:
    • for a local deployment, copy it into your .env file, like exaplained above
    • for a Docker deployment, copy it into your config/cloudinary.rb file like explained above

Docker Deploy

Prerequisites

  • Docker 20.10.22 or latest
  • Docker Compose v2.15.1

Run

  docker compose up -d

Local deploy

Prerequisites

  • Ruby 3.0.2p107
  • Rails 6.1.4.1
  • PostgreSQL 14
  • Cloudinary account and cloudinary_url

Install Dependencies

  1. If you are not in your system terminal/command prompt already, please open it and go to the directory where you cloned the remote repository or extracted the project files.
  2. While in the project root directory, type
    bundle install
    
    This command will install all the necessary gems in your system.

Database Setup

Run

bin/rails db:setup

This will create your local databases, load the schema, and initialize with the seed data.

Note: If you get an error after running this command, it might be because you don't have a database called "postgres". This happens because when you create a new Rails application, Rails uses this "postgres" database to create and manage the databases for your application. You can easily create one by running this command:

createdb postgres

If Rails still complains about not finding the "postgres" role, you can create one with super-user priviledges:

createuser -s postgres

Now try running the db:setup command again!

You are all set now!

Usage

  1. In your terminal, run

    bin/rails server

    while inside the root directory of the repository files

    Note: This command will not stop on its own. To exit, hit "ctrl + c"

  2. The app allows API calls using curl or your favorite API client, such as Postman, HTTPPie or VS Code's Thunder Client. Here's a link to HTTPIE.

Development

Testing

We created all types of tests for this project:

  • Unit / Model tests
  • Integration tests
  • API request tests

Coverage report

test Coverage

To run all tests, type this into command line:

bundle exec rspec

Linters

To run Rubocop, go to the root directory of your repository and copy/paste the following command into your terminal:

 rubocop .

Authors

πŸ‘€ Arturo Alvarez

πŸ‘€ Breno Xavier

πŸ‘€ Francis Uloko

πŸ‘€ Mih Julius

🀝 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.

expert-class's People

Contributors

brenoxav avatar francisuloko avatar mihndim2020 avatar starsheriff2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

expert-class's Issues

Set up Rails App - Group Task - [2pts]

  • Set up branches

  • Github workflows

  • Set up linters

  • Create Rails app with Postgres db

  • Create API only

  • Configure role for db if necesasary

  • Configure Cors with gem 'cors'

Implement Reservation create endpoint [1pt]

  • Accepts JSON with properties: class_id, user_id, city, date
  • Check if date is available before creating entry
  • Creates entry in the database
  • Returns a success message
  • Create tests

Connect Session Controller with Frontend [3pts]

  • connect session controller endpoints with backend
  • pass session cookie to frontend
  • pass CRFToken to frontend
  • create API call methods on Frontend
  • Test that all session endpoints work in frontend to persist user session

Implement Nav Panel [1pt]

  • Implement Nav Panel with links to React pages
  • Implement React Routes
  • The Nav Panel should have links to:
    • Classes (list of available classes)
    • Reserve Class
    • My Reservations
    • Add Class
    • Remove Class

This task is implemented at expert-class-frontend

Create "Class Details" page [2pts]

  • When the user selects a specific item, they can see the details page with its full description
  • In the details page, the user can click the "Reserve" button
  • The details page should show title, description, duration, instructor and image

Create β€œAdd Class” page [2pts]

  • This page should have a form with the fields title, description, duration, instructor, image
  • It should submit the form to the API
  • After submit the form, it should redirect to the show page

Connect Landing Page Authentication with Backend [1ps]

The main purpose of this task is to connect all the components related to user authentication to the backend API calls properly.

  • connect signup and sign in pages to API
  • Create Logout button
  • Build frontend routing redirects based on logged in Status of user
  • Create error messages for authentication requests

This task is linked to this external PR too: brenoxav/expert-class-frontend#15

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.