Giter VIP home page Giter VIP logo

df-ecomm's Introduction

๐Ÿ›’ DF E-commerce

A simple e-commerce API built with Gin and GORM to manage products and a shopping cart.

Getting Started

After cloning this repository and download all the required modules (using the command go mod download), you can run make db to start the PostgreSQL database in a Docker container.

docker-compose up -d db

The database is initialized with some data. You can check out the .sql file to see the database schema and the initial data.

Then, you can run make run to start the Go server.

go run cmd/server/main.go

The server will be listening on port 8080 by default. You can change this by setting the PORT environment variable in the .env file. You can also change the secret key used to sign the JWT tokens with the SECRET_KEY environment variable.

API Endpoints

All /products APIs requires a valid JWT token in the Authorization header, which can be obtained by calling the /auth API with a valid username and password. Currently, only users with the admin role can manage the products. Check out the .sql file to see the initial users and their roles.

You can check out the .http file to see some examples of requests to the API.

If you are using Visual Studio Code, you can install the REST Client extension to send requests directly from the editor. For GoLand users, the HTTP Client plugin also provides similar functionality. See their documentation for more details.

Method Path Description Notes
POST /products Create a new product Receives product details
PUT /products/:id Update a product's details Receives updated product details
DELETE /products/:id Delete a product by its ID
GET /products Retrieve a list of all products
POST /cart/add Add items to the cart Receives product ID and quantity
DELETE /cart/remove Remove items from the cart Receives product ID
POST /cart/checkout Checkout and clear the cart Returns a receipt with the total price

df-ecomm's People

Watchers

Long Nguyen 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.