E-commerce implemented with gin

This is e-commerce backend implemented with gin, fiber(v2),gorm and PostgresSQL. It is a simple e-commerce backend with basic features.

Features

  • User jwt authentication with argon2 password hashing
  • User roles (admin, user)
  • User profile
  • User cart
  • User orders
  • Product CRUD
  • Admin routes
  • CORS
  • HTTPS

Routes

Auth Routes

  • POST /api/v1/auth/signup (signup)
  • POST /api/v1/auth/signin (signin)
  • POST /api/v1/auth/signout (signout)
  • POST /api/v1/auth/profile (get user profile)

Product Routes

  • GET /api/v1/products (get all products)
  • GET /api/v1/products/:id (get product by id)
  • POST /api/v1/products/create (create product) -- admin only
  • PUT /api/v1/products/:id (update product) -- admin only
  • DELETE /api/v1/products/:id (delete product) -- admin only

Cart Routes

  • POST /api/v1/cart/remove/:id (remove product from cart)
  • POST /api/v1/cart/add/:id (add product to cart)

Order Routes

  • POST /api/v1/orders (get all orders)
  • POST /api/v1/orders/create (create order)

Admin Routes

  • GET /api/v1/admin/getUsers (get all users) -- admin only
  • GET /api/v1/admin/getUser/:id (get user by id) -- admin only
  • GET /api/v1/admin/deleteUsers (delete all users) -- admin only
  • GET /api/v1/admin/delete/:id (delete user by id) -- admin only

How to work with this repo

  • Clone the repo
  • Run go mod tidy to install all the dependencies
  • Run go run . to start the server