Rails Engine API is the back end of a project to demonstrate service-oriented architecture for a fictional E-Commerce Application, where the front and back ends are separate and communicate via APIs.
Goals of the project include:
- Exposing an API
- Using serializers to format JSON responses
- Testing API exposure
- Compose advanced ActiveRecord queries to analyze information stored in SQL databases
Once you have forked and cloned your copy of this repo, run the following terminal commands to create your database:
rake db:{drop,create,migrate,seed}rails db:schema:dump
Check that your schema.rb exists and use a tool like Postico to confirm the data matches the tables shown above.
MERCHANTS
GET /api/v1/merchants
GET /api/v1/merchants?per_page=<int>&page=<int>
GET /api/v1/merchants/<id>
ITEMS
GET /api/v1/items
GET /api/v1/items?per_page=<int>&page=<int>
GET /api/v1/items/<id>
POST /api/v1/items
PATCH /api/v1/items/<id>
DELETE /api/v1/items/<id>
RELATIONSHIPS
GET /api/v1/merchants/<id>/items
GET /api/v1/items/<id>/merchant
SEARCH FOR SINGLE RECORD
GET /api/v1/merchants/find?name=<text fragment>
GET /api/v1/items/find?name=<text fragment>
GET /api/v1/items/find?min_price=<numerical value>
GET /api/v1/items/find?max_price=<numerical value>
GET /api/v1/items/find?max_price=<numerical value>&min_price=<numerical value>
SEARCH FOR ALL RECORDS
Follows the same rules as finding "ONE" endpoints, just substitute find_all for find in the query parameter. For example:
GET /api/v1/merchants/find_all?name=<text fragment>
BUSINESS LOGIC ENDPOINTS
GET /api/v1/revenue/merchants?quantity=<integer>
GET /api/v1/revenue/merchants/<id>
GET /api/v1/revenue/unshipped?quantity=<integer>
NOTE: quantity is an optial param referring to the requested number of records to return
To run server on localhost:3000/:
rails s
- Back-End
- Language: Ruby 2.6.3
- Framework: Rails 5.2.6
- Testing: RSpec, SimpleCov
- Database: PostgreSQL