wiki

command module
v0.0.0-...-dbbb3a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 2 Imported by: 0

README

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 Maybe repository 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)

WIKI_STORE_TYPE=mongo go test -v

Architecture references and Tips

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL