Skip to content

elysiamori/minicommerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Minicommerce API πŸ›

The purpose of this API is to understand the basic concepts of crud operations in a rest api by implementing a project for an online store. This api was also developed as a final project for a mobile programming course and will be consumed by a flutter-based frontend as part of the project.

Tech Stack

Library

  • Fiber : go get github.com/gofiber/fiber/v2
  • GORM Postgres : go get gorm.io/gorm gorm.io/driver/postgres
  • Validator : go get github.com/go-playground/validator/v10
  • Accounting Format : go get github.com/leekchan/accounting

Deployment

MINI-COMMERCE API [DOCS]

Key Feature :

  • CRUD product
  • List product
  • Search product
  • Details product

API URL : https://minicommerce.fly.dev

Product CRUD

[POST] /api/products πŸš€

Request :

  • description : add product
  • header : multipart/form-data
  • body :
    - product_name : string
    - img_product : byte (uploaded image)
    - type_product : string
    - desc : string
    - sold : int
    - location : string
    - price : integer
    - stock : integer

Response :

  • status [201] created
  • data :
            {
                "id" : "integer",
                "product_name" : "string",
                "img_product" : "byte",
                "type_product" : "string",
                "desc" : "string",
                "sold" : "int",
                "location" : "string",
                "price" : "integer",
                "stock" : "integer",
                "created_at" : "date"
            }

[GET] /api/products πŸ“©

Request :

  • description : get all products

Response :

  • status [200] success
  • data :
            {
                [
                    {
                        "id" : "integer",
                        "product_name" : "string",
                        "img_product" : "byte",
                        "type_product" : "string",
                        "desc" : "string",
                        "sold" : "int",
                        "location" : "string",
                        "price" : "integer",
                        "stock" : "integer",
                    },
    
                    {
                        "id" : "integer",
                        "product_name" : "string",
                        "img_product" : "byte",
                        "type_product" : "string",
                        "desc" : "string",
                        "sold" : "int",
                        "location" : "string",
                        "price" : "integer",
                        "stock" : "integer",
                    }
                ]
            }

[PUT] /api/products/:productID πŸ“€

Request :

  • description : update product
  • header : multipart/form-data
  • params : productID(integer)
  • body:
   - product_name : string
   - img_product : byte (uploaded image)
   - type_product : string
   - desc : string
   - sold : int
   - location : string
   - price : integer
   - stock : integer

Response :

  • status [200] success
  • data :
            {
                "Product":{
                    "id" : "integer",
                    "product_name" : "string",
                    "img_product" : "byte",
                    "type_product" : "string",
                    "desc" : "string",
                    "sold" : "int",
                    "location" : "string",
                    "price" : "integer",
                    "stock" : "integer",
                    "created_at" : "date",
                    "updated_at" : "date"
                }
            }

[DELETE] /api/products/:productID ❌

Request :

  • description : delete product
  • params : productID

Response :

  • status [200] success
  • data :
            {
                "message" : "product successfully deleted"
            }

List Product

[GET] /api/list-products πŸ“ƒ

Request :

  • description : show all product to the menu

Response :

  • status [200] success
  • data :
            {
                "Products": [
                    {
                        "id" : "integer",
                        "product_name" : "string",
                        "img_product" : "byte",
                        "type_product" : "string",
                        "sold" : "int",
                        "location" : "string",
                        "price" : "integer",
                        "stock" : "integer"
                    }
                ]
            }

[GET] /api/search-product πŸ”

Request :

  • description : search product
  • params : query paramaeter (product_name, type_product) Response :
  • status [200] success
  • data :
            {
                "product_name" : "string",
                "img_product" : "byte",
                "type_product" : "string",
                "sold" : "int",
                "location" : "string",
                "price" : "integer",
                "stock" : "integer"
            }

Detail product

[GET] /api/list-products/detail-product/productID πŸ“

Request :

  • description : detail product
  • params : productID(integer)

Response :

  • status [200] success
  • data :
            {
                "product_name" : "string",
                "img_product" : "byte",
                "type_product" : "string",
                "sold" : "int",
                "location" : "string",
                "price" : "integer",
                "stock" : "integer",
                "desc" : "string"
            }

Importing Postman API Documentation

Steps to Import API Documentation into Postman

1. Install Postman
  • Download and install Postman from the official website.
  • Follow the installation instructions for your operating system.

2. Download the minicommerce.json File

  • Ensure you have the minicommerce.json file, download or copied into your local machine.

3. Import the Collection into Postman

  • Open Postman.
  • Click on the "Import" button in the top left corner of the Postman app.
  • Select the "File" tab.
  • Click on "Choose Files" and select the minicommerce.json file from your local machine.
  • Postman will import the collection, and you will see it appear in the Collections sidebar.

4. Using the Imported Collection

  • Once imported, you will see the collection in the Collections sidebar.
  • Click on the collection to browse through the API requests.
  • Select any request and click the "Send" button to execute it and view the response.

By following these steps, you will have the API documentation and requests ready to use in Postman, making it easier to interact with the API endpoints provided in the minicommerce.json file.