• Stars
    star
    212
  • Rank 186,122 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

A web application boilerplate built with go and clean architecture.

go-clean-architecture-web-application-boilerplate

A web application boilerplate built with go and clean architecture. Most of this application built by standard libray.

image

Get Started

cp app/.env_example app/.env docker-compose build docker-compose up

After running docker, you need to execute sql files in app/database/sql.

Architecture

app
โ”œโ”€โ”€ database
โ”‚ย ย  โ”œโ”€โ”€ migrations
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ schema.sql
โ”‚ย ย  โ””โ”€โ”€ seeds
โ”‚ย ย      โ””โ”€โ”€ faker.sql
โ”œโ”€โ”€ domain
โ”‚ย ย  โ”œโ”€โ”€ post.go
โ”‚ย ย  โ””โ”€โ”€ user.go
โ”œโ”€โ”€ infrastructure
โ”‚ย ย  โ”œโ”€โ”€ env.go
โ”‚ย ย  โ”œโ”€โ”€ logger.go
โ”‚ย ย  โ”œโ”€โ”€ router.go
โ”‚ย ย  โ””โ”€โ”€ sqlhandler.go
โ”œโ”€โ”€ interfaces
โ”‚ย ย  โ”œโ”€โ”€ post_controller.go
โ”‚ย ย  โ”œโ”€โ”€ post_repository.go
โ”‚ย ย  โ”œโ”€โ”€ sqlhandler.go
โ”‚ย ย  โ”œโ”€โ”€ user_controller.go
โ”‚ย ย  โ””โ”€โ”€ user_repository.go
โ”œโ”€โ”€ log
โ”‚ย ย  โ”œโ”€โ”€ access.log
โ”‚ย ย  โ””โ”€โ”€ error.log
โ”œโ”€โ”€ main.go
โ””โ”€โ”€ usecases
    โ”œโ”€โ”€ logger.go
    โ”œโ”€โ”€ post_interactor.go
    โ”œโ”€โ”€ post_repository.go
    โ”œโ”€โ”€ user_interactor.go
    โ””โ”€โ”€ user_repository.go

8 directories, 22 files
Layer Directory
Frameworks & Drivers infrastructure
Interface interfaces
Usecases usecases
Entities domain

API

ENDPOINT HTTP Method Parameters
/users GET
/user GET ?id=[int]
/posts GET
/post POST
/post DELETE ?id=[int]

Controller method naming rule

Controller Method HTTP Method Description
Index GET Display a listing of the resource
Store POST Store a newly created resource in storage
Show GET Display the specified resource
Update PUT/PATCH Update the specified resource in storage
Destroy DELETE Remove the specified resource from storage

Repository method naming rule

Repository Method Description
FindByXX Returns the entity identified by the given XX
FindAll Returns all entities
Save Saves the given entity
SaveByXX Saves the given entity identified by the given XX
DeleteByXX Deletes the entity identified by the given XX
Count Returns the number of entities
ExistsBy Indicates whether an entity with the given ID exists

cf. Spring Data JPA - Reference Documentation

Tests

I have no tests because of my laziness, but I will prepare tests in github - gobel-api which is a my more practical clean architecture application with golang.

References

More Repositories

1

Rubel

Rubel is a cms built with Laravel and React.
PHP
71
star
2

goblin

A golang http router based on trie tree.
Go
53
star
3

gobel-api

Gobel is a headless cms built with golang.
Go
26
star
4

godon

Godon is a simple L4 load balancer built with golang
Go
19
star
5

oilking

A trading bot using bitflyer api.
Go
9
star
6

react-redux-spa-boilerplate

The SPA boilerplate working with react, react-redux, react-router, redux-form, redux-promise.
JavaScript
5
star
7

setup-kubernetes-cluster-on-vps-boilerplate

This is a boilerplate for setup kubernetes cluster on vps by terraform and ansible.
HCL
5
star
8

sea.css

sea.css is a simple and easy to use css framework.
CSS
4
star
9

akashi-slack-slash-command

This is a slack slash command for Akashi
Go
3
star
10

bmf-php-router

The simple URL router built with PHP
PHP
3
star
11

introduction-to-golang-http-router-made-with-net-http

It is a repository to introduce how to implement your own HTTP router with golang.
Go
3
star
12

vagrant-development-workflow

Vagrant Development Workflow
2
star
13

go-mysqldump

This is a mysqldump tool working with golang.
Go
2
star
14

akashigo

Go library for accessing the akashi API
Go
2
star
15

golem

A leveled logger in json format built with golang.
Go
2
star
16

terraform-ansible-openstack-boilerplate

Boilerplate for building vps using terraform and ansible.
HCL
2
star
17

psr4-autoloader-boilerplate

PSR-4 Autoloader Boilerplate
PHP
2
star
18

bitflyer-chat-morphological-analysis

Bitflyer Chat Morphological Analysis
PHP
2
star
19

go-router-benchmark

Benchmark tests for http router implemented in golang.
Go
2
star
20

laravel-test-handson

This is handson for feature test of laravel
PHP
1
star
21

goemon

A dotenv built with golang.
Go
1
star
22

bitflyer-private-api-and-slack-api-sample

Bitflyer Private Api And Slack Api Sample
JavaScript
1
star
23

bitbankgo

Go library for accessing the bitbank API
Go
1
star
24

docker-based-monitoring-stack-boilerplate

This is a boilerplate for docker based monitoring stack.
Dockerfile
1
star
25

go-snippets

This is my go snippets.
Go
1
star
26

gobel-admin-client-example

Gobel is a headless cms built with golang.
Vue
1
star
27

road-to-vimmer

This is a workbook for studing vim
1
star
28

book-introduction-to-golang-http-router-made-with-net-http

Introduction to Golang HTTP router made with net/http.
1
star
29

gobel-client-example

Gobel is a headless cms built with golang.
Go
1
star
30

docs-md-to-pdf-example

This is a document management sample that converts markdown format documents to PDF format. It supports emoji, toc generation, and mermaid.
JavaScript
1
star