Clean Architecture with GO

Introducing Clean architecture with Go.

Image for post
Image for post
Clean Architecture with Go

Example repo

Pre-requisites

The darkness of software design

Advantages in Clean Architecture

Image for post
Image for post
The Clean Architecture

The only rules you need to know

1. The dependencies can only point inward

Image for post
Image for post
The dependencies only point inward

2. Separation of details and abstracts

Image for post
Image for post
The flow of control

The Layers

Entities

Use Cases

Interface Adapter

Frameworks and Drivers

Implementation of Clean Architecture in GO

.
├── domain
│ └── model
│ └── user.go
├── infrastructure
│ ├── datastore
│ │ └── db.go
│ └── router
│ └── router.go
├── interface
│ ├── controller
│ │ ├── app_controller.go
│ │ ├── context.go
│ │ └── user_controller.go
│ ├── presenter
│ │ └── user_presenter.go
│ └── repository
│ └── user_repository.go
├── main.go
├── registry
│ ├── registry.go
│ └── user_registry.go
├── usecase
│ ├── presenter
│ │ └── user_presenter.go
│ ├── repository
│ │ └── user_repository.go
│ └── interactor
│ └── user_interactor.go
Image for post
Image for post
Directory and Layer

Entities Layer

Use Cases Layer

Interface Adapter Layer

Frameworks and Drivers Layer

Registry

Booting

Image for post
Image for post

Conclusion

Written by

Web Developer, TypeScript, React, React Native, Vue.js, Go, Swift, and Ruby on Rails https://manatoworks.me/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store