Code Map explains how the codes are structured in this project. This document will list down all folders or packages and their purpose.
This folder contains any executable binary to support the project.
For example, there is generate-mock.sh
. It is a shell script file used to generate mocks for all interfaces available in this project.
This folder contains the main.go
.
The use case may be run and served in multi forms, such as API, cron, or fullstack web.
To cater that case, cmd
folder can contains subfolders with each folder named accordingly to the form and contain only main package.
e.g: cmd/api/main.go
, cmd/cron/main.go
, and cmd/web/main.go
For this project, we prefer to use cmd/server/main.go
as our use cases are only in the form of gRPC server.
This folder contains all database migration files. Each migration has exactly two files: UP and DOWN.
This folder contains all documents related to the project.
This folder contains all dockerfiles related to the project.
This folder contains the domain of the project.
Mostly, this folder contains only structs, constants, global variables, enumerations, or functions with simple logic related to the core domain of the module (not a business logic).
Since we use Protocol Buffer, entity has a close (tightly coupled) relationship with any struct generated from .proto
files.
This folder contains all Cucumber definitions for the purpose of integration / API test. We use Gherkin syntax to define the features.
This folder contains any configuration for deployment infrastructure, such as monitoring, logging, kubernetes, etc.
All APIs/codes in the internal folder (and all if its subfolders) are designed to not be able to be imported.
This folder contains all detail implementation specified in the service
folder.
This folder contains the global variables related to the app.
This folder contains the builder design pattern. It composes all codes needed to build a full usecase.
This folder contains configuration for the project.
This folder contains decorator pattern implementation.
This folder contains the HTTP/2 gRPC handlers. Codes in this folder implement gRPC server interface.
This folder contains the HTTP/2 gRPC server.
This folder contains the HTTP/1.1 grpc gateway server.
This folder contains codes that connect to the message queue system, such as Kafka and Redis Queue.
This folder contains codes that connect to the repository, such as database. Repository is not limited to databases. Anything that can be a repository can be put here.
This folder contains all scripts related to the service.
This folder contains high-level interface to define a server. It also contains server manager.
This folder contains API definition for HTTP/1.1 REST.
The contents of this folder are generated from .proto
as well.
This folder contains exported toggle functionality, such as client SDK to connect with toggle.
This folder contains .proto
files and all files generated from or based on .proto
.
This folder contains the main business logic of the project. Almost all interfaces and all the business logic flows are defined here. If someone wants to know the flow of the project, they better start to open this folder.
This folder contains test related stuffs. For the case of unit test, the unit test files are put in the same directory as the files that they test. It is one of the Go best practice, so we follow.
This folder contains a well defined support for test.
This folder contains mock for testing.