This is a basic implementation of warehousing software built in Ruby on Rails. This uses an SQLite database and exposes an RESTful JSON API for interacting with the warehouse.
The features are limited but in this version, you can:
- Import the Inventory and Products from a file
- View all Products and their available quantity based on articles in the warehouse
- The ability to remove a product from the warehouse
To run this app you will need Ruby 2.7.2.
- Install dependencies
We're using Bundler as a dependency manager.
gem install bundler
bundle install
- Migrate the database
bundle exec rake db:create
bundle exec rake db:migrate
- Run Server
bundle exec rails s
- To Drop and Recreate the db
bundle exec rake db:drop
bundle exec rake db:create
bundle exec rake db:migrate
To run the automated tests:
bundle exec rspec
2 Rake tasks exist for this purpose. As a parameter provide a path to the file.
bundle exec rake import:inventory["lib/inventory.json"]
bundle exec rake import:products["lib/products.json"]
Get all products including quantity available.
Success response (Status code: 200)
[
{
"id": 1,
"name": "Dining Chair",
"price": null,
"created_at": "2021-01-17T14:41:38.985Z",
"updated_at": "2021-01-17T14:41:38.985Z",
"quantity_available": 2
},
{
"id": 2,
"name": "Dinning Table",
"price": null,
"created_at": "2021-01-17T14:41:39.059Z",
"updated_at": "2021-01-17T14:41:39.059Z",
"quantity_available": 1
}
]
Returns a product details
Success response (Status code: 200)
{
"id": 2,
"name": "Dinning Table",
"price": null,
"created_at": "2021-01-17T14:41:39.059Z",
"updated_at": "2021-01-17T14:41:39.059Z",
"quantity_available": 1
}
Remove a product from the warehouse. Will respond with the updated product details including the new available quantity.
Success response (Status code: 200)
{
"id": 2,
"name": "Dinning Table",
"price": null,
"created_at": "2021-01-17T14:41:39.059Z",
"updated_at": "2021-01-17T14:41:39.059Z",
"quantity_available": 0
}
Bad response: no stock available (status code: 409):
{
"message": "Insufficient stock available"
}
Email me on heinvogel@gmail.com