Examples and Usage Patterns

This document walks through common envstack usage patterns at a conceptual level and points to concrete examples under the examples/ directory.

The goal is to show how envstack is typically used, not to exhaustively document every feature.

Basic stacked environment

Pattern: single base environment with simple defaults

This is the simplest envstack use case and a direct evolution of a .env file.

flowchart LR default[default.env] --> local[local.env]

Typical characteristics:

Common use cases:

Example:
examples/default/

Environment tiers (dev / prod / CI)

Pattern: shared base + environment-specific overrides

A common pattern is to define a shared base environment and layer environment tiers on top (e.g. dev, prod, CI).

flowchart LR default[default.env] --> prod[prod.env] prod --> dev[dev.env] prod --> test[test.env]

Typical characteristics:

Common use cases:

Example:
examples/default/

Project-level environments

Pattern: shared facility base + project-specific configuration

Projects often share infrastructure but differ in paths, naming, or behavior. envstack models this naturally through inheritance and layering.

flowchart LR default[default.env] --> prod[prod.env] prod -. include .-> project[project.env]

Typical characteristics:

Common use cases:

Example:
examples/project/

Hierarchical composition

Pattern: base → environment → project → task

This pattern combines multiple layers into a single stack, with each layer responsible for a specific concern.

flowchart LR default --> env --> project --> task

Typical characteristics:

Common use cases:

Summary

These examples demonstrate how envstack is typically used to model real-world environment configuration:

Start with the simplest example and build up complexity as needed.