Skip to content

hieronimusbudi/komodo-backend

Repository files navigation

Komodo REST API

Coverage Status

Golang Ecommerce API using MySQL DB and Fiber

How to install

For local

  1. Install dependencies.
go get ./...
  1. Add Config at .env file at root folder.
PORT = 9000
JWT_SECRET = "secret"
MYSQL_USER = "root"
MYSQL_PASSWORD = ""
MYSQL_HOST = "localhost"
MYSQL_PORT = 3306
MYSQL_DATABASE = "ecommerce_go"
  1. Import table and data using schema.sql and data.sql at ./scripts folder.

Using Docker Compose

  1. Setting enviroment variable using docker-compose.yml at root folder.
  2. If MYSQL_HOST and MYSQL_PORT are changed, make sure to change mysql:3306 part in CMD at dockerfile at root folder.
CMD ["./wait-for.sh" , "mysql:3306" , "--timeout=300" , "--" , "./komodo-backend"]

How to use

For local

  1. Use this command at root folder to start the app.
go run main.go
  1. Run test using this command at root folder.
go test ./...

Using Docker Compose

  1. Clear docker compose
docker-compose rm -v
  1. Run this command to start docker compose.
docker-compose up --build

App Endpoints

No Path Method Payload Description
1 /buyers/register POST
{ "email":"buyer@mail.com", "name":"john buyer", "password":"12345", "sendingAddress":"Jl jalan"}
Buyer register
2 /buyers/login POST
{ "email":"buyer@mail.com", "password":"12345"}
Buyer login
3 /sellers/register POST
{ "email":"seller@mail.com", "name":"john seller", "password":"12345", "pickupAddress":"Jl jalan"}
Seller register
4 /sellers/login POST
{ "email":"seller@mail.com", "password":"12345"}
Seller login
5 /products GET Get all products
6 /products POST
{ "name":"pro1", "description":"check", "price":91051551.13, "sellerId":1}
Create a product
7 /orders/find/byuser GET Get all orders by buyer/seller id inside JWT token
8 /orders POST
{"buyerId": 1,"sellerId": 1,"deliverySourceAddress": "source","deliveryDestinationAddress": "destination","items": [{"productId": 1,"quantity": 12},{"productId": 2,"quantity": 8},{"productId": 3,"quantity": 10}]}
Create an order
9 /orders/:id/accept PUT Accept order

Endpoints security

No Path Method Need Login? Access by
1 /buyers/register POST no all
2 /buyers/login POST no all
3 /sellers/register POST no all
4 /sellers/login POST no all
5 /products GET yes all
6 /products POST yes seller
7 /orders/find/byuser POST yes all
8 /orders POST yes buyer
9 /orders/:id/accept PUT yes seller

Database Design

db_design

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published