RESTful API for a fictitious e-commerce site that provides business analytics for frontend consumption.
About The Project • Tools Used • Set Up • Installation • How To Use • Database Schema • Contributing • Acknowledgements
Rails Engine was built to practice RESTful API development for a front end consumption. The API uses Active Record and SQL to create business analytics and expose select data and information for a front end team.
- Building and testing a RESTful API
- Active Record/SQL queries
- Serializing data to follow proper JSON contracts
- CRUD functionality
Development | Testing | Gems |
---|---|---|
Ruby 2.7.2 | RSpec | Pry |
Rails 5.2.5 | SimpleCov | ShouldaMatchers |
JSON | FactoryBot | Faraday |
Atom | Faker | FastJSON |
Git/Github | ||
Heroku |
- To clone and run this application, you'll need Ruby 2.7.2 and Rails 2.5.3. Using rbenv you can install Ruby 2.7.2 (if you don't have it already) with:
rbenv install 2.7.2
- With rbenv you can set up your Ruby version for a directory and all subdirectories within it. Change into a directory that will eventually contain this repo and then run:
rbenv local 2.7.2
You can check that your Ruby version is correct with ruby -v
- Once you have verified your Ruby version is 2.7.2, check if you have Rails. From the command line:
rails -v
- If you get a message saying rails is not installed or you do not have version 5.2.5, run
gem install rails --version 5.2.5
- You may need to quit and restart your terminal session to see these changes show up
- Fork this repo
- Clone your new repo
git clone https://github.com/#{your_github_username}/rails_engine.git
- Install gems
bundle install
- Setup the database
rails db:create rails db:migrate
Rails Engine can be used to access fictitious e-commerce data and calculations.
Request:
GET /api/v1/merchants?per_page=50&page=2
Response:
{
"data": [
{
"id": "1",
"type": "merchant",
"attributes": {
"name": "Store 1",
}
},
{
"id": "2",
"type": "merchant",
"attributes": {
"name": "Store 2",
}
},
{
"id": "3",
"type": "merchant",
"attributes": {
"name": "Store 3",
}
}
]
}
Request:
GET /api/v1/<resource>/:id
Response:
{
"data": {
"id": "1",
"type": "item",
"attributes": {
"name": "Bouncy Ball",
"description": "A really bouncy ball",
"unit_price": 109.99
}
}
}
Request:
POST /api/v1/items
{
"name": "value1",
"description": "value2",
"unit_price": 100.99,
"merchant_id": 14
}
Response:
{
"data": {
"id": "16",
"type": "item",
"attributes": {
"name": "Widget",
"description": "High quality widget",
"unit_price": 100.99,
"merchant_id": 14
}
}
}
👤 Marla Schulz
- Turing School of Software and Design
- Project created for completion towards Backend Engineering Program