# tiangong-lca/pcr architecture

> Architecture diagram of the GitHub repository tiangong-lca/pcr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tiangong-lca/pcr
- Repository: https://github.com/tiangong-lca/pcr

## Overview

TianGong LCA PCR Library stores canonical product-category-rule methodology and classification mappings, with tooling to author, validate, publish and consume them. The authoring path imports classification data or edits PCR records, checks and publishes revisions, then exposes the catalog through the public documentation site and viewer. Consumers resolve classification codes or read PCR guidance through the CLI. The local Goal Harness coordinates bounded authoring tasks and integration/landing. The README documents major subsystems not represented in sampled source; those links are shown only where it explicitly establishes the relationship.

Main entry points: [`builder/cli/index.mjs`](https://github.com/tiangong-lca/pcr/blob/main/builder/cli/index.mjs) (Builder CLI), [`builder/goal-harness/orchestrator.mjs`](https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/orchestrator.mjs) (Goal orchestration), [`packages/pcr-core/src/index.mjs`](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-core/src/index.mjs) (PCR core), [`builder/lib/cpc-scaffold.mjs`](https://github.com/tiangong-lca/pcr/blob/main/builder/lib/cpc-scaffold.mjs) (CPC import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["PCR authoring"]
  node_builder_cli["Builder CLI<br/>[index.mjs]"]
  node_builder_ops["PCR lifecycle tools"]
  node_cpc_import["CPC import<br/>[cpc-scaffold.mjs]"]
end

subgraph group_catalog["Catalog and classification"]
  node_pcr_records[("Canonical PCR records")]
  node_classifications[("Classification data")]
end

subgraph group_consumption["Consumer products"]
  node_core["PCR core<br/>[index.mjs]"]
  node_public_cli["PCR consumer CLI<br/>[commands.mjs]"]
  node_docs_content["Documentation content source<br/>[content-source.mjs]"]
  node_docs_site["Public documentation site"]
  node_search_dialog["Documentation search<br/>[search-dialog.tsx]"]
  node_search_client["Search client<br/>[search-client.ts]"]
  node_search_worker["Search worker<br/>[search-worker.mjs]"]
  node_viewer["PCR viewer<br/>[app.js]"]
  node_viewer_data[("Viewer snapshots<br/>[snapshot-store.mjs]")]
end

subgraph group_harness["Goal Harness"]
  node_goal_cli["Goal CLI<br/>[goal.mjs]"]
  node_goal_orchestrator["Goal orchestration<br/>[orchestrator.mjs]"]
  node_author_review["Author review<br/>[author-review.mjs]"]
  node_repository_coordinator["Repository coordinator"]
  node_goal_state[("Harness event state<br/>[event-store.mjs]")]
end

node_author(("PCR author"))
node_consumer(("PCR guidance consumer"))
node_external_classification["CPC source data"]

node_author -->|"runs commands"| node_builder_cli
node_builder_cli -->|"dispatches lifecycle"| node_builder_ops
node_builder_cli -->|"dispatches import"| node_cpc_import
node_external_classification -->|"provides source"| node_cpc_import
node_cpc_import -->|"writes normalized data"| node_classifications
node_builder_ops -->|"updates lifecycle"| node_pcr_records
node_builder_cli -->|"checks records"| node_pcr_records
node_pcr_records -->|"provides PCR data"| node_core
node_classifications -->|"provides mappings"| node_core
node_core -->|"serves consumption"| node_public_cli
node_consumer -->|"requests guidance"| node_public_cli
node_core -->|"provides read model"| node_docs_content
node_docs_content -->|"supplies content"| node_docs_site
node_consumer -->|"browses guidance"| node_docs_site
node_search_dialog -->|"submits queries"| node_search_client
node_search_client -->|"posts query"| node_search_worker
node_search_worker -->|"returns results"| node_search_client
node_viewer_data -->|"provides snapshots"| node_viewer
node_consumer -->|"browses snapshots"| node_viewer
node_author -->|"starts goal"| node_goal_cli
node_goal_cli -->|"dispatches operation"| node_goal_orchestrator
node_goal_orchestrator -->|"records events"| node_goal_state
node_goal_orchestrator -->|"reviews commits"| node_author_review
node_goal_orchestrator -->|"coordinates integration"| node_repository_coordinator
node_repository_coordinator -->|"persists coordination"| node_goal_state

click node_builder_cli "https://github.com/tiangong-lca/pcr/blob/main/builder/cli/index.mjs"
click node_builder_ops "https://github.com/tiangong-lca/pcr/blob/main/builder/lib/builder-operations.mjs"
click node_cpc_import "https://github.com/tiangong-lca/pcr/blob/main/builder/lib/cpc-scaffold.mjs"
click node_pcr_records "https://github.com/tiangong-lca/pcr/tree/main/library/pcrs"
click node_classifications "https://github.com/tiangong-lca/pcr/tree/main/classifications"
click node_core "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-core/src/index.mjs"
click node_public_cli "https://github.com/tiangong-lca/pcr/blob/main/packages/tiangong-pcr-cli/src/commands.mjs"
click node_docs_content "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/lib/content-source.mjs"
click node_docs_site "https://github.com/tiangong-lca/pcr/tree/main/packages/pcr-docs/app"
click node_search_dialog "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/components/search-dialog.tsx"
click node_search_client "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/lib/search-client.ts"
click node_search_worker "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/lib/search-worker.mjs"
click node_viewer "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-viewer/static/app.js"
click node_viewer_data "https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-viewer/scripts/snapshot-store.mjs"
click node_goal_cli "https://github.com/tiangong-lca/pcr/blob/main/builder/cli/goal.mjs"
click node_goal_orchestrator "https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/orchestrator.mjs"
click node_author_review "https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/author-review.mjs"
click node_repository_coordinator "https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/repository-coordinator.mjs"
click node_goal_state "https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/event-store.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_builder_cli,node_builder_ops,node_cpc_import toneBlue
class node_pcr_records,node_classifications toneAmber
class node_core,node_public_cli,node_docs_content,node_docs_site,node_search_dialog,node_search_client,node_search_worker,node_viewer,node_viewer_data toneMint
class node_goal_cli,node_goal_orchestrator,node_author_review,node_repository_coordinator,node_goal_state toneRose
class node_author,node_consumer,node_external_classification toneIndigo
```

## Components

### PCR authoring

- [Builder CLI](https://github.com/tiangong-lca/pcr/blob/main/builder/cli/index.mjs): `builder/cli/index.mjs`
- [PCR lifecycle tools](https://github.com/tiangong-lca/pcr/blob/main/builder/lib/builder-operations.mjs): `builder/lib/builder-operations.mjs`
- [CPC import](https://github.com/tiangong-lca/pcr/blob/main/builder/lib/cpc-scaffold.mjs): `builder/lib/cpc-scaffold.mjs`

### Catalog and classification

- [Canonical PCR records](https://github.com/tiangong-lca/pcr/tree/main/library/pcrs): `library/pcrs`
- [Classification data](https://github.com/tiangong-lca/pcr/tree/main/classifications): `classifications`

### Consumer products

- [PCR core](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-core/src/index.mjs): `packages/pcr-core/src/index.mjs`
- [PCR consumer CLI](https://github.com/tiangong-lca/pcr/blob/main/packages/tiangong-pcr-cli/src/commands.mjs): `packages/tiangong-pcr-cli/src/commands.mjs`
- [Documentation content source](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/lib/content-source.mjs): `packages/pcr-docs/lib/content-source.mjs`
- [Public documentation site](https://github.com/tiangong-lca/pcr/tree/main/packages/pcr-docs/app): `packages/pcr-docs/app`
- [Documentation search](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/components/search-dialog.tsx): `packages/pcr-docs/components/search-dialog.tsx`
- [Search client](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/lib/search-client.ts): `packages/pcr-docs/lib/search-client.ts`
- [Search worker](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-docs/lib/search-worker.mjs): `packages/pcr-docs/lib/search-worker.mjs`
- [PCR viewer](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-viewer/static/app.js): `packages/pcr-viewer/static/app.js`
- [Viewer snapshots](https://github.com/tiangong-lca/pcr/blob/main/packages/pcr-viewer/scripts/snapshot-store.mjs): `packages/pcr-viewer/scripts/snapshot-store.mjs`

### Goal Harness

- [Goal CLI](https://github.com/tiangong-lca/pcr/blob/main/builder/cli/goal.mjs): `builder/cli/goal.mjs`
- [Goal orchestration](https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/orchestrator.mjs): `builder/goal-harness/orchestrator.mjs`
- [Author review](https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/author-review.mjs): `builder/goal-harness/author-review.mjs`
- [Repository coordinator](https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/repository-coordinator.mjs): `builder/goal-harness/repository-coordinator.mjs`
- [Harness event state](https://github.com/tiangong-lca/pcr/blob/main/builder/goal-harness/event-store.mjs): `builder/goal-harness/event-store.mjs`

### Other components

- **PCR author**
- **PCR guidance consumer**
- **CPC source data**

## Connections

- PCR author → Builder CLI: runs commands
- Builder CLI → PCR lifecycle tools: dispatches lifecycle
- Builder CLI → CPC import: dispatches import
- CPC source data → CPC import: provides source
- CPC import → Classification data: writes normalized data
- PCR lifecycle tools → Canonical PCR records: updates lifecycle
- Builder CLI → Canonical PCR records: checks records
- Canonical PCR records → PCR core: provides PCR data
- Classification data → PCR core: provides mappings
- PCR core → PCR consumer CLI: serves consumption
- PCR guidance consumer → PCR consumer CLI: requests guidance
- PCR core → Documentation content source: provides read model
- Documentation content source → Public documentation site: supplies content
- PCR guidance consumer → Public documentation site: browses guidance
- Documentation search → Search client: submits queries
- Search client → Search worker: posts query
- Search worker → Search client: returns results
- Viewer snapshots → PCR viewer: provides snapshots
- PCR guidance consumer → PCR viewer: browses snapshots
- PCR author → Goal CLI: starts goal
- Goal CLI → Goal orchestration: dispatches operation
- Goal orchestration → Harness event state: records events
- Goal orchestration → Author review: reviews commits
- Goal orchestration → Repository coordinator: coordinates integration
- Repository coordinator → Harness event state: persists coordination
