E-Commerce API is a rails-api where users can add items to their baskets and convert orders by purchasing them.
You can reach documentation page
With Rails E-Commerce API you can
list/show/create/update/destroyuserslist/show/create/update/destroyproductslist/showordersshow/add/clear/purchasebasket
In this project there are 4 type of models
- User
- Product
- Order(includes basket)
- OrderItem
OrderItemsbelong toOrdersandProducts,Ordersbelong toUsers.Basketsare always the lastOrderofUserswithorder_type: basketandUserswill be created with their baskets.Userscan addOrderItemsto their basket and clear their baskets.- When purchase process is done
Product's inventory will be decrease byOrder's amount then new basket will be created. - Stock error will be given if one of
Productsout of stock while purchasing or adding items to basket.
The setups steps expect following tools installed on the system.
git clone [email protected]:menafkasap/rails-e-commerce-api.gitCopy the sample database.yml file and edit the database configuration as required.
cp config/database.yml.sample config/database.ymlRun the following commands to create and setup the database.
bundle exec rake db:create
bundle exec rake db:create RAILS_ENV=testYou can start the rails server using the command given below.
bundle exec rails sAnd now you can visit the site with the URL http://localhost:3000
You can start to run using the command given below.
rails testYou can send API request via Postman. Download and import json collection file using the link given below.