Skip to content

cgzirim/ecommerce-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-Commerce API

This is a sample e-commerce API built with Go and Gin framework. It provides endpoints for user authentication, product management, and order processing.

Features

  • User authentication (login, register)
  • Product management (list, create, update, delete)
  • Order management (create, list, update status, cancel)
  • Swagger documentation

Getting Started

Prerequisites

  • Go 1.22

Installation

  1. Clone the repository:

    git clone https://github.com/cgzirim/ecommerce-api.git
    cd ecommerce-api
  2. Install dependencies:

    go mod tidy
  3. Set up environment variables:

    Create a .env file in the root directory and add the necessary environment variables. Example:

    DB_HOST=localhost
    DB_PORT=5432
    DB_USER=your_db_user
    DB_PASSWORD=your_db_password
    DB_NAME=ecommerce_db
  4. Run the database migrations:

    go run main.go migrate

Running the API

  1. Start the server:

    go run main.go
  2. The API will be available at http://localhost:8080.

Running the API with Docker Compose

You can use Docker Compose to run the application along with the PostgreSQL database.

  1. Ensure Docker and Docker Compose are installed on your machine.

  2. Build and start the containers:

    docker-compose up --build
  3. The API will be available at http://localhost:8080.

  4. The PostgreSQL database will be available at localhost:5444.

API Documentation

Swagger documentation is available at http://localhost:8080/swagger/index.html.

Project Structure

  • controllers/: Contains the handler functions for the API endpoints and their tests.
  • db/: Database connection and migration scripts.
  • middleware/: Custom middleware functions.
  • docs/: Swagger documentation files.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published