Skip to content

Lectron-Fazztrack/Final-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

221 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LECTRON - FINAL PROJECT

ERD (Entity Relation Database)

logo

Table Spesification

USER

user

CART

cart

MIGRATION

migration

PRODUCT

product

CHECK OUT

check out

REVIEW

review

Some commands you should know to run this application

1. go run . serve // to run the app/server
2. go run . migrate -u // for database migration
   go run . migrate -d // for database rollback
3. go run . seed // to seeding data Role admin if you want :

email : "admin@gmail.com"
password : admin12345678

🛠️ Installation Steps

1️⃣ Make root folder in your Gopath

github.com/Lectron-Fazztrack

2️⃣ Chosee project name "Final-Project"

3️⃣ Clone the repository inside the folder that was created "github.com/Lectron-Fazztrack"

git clone https://github.com/Lectron-Fazztrack/Final-Project.git

4️⃣ Intstall dependencies

go mod tidy

5️⃣ Add Env

DBHOST = DB Host
DBUSER = DB User
DBPASS = DB Password
DBNAME = DB Name
JWT_KEYS = JWT Keys
DBSSL = DB SSL

CLOUD_NAME = Cloud Name
CLOUD_KEY = API Key
CLOUD_SEC = API Secret

6️⃣ Database Migration and Rollback

go run . migrate --up // database migrate table

go run . migrate --down //rollback the database

7️⃣ Seeding data admin

go run . seed

➡️ PURPOSE TO LOGIN AS ADMIN'S ROLE { "email" : "admin@gmail.com", "password" : "admin12345678" }

8️⃣ Run the app

go run . serve

⚙️ You are all set

==================================================

🔗 ROUTE test

📌 Authentication Register

route.POST("/register", ctrl.Register)

🔧 Create new Admin :

{
    "name": "<your name>",
    "email": "<your email>",
    "role": "<admin>",
    "password": "<your password>",
    "addres": "<your address>",
    "phone": "<your phone number>",
    "gender": "<male/female>"
}

✔️ Respond :

{

"status": "OK",
 "isError": false,
 "data": {
     "id": "<uuid>",
     "name": "<name>",
     "email": "<email>",
     "role": "<admin>",
     "Password": "<generate password>",
     "gender": "<male/female>",
     "date": "<date>",
     "created_at": "<created time>",
     "updated_at": "<updated time>"
 }
}

🔧 Create new User :

{
    "name": "<your name>",
    "email": "<your email>",
    "password": "<your password>",
    "addres": "<your address>",
    "phone": "<your phone number>",
    "gender": "<male/female>"
}

✔️ Respond :

{
  "status": "OK",
  "isError": false,
  "data": {
      "id": "<uuid>",
      "name": "<name>",
      "email": "<email>",
      "role": "<user>",
      "Password": "<generate password>",
      "gender": "<male/female>",
      "date": "<date>",
      "created_at": "<created time>",
      "updated_at": "<update time>"
  }
}

⚔️ Request Body :

{
    "name": "<your name>", (STRING)
    "email": "<your email>", (STRING)
    "role": "<admin>", (STRING)
    "password": "<your password>", (STRING)
    "addres": "<your address>", (STRING)
    "phone": "<your phone number>", (INT)
    "gender": "<male/female>" (STRING)
}

==================================================

📌 Authentication Login

route.POST("/login", ctrl.Login)

🔧 Proses Login

{
    "email" : "<your email>",
    "password" : "<your password>"
}

✔️ Respond :

{
    "status": "OK",
    "isError": false,
    "data": {
        "token": "<your token>"
    }
}

⚔️ Request Body :

{
    "email" : <your email> (STRING),
    "password" : <your password> (STRING)
}

==================================================

📌 Product

➕ Add Product

route.POST("", middleware.CheckAuth(), middleware.CheckAuthor(), middleware.Cloudinary(), ctrl.AddProduct)

♾️ Update Product

route.PUT("/:id", middleware.CheckAuth(), middleware.CheckAuthor(), middleware.Cloudinary(), ctrl.UpdateProduct)

❌ Delete Product

route.DELETE("/:id", middleware.CheckAuth(), middleware.CheckAuthor(), ctrl.DeleteProduct)

®️ Get All

route.GET("", ctrl.GetAllProduct)

®️ Get By Id

route.GET("/:id", ctrl.GetById)

®️ Get By Type

route.GET("/types/:type", ctrl.GetByType)

⚔️ Request Body :

{
    "name" : "<product name>", (STRING)
    "image" : "<product image>", (STRING)
    "stock" : "<product stock>", (STRING)
    "telphone" : "<your password>", (INT)
    "price" : "<product price>", (INT)
    "type" : "<product type>", (INT)
    "sold" : "<product sold>" (STRING),
    "description" : "<description product>" (STRING)
}

==================================================

📌 Cart

⚔️ Request Body :

{
   "product_id" : "<rate>", (INT)
   "amount" : "<comment>" (INT)
}

==================================================

📌 Checkout and History

🛒 route.POST("/checkout", ctrl.Checkout)

📋 route.GET("/histories", ctrl.Histories)

⚔️ Request Body :

{
    "checkout_name" : "<checkout name>", (STRING)
    "product_id" : "<product id>", (INT)
    "deliv_address" : "<delivery address>", (STRING)
    "telphone" : "<your password>", (INT)
    "notes" : "<notes>", (STRING)
    "discount" : "<product discount>", (INT)
    "amount" : "<amount>", (INT)
    "total" : "<total>", (INT)
    "status" : "<status product>", (STRING)
    "payment" : "<payment>" (STRING)
}

==================================================

📌 Review

➕ Add Review

route.POST("/review", middleware.CheckAuth(), ctrl.PostReview)

®️ Get By Type

route.GET("/review/:id", ctrl.GetReview)

⚔️ Request Body :

{
  "rate" : "<rate>", (INT)
  "comment" : "<comment>" (STRING)
}

==================================================

==================================================

📌 Deployment

➕ Deployment on heroku

heroku container:login
heroku create <app-backend-name>
heroku create <app-frontend-name>
heroku git:remote -a <app-backend-name>
heroku git:remote -a <app-frontend-name>
heroku container:push backend --app <app-backend-name>
heroku container:release backend --app <app-backend-name>
heroku container:push frontend --app <app-frontend-name>
heroku container:release frontend --app <app-frontend-name>

==================================================

Releases

No releases published

Packages

No packages published

Contributors 7