Skip to content

Service Design

Angelos Roussakis edited this page Aug 8, 2021 · 1 revision

Service Layout

  • cmd/SERVICE NAME/main.go → Where bootstrapping should take place.
  • config → keeps all the configuration files.
  • internal → should contain 2 folders: app & infra
  • internal/app/DOMAIN/aggregate.go → models representing the domain model/ DTO's. Those are the models that are passed around between services.ex: internal/app/account/aggregate.go → keeps the account domain models
  • internal/app/DOMAIN/service.go → service methods that call the repository 3rd party components (those are basically the adapters)
  • internal/app/DOMAIN/repository.go - holding as interface the methods needed from sql and | or remote (third party services) repository is implementing
  • internal/infra/http/http.go - the http server with response/request structures etc.
  • internal/infra/http/DOMAIN - the domain http handler
  • internal/infra/http/model.go - contains the request models and their respective methods to transform them into Data Transfer Objects (DTO)objects the app uses internally (see bullet 4)
  • internal/infra/repository/sql/sql.go → the initialisation of the DB
  • internal/infra/repository/sql/TABLE/models/xx.go → will hold the model that represents the table of the database (The TABLE_NAME in the path exists in order to make )
  • internal/infra/repository/sql/TABLE/repository.go → the repository methods talking to the database.
Clone this wiki locally