Skip to content

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.

  • kinds — reserved exclusively for Plat5’s resource hierarchy (organization, project, environment) in plat5.yml.
  • type — what a registry entry is (idp, authorizer, observability, ci, deploy for integrations; service, customer-console, operator-console for templates; example for standalone runnable examples).
  • slot — where an integration or template attaches in a project (e.g. a type: idp integration can fill either the idp slot or the operator-idp slot; a type: authorizer integration can fill authorizer or operator-authorizer).
  1. First-party uses the community system. Official integrations and templates (go-fiber-service, auth0, cerbos, grafana-cloud, github-actions, …) are authored in the exact same plat5.plugin.yml format and distributed through the exact same registry.yml mechanism as third-party plugins. The only special thing about the official registry (plat5dev/registry) is that it is preconfigured as the default.
  2. 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 templating if auth0 && cerbos conditionals across service source files.
  3. Multi-service by default (plug-and-play DDD slices). Plat5’s gateway routes to any number of independent services (services/*.yml). type: service templates are 0..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.
  4. Declarative and safe. Running plat5 init or plat5 add executes no untrusted plugin scripts. Plugins declare manifests, static files, [[ ]] templates, prompts, optional read-only HTTP verification probes, and structured YAML merge-patches.
  5. Projects own what init/add writes. Generated services, policies, Compose files, and CI workflows belong to the project, not to a runtime dependency.
  6. Valid before touching disk. Every assembled plat5.yml and its services/*.yml—including cross-service route collision checks—are validated in memory against Plat5’s embedded JSON Schemas before a single file is written.
  7. Interactive and scriptable stay equivalent. Every interactive wizard run produces a typed Spec and prints the exact non-interactive plat5 init flags that reproduce it.

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.url and services.*.url)
  • plat5.local.yml (authorizer.url, idp.jwks_uri, operator.idp.jwks_uri, and otel.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.

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.

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, .gitignore
5. 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.

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"]] in services/*.yml and plat5.yml use _ consistently, and routes.permission_separator: "_" is written to plat5.local.yml.
  • Claimed-route deduplication: If a service plugin wraps a lifecycle route such as POST /orgs, routegen.Generate omits it from services/identity.yml automatically.

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:

  1. Any prompt with type: secret or env entry with secret: true is never written into plat5.local.yml, plat5.yml, operator.yml, or docker-compose.yml.
  2. Secret values are written only to .env.local (file mode 0600). Config files reference them by ${ENV_VAR} interpolation or token_env: ENV_VAR.
  3. Every project with a .env.local also gets .env.example (key names + comments, no secret values) and .env.local added to .gitignore.

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.yml
plat5 add go-fiber-service --as orders # instantiate a bare starter under a custom service name
plat5 add github-actions # type: ci inferred → .github/workflows/*
plat5 add okta --slot operator-idp # disambiguate slot when a type can attach to either plane
plat5 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, and docker-compose.yml as the starting state instead of the built-in default plat5.yml.
  • Patches existing YAML files at the yaml.Node AST level so hand-written comments and key ordering are preserved.
  • Renders service and console templates against the project’s actual plat5.yml Kinds, HasAuthorizer, and ManagesRoles (including any hierarchy edits you made after init).
  • 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 --force is passed.

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.