This system is using GRPC and GRPC Gateway. The diagram below which explains how GRPC and gRPC Gateway work.
source: https://blog.logrocket.com/guide-to-grpc-gateway/This system is hosted on AWS EC2 and using github actions as a CI/CD Pipeline
Complete ERD Docs: Link ERD This API Docs are built with Swagger and Redocs. To Access the API Docs can see the link below : Link API Docs{
"code": integer,
"message": string
}
There are some error codes used below:
- 13 : (Internal Error)
- 10 : (Aborted)
- 5 : (Not Found)
- 11 : (Out Of Range)
- 16 : (Unauthenticated)
- 6 : (Already Exists)
- User Service (Login, Register)
- Order Service (Add To Cart, Get Cart Products, Delete Cart Product, Checkout Order)
- Product Service (Get Products, Get Products by Category, Get Product Details)
Example:
- POST /api/v1/carts
HEADERS : {
"Authorization": "Bearer {Token}"
}
BODY : {
"pid": "5ab402c1-a469-427a-8e1a-d21d08d33338",
"quantity": 10,
"amount": 18286
}
Example:
- To get list of products by category
Note that category params can be optional
GET /api/v1/products?category=Laptop
- To get list of products pagination
Note that limit and offset can be optional
GET /api/v1/products?limit=10&offset=2
To get started this API you need to setup infrastructure:
- Run Postgresql in Docker
make postgres
- Create Database in Postgresql
make createdb
- Create New Migrations
make createmigrate
- Create New Migrations with specific name
make newmigration name={your migration name}
- Run Migrate Up
make migrateup
- Run Migrate Down
make migratedown
- Generate SQL CRUD using SQLC
make sqlc
- Generate Schema Database From DBML
make dbschema
- Generate Proto File to Golang Code
make proto
- Generate DB Docs
make dbdocs
- Create Environment
app.env : for production
dev.env : for development
.env : for mapping env
- Install All Packages
go mod tidy
OR
go mod download
- Run Seeder to generate dump products
make seed
- Run Server
make server