Project composition
This doc defines the rules for plat5 init, plat5 add, plugins, and registries. Reference shapes live in ../reference/plugin.md and ../reference/registry.md.
Terminology
Section titled “Terminology”kinds— reserved exclusively for Plat5’s resource hierarchy (organization,project,environment) inplat5.yml.type— what a registry entry is (idp,authorizer,observability,ci,deployfor integrations;service,customer-console,operator-consolefor templates;examplefor standalone runnable examples).slot— where an integration or template attaches in a project (e.g. atype: idpintegration can fill either theidpslot or theoperator-idpslot; atype: authorizerintegration can fillauthorizeroroperator-authorizer).
Principles
Section titled “Principles”- First-party uses the community system. Official integrations and templates (
go-fiber-service,auth0,cerbos,grafana-cloud,github-actions, …) are authored in the exact sameplat5.plugin.ymlformat and distributed through the exact sameregistry.ymlmechanism as third-party plugins. The only special thing about the official registry (plat5dev/registry) is that it is preconfigured as the default. - Protocols are the boundaries, not source-code branches. Layers compose at open standards—RFC 9068 JWT/JWKS for authentication, OpenID AuthZEN 1.0 for authorization, OTLP for telemetry, and Docker Compose
include:for local runtime—not by templatingif auth0 && cerbosconditionals across service source files. - Multi-service by default (plug-and-play DDD slices). Plat5’s gateway routes to any number of independent services (
services/*.yml).type: servicetemplates are0..N: a project can start bare or add polyglot domain slices anytime (plat5 add go-fiber-service --as orders,plat5 add bun-effect-service --as billing). Every slice shares the project’s tenancy tree, authn, authz, audit log, rate limits, and OTEL tracing. - Declarative and safe. Running
plat5 initorplat5 addexecutes no untrusted plugin scripts. Plugins declare manifests, static files,[[ ]]templates, prompts, optional read-only HTTP verification probes, and structured YAML merge-patches. - Projects own what init/add writes. Generated services, policies, Compose files, and CI workflows belong to the project, not to a runtime dependency.
- Valid before touching disk. Every assembled
plat5.ymland itsservices/*.yml—including cross-service route collision checks—are validated in memory against Plat5’s embedded JSON Schemas before a single file is written. - Interactive and scriptable stay equivalent. Every interactive wizard run produces a typed
Specand prints the exact non-interactiveplat5 initflags that reproduce it.
Managed core vs. project-owned components
Section titled “Managed core vs. project-owned components”To avoid growing hardcoded modules in the CLI for every third-party tool, local runtime ownership splits cleanly in two:
| Owned by | What lives there | How plat5 start runs it |
|---|---|---|
CLI (bundle/stack/) |
Plat5 core (gateway, control-plane, identity, audit, postgres, valkey) and optional first-party sidecars (plat5-auth, operator, lgtm, alloy) |
Embedded Compose files in the plat5-<project_id> compose project |
Project infra (docker-compose.infra.yml) |
Project-owned infrastructure: external AuthZEN PDPs (cerbos, topaz, openfga), local IdPs (keycloak, dex), dev mail (mailpit) |
include:d in docker-compose.infra.yml (infra.compose), auto-joined to the plat5 network; stays running with plat5 start -x app |
Project apps (docker-compose.yml) |
Application services & DDD slices (api/, billing/, orders/), customer & operator consoles |
include:d in docker-compose.yml (app.compose), auto-joined to the plat5 network; skipped by plat5 start -x app so you can run apps on your host |
plat5 start discovers which project services must join the plat5 network by reading hostnames referenced in:
plat5.yml(services.*.url)operator.yml(authorizer.urlandservices.*.url)plat5.local.yml(authorizer.url,idp.jwks_uri,operator.idp.jwks_uri, andotel.endpoint)
Any project-owned container referenced by one of those URLs is automatically reachable from Plat5’s gateways without modifying the CLI. Inside the plat5 network, services are addressed by container name (http://billing:3000, http://api:3000), so multiple slices can listen on the same internal port without colliding.
Slots and cardinality
Section titled “Slots and cardinality”A project Spec attaches plugins to orthogonal slots:
| Slot | Accepts plugin type |
Cardinality | Role |
|---|---|---|---|
idp |
idp |
0..1 (default plat5-auth) |
Customer authentication (modules.auth or idp: block, optional local IdP container) |
authorizer |
authorizer |
0..1 (default plat5-rbac) |
Customer authorization (built-in RBAC or external AuthZEN 1.0 PDP + starter policies) |
service |
service |
0..N | Application APIs and plug-and-play domain slices (services/<name>.yml, <name>/, compose include) |
customer-console |
customer-console |
0..1 | General-purpose customer starter UI (customer-console/, compose file, app.web) adapted to your plat5.yml |
operator-console |
operator-console |
0..1 | General-purpose operator starter UI (operator-console/, compose file, operator.console) adapted to your plat5.yml |
operator-idp |
idp |
0..1 | Operator authentication (operator.idp:) |
operator-authorizer |
authorizer |
0..1 | Operator authorization (operator.yml authorizer:) |
observability |
observability |
0..1 (default local-lgtm) |
Telemetry pipeline (local-lgtm, grafana-cloud, OTLP vendor, or none) |
ci |
ci |
0..N | Additive CI workflows (GitHub Actions, GitLab CI, Docker build/push) |
deploy |
deploy |
0..N | Additive deployment assets (environment overlays, Helm, Kustomize, ArgoCD) |
Every plat5 init starts from one built-in canonical plat5.yml (organization → project, admin/member/developer/viewer, flat standard rate limit) that you own and edit freely. Standalone complete apps (type: example in registry.yml, such as tasks-saas, topaz-documents, enterprise-sso) are plain runnable directories copied via plat5 init <dir> --example <id>.
Single-select slots (0..1) implicitly replace/conflict with another plugin in the same slot. Multi-select slots (0..N) compose additively; two plugins writing the same output path, registering the same service name, or declaring overlapping HTTP routes fail during planning/validation before touching disk.
The assembly pipeline
Section titled “The assembly pipeline”Both plat5 init and plat5 add execute the same six stages. Stages 1–5 perform zero writes to the project directory.
1. Resolve Fetch manifests and files from registries, owner/repo//subdir@ref, .tar.gz URLs, or local paths; match cli: semver floors.2. Check Verify requires / conflicts across all selected plugins (and existing project state for plat5 add).3. Prompt Collect missing prompt values (flags/spec → interactive wizard → defaults); optionally run read-only verify HTTP probes.4. Assemble Apply fragments in two deterministic phases to build an in-memory Plan: Phase 1 (Integrations): a. base plat5.yml → built-in default (on init) or existing plat5.yml (on add) b. authorizer → patch plat5.yml (roles only, authorizer + roles, or authorizer only) c. idp / operator / observability → patch plat5.local.yml, operator.yml, infra compose d. finalize meta → reconcile authorizer/roles fields and extract Kinds + HasAuthorizer/ManagesRoles Phase 2 (Templates & Ops): e. service (0..N) → copy/render each service dir + services/<name>.yml with Kinds & separator f. consoles → copy/render consoles from finalized Kinds + ManagesRoles, wire origins g. ci / deploy → render additive workflows, overlays, deploy files h. routegen.Generate → synthesize services/identity.yml + services/audit.yml i. hygiene → assemble .env.example, .env.local, .gitignore5. Validate Run plat5yml.Config.Validate() on the assembled plat5.yml + services/*.yml (verifying schema rules, referenced kinds, and cross-service route overlaps), plus validate plat5.local.yml and operator.yml in memory.6. Emit Apply the Plan to disk (refusing unexpected overwrites unless --force), writing .env.local with mode 0600, and print the reproducible CLI command.Why routegen.Generate runs after services
Section titled “Why routegen.Generate runs after services”Running routegen.Generate after authorizer and all service templates guarantees two things automatically:
- Permission separator adaptation: If an authorizer declares
capabilities.permission_separator: "_"(e.g. Topaz, which forbids:),services/identity.yml,services/audit.yml, and every[[.Perm "billing" "read"]]inservices/*.ymlandplat5.ymluse_consistently, androutes.permission_separator: "_"is written toplat5.local.yml. - Claimed-route deduplication: If a service plugin wraps a lifecycle route such as
POST /orgs,routegen.Generateomits it fromservices/identity.ymlautomatically.
Secret hygiene
Section titled “Secret hygiene”Plugins may prompt for credentials (Stripe API keys, Grafana Cloud tokens, OTLP headers, AuthZEN PDP bearer tokens, IdP client secrets). The engine enforces three hard rules:
- Any prompt with
type: secretorenventry withsecret: trueis never written intoplat5.local.yml,plat5.yml,operator.yml, ordocker-compose.yml. - Secret values are written only to
.env.local(file mode0600). Config files reference them by${ENV_VAR}interpolation ortoken_env: ENV_VAR. - Every project with a
.env.localalso gets.env.example(key names + comments, no secret values) and.env.localadded to.gitignore.
Day-2 additions (plat5 add)
Section titled “Day-2 additions (plat5 add)”Because blueprint.Build emits an explicit Plan (CreateFile, MergeYAML, AppendLines, AddComposeInclude), plat5 add <ref> reuses the same pipeline against an existing project directory:
plat5 add stripe-billing # type: service inferred from manifest → billing/ + services/billing.ymlplat5 add go-fiber-service --as orders # instantiate a bare starter under a custom service nameplat5 add github-actions # type: ci inferred → .github/workflows/*plat5 add okta --slot operator-idp # disambiguate slot when a type can attach to either planeplat5 add stripe-billing --dry-run # preview file diff and config changes without writing- Reads existing
plat5.yml,services/*.yml,plat5.local.yml,operator.yml,docker-compose.infra.yml, anddocker-compose.ymlas the starting state instead of the built-in defaultplat5.yml. - Patches existing YAML files at the
yaml.NodeAST level so hand-written comments and key ordering are preserved. - Renders service and console templates against the project’s actual
plat5.ymlKinds,HasAuthorizer, andManagesRoles(including any hierarchy edits you made afterinit). - Runs
plat5yml.Config.Validate()across existing + newly added services before writing, catching route collisions or missing kinds immediately. - Refuses to overwrite existing non-managed files unless
--forceis passed.
Package boundaries in cli/
Section titled “Package boundaries in cli/”To keep composition fast to test and shared by both init and add, the implementation separates into four packages:
| Package | Responsibility | Side effects |
|---|---|---|
internal/registry |
Registry config, index fetching, ETag cache, cli: version matching, archive/subdir extraction |
Network + cache dir only |
internal/plugin |
plat5.plugin.yml parsing, schema validation, compatibility checking |
Read-only FS |
internal/blueprint |
Template rendering, YAML fragment merging, routegen, in-memory validation, Plan generation |
Pure (zero TTY, zero stdout, zero disk writes) |
internal/wizard |
Interactive Bubble Tea + huh shell (New project vs. Example, Back navigation, live stack summary, async verify spinners) |
Terminal UI only |
internal/cmd/init.go and internal/cmd/add.go are thin adapters binding flags onto command-local structs (no package-global flag state), invoking wizard when interactive, calling blueprint.Build, and applying the resulting Plan.