Skip to content

Backend service for an e-commerce platform using Go and PostgreSQL. It provides APIs for user authentication, product management, cart functionality, and order processing.

Notifications You must be signed in to change notification settings

matimortari/go-ecom-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go E-Commerce Backend 🛒⚡

Backend service for an e-commerce platform using Golang and PostgreSQL. It provides APIs for user authentication, product management, cart functionality, and order processing. Alt text

📦 Key Features

  • Modular Architecture: Clean and scalable codebase for easy maintenance.
  • Authentication: Secure user authentication with JWT and password hashing.
  • Products: Get, create and update products.
  • Cart: Get and create orders with multiple products and secure validation.
  • Database Migrations: Easy setup and migration of database schemas.
  • Automated Testing: Easy-to-run tests for ensuring code reliability, using Go's built-in testing framework.
  • Makefile Automation: Simplified commands for building, running, testing, and managing migrations.

📂 Directory Structure

  bin/          - Compiled binaries
  cmd/          - Main application entry points
  config/       - Configuration files
  services/     - Business logic and API handlers
  types/        - Shared data types
  utils/        - Utility functions

🏁 Getting Started

  • Clone this repository:

    git clone https://github.com/matimortari/go-ecom-backend .
  • Install dependencies:

    go mod tidy
  • Create a .env file in the project root with the following environment variables (modify as needed):

     # Server configuration
    PUBLIC_HOST=http://localhost/
    PORT=8080
    
     # PostgreSQL database configuration
    DB_USER=postgres
    DB_PASSWORD=postgres
    DB_HOST=localhost
    DB_PORT=5432
    DB_NAME=ecom
  • Use the Makefile to automate common tasks.

⚙️🧪 Makefile Commands

  • Build the application to a binary at bin/ecom:

    make build
  • Run the compiled binary:

    make run
  • Run tests:

    make test
  • Create a new migration file at cmd/migrate/migrations:

    make migration-create name=<migration_name>
  • Run migrations "up" to apply all pending migrations:

    make migrate-up
  • Run migrations "down" to roll back the last applied migration:

    make migrate-down
  • Check migration status and version:

    make migrate-status

📬 Contact

Feel free to reach out to discuss collaboration opportunities or to say hello!

About

Backend service for an e-commerce platform using Go and PostgreSQL. It provides APIs for user authentication, product management, cart functionality, and order processing.

Topics

Resources

Stars

Watchers

Forks