Project Layout Guide¶
1. Category¶
1.1. C/C++¶
The Pitchfork Layout (PFL) is a convention for arranging source, build, and resource files in a file system to support uniformity, comprehensibility, and partitioning.
1.1.1. Library¶
-
Layout and Structure
Note
Replace
<...>brackets with the library-specific information.<library>/ │ . `Hierarchical Structure` │ ├── inc/ │ └── <library>/ │ └── file.h │ ├── src/ │ │ │ . `Functional-based Structure` │ │ │ ├── file.c │ ├── file_test.cc │ ├── CMakeLists.txt │ └── README.md │ ├── external/ │ ├── <third-party>/ │ └── README.md │ ├── test/ │ ├── performance/ │ │ ├── benchmark_test.cc │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ └── README.md │ ├── examples/ │ ├── example.c │ ├── CMakeLists.txt │ └── README.md │ ├── docs/ │ ├── decisions/ │ │ └── adr-<topic>.md │ └── README.md │ ├── build/ │ ├── debug/ │ │ └── lib/ │ │ └── libprojectd.a │ └── release/ │ └── lib/ │ └── libproject.a │ ├── /tools │ ├── /cmake │ └── README.md │ ├── scripts/ │ ├── shell/ │ ├── python/ │ ├── bootstrap │ ├── setup │ ├── teardown │ └── README.md │ ├── CMakeLists.txt ├── CMakePresets.json ├── LICENSE └── README.md -
Files and Folders
1.1.2. Application¶
-
Layout and Structure
Note
Replace
<...>brackets with the application-specific information./<project> │ . `Hierarchical Structure` │ ├── /internal │ │ │ . `Layered Structure` │ │ │ ├── /presentation │ │ └── README.md │ │ │ ├── /application │ │ ├── CMakeLists.txt │ │ └── README.md │ │ │ ├── /domain │ │ ├── CMakeLists.txt │ │ └── README.md │ │ │ ├── /infrastructure │ │ ├── CMakeLists.txt │ │ └── README.md │ │ │ ├── CMakeLists.txt │ └── README.md │ ├── /external │ └── README.md │ ├── /test │ ├── /performance │ │ ├── benchmark_test.cc │ │ └── CMakeLists.txt │ ├── /integration │ │ ├── top_down_test.cc │ │ └── CMakeLists.txt │ ├── /e2e │ │ ├── scenario_test.cc │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ └── README.md │ ├── /examples │ ├── example.c │ ├── CMakeLists.txt │ └── README.md │ ├── /docs │ ├── /adr │ │ ├── merging-strategy-adr.md │ │ └── branching-strategy-adr.md │ ├── api.md │ └── README.md │ ├── /build │ ├── /bin │ │ └── project.exe │ ├── /lib │ │ └── project.a │ └── /cmake │ ├── /tools │ ├── /cmake │ └── README.md │ ├── scripts/ │ ├── shell/ │ ├── python/ │ ├── bootstrap │ ├── setup │ ├── teardown │ └── README.md │ ├── /data │ ├── dataset.csv │ └── README.md │ ├── CMakeLists.txt ├── LICENSE └── README.md -
Files and Folders
1.2. Go¶
1.2.1. Package¶
-
Layout and Structure
Note
Replace
<...>brackets with the package-specific information. -
Files and Folders
1.2.2. Application¶
Go Project Layout for applications. It is a set of common historical and emerging project layout patterns in the Go.
Note
It's not an official standard defined by the core Go dev team.
-
Layout and Structure
Note
Replace
<...>brackets with the application-specific information. -
Files and Folders
1.3. Python¶
Python Project Layout using best practices.
1.3.1. Module¶
-
Layout and Structure
Note
Replace
<...>brackets with the module-specific information. -
Files and Folders
1.3.2. Application¶
-
Layout and Structure
Note
Replace
<...>brackets with the application-specific information. -
Files and Folders
-
/module -
/docsPackage reference documentation.
-
/testsPackage unit tests, execution tests, integration tests.
-
/binHolds executable files.
-
setup.pyPackage and distribution management.
-
requirements.txtPackage dependency and version management.
-
1.4. Ansible¶
1.4.1. Collection¶
An Ansible Collection packages and distributes roles, modules and plugins. Organizing Ansible Collection content under a directory structure, it is crucial to follow a specific layout to ensure that Ansible can recognize and properly utilize the collection.
-
Layout and Structure
The project path is based on the
collections/ansible_collectionskeywords and the Fully Qualified Collection Name (FQCN)<namespace>.<collection>, in accordance with the naming convention.Note
None of the directories are required.
Note
Replace
<...>brackets with the project-specific information.<project>-ansible-collection/ └── collections/ └── ansible_collections/ └── <namespace>/ └── <collection>/ │ ├── meta/ │ └── runtime.yml │ ├── plugins/ │ ├── action/ │ ├── become/ │ ├── cache/ │ ├── callback/ │ ├── cliconf/ │ ├── connection/ │ ├── filter/ │ ├── httpapi/ │ ├── inventory/ │ ├── lookup/ │ ├── module_utils/ │ ├── modules/ │ │ ├── __init__.py │ │ └── <module>.py │ ├── netconf/ │ ├── shell/ │ ├── strategy/ │ ├── terminal/ │ ├── test/ │ └── vars/ │ ├── roles/ │ ├── <role-a>/ │ │ ├── defaults/ │ │ │ └── main.yml │ │ ├── files/ │ │ │ └── LICENSE │ │ ├── handlers/ │ │ │ └── main.yml │ │ ├── tasks/ │ │ │ └── main.yml │ │ ├── templates/ │ │ │ ├── config.yml.j2 │ │ │ └── docker-compose.yml.j2 │ │ ├── vars/ │ │ │ └── main.yml │ │ └── README.md │ └── <role-b>/ │ ├── defaults/ │ │ └── main.yml │ ├── handlers/ │ │ └── main.yml │ ├── tasks/ │ │ └── main.yml │ └── README.md │ ├── playbooks/ │ ├── files/ │ ├── vars/ │ ├── templates/ │ └── tasks/ │ ├── galaxy.yml └── README.md -
Files and Folders
-
galaxy.ymlThe source of the metadata file used to generate a collection on Galaxy and to build a collection artifact.
-
Modules
-
/meta -
runtime.yml -
plugins/The Collections plugins directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that is named after the type of plugin it is in. It can also include the
module_utilsandmodulesdirectory that would contain module utils and modules respectively. -
/modulesAt least one plugin
required. -
__init__.pyA
requiredempty file to initialize namespace and allow Python to import the files. -
/inventoryAt least one plugin
required. -
Roles
-
Playbooks
-
/docsDescribes the use of the roles, plugins and role requirements provided by the collection.
-
1.4.2. Playbook¶
Ansible Playbook directory layout organizes tasks in roles, with a inventory file for each environment and a playbooks.
Tip
The layout promotes separation of concerns and enables scalable management across multiple environments.
-
Layout and Structure
Note
Replace
<...>brackets with the project-specific information.<project>-ansible-playbook/ │ . `Modular Structure` │ ├── collections/ │ └── ansible_collections/ │ └── <namespace>/ │ ├── <collection-a>/ │ │ ├── meta/ │ │ │ └── runtime.yml │ │ ├── roles/ │ │ │ ├── <role-a>/ │ │ │ └── <role-b>/ │ │ ├── tests/ │ │ ├── docs/ │ │ ├── galaxy.yml │ │ └── README.md │ │ │ └── <collection-b>/ │ ├── meta/ │ │ └── runtime.yml │ ├── roles/ │ │ ├── <role-a>/ │ │ └── <role-b>/ │ ├── tests/ │ ├── docs/ │ ├── galaxy.yml │ └── README.md │ . `Hierarchical Structure` │ ├── playbooks/ │ ├── <playbook-a>.yml │ └── <playbook-b>.yml │ ├── inventory/ │ ├── dev/ │ │ ├── group_vars/ │ │ │ ├── all/ │ │ │ │ ├── all.yml │ │ │ │ └── vault.yml │ │ │ ├── <group-a>.yml │ │ │ └── <group-b>.yml │ │ ├── host_vars/ │ │ │ ├── <host-a.localhost>.yml │ │ │ └── <host-b.localhost>.yml │ │ └── hosts.yml │ ├── stage/ │ │ ├── group_vars/ │ │ │ ├── all/ │ │ │ │ ├── all.yml │ │ │ │ └── vault.yml │ │ │ ├── <group-a>.yml │ │ │ └── <group-b>.yml │ │ ├── host_vars/ │ │ │ ├── <staging.host-a.com>.yml │ │ │ └── <staging.host-b.com>.yml │ │ └── hosts.yml │ └── prod/ │ ├── group_vars/ │ │ ├── all/ │ │ │ ├── all.yml │ │ │ └── vault.yml │ │ ├── <group-a>.yml │ │ └── <group-b>.yml │ ├── host_vars/ │ │ ├── <host-a.com>.yml │ │ └── <host-b.com>.yml │ └── hosts.yml │ ├── site.yml ├── requirements.yml ├── ansible.cfg └── README.md -
Files and Folders
1.5. Terraform¶
1.5.1. Module¶
Terraform modules define self-contained, reusable resources of Infrastructure-as-Code (IaC). The Terraform module structure for reusable modules distributed in separate repositories.
-
Layout and Structure
Note
Replace
<...>brackets with the module-specific information.terraform-<provider>-<project>/ ├── modules/ │ ├── <module-a>/ │ │ ├── main.tf │ │ ├── data.tf │ │ ├── locals.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ ├── versions.tf │ │ └── README.md │ └── <module-b>/ │ ├── main.tf │ ├── data.tf │ ├── locals.tf │ ├── outputs.tf │ ├── variables.tf │ ├── versions.tf │ └── README.md │ ├── examples/ │ ├── simple/ │ │ ├── main.tf │ │ ├── variables.tf │ │ ├── outputs.tf │ │ ├── versions.tf │ │ └── README.md │ └── complete/ │ ├── main.tf │ ├── variables.tf │ ├── outputs.tf │ ├── versions.tf │ └── README.md │ ├── tests/ │ ├── unit/ │ │ ├── bucket_name.tftest.hcl │ │ ├── input_validation.tftest.hcl │ │ └── provider.tftest.hcl │ ├── integration/ │ │ └── modules.tftest.hcl │ └── README.md │ ├── main.tf ├── variables.tf ├── outputs.tf ├── versions.tf │ ├── LICENSE └── README.md -
Files and Folders
1.5.2. Project¶
A structured Terraform project designed to facilitate the management of Terraform configurations, reusable modules, and environment-specific settings.
Tip
The layout promotes separation of concerns and enables scalable management across multiple environments.
-
Layout and Structure
Note
Replace
<...>brackets with the project-specific information.terraform-<project>/ │ . `Modular Structure` │ ├── modules/ │ ├── <module-a>/ │ └── <module-b>/ │ . `Hierarchical Structure` │ ├── environments/ │ ├── dev/ │ ├── stage/ │ │ ├── <stack-a>/ │ │ │ ├── main.tf │ │ │ ├── backend.tf │ │ │ ├── provider.tf │ │ │ ├── locals.tf │ │ │ ├── variables.tf │ │ │ ├── outputs.tf │ │ │ ├── data.tf │ │ │ └── versions.tf │ │ └── <stack-b>/ │ └── prod/ │ ├── <stack-a>/ │ │ ├── main.tf │ │ ├── backend.tf │ │ ├── provider.tf │ │ ├── locals.tf │ │ ├── variables.tf │ │ ├── outputs.tf │ │ ├── data.tf │ │ └── versions.tf │ └── <stack-b>/ │ ├── tests/ │ └── README.md -
Files and Folders
-
Examples and Explanations
1.6. Kubernetes¶
1.6.1. Charts¶
Helm Charts as a packaging is a collection of to describe a related set of Kubernetes resources. The Chart File Structure of files inside of a directory.
Note
Helm reserves use of the charts/, crds/, and templates/ directories, and of the listed file names.
-
Layout and Structure
Note
Replace
<...>brackets with the charts-specific information. -
Files and Folders
Note
The template files follow the standard conventions for writing Go templates.
-
Chart.yamlA Helm chart defining the applications Kubernetes resources.
-
values.yamlThe default configuration values for this chart.
-
values.schema.jsonA OPTIONAL JSON Schema for imposing a structure on the
values.yamlfile. -
charts/A directory containing any charts upon which this chart depends.
-
crds/Kubernetes provides a mechanism for declaring new types of Kubernetes objects using CustomResourceDefinitions (CRDs).
-
templates/A directory of templates that, when combined with values, will generate valid Kubernetes manifest files.
-
_helpers.tplTODO
-
deployment.yamlTODO
-
hpa.yamlTODO
-
ingress.yamlTODO
-
service.yamlTODO
-
serviceaccount.yamlTODO
-
NOTES.txtA OPTIONAL plain text file containing short usage notes.
-
-
-
Examples and Explanations
-
Local Chart
Create a new local helm chart.
-
Vendor Chart
Vendor a public chart into
charts/and lock its version, e.g. pull app-a@1.4.2 into charts/app-a. -
Render Chart
Render a chart into
render/to validate e.g. Go templates.
-
1.6.2. Project¶
A structured Kubernetes project designed to facilitate the management of Kubernetes manifests, Helm charts, and environment-specific configurations using Kustomize.
Tip
The layout promotes separation of concerns and enables scalable management across multiple environments.
-
Layout and Structure
Note
Replace
<...>brackets with the project-specific information.k8s-<project>/ │ . `Modular Structure` │ ├── charts/ │ ├── <chart-a>/ │ └── <chart-b>/ │ . `Hierarchical Structure` │ ├── manifests/ │ ├── base/ │ │ ├── kustomization.yaml │ │ ├── namespace.yaml │ │ └── common-labels.yaml │ └── overlays/ │ ├── dev/ │ │ ├── kustomization.yaml │ │ └── patch.yaml │ ├── stage/ │ │ ├── kustomization.yaml │ │ └── patch.yaml │ └── prod/ │ ├── kustomization.yaml │ └── patch.yaml │ └── README.md -
Files and Folders
-
Examples and Explanations
# Usage: make k8s-deploy-<env> # ## Deploys Kubernetes manifests integrating Helm charts for application templating and Kustomize for environment-specific overlays k8s-deploy-%: kustomize build manifests/overlays/$* \ --enable-helm \ --load-restrictor=LoadRestrictionsNone \ | kubectl apply --kubeconfig examples/config/kubeconfig.yaml -f - .PHONY: k8s-deploy-% # Usage: make k8s-destroy-<env> # ## Destroys Kubernetes manifests integrating Helm charts for application templating and Kustomize for environment-specific overlays k8s-destroy-%: kustomize build manifests/overlays/$* \ --enable-helm \ --load-restrictor=LoadRestrictionsNone \ | kubectl delete --kubeconfig examples/config/kubeconfig.yaml -f - .PHONY: k8s-destroy-%
2. References¶
- Sentenz Project Layout article.