Git Product home page Git Product logo

go-bootcamp-ending-project's Introduction

Go-Bootcamp-Ending-Project

This project is the Golang Backend Web Development bootcamp ending project organized by patika.dev and kodluyoruz, sponsored by Picus Security. Within the scope of the project, Basket API application was realized.

Used technologies;

  • GORM
  • Gin
  • MySQL
  • JWT
  • Swagger

PS: Before you start, set the sql connections in the configs/project.qa.yaml file. If you have your own connections you can do it by setting it on main.go line:18.

Simple Entity Representations

Entities

Only admins can add categories and products admin id can be added as foreignkey adminId to category, product entities.

Basket and Order difference is providing with IsOrder attribute.

API Endpoints

-Login

In this point requests contain email and password if DB has this user returns JWT token to use other points' Authorization processes.

Point has 2 using with request body(email,password);
POST localhost:8080/login/customer
POST localhost:8080/login/admin

-Signup

This point takes customer with name,username,email,password,phone and address information but only username,email and password is necessary fields. If there is same name or email customer it will return err. After signup point returns JWT token.

Point has using with request body(Customer fields);
POST localhost:8080/signup

-Category

Getting all categories comes with pagination. An admin can add a category with uploading csv file, in this file should contains name,code and description columns if there is not one of them api will response with not readable. In adding process if given file line is in DB with same name or code it will not create you can see on logs.

Point has using two router;
Getting all categories with pagination takes page and size query parameters, if you dont enter will be default(1-100). Max size is 10000.
GET localhost:8080/category

Adding category runs with takes Authorization JWT token and form-data body key should be named as "file", this file taken and uploads in /assets with random name, after this process checks it and adds to DB its lines, if there is some problem with reading deletes the file from /assets if there is not holds the file in /assets .
POST localhost:8080/category

-Product

Point has five router;
Get products works like categories, it has same pagination specialities. Pagination takes page and size query parameters.
GET localhost:8080/product

Searching has 3 query parameters. These are "name","categoryId" or "amount". All can work together, name field checks which categories has same query input, categoryId gives back all entered input products that has same categoryId and lastly amount returns back products which has equal or bigger amount products. If there is not entered data returns not found.
GET localhost:8080/product/search

Creating new product needs Authorization JWT token and request body of Product it should has unique name and code. If category id is not given then categorizing will be default with category named Other.
POST localhost:8080/product

Deleting product runs with Authorization JWT token and query product id or request body product but this process needs only product id.
DELETE localhost:8080/product

Updating product needs Authorization JWT token and all product fields especially id,name,categoryid and code. Takes fields and updates them.
PUT localhost:8080/product

-Basket

Point has five router;
Get basket works with Authorization JWT token gives back customers all basket items.
GET localhost:8080/basket

Adding basket runs with Authorization JWT token and request body (product id and amount is needed). There can be one or more product in request and request should not contain same product twice or more. Checks product with given id and is there enough amount of product if there is decreases the products amount. After checking adds them into DB.
POST localhost:8080/basket

Complete to order needs Authorization JWT token. If the basket products deleted by admin. customer should delete the product from own basket.
POST localhost:8080/basket/complete

Deleting basket products runs with Authorization JWT token and query product id or request body product but this process needs only product id. Deleting process contains delete basket products by one by.
DELETE localhost:8080/product

Updating basket product needs Authorization JWT token and request body(amount and product id is needed). This process runs on amount count.
PATCH localhost:8080/product

-Order

There is two router;
Get orders runs with Authorization JWT token and returns customers orders.
GET localhost:8080/order

Cancel order works with Authorization JWT token and query parameter "code". Code represents order and cancels if it has not been 14 days since ordered.
PATCH localhost:8080/order/cancel

Info

In Swagger POST /category with CSV not implemented. Can be run in Postman.

Order and Basket implement works on same entity named order. Difference is providing with isOrder and orderCode. If IsOrder is true it is order but if it is false it represents basket item. The order code is created when the basket is ordered.

When program starts admin users and one category named as Other will be created.

If a product is deleted but if it is in order it will not shown on get all orders, if is in basket it will be deleted customers by self.

Adding category process CSV file shoud contain columns name,code(uint) and description.

When a customer or admin added password will be hashed. Same hashing is using at user roles.

-Shortcomings

There are soft deletes working on the DB so the response can contain more information.

Basket entity can be added to DB

No test execution provided yet.

go-bootcamp-ending-project's People

Contributors

yusufbu1ut avatar

Stargazers

 avatar Özlem Göksu avatar

Watchers

Mehmet Can Taş avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.