tvaroglu / rails-engine

Rails Engine is a 7-day, 1 person project, during Mod 3 of 4 for Turing School's Back End Engineering Program.

Home Page:https://tvaroglu-rails-engine.herokuapp.com/api/v1/merchants

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails Engine

Contributors Issues Stargazers Forks

Welcome to Rails Engine: A hand-rolled RESTful JSON API

Schema

rails_engine_db_schema

Find the project spec here

Table of Contents


Overview

Rails Engine is a 7 day, 1 person project, during Mod 3 of 4 for Turing School's Back End Engineering Program.

The challenge was to build a fully functional JSON API 1.0 spec-compliant REST API that exposes endpoints for multiple resources from a relational database, modeling a true back-end framework that could be consumed by an entirely separate front-end framework.

Learning goals and areas of focus consisted of:

  • Exposing a RESTful JSON API
  • Using serializers to format JSON responses
  • Testing API exposure, including edge case coverage and error handling
  • Writing SQL statements without the assistance of an ORM

Technical Requirements

Framework

Languages

Tools


Gems


Development Principles

Contributors

👤 Taylor Varoglu

Sample Endpoints

GET Merchants

  • Get All Merchants: {{base_url}}/api/v1/merchants
    • Optional query params for pagination:
      • ?per_page=<integer>
      • ?page=<integer>
  • Get Merchant by Id: {{base_url}}/api/v1/merchants/{{id}}
  • Get Merchant by Name: {{base_url}}/api/v1/merchants/find?name={{search_param}}
    • REQUIRED query params for search:
      • ?name=<string>
  • Get Merchant's Items: {{base_url}}/api/v1/merchants/{{id}}/items
  • Get Top Merchants by Items Sold:{{base_url}}/api/v1/merchants/most_items?quantity={{search_param}}
    • REQUIRED query params for search:
      • ?quantity=<integer>

GET Items

  • Get All Items: {{base_url}}/api/v1/items
    • Optional query params for pagination:
      • ?per_page=<integer>
      • ?page=<integer>
  • Get Item by Id: {{base_url}}/api/v1/items/{{id}}
  • Get Item by Name: {{base_url}}/api/v1/items/find_all?name={{search_param}}
    • REQUIRED query params for search:
      • ?name=<string>
  • Get Item's Merchant: {{base_url}}/api/v1/items/{{id}}/merchant

GET Revenue

  • Get Merchants Ranked by Revenue: {{base_url}}/api/v1/revenue/merchants?quantity={{search_param}}
    • REQUIRED query params for search:
      • ?quantity=<integer>
  • Get Revenue for a Merchant: {{base_url}}/api/v1/revenue/merchants/{{id}}
  • Get Items Ranked by Revenue: {{base_url}}/api/v1/revenue/items
    • Optional query params for search:
      • ?quantity=<integer>

Setup

This project requires Ruby 2.7.2 and Rails 5.2.6.

  • Fork this repository
  • Install gems and set up your database:
    • bundle
    • rails db:{drop,create,migrate,seed}
    • rails db:schema:dump
  • Run the test suite with bundle exec rspec -fd
  • Run your development server with rails s

Project Configurations

  • Ruby version

    $ ruby -v
    ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
  • System dependencies

    $ rails -v
    Rails 5.2.6
  • Database creation

    $ rails db:{drop,create,migrate,seed}
    ...
    $ rails db:schema:dump
  • How to run the test suite

    $ bundle exec rspec -fd
  • Local Deployment, for testing:

    $ rails s
    => Booting Puma
    => Rails 5.2.6 application starting in development
    => Run `rails server -h` for more startup options
    Puma starting in single mode...
    * Version 3.12.6 (ruby 2.7.2-p137), codename: Llamas in Pajamas
    * Min threads: 5, max threads: 5
    * Environment: development
    * Listening on tcp://localhost:3000
    Use Ctrl-C to stop

About

Rails Engine is a 7-day, 1 person project, during Mod 3 of 4 for Turing School's Back End Engineering Program.

https://tvaroglu-rails-engine.herokuapp.com/api/v1/merchants


Languages

Language:Ruby 99.7%Language:HTML 0.3%