Rails Engine is a REST API which exposes data about merchants, items and revenue. This is a service oriented architecture project completed in the course of six days.
All endpoints return JSON data compliant with the JSON API spec through the use of serializers. Additionally, all endpoints are exposed under an api
and v1
namespace, and tested at the request and unit level.
Both Merchants and Items have all CRUD endpoints (index
, show
,create
, update
, and destroy
) as well as find_all
and find
endpoints which have been namespaced in a SearchController with index
and show
functions corresponding to those endpoints. I also explored two relationship endpoints in this project between merchants and items - this is reflected in an endpoint for a specific merchant's items and an endpoint for a specific item's merchant.
Finally, this project utilizes ActiveRecord to complete 4 separate "business intelligence" endpoints which created the necessity for a merchant's revenue controller and a revenue controller outside of either merchants or items namespace.
To get a copy of the project on your local machine for development and testing purposes, first confirm your Ruby and Rails versions, then follow the Local Setup steps below.
- Ruby 2.5.3
- Rails 5.2.4.3
- Fork and clone this repo into a new directory.
- CD into
rails_engine
- Run
bundle install
to install gem packages - Run
rails db:setup
to setup the databases
- Run Unit tests:
bundle exec rspec
- Run through the different endpoints by running your server from the console:
rails s
Gems
rspec-rails
- testing suitefactory-bot
- testing object generatorfaker
- generates fake data for testingpry
- runtime developer consolecapybara
- aids in application testing and interactionsimplecov
- tracks test coverageshoulda-matchers
- simplifies testing syntaxlaunchy
- helper class for launching cross-platform applicationsrubocop-rails
- enforces Rails best practices and coding conventions
Merchant resources have full CRUD capabilities through the following endpoints:
GET /api/v1/merchants
GET /api/v1/merchants/:id
POST /api/v1/merchants
PATCH /api/v1/merchants/:id
DELETE /api/v1/merchants/:id
Additionally, Merchants have the following search functionalities:
GET /api/v1/merchants/find?{attribute}={value}
- finds a single merchant based on query
GET /api/v1/merchants/find_all?{attribute}={value}
- finds all merchants matching query
Item resources have full CRUD capabilities through the following endpoints:
GET /api/v1/items
GET /api/v1/items/:id
POST /api/v1/items
PATCH /api/v1/items/:id
DELETE /api/v1/items/:id
Additionally, Items have the following search functionalities:
GET /api/v1/items/find?{attribute}={value}
- finds a single item based on query
GET /api/v1/items/find_all?{attribute}={value}
- finds all items matching query
We can explore the relationship between items and merchants through the following endpoints:
- `GET /api/v1/items/:item_id/merchant
- returns a merchant that sells the item associated with the id in params
- `GET /api/v1/merchants/:merchant_id/items
- returns a list of items sold by the merchant associated with the id in params
The following endpoints require ActiveRecord to analyze and return specified datasets:
GET /api/v1/merchants/most_items?quantity={integer}
- returns the number of merchants ranked by how many items they have sold in total
GET /api/v1/merchants/most_revenue?quantity={integer}
- returns the number of merchants ranked by their total revenue
GET /api/v1/revenue?start={yyyy-mm-dd}&end={yyyy-mm-dd}
- returns total revenue across all merchants for the date range queried
GET /api/v1/merchants/:merchant_id/revenue
- returns the total revenue for a specific merchant
- Shaunda Cunningham (she/her)