tirzasrwn / shopping-cart

An API for shopping-cart using go, go-gin, swaggo, and postgresql.
GNU General Public License v2.0
1 stars 0 forks source link
backend backend-api backend-service crud crud-api docker docker-compose erd gin gin-gonic go jwt make makefile postgresql rest-api shopping-cart swagger-documentation swaggo

shopping-cart

About

A shopping-cart API for case study using go, go-gin, swaggo, and postgresql. Main features for this case studiying are:

Stack

Entity Relationship Diagram (ERD)

shopping-cart-erd

Requirement

Running

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

API Routes

swagger

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.

Feature and route corelations

Service Details

service name port
backend 4000
database 5432

Database Migration

If you want to do a database migration for development, read this documentation.