Jvls1 / go-ecommerce

E-Commerce using Go with the microservices architecture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go E-commerce

E-commerce project with microservice architecture using Go, Gin-Gonic, Postgres, Mongo and Docker.

Auth Service

The auth service handle the login with JWT Token and user creation, also create the roles and permissions for access control.

Techs: Go, Chi, Postgres

Header for all the POST routes except the /login:

Header Value
Content-Type application/json
Authorization Bearer jwt-token

Header for the GET routes:

Header Value
Authorization Bearer jwt-token

Login

POST /login
Header Type
Content-Type application/json
{
  "email": "email@gmail.com",
  "password": "strongPassword123"
}

Create permission

POST /permissions
{
  "name": "read-permission",
  "description": "Grant access to create a permission"
}

Find permission by id

GET /permissions/${permissionId}
Param Type
permissionId uuid

Create permission

POST /permissions/
{
  "name": "read-permission",
  "description": "Grant access to read a permission"
}

Find user by id

GET /users/${userId}
Param Type
userId uuid

Create user

POST /users/
{
  "name": "John Doe",
  "password": "strongPassword123",
  "email": "test@gmail.com"
}

Add role to user

POST /users/roles
{
  "userId": "bd42b8fd-5ba1-482b-8b3e-13b77095a7d7",
  "roleId": "5658b58d-b749-4a74-bb71-483324eb0705"
}

Find role by id

GET /roles/${roleId}
Param Type
roleId uuid

Create role

POST /roles/
{
  "name": "Admin1",
  "description": "Admin role"
}

Add permission to role

POST /roles/permissions
{
  "roleId": "5658b58d-b749-4a74-bb71-483324eb0705",
  "permissionId": "c523de53-8b8e-47fa-a751-15f0e678f8d9"
}

Product Service

Create product

POST /api/v1/products/
{
  "name": "Product Test",
  "description": "This is a test product",
  "image_url": "https://example.com/image.jpg",
  "price": 19.99,
  "quantity": 10,
  "department_id": 1
}

Find all products (with pagination)

GET /api/v1/products?page=0&pageSize=10
Param Type
page number
pageSize number

Find product by id

GET /api/v1/products/${id}
Param Type
id uuid

Find product by department id

GET /api/v1/products/department/${departmentId}
Param Type
departmentId uuid

About

E-Commerce using Go with the microservices architecture

License:MIT License


Languages

Language:Go 100.0%