Rails Engine is a sales engine API platform. This project utilizes Ruby on Rails, ActiveRecord, and SQL to construct a JSON API that exposes and serves up data from sales relational database comprised of six interconnected resources.
- Uses single-responsibility controllers to provide a well-designed and versioned API. This easily seen from the routes.rb file.
- Uses controller tests to drive the design.
- Uses ActiveRecord and SQL to perform complex business inteligence.
- Serves data formatted as JSON utilizing serializers to tailor responses accordingly.
- Uses a custom rake task to load the data into the database.
- Clone the project down -
git clone git@github.com:calaway/rails_engine.git - Move into the cloned directory
- Create the database and migrate it -
rake db:{create,migrate} - Populate the database with data -
rake load:all- If you ever want to load just one type of data you can specify, e.g.
rake load:customers
- If you ever want to load just one type of data you can specify, e.g.
- Launch the server
- By default Rails will run off of localhost:3000
- The api should now be working, all paths begin with
/api/v1, see the full list of endpoints below.
- Merchants
GET /api/v1/merchants/:id/itemsreturns a collection of items associated with that merchantGET /api/v1/merchants/:id/invoicesreturns a collection of invoices associated with that merchant from their known orders- Invoices
GET /api/v1/invoices/:id/transactionsreturns a collection of associated transactionsGET /api/v1/invoices/:id/invoice_itemsreturns a collection of associated invoice itemsGET /api/v1/invoices/:id/itemsreturns a collection of associated itemsGET /api/v1/invoices/:id/customerreturns the associated customerGET /api/v1/invoices/:id/merchantreturns the associated merchant- Invoice Items
GET /api/v1/invoice_items/:id/invoicereturns the associated invoiceGET /api/v1/invoice_items/:id/itemreturns the associated item- Items
GET /api/v1/items/:id/invoice_itemsreturns a collection of associated invoice itemsGET /api/v1/items/:id/merchantreturns the associated merchant- Transactions
GET /api/v1/transactions/:id/invoicereturns the associated invoice- Customers
GET /api/v1/customers/:id/invoicesreturns a collection of associated invoicesGET /api/v1/customers/:id/transactionsreturns a collection of associated transactions
- All Merchants
GET /api/v1/merchants/most_revenue?quantity=xreturns the top x merchants ranked by total revenueGET /api/v1/merchants/most_items?quantity=xreturns the top x merchants ranked by total number of items soldGET /api/v1/merchants/revenue?date=xreturns the total revenue for date x across all merchants- Single Merchant
GET /api/v1/merchants/:id/revenuereturns the total revenue for that merchant across all transactionsGET /api/v1/merchants/:id/favorite_customerreturns the customer who has conducted the most total number of successful transactions.GET /api/v1/merchants/:id/customers_with_pending_invoicesreturns a collection of customers which have pending (unpaid) invoices- Items
GET /api/v1/items/most_revenue?quantity=xreturns the top x items ranked by total revenue generatedGET /api/v1/items/most_items?quantity=xreturns the top x item instances ranked by total number sold- Customers
GET /api/v1/customers/:id/favorite_merchantreturns a merchant where the customer has conducted the most successful transactions
- Ruby - 2.3.0
- Rails - 5.0.0.1
