All Projects → restuwahyu13 → go-clean-architecture

restuwahyu13 / go-clean-architecture

Licence: other
Example go clean architecture folder pattern

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to go-clean-architecture

DropBeat
A Music Player with downloading, playing, searching, exploring functions.
Stars: ✭ 13 (-53.57%)
Mutual labels:  clean-architecture
GitHubSearch
GitHub iOS client with minimum third-party dependencies.
Stars: ✭ 34 (+21.43%)
Mutual labels:  clean-architecture
paybill-manager
Your personal finance manager
Stars: ✭ 46 (+64.29%)
Mutual labels:  clean-architecture
clean-architecture-example
A simple clean architecture example in Kotlin and Spring Boot 2.0
Stars: ✭ 63 (+125%)
Mutual labels:  clean-architecture
app-from-scratch
Book about Clean Architecture and Clojure
Stars: ✭ 83 (+196.43%)
Mutual labels:  clean-architecture
car-rental
CarRental Project
Stars: ✭ 13 (-53.57%)
Mutual labels:  clean-architecture
React-CleanArchitecture-Example
Sample frontend project with Clean Architecture using React.js and jest.
Stars: ✭ 73 (+160.71%)
Mutual labels:  clean-architecture
MVPArchitecture
Android MVP architecture in Kotlin using Dagger2, RxJava2, Retrofit2 and so on
Stars: ✭ 27 (-3.57%)
Mutual labels:  clean-architecture
ModernKeePass
KDBX password manager for the Windows Store
Stars: ✭ 29 (+3.57%)
Mutual labels:  clean-architecture
CleanArchitectureMVVM
Example of Clean Architecture of Android app using MVVM, Koin, Coroutines, Retrofit, Room, Solid Principle, DRY, KISS, OOP
Stars: ✭ 60 (+114.29%)
Mutual labels:  clean-architecture
google-calendar-api
Demo Project for Google Calendar API Using Spring Boot Rest API with OAuth2
Stars: ✭ 25 (-10.71%)
Mutual labels:  google-api
clean-ddd-php-poc-contacts
A simple contact manager API to demonstrate the concepts of Clean Architecture and DDD with PHP 7.4+.
Stars: ✭ 31 (+10.71%)
Mutual labels:  clean-architecture
RSS-Reader
Simple project with clean architecture
Stars: ✭ 31 (+10.71%)
Mutual labels:  clean-architecture
archunit-junit5-kotlin
Generic Architecture Tests written in Kotlin using ArchUnit and Junit5
Stars: ✭ 22 (-21.43%)
Mutual labels:  clean-architecture
ApolloRickAndMorty
just a side project to try out GraphQL and Dagger Hilt with Clean architecture and MVVM
Stars: ✭ 28 (+0%)
Mutual labels:  clean-architecture
Compose-BreakingBad
🧪 ☠︎ Jetpack Compose - Breaking Bad ☢︎
Stars: ✭ 26 (-7.14%)
Mutual labels:  clean-architecture
buchu
Use Cases - Uniform, auditable and secure use case library
Stars: ✭ 23 (-17.86%)
Mutual labels:  clean-architecture
KotlinMvpTemplateGenerator
Android Studio template for Kotlin with MVP + Dagger2 + Retrofit2
Stars: ✭ 65 (+132.14%)
Mutual labels:  clean-architecture
MGCleanArchitecture
Clean Architecture with RxSwift & MVVM - Templates and Solutions
Stars: ✭ 156 (+457.14%)
Mutual labels:  clean-architecture
COVID-19-ANDROID
A simple android application builds for showcase COVID-19.
Stars: ✭ 21 (-25%)
Mutual labels:  clean-architecture

Golang Clean Architecture

The following is a folder structure pattern that I usually use, although I don't use all of them because of the project I'm working on only small projects that are not too big, so if you are interested in the pattern I made, you can use it if you think it's good.

Table Of Content

What Are The Benefits ?

  • Easy to maintance
  • Easy to scalable you project
  • Readable code
  • Suitable for large projects or small projects
  • Easy to understand for junior or senior
  • And more

Flow Diagram

flow-diagram

Folder Structure 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
│   └── helper.apiResponse.go
│   └── helper.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
│   └── script.gcpRunner.sh
│   └── script.awsRunner.sh
└── configs
│   └── openapi.yml
│   └── serverless.yml
└── cmd
│   └── cmd.pgMigration.go
│   └── cmd.pgSeeds.go
└── crons
│   └── cron.autoDeleteLogs.go
│   └── cron.emailBlast.go
└── databases
│   └── migrations
│   │     └── auth_20210913.go //generate auto by cli using third party library
│   │     └── student_20210913.go //generate auto by cli using third party library
│   └── seeds
│   │     └── auth_20210913.go //generate auto by cli using third party library
│   │     └── student_20210913.go //generate auto by cli using third party library
│   └── sql
│   │     └── database.auth.sql
│   │     └── database.student.sql

Folder Status And Description

  • Tests

Folder Name Folder Status Description
Tests Optional A collection of functions used to create a series of tests or run a test, be it unit testing or integration testing, which will later be used for the application itself.
  • Docker

Folder Name Folder Status Description
Docker Optional A collection of functions that are used to create a container for the application that has been created, which will later be used for the application itself.
  • Handlers

Folder Name Folder Status Description
Hanlders Optional A collection of functions used to handle all requests passed down from the client via routing, where later those requests will be forwarded to services and repositories for further processing, which will later be used for the application itself.
  • Repositorys

Folder Name Folder Status Description
Repositorys Required A collection of functions used to handle all requests given from handlers and services, which then those requests will be used to communicate with the database, which will later be used for the application itself.
  • Services

Folder Name Folder Status Description
Services Required A collection of functions that are used to forward requests given by handlers to repositories, which will later be used for the application itself.
  • Helpers

Folder Name Folder Status Description
Helpers Optional A collection of functions used to create utilities for application purposes, such as customError or customResponse, which will later be used for the application itself.
  • Middlewares

Folder Name Folder Status Description
Middlewares Optional A collection of functions that are used as a service for HTTP Requests such as authJWt, authRole, customLogger whether used per-route or used globally without the need to use them in each route, which will later be used for the application itself.
  • Models

Folder Name Folder Status Description
Models Required A collection of functions used to represent the table structure in a database, which will later be used for the application itself.
  • Routes

Folder Name Folder Status Description
Routes Required A collection of endpoints or addresses from the server itself, which is used for communication lines between the client and the server, which will later be used for the application itself.
  • Schemas

Folder Name Folder Status Description
Schemas Required A collection of functions that are used to represent the desired request structure, according to the requests required by the database, which will later be used for the application itself.
  • Templates

Folder Name Folder Status Description
Templates Optional A collection of functions that are used to output HTML code into emails to be used as templates, which will later be used for purposes such as activationCode or resetPassword, which will later be used for the application itself.
  • Pkg

Folder Name Folder Status Description
Pkg Optional A collection of functions that are used for the purpose of customizing a library into a separate function, which will later be used for the application itself.
  • Scripts

Folder Name Folder Status Description
Scripts Optional A collection of functions that are used to trigger a function from another function, such as importing a database from a .sql file into a container using docker, which will later be used for the application itself.
  • Configs

Folder Name Folder Status Description
Configs Optional A collection of functions that contains all the configurations related to the application needs, such as .env or serverless.yml, which will later be used for the application itself.
  • Cmd

Folder Name Folder Status Description
Cmd Optional A collection of functions that are used to interact directly with the terminal, usually used for purposes such as running database migrations or seeds, which will later be used for the application itself.
  • Crons

Folder Name Folder Status Description
Crons Optional A collection of functions that are used to trigger a desired function, according to the time specified by the user, which will later be used for the application itself.
  • Databases

Folder Name Folder Status Description
Databases Optional A collection of functions used to create migrations or seeds for the database, which will later be used for the application itself.

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

BACK TO TOP

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].