Skip to content

datumbrain/go-hex-arch-demo

Repository files navigation

HexaShop

HexaShop is a simple Golang application built to learn and implement hexagonal architecture. It includes APIs for managing users and products, demonstrating the core principles of domain-driven design and separation of concerns.

Features

  • User management API (CRUD operations)
  • Product management API (CRUD operations)
  • Demonstrates hexagonal Architecture (ports & adapters pattern)

Architecture Overview

This project uses the hexagonal architecture (also known as Ports and Adapters), which aims to create a more modular, loosely-coupled code structure. The business logic (core domain) is separated from the infrastructure (database, HTTP layer), making it easier to test and extend.

Pre-requisites

  • Must have installed go 1.21.1 or latest.
  • Must have installed task command

How to Run

  • Run the following command to execute the application

    task run

Project Structure

./
β”œβ”€β”€ cmd/
β”‚   └── app/
β”‚       └── main.go
β”œβ”€β”€ conf/
β”‚   └── conf.go
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ adapter/
β”‚   β”‚   β”œβ”€β”€ http/
β”‚   β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ product.go
β”‚   β”‚   β”‚   β”‚   └── user.go
β”‚   β”‚   β”‚   β”œβ”€β”€ rq/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ product.go
β”‚   β”‚   β”‚   β”‚   └── user.go
β”‚   β”‚   β”‚   └── router.go
β”‚   β”‚   └── storage/
β”‚   β”‚       β”œβ”€β”€ postgres/
β”‚   β”‚       β”‚   β”œβ”€β”€ migration/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ 000001_init.down.sql
β”‚   β”‚       β”‚   β”‚   └── 000001_init.up.sql
β”‚   β”‚       β”‚   β”œβ”€β”€ repo/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ product.go
β”‚   β”‚       β”‚   β”‚   └── user.go
β”‚   β”‚       β”‚   β”œβ”€β”€ schema/
β”‚   β”‚       β”‚   β”‚   └── schema.sql
β”‚   β”‚       β”‚   β”œβ”€β”€ db.go
β”‚   β”‚       β”‚   └── migration.go
β”‚   β”‚       └── redis/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ domain/
β”‚   β”‚   β”‚   β”œβ”€β”€ product.go
β”‚   β”‚   β”‚   └── user.go
β”‚   β”‚   └── service/
β”‚   β”‚       β”œβ”€β”€ product.go
β”‚   β”‚       └── user.go
β”‚   └── port/
β”‚       β”œβ”€β”€ product.go
β”‚       └── user.go
β”œβ”€β”€ .env.sample
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
β”œβ”€β”€ Taskfile.yml
β”œβ”€β”€ go.mod
└── go.sum

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published