• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    Go
  • Created about 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example go clean architecture folder pattern

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, check this link for new update for this architecture here.

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

More Repositories

1

go-rest-api

Example golang using gin framework everything you need, i create this tutorial special for beginner.
Go
123
star
2

express-rest-api-clean-architecture

About Folder pattern for express rest api starterkit clean architecture, easy to scalable and easy to maintenance.
TypeScript
96
star
3

express-mvc-pattern

Example nodejs using express implementation design pattern using mvc architecture.
TypeScript
79
star
4

bangjago-android-emulator

Simple android emulator cli for mobile development
Batchfile
77
star
5

golang-pos

Example golang point of sale.
Go
45
star
6

midtrans-node

Unoffficial Midtrans Payment API Client for Node JS | Alternative for Midtrans Official Module | https://midtrans.com
TypeScript
26
star
7

competitive-programming

Competitive Programming Exercises
21
star
8

javascript-fundamentals

Tutorial Javascript Basic to Advanced
JavaScript
21
star
9

express-microservices-jobs-portal

example simple microservices using express.js building jobs portal reference by glints
TypeScript
19
star
10

jwt-transform

Transform your real jwt token into fake jwt token.
TypeScript
19
star
11

react-boilerplate

minimalize modern react boilerplate created using webpack 4 include technology pwa and include popular tools for react developer
JavaScript
18
star
12

express-payment-gateway

express payment gateway rest api
TypeScript
16
star
13

node-disk-storage

Fast and Secure local storage persistent data for Node JS
TypeScript
15
star
14

go-playground-converter

Formatter error response inspiration like express-validator in nodejs build on top go-playground-validator
Go
14
star
15

express-mini-project

example mini project using express real world application
JavaScript
12
star
16

golang-testing-fundamental

Example basic fundamental testing in golang
Go
11
star
17

express-todo-bullmq

todo app example express.js implementation custom pub/sub using bullmq and redis
JavaScript
11
star
18

express-graphql-clean-architecture

Folder pattern for express graphql starterkit clean architecture, easy to scalable and easy to maintenance, explore documentation for more about this starterkit https://typegraphql.com
TypeScript
11
star
19

node-nginx

simple setup node with nginx on docker for beginner
JavaScript
10
star
20

streambox-collection

streambox-collection is a lightweight utility as a wrapper for displaying objects, arrays, strings, and number formats to clients using data streams.
TypeScript
9
star
21

Ongkir-App

mini project delivery cost app uses Rajaongkir Api using MERN + Redux
JavaScript
9
star
22

go-trakteer-api

Building simple trakteer app like trakteer.id or saweria using chi router.
Go
9
star
23

mern-real-auth

this case example implementation MERN real word authentication include simple app Caesar Chritography
JavaScript
9
star
24

golang-rabbitmq-rpc

Example rabbitmq rpc pattern using messaging pattern (Request & Reply)
Go
8
star
25

node-grpc

Basic concept GRPC and sample implementation using nodejs and typescript
JavaScript
8
star
26

gocek

Gocek is a simple tools for BDD / TDD testing assertion library for golang.
Go
8
star
27

react-fakers

React-Fakers is a collection of dummy data for application development testing
JavaScript
7
star
28

react-todolist-redux-saga

example react todo app using redux saga
HTML
7
star
29

sijago

SiJago is GraphQL Client for browser and node, you can write request graphql schema using javascript object style.
TypeScript
7
star
30

go-jwt-transform

Transform your real jwt token into fake jwt token.
Go
7
star
31

go-supertest

Go Supertest is minimalize HTTP Client Testing only for Gin Framework, inspired by Supertest package library HTTP Client Testing for Express.js Framework.
Go
7
star
32

express-booking-room-rest-api

express booking room rest api
JavaScript
6
star
33

graphql-typedefs-loader

Multiple loader for graphql schema file
TypeScript
6
star
34

golang-scanner-app

Example mini project golang scanner application
Go
6
star
35

is-any-type

Simple functionality alternative to check data type references such as typeof and instanceof.
TypeScript
6
star
36

node-facebook-bot

example automation nodejs bot facebook status using puppeteer
JavaScript
6
star
37

kraken-node

Dependency injection to register module to global access, you can load each given module from kraken.config.json
TypeScript
6
star
38

express-grpc-rest-api

example express crud using grpc (google remote procedure call) rest api
TypeScript
6
star
39

automation-with-jenkins

Example automation deploy, using jenkins.
JavaScript
6
star
40

express-refactor-starterkit

This is sample code for refactor my starterkit https://github.com/restuwahyu13/express-rest-api-clean-architecture
TypeScript
6
star
41

express-simple-microservices

example simple implementation microservices using cote.js
JavaScript
5
star
42

gopack-cli

Instant package downloader for Go programming
TypeScript
5
star
43

node-kafka

Basic fundamental concept for Kafka
JavaScript
5
star
44

securing-upload

Tips & tricks to secure uploaded file/image sensitive.
TypeScript
5
star
45

node-own-package

step by step how to build your own package library in nodejs using javascript and typescript
JavaScript
5
star
46

express-opp-pattern

example simple implementation nodejs oop pattern using express framework
JavaScript
5
star
47

express-krakend

demo example simple microservices using krakend
JavaScript
5
star
48

natural-utility

natural-utility is a simple helper tool to get easily your work as a module loader, route middleware, plugin middleware and flash message.
JavaScript
5
star
49

express-redux

understand the basic ways of using redux in a javascript application with express js
JavaScript
5
star
50

express-cronjob-api-key

this method is a simple implementation of how to provide double extra protection on each route api
JavaScript
4
star
51

express-for-beginner

learning nodejs framework using express series complete for beginner
JavaScript
4
star
52

vanilla-javascript-with-redux

understand the basic ways of using redux in a javascript application
JavaScript
4
star
53

express-graphql

example how to use graphql in express
JavaScript
4
star
54

express-microservices

Express microservices tecnical test from YC W22.
TypeScript
4
star
55

docker-production-setup

Example docker for production setup using golang.
Dockerfile
4
star
56

node-rabbitmq

Basic fundamental concept for RabbitMQ
TypeScript
4
star
57

kraken-browser

Dependency injection to register module to global access, you can load each given module from kraken config
TypeScript
4
star
58

database-caching

Simple tips and trick how to reduce and speed up your load data from database or third-party api.
TypeScript
4
star
59

stress-testing-api

Example stress testing using siege cli alternative for locust.
Shell
3
star
60

express-testing-collection

This repository is testing collection using nodejs and express framework
JavaScript
3
star
61

express-load-testing-api

example api load testing using locusts
JavaScript
3
star
62

express-booking-room-graphql

express booking room graphql api
JavaScript
3
star
63

express-book-store

Example book store api using Express + Typescript and Knex ORM + Objection.
TypeScript
3
star
64

nodejs-load-balancer

Example nodejs load balancer using express + docker + nginx
TypeScript
3
star
65

express-sequelize-typescript

FullStack MERN (MYSQL, EXPRESS, REACT, NODE)
TypeScript
3
star
66

deno-purenative

example fetch data api and render template using custom router and custom template
TypeScript
3
star
67

queue-redis-cluster

example bull and bullmq using redis cluster
JavaScript
3
star
68

express-cronjob-rate-limit

express middleware simple cronjob rate limit request API from user
JavaScript
3
star
69

gin-unit-testing

example simple implementation unit testing using go and gin framework
Go
3
star
70

grpc-typescript-config

grpc typescript config for generating proto file to javascript and typescript using makefile
3
star
71

realtime-streaming-data

Realtime streaming data with Socket.io and Kafka.
JavaScript
3
star
72

go-microservices

TypeScript
2
star
73

nyelem

Simple Kubernetes deployment tool for automating creation, configuration, and deployment of applications and services for Kubernetes.
TypeScript
2
star
74

differences-lifecycle-method-react

differences each lifecycle method in react js
JavaScript
2
star
75

node-purenative

example rest api using pure native nodejs include mongodb database
JavaScript
2
star
76

golang-pm2

Example running golang application using pm2
Dockerfile
2
star
77

nestjs-crud-api

Example Nestjs CRUD API + JWT Authorization + Redis + Elasticsearch.
TypeScript
2
star
78

golang-kafka-rcp

Example kafka rpc pattern using messaging pattern (Request & Reply)
Go
2
star
79

express-ssl

generate free ssl certificate for development mode for using https protocol
JavaScript
2
star
80

docker-rootless

Docker Rootless mode for production environtment
Dockerfile
2
star
81

express-todo-redis

todo app example express.js with redis custom pub/sub implementation
JavaScript
2
star
82

express-todo-list

TypeScript
2
star
83

node-scraper-content

example node scraper all content programming using puppeteer
JavaScript
2
star
84

express-reverse-proxy

example reverse proxy using http proxy middleware without nginx
JavaScript
2
star
85

nextjs-with-redux

example basic implementation nextjs using redux with create simple counter app
JavaScript
2
star
86

devsecops-with-jenkins

Simple implementation devsecops with jenkins, sonarqube & trivy
TypeScript
2
star
87

feathersjs-starterkit

feathersjs starterkit project, refactoring concept structure from featherjs for better experience, relate with my express starterkit here https://github.com/restuwahyu13/express-rest-api-clean-architecture.
TypeScript
2
star
88

agtran-test-backend

agtran test backend developer
TypeScript
2
star
89

mini-project-php-native

example mini project with php native use raja ongkir api
PHP
2
star
90

phone-service-api

Tecnical Test from PT.Sun Artha Putra Mandiri for Junior Backend Developer Position.
TypeScript
1
star
91

go-http-roundtripper

Example HTTP Client Round Tripper Request
Go
1
star
92

graphql-with-php

example simple setup graphql with php
PHP
1
star
93

secure-keys-message-brokers

Tips to securing event name for message brokers
TypeScript
1
star
94

blog-api-service

Tecnical Test from Zettabyte Pte Ltd for Junior Backend Developer Position.
JavaScript
1
star
95

jest-basic-mocking

Example basic fundamental mocking using nodejs and jest
JavaScript
1
star
96

node-rabbitmq-ae

Example rabbitmq alternate exchange configuration policy
TypeScript
1
star
97

node-shared-modules

Tips and tricks how to create shared modules between service.
TypeScript
1
star
98

snap-collection-tools

This repo tools for help you integration with API Services BI SNAP.
Go
1
star
99

nodejs-restapi

All example REST API Request
JavaScript
1
star
100

golang-grpc

Example simple implementation GRPC using golang as services and nodejs as gateway.
TypeScript
1
star