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/destroy
userslist/show/create/update/destroy
productslist/show
ordersshow/add/clear/purchase
basket
In this project there are 4 type of models
- User
- Product
- Order(includes basket)
- OrderItem
OrderItems
belong toOrders
andProducts
,Orders
belong toUsers
.Baskets
are always the lastOrder
ofUsers
withorder_type: basket
andUsers
will be created with their baskets.Users
can addOrderItems
to 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
Products
out 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.git
Copy the sample database.yml file and edit the database configuration as required.
cp config/database.yml.sample config/database.yml
Run the following commands to create and setup the database.
bundle exec rake db:create
bundle exec rake db:create RAILS_ENV=test
You can start the rails server using the command given below.
bundle exec rails s
And now you can visit the site with the URL http://localhost:3000
You can start to run using the command given below.
rails test
You can send API request via Postman. Download and import json collection file using the link given below.