Wiki: a web application with clean architecture for Golang
Goal
Make a simple CRUD wiki based on the clean architecture.
Architecture(Project directory structure)
cmd: entry for the app
app: Web application Source
script: various script(e.g. build, docker-compose, etc...)
cmd
This is an entry to run my app. I didn't need this until now.
app
Most of codes are located here. They are ordered by dependencies.
initialize: Initialize the app configurations. Build Container
configs: Manage configurations for the app.
router: Router group and its handler. Sanitize request so usecase doesn't have to know where requests come from. This depends on usecase.
rest: Manage a router group for REST API
grpc: Manage a router griyo for gRPC API but I think this won't be needed.
usecase: Most of business(application) logic. This depends on data_service and model.
user: usecase about user
data_service: Handle the work about data. Data source can be mongo, MySQL, other microservices.
This works with interface and there are only unified input independent of which data_service you use and output. The output would be model.
This depends on model
Mayberepository would be needed to convert unified input into proper input for each data service.
local_memory: Use just local memory and mock data for dev.
dynamo
mongo
model: Basic model like User, Project, Comment, not UseCase or DataService.
Validation can be included. This might be the lowest level.
container(dependency execption): This is the only one part
which is independent from dependency and manages it. This can be some
dependency injection frameworks like dig, fx and wire.
This creates concrete struct. Creating struct should refer to interface, so
we separated creating inside container.
This let ancestor objects not to pass pointers or values for descendants.
e.g. - Supposing descendant B should refer to C, with container, ancestor A doesn't have to
pass C to B because B can refer to C through container.
What I removed from general clean architecture in Golang
adapter: I don't need converting input and output depending on the infrastructure and communicating methods very much.
internal and pkg: I think web application doesn't need this.
script
docker-compose
build
run
...
How to test
This application can execute tests.
WIKI_STORE_TYPE means what you will use as the data store. (e.g. mongo or just memory)