Chengchang Yu
Published on

Repo Discussion for 3 tier architecture for a containerized application

Authors

This follow-up explores repository structure decisions for the 3-tier containerized application architecture introduced in prevoius post

Option 1: Single Repository (If team is small <5 people)

project/
├── infrastructure/          # All Terraform
├── application/            # All app code
├── kubernetes/             # All K8s configs
├── scripts/
└── .github/workflows/

Option 2: Multi Repositories

1. infrastructure

Everything infrastructure-related:

infrastructure/
├── terraform/
│   ├── modules/
│   │   ├── networking/
│   │   ├── eks/
│   │   ├── rds/
│   │   ├── elasticache/
│   │   ├── ecr/
│   │   └── monitoring/
│   └── environments/
│       ├── dev/
│       ├── staging/
│       └── prod/
├── kubernetes/
│   ├── base/
│   │   ├── namespaces/
│   │   ├── rbac/
│   │   ├── network-policies/
│   │   └── ingress/
│   └── overlays/
│       ├── dev/
│       ├── staging/
│       └── prod/
├── helm-charts/
│   ├── monitoring-stack/
│   └── logging-stack/
├── scripts/
│   ├── deploy-infra.sh
│   ├── deploy-k8s.sh
│   └── dr-failover.sh
├── policies/
│   ├── opa/
│   └── security-policies/
└── .github/workflows/
    ├── terraform-plan.yml
    └── terraform-apply.yml

Purpose:

  • All Terraform code for AWS resources
  • All Kubernetes manifests and Helm charts
  • Deployment scripts
  • Infrastructure CI/CD

2. application (or whatever your app is called)

Your actual application code:

application/
├── backend/
│   ├── src/
│   ├── tests/
│   └── Dockerfile
├── frontend/
│   ├── src/
│   ├── tests/
│   └── Dockerfile
├── kubernetes/
│   ├── backend/
│   │   ├── deployment.yaml
│   │   ├── service.yaml
│   │   └── hpa.yaml
│   └── frontend/
│       ├── deployment.yaml
│       ├── service.yaml
│       └── hpa.yaml
└── .github/workflows/
    ├── build-backend.yml
    ├── build-frontend.yml
    └── deploy.yml

Purpose:

  • Application source code
  • Application-specific Kubernetes manifests
  • Application CI/CD

Why This Split?

AspectInfrastructure RepoApplication Repo
Changes byPlatform/DevOps teamDevelopment team
Change frequencyLow (weekly/monthly)High (daily)
Deployment impactHigh riskMedium risk
Approval neededSenior engineersTeam leads
LifecycleLong-term, stableIterative, frequent

Summary:

Choose single repo if:

  • Team < 5 people
  • Everyone works on everything
  • Simpler is better for your context

Choose multi repos if:

  • Team > 5 people
  • Clear separation between platform and app teams
  • Want independent deployment cycles