Skip to content

Latest commit

 

History

History
183 lines (99 loc) · 4.29 KB

CODE_MAP.md

File metadata and controls

183 lines (99 loc) · 4.29 KB

Code Map

Code Map explains how the codes are structured in this project. This document will list down all folders or packages and their purpose.


bin

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.


cmd

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.


db/migrations

This folder contains all database migration files. Each migration has exactly two files: UP and DOWN.


doc

This folder contains all documents related to the project.


dockerfile

This folder contains all dockerfiles related to the project.


entity

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.


feature

This folder contains all Cucumber definitions for the purpose of integration / API test. We use Gherkin syntax to define the features.


infrastructure

This folder contains any configuration for deployment infrastructure, such as monitoring, logging, kubernetes, etc.


internal

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.


internal/app

This folder contains the global variables related to the app.


internal/builder

This folder contains the builder design pattern. It composes all codes needed to build a full usecase.


internal/config

This folder contains configuration for the project.


internal/decorator

This folder contains decorator pattern implementation.


internal/grpc/handler

This folder contains the HTTP/2 gRPC handlers. Codes in this folder implement gRPC server interface.


internal/grpc/server

This folder contains the HTTP/2 gRPC server.


internal/grpc-gateway/server

This folder contains the HTTP/1.1 grpc gateway server.


internal/messaging

This folder contains codes that connect to the message queue system, such as Kafka and Redis Queue.


internal/repository

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.


internal/script

This folder contains all scripts related to the service.


internal/server

This folder contains high-level interface to define a server. It also contains server manager.


openapiv2

This folder contains API definition for HTTP/1.1 REST. The contents of this folder are generated from .proto as well.


pkg

This folder contains exported toggle functionality, such as client SDK to connect with toggle.


proto

This folder contains .proto files and all files generated from or based on .proto.


service

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.


test

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.


test/fixture

This folder contains a well defined support for test.


test/mock

This folder contains mock for testing.