A shopping-cart API for case study using go, go-gin, swaggo, and postgresql. Main features for this case studiying are:
git clone https://github.com/tirzasrwn/shopping-cart.git
cd shopping-cart
# start docker compose
make up
# stop docker compose
make down
make start
There are two docker images, backend go and database postgresql. You can run them separately.
make docker_<service>_build
make docker_<service>_start
make docker_<service>_stop
# where <service> is db for database and be for backend
This API documentaiton using Swagger API documentation. Here are all the routes:
route | method | description |
---|---|---|
/category | get | this is api to get product category |
/login | post | this is api to authenticate user then returns jwt token |
/product | get | this is api to get all product |
/product/{category_id} | get | this is api to get product by category_id. category_id can be found at /category |
/register | post | this is api to register new user |
/user | get | this is api to get all user information |
/user/checkout | post | this api is to checkout and make payment transactions. total payment can be found at get /user/order |
/user/order | get | this api is to get user order |
/user/order | post | this api to post new order or update the quantity. prouduct_id can be found at /product |
/user/order/{order_id} | delete | this api to delete order by order_id. order_id can be found at get /user/order |
/user/payment | get | this api is to get user payment |
Swagger API documentaiton can be found at http://localhost:4000/swagger/index.html.
service name | port |
---|---|
backend | 4000 |
database | 5432 |
Credential
email: user1@example.com
password: user1
username: postgres
password: postgres
db name: shopping-cart
If you want to do a database migration for development, read this documentation.