Example go clean architecture folder pattern

Golang Clean Architecture (Maintenance)

Berikut ini adalah folder structure pattern yang biasa saya gunakan, walaupun tidak semua nya saya terapkan dikarenakan project yang saya kerjakan hanyalah project - project kecil yang tidak terlalu besar, jadi jika anda tertarik dengan pattern yang saya buat ini anda bisa menggunakan nya jika menurut anda baik.

Structure Folder Pattern

├── tests
│   └── test.auth_test.go
│   └── test.student_test.go
└── docker
│   └── swagger
│   │     └── Dockerfile
│   │     └── openapi.yml
│   └── mysql
│   │     └── Dockerfile
│   │     └── mysql.cnf
│   └── golang
│   │     └── Dockerfile
├── handlers
│   └── auth
│   │     └── handler.login.go
│   │     └── handler.register.go
│   └── student
│   │     └── handler.create.go
│   │     └── handler.create.go
└── repositorys
│   └── auth
│   │     └── repository.login.go
│   │     └── repository.register.go
│   └── student
│   │     └── repository.create.go
│   │     └── repository.create.go
└── services
│   └── auth
│   │     └── services.login.go
│   │     └── services.register.go
│   └── student
│   │     └── services.create.go
│   │     └── services.create.go
└── helpers
│   └── helpers.apiResponse.go
│   └── helpers.randomString.go.go
└── middlewares
│   └── middleware.auth.go
│   └── middleware.role.go.go
└── models
│   └── model.auth.go
│   └── model.student.go.go
└── routes
│   └── route.auth.go
│   └── route.student.go
└── schemas
│   └── schema.auth.go
│   └── schema.student.go.go
└── templates
│   └── template.register.html
│   └── template.activation.html
└── pkg
│   └── pkg.jwt.go
│   └── pkg.bcrypt.go
│   └── pkg.cron.go
└── scripts
│   └── gcpRunner.sh
│   └── awsRunner.sh
└── configs
│   └── openapi.yml
│   └── serverless.yml
└── cmd
│   └── cmd.pgMigration.go
│   └── cmd.pgSeeds.go
└── crons
│   └── cron.autoDeleteLogs.go
│   └── cron.emailBlast.go
└── databases
│   └── migrations
│   │     └── migration.auth.go
│   │     └── migration.student.go
│   └── seeds
│   │     └── seed.auth.go
│   │     └── seed.student.go
│   └── sql
│   │     └── sql.auth.sql
│   │     └── sql.student.sql

Table Folder Status

Folder Name Folder Status
tests optional
docker optional
handlers required
repositorys required
services required
helpers optional
middlewares optional
models required
routes required
schemas required
templates optional
pkg optional
scripts optional
configs optional
cmd optional
crons optional
databases optional

Command

  • Application Lifecycle

    • Install node modules
    $ go get . || go mod || make goinstall
    • Build application
    $ go build -o main || make goprod
    • Start application in development
    $ go run main.go | make godev
    • Test application
    $ go test main.go main_test.go || make gotest
  • Docker Lifecycle

    • Build container
    $ docker-compose build | make dcb
    • Run container with flags
    $ docker-compose up -d --<flags name> | make dcu f=<flags name>
    • Run container build with flags
    $ docker-compose up -d --build --<flags name> | make dcubf f=<flags name>
    • Run container
    $ docker-compose up -d --build | make dcu
    • Stop container
    $ docker-compose down | make dcd
Owner
Restu Wahyu Saputra
A bright future will come, just waiting times, someday I will definitely become a software engineer
Restu Wahyu Saputra
Similar Resources

Example resource for alt:V Go module

Example resource for alt:V Go module

Dec 9, 2022

Example skills and a cli utility written in Go for interacting with Webex Assistant Skills

Webex Assistant Skills - Go This repository holds example skills and a cli utility written in Go for interacting with Webex Assistant Skills. It is in

Oct 29, 2021

This is an example of a keep-it-simple directory layout for Go projects that was created using DDD principles, please copy and share if you like it.

DDD Go Template This project was created to illustrate a great architectural structure I developed together with @fabiorodrigues in the period I was w

Dec 5, 2022

Questions and answers example project.

Question Answer Service REST Service for questions and answers Database modeling Directory tree pkg: Here is the main source code. sql: Here are all t

Dec 17, 2021

Go realworld example

TODOs Users and Authentication POST /user/login: Existing user login POST /users: Register a new user GET /user: Get current user PUT /user: Update cu

Dec 8, 2022

A golang example of gRPCtutorials.

A golang example of gRPCtutorials.

Nov 20, 2021

Learn-Nakama - An example project template on how to set up and write custom logic in Nakama server

Nakama Project Template An example project template on how to set up and write c

Apr 18, 2022

Go (Golang) Clean Architecture based on Reading Uncle Bob's Clean Architecture

Go (Golang) Clean Architecture based on Reading Uncle Bob's Clean Architecture

go-clean-arch Changelog v1: checkout to the v1 branch Proposed on 2017, archived to v1 branch on 2018 Desc: Initial proposal by me. The story can be r

Jan 1, 2023

Golang Clean Architecture based on Uncle Bob's Clean Architecture and Summer internship in 2021

clean-architecture-api Description This is an example of implemention of Clean Architecture in Golang projects. This project has 4 layer : Infrastruct

Feb 20, 2022

This is a POC (Proof of Concept) using Hexagonal Architecture, SOLID, DDD, Clean Code, Clean Architecture

This is a POC (Proof of Concept) using Hexagonal Architecture, SOLID, DDD, Clean Code, Clean Architecture

Projeto Planetas Star Wars: Esse projeto de trata de uma POC utilizando os conceitos de Clean Arch, Hexagonal Arch, Clean Code, DDD, e SOLID. O princi

Feb 10, 2022

Clean-todo - An example of go app with clean architecture

clean-todo An example of go app with clean application Functionality This is a s

Jan 26, 2022

Go clean architecture fully working example

Burp - clean architecture app Burp is a CRUD app managing beers. Front-end is written in Angular 12. Database in this example is mongodb. Root project

Nov 27, 2022

An example of implementation of Clean Architecture in Golang

Golang Template Description This is an example of implementation of Clean Archit

Dec 29, 2021

📸 Clean your image folder using perceptual hashing and BK-trees using Go!

📸 Clean your image folder using perceptual hashing and BK-trees using Go!

Image Cleaner 🏞 🏞 ➡ 🏞 This tool can take your image gallery and create a new folder with image-alike-cluster folders. It uses a perceptual image ha

Oct 8, 2022

Go-ant-pattern: An ant pattern parser

go-ant-pattern - An ant pattern parser. Usage package main import ( "fmt" "github.com/cbuschka/go-ant-pattern" ) func main() { path := "

Dec 7, 2021

Leader-follower-pattern - Build leader-follower system pattern with etcd election

主备系统模式 原理 使用分布式锁实现主备节点系统。通过对分布式锁进行续期,保持长期锁, 从而使当前服务节点处于主服务节点 无法获取分布式锁的服务节点,则作为备选

Jan 24, 2022

Cleanv - Golang SDK for Vue Projects. It is able to structure a clean code/arch pattern

Cleanv - Golang SDK for Vue Projects.  It is able to structure a clean code/arch pattern

Cleanv - Golang SDK for Vue Projects Why? This project is part of my personal portfolio, so, I'll be happy if you could provide me any feedback about

Apr 24, 2022

Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects.

Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects.

Clean Architecture checker for Golang go-cleanarch was created to keep Clean Architecture rules, like a The Dependency Rule and interaction between mo

Dec 31, 2022

CRUD API server of Clean Architecture with Go(Echo), Gorm, MySQL, Docker and Swagger

CRUD API server of Clean Architecture with Go(Echo), Gorm, MySQL, Docker and Swagger

CRUD API Server of Clean Architecture Go(echo) gorm mysql docker swagger build docker-compose up -d --build API Postman and Fiddler is recommended to

May 14, 2022
Comments
  • docker image is to big

    docker image is to big

    Hi sir, i'm a beginner with docker , when i run your docker file the image size is ~3.95GB ,can u provide a docker file which can build a smallest image. Kind regards

  • model depends on external package

    model depends on external package

    Hello! Why does your model have a dependency like "gorm.io/gorm". you will be forced to change the model if:

    1. the database provider will change (for example, from gorm to gopg)
    2. database type will change (mysql to mongodb) I think a method like BeforeCreate should be inside the repo in an implementation specific internal structure.
Clean Architecture in Go (Golang) projects-DDD
Clean Architecture in Go (Golang) projects-DDD

go-clean-arch Changelog v1: checkout to the v1 branch Proposed on 2017, archived to v1 branch on 2018 Desc: Initial proposal by me. The story can be r

Oct 11, 2021
At this example project, I'm trying to learn Golang with Clean structure and come up with a reusable

Learning Golang Language In Clean Structure At this example project, I'm trying to learn Golang with Clean structure and come up with a reusable, nice

Sep 25, 2022
A software architecture style example for APIs that utilizes the features of SOLID-Principle.
A software architecture style example for APIs that utilizes the features of SOLID-Principle.

Engelbyte's Waterbyte Clean Architecture A software architecture style example for APIs that utilizes the features of SOLID-Principle. The example sho

Feb 9, 2022
Go.work-workspace-example - Go1.18 workspace example

Go.work-workspace-example - Go1.18 workspace example

Jan 20, 2022
Go-design-pattern-examples - Golang implementations of common design patterns

Design Patterns Golang implementations of common design patterns Build project T

Oct 29, 2022
Learning Hexagonal Pattern with Golang

Marketplace Utility Software yang harus terinstal di komputer Software Versi Golang 1.17+ MariaDB 10.3+ Cara Menjalakan Clone repo ini Buat database d

Feb 10, 2022
DCI Architecture Implementation
DCI Architecture Implementation

前言 在面向对象编程的理念里,应用程序是对现实世界的抽象,我们经常会将现实中的事物建模为编程语言中的类/对象(“是什么”),而事物的行为则建模为方法(“做什么”)。面向对象编程有三大基本特性(封装、继承/组合、多态)和五大基本原则(单一职责原则、开放封闭原则、里氏替换原则、依赖倒置原则、接口分离原则

Dec 15, 2022
Example repository for embedding Litestream in a Go application.

Litestream as Library This repository is an example of embedding Litestream as a library in a Go application. The Litestream API is not stable so you

Dec 6, 2022
go mev-geth example. signTx,send transaction to relay.

go-mev-geth go mev-geth example. signTx,send transaction to relay. sample smart contract /eth/contract/mevtransfer/mevtransfer.sol pragma solidity 0.6

Dec 9, 2022
Example code for my Cadence Intro Workshop

Temporal Intro Workshop This repository contains example code for my Temporal Intro Workshop. Prerequisites Git, Make, etc. Make sure you have the lat

Dec 18, 2022