Skip to content

Repository Organization

Alan Cleary edited this page Nov 23, 2021 · 2 revisions

This repository is a monorepo, meaning it houses multiple applications (microservices) that are independently versioned. However, to enable automated builds and the use of Protocol Buffers by external programs there is a Standard Operating Procedure for how the contents of this repository should be organized.

Top-Level Contents

The top-level of the repository should only contain three things:

  1. Git/GitHub related content
  2. The global Protocol Buffer directory
  3. Microservice directories

Git/GitHub related content

This includes the following files:

root/
├── .github/
├── .gitignore
├── LICENSE
└── README.md

The .github/ directory contains GitHub specific content, such as the repository's CODE_OF_CONDUCT.md file and the GitHub Workflow that builds Docker container images when releases are tagged.

The .gitignore file is a top-level ignore file, i.e. microservice-specific files that should be ignored by git should go in the appropriate microservice directory's .gitignore file, not the top-level .gitignore file.

The LICENSE file contains the software license under which all contents of the repository are bound. It is recommended that individual microservices also contain a copy of this license to be distributed with the microservice when they are built.

The global Protocol Buffer directory

Normalizing data types across microservices is encouraged. As such, any data type a microservice that supports gRPC uses (other than service specific messages) should be defined in global Protocol Buffer files, i.e. they are "owned" by the repository and independently versioned, rather than being tied to any one microserrvice. All such Protocol Buffers should be put in the top-level proto/ directory:

root/
└── proto/

See the Protocol Buffers page for more information on how the contents of the proto/ directory should be organized and used, and see the Tagging Releases and Automated Builds page for more information on how Protocol Buffers should be versioned.

Microservice Directories

Each microservice should be contained in its own top-level directory. The name of a microservice's directory should conform to the standards of the language it is implemented in. For example, microservices impllemented in Python should use the PEP 8 package naming convention - all lowercase with optional underscores:

root/
├── <microservice_1>/
├── <microservice_2>/
├── ...
└── <microservice_n>/

Microservices

The top-level of each microservice directory should contain three things:

  1. A Dockerfile
  2. A readme file
  3. Git/GitHub related content

Additionally, if the microservice supports gRPC, then it must also contain:

  1. A Protocol Buffer directory

Specifically, a microservice should have the following top-level file structure:

root/
└── <microservice>/
    ├── proto/
    ├── .gitignore
    ├── Dockerfile
    ├── LICENSE
    └── README.md

The README.md file is required and should explain what the microservice does and how to install and run it.

The Dockerfile file is also required. At a minimum, this should build a container image for use in production. It is encouraged to use a multi-stage build that also provides a container image for development. See the Tagging Releases and Automated Builds page for information on how to automate building and publishing the container images defined in this file.

The .gitignore file is not required but should be used to specify any files specific to the microservice that should be ignored by git.

The LICENSE file is also not required. If it is included, it should be a copy of the LICENSE file at the top-level of the repository.

The proto/ directory is only required if the microservice supports gRPC. It should contain the Protocol Buffers that define the service's gRPC messages and copies of any global Protocol Buffers that define data types the service uses. See the Protocol Buffers page for information on how these files should be organized and how global Protocol Buffers should be copied into microservice directories in a version controlled manner.

Clone this wiki locally