Skip to content

Structuring Netherframe at Scale

When an infrastructure repository grows from one engineer's prototype to dozens of services and multiple teams, the most important design decision is where to draw state, approval, and repository boundaries.

For single-project file layouts, start with Project Structure. This guide covers organization-level scaling patterns.


1. Choosing boundaries: Stack vs. App vs. Graph State

Boundary State unit Plan / approval unit Best used when
Multiple Stacks in one App Shared state One whole-app plan & approval; stacks apply in parallel Tightly coordinated domains owned by one team (e.g., network + compute + observability for a service).
Separate Apps Separate state per app Independent saved plans, IAM roles, and blast radius Different lifecycles or teams (e.g., shared VPC foundation vs. product microservices vs. stateful databases).
One shared App on PostgreSQL Graph State Row-level transactional state Per-branch plans with --concurrent-applies and --graph-plan-scope affected Platform-wide shared apps where multiple teams deploy disjoint changes concurrently without splitting into dozens of tiny states.

Rule of thumb for splitting Apps

Split into separate Apps whenever two domains have:

  • Different blast-radius or approval policies (e.g., base VPC/IAM vs. rapid app releases)
  • Different IAM credentials or AWS accounts
  • Different change cadence (quarterly networking changes vs. hourly service deploys)

Avoid splitting so aggressively that every deploy requires manually copying outputs across six repositories.


2. Monorepo vs. multi-repo with uv workspaces

Use a uv workspace so shared internal construct packages and individual apps share one lockfile, pinned provider versions, and unified pytest + nf lint CI checks:

infra-monorepo/
  pyproject.toml                 # uv workspace root + [tool.nf].apps
  packages/
    acme-net/                    # shared internal constructs (standard Python package)
      pyproject.toml
      acme_net/vpc.py
    acme-policies/               # internal nf.lint_packs plugin
      pyproject.toml
      acme_policies/rules.py
  apps/
    foundation/app.py            # foundation app (rare changes, strict approval)
    payments/app.py              # payments app (owned by @acme/payments)
    search/app.py                # search app (owned by @acme/search)
  envs/
    dev.toml
    staging.toml
    prod.toml
  tests/
    test_foundation.py
    test_payments.py
# Root pyproject.toml
[tool.uv.workspace]
members = ["packages/*"]

[tool.nf]
apps = [
  "apps.foundation.app:foundation",
  "apps.payments.app:payments",
  "apps.search.app:search",
]

Publish shared internal construct libraries (acme-infra-constructs), pinned generated provider wheels, and internal nf.lint_packs packages to your private Python package index (Artifactory, Nexus, Cloud Artifact Registry, or GitHub Packages):

# In each product repository:
uv add netherframe.cli acme-infra-constructs==1.4.0 acme-lint-pack==2.1.0

Teams upgrade shared infrastructure building blocks through normal semantic-versioned dependency PRs rather than implicit Git branch references.


3. Sharing values across separate Apps

  • Within one App: Pass Python construct references directly across Stacks (vpc.output.id).
  • Across separate Apps: Avoid tight state-file coupling. Publish stable discovery identifiers (SSM parameters, Route 53 records, tags, or deterministic names) from the foundation app and read them via DataSource (for example, SsmParameterDataSource or VpcDataSource) in downstream apps.

4. Team guardrails, CODEOWNERS, and TUI safety

  • Enforce policy in code, not just CI YAML: Attach shared app.check functions (no prod deletes, maintenance window, blast-radius cap, mandatory finalizer) inside a company-wide helper create_standard_app(...) so every app inherits them automatically— even for local runs.
  • Protect production in nf tui: Mark production app selectors read-only by default in pyproject.toml:
    [tool.nf.tui]
    readonly = ["foundation", "payments_prod"]
    
  • Pair CODEOWNERS with per-app CI jobs: Trigger nf plan --app <changed_app> per directory path and route PR approvals to the owning team.
  • Use corporate provider mirrors: Point [tool.nf.config].provider_mirrors at your internal Artifactory/Nexus mirror so every developer and CI runner fetches verified, approved provider binaries reliably.