Based on well known Uncle Bob's article, The Clean Architecture, and sample from Bxcodec
I didn't test yet but it should be something similar to this
glide install
docker-compose up
Clean Architecture as I understand, it all about split application in to independence layer which must be test separately and can swapable.
Here we have models
, repository
, usecase
and delivery
as four layers.
models
- contain a struct that represent things in our application.repository
- provide low level operations such as CRUD. In this example we have aMongoUserRepositoty
but we also haveUserRepository
interface then someday we might change fromMongo
toMysql
usecase
- contain business logic about thing. For example,CreateUser
,ResetPassword
,DeactivateUser
andGetUser
.delivery
- contain delivery method such asHTTP
orgRPC
One last thing, if you take a look at app.go
, it might look mess because of all dependencies setup go here but it will be easy when write a unit test.
- Add unit test
- Add more usecase
- Add more delivery method
- Add http authentication