# google/oss-rebuild architecture

> Architecture diagram of the GitHub repository google/oss-rebuild, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google/oss-rebuild
- Repository: https://github.com/google/oss-rebuild

## Overview

OSS Rebuild reproduces selected upstream open-source package builds and publishes attestations that can be checked against upstream artifacts. The main user path is package/version lookup through the CLI or dashboard to stored rebuild and attestation data; the service API also exposes rebuild and inference operations. Ecosystem-specific rebuilders cover npm, PyPI, and Crates.io, while the README documents successful attestation publication and verification. Additional branches include automated analysis, an AI-assisted agent, and snapshot-backed dashboard reads. Some service internals were not sampled, so those subsystem links are documented or omitted rather than inferred.

Main entry points: [`pkg/rebuild/rebuild/rebuild.go`](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/rebuild/rebuild.go) (Rebuild Workflow), [`pkg/rebuild/rebuild/storage.go`](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/rebuild/storage.go) (Attestation Store), [`internal/api/apiservice`](https://github.com/google/oss-rebuild/tree/main/internal/api/apiservice) (API Operations), [`cmd/api/main.go`](https://github.com/google/oss-rebuild/blob/main/cmd/api/main.go) (Core API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["User Access"]
  node_cli["Rebuild CLI<br/>[main.go]"]
  node_dashboard["Web Dashboard<br/>[main.go]"]
end

subgraph group_services["Service APIs"]
  node_api["Core API<br/>[main.go]"]
  node_api_handlers["API Operations"]
  node_agent_api["Agent API<br/>[main.go]"]
  node_inference["Inference Service<br/>[infer.go]"]
end

subgraph group_rebuild["Rebuild Engine"]
  node_rebuild_flow["Rebuild Workflow<br/>[rebuild.go]"]
  node_npm["npm Rebuilder<br/>[rebuild.go]"]
  node_pypi["PyPI Rebuilder<br/>[rebuild.go]"]
  node_crates["Crates.io Rebuilder<br/>[rebuild.go]"]
  node_debian["Debian Rebuilder<br/>[rebuild.go]"]
  node_maven["Maven Rebuilder<br/>[rebuild.go]"]
  node_stabilizer["Artifact Stabilizer<br/>[stabilizer.go]"]
end

subgraph group_analysis["Analysis and Automation"]
  node_agent["Rebuild Agent<br/>[session.go]"]
  node_analyzer["Network Analyzer<br/>[analyze.go]"]
  node_system_analyzer["System Analyzer<br/>[analyze.go]"]
  node_feed["Package Feed<br/>[tracker.go]"]
end

subgraph group_state["Data and Attestations"]
  node_attestations[("Attestation Store<br/>[storage.go]")]
  node_db[("Run Database<br/>[db.go]")]
  node_snapshots[("Snapshot Service<br/>[snapshot.go]")]
end

node_user(("Package User"))
node_upstream(("Upstream Ecosystems"))

node_user -->|"requests rebuild data"| node_cli
node_user -.->|"explores rebuilds"| node_dashboard
node_cli -.->|"reads rebuild data"| node_attestations
node_dashboard -->|"reads snapshot data"| node_snapshots
node_api -->|"routes requests"| node_api_handlers
node_api -->|"configures inference"| node_inference
node_api_handlers -.->|"serves rebuild operations"| node_rebuild_flow
node_agent_api -.->|"serves agent operations"| node_agent
node_agent -->|"iterates rebuild work"| node_rebuild_flow
node_rebuild_flow -.->|"supports ecosystem builds"| node_npm
node_rebuild_flow -.->|"supports ecosystem builds"| node_pypi
node_rebuild_flow -.->|"supports ecosystem builds"| node_crates
node_rebuild_flow -.->|"supports rebuilds"| node_debian
node_rebuild_flow -.->|"supports rebuilds"| node_maven
node_upstream -->|"provides package inputs"| node_rebuild_flow
node_rebuild_flow -->|"publishes attestations"| node_attestations
node_upstream -->|"artifact comparison"| node_attestations
node_feed -->|"enqueues analysis"| node_analyzer
node_feed -->|"enqueues analysis"| node_system_analyzer
node_analyzer -.->|"writes analysis attestations"| node_attestations
node_system_analyzer -.->|"writes analysis attestations"| node_attestations
node_api_handlers -.->|"persists run state"| node_db
node_user -->|"verifies signatures"| node_attestations

click node_cli "https://github.com/google/oss-rebuild/blob/main/cmd/oss-rebuild/main.go"
click node_dashboard "https://github.com/google/oss-rebuild/blob/main/cmd/dashboard/main.go"
click node_api "https://github.com/google/oss-rebuild/blob/main/cmd/api/main.go"
click node_api_handlers "https://github.com/google/oss-rebuild/tree/main/internal/api/apiservice"
click node_agent_api "https://github.com/google/oss-rebuild/blob/main/cmd/agent-api/main.go"
click node_agent "https://github.com/google/oss-rebuild/blob/main/internal/agent/session.go"
click node_inference "https://github.com/google/oss-rebuild/blob/main/internal/api/inferenceservice/infer.go"
click node_rebuild_flow "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/rebuild/rebuild.go"
click node_npm "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/npm/rebuild.go"
click node_pypi "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/pypi/rebuild.go"
click node_crates "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/cratesio/rebuild.go"
click node_debian "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/debian/rebuild.go"
click node_maven "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/maven/rebuild.go"
click node_stabilizer "https://github.com/google/oss-rebuild/blob/main/pkg/stabilize/stabilizer.go"
click node_analyzer "https://github.com/google/oss-rebuild/blob/main/analyzer/network/analyzerservice/analyze.go"
click node_system_analyzer "https://github.com/google/oss-rebuild/blob/main/analyzer/system/analyzerservice/analyze.go"
click node_feed "https://github.com/google/oss-rebuild/blob/main/pkg/feed/tracker.go"
click node_attestations "https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/rebuild/storage.go"
click node_db "https://github.com/google/oss-rebuild/blob/main/internal/db/db.go"
click node_snapshots "https://github.com/google/oss-rebuild/blob/main/internal/snapshot/snapshot.go"

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_cli,node_dashboard,node_user toneBlue
class node_api,node_api_handlers,node_agent_api,node_inference toneAmber
class node_rebuild_flow,node_npm,node_pypi,node_crates,node_debian,node_maven,node_stabilizer toneMint
class node_agent,node_analyzer,node_system_analyzer,node_feed toneRose
class node_attestations,node_db,node_snapshots,node_upstream toneIndigo
```

## Components

### User Access

- [Rebuild CLI](https://github.com/google/oss-rebuild/blob/main/cmd/oss-rebuild/main.go): `cmd/oss-rebuild/main.go`
- [Web Dashboard](https://github.com/google/oss-rebuild/blob/main/cmd/dashboard/main.go): `cmd/dashboard/main.go`

### Service APIs

- [Core API](https://github.com/google/oss-rebuild/blob/main/cmd/api/main.go): `cmd/api/main.go`
- [API Operations](https://github.com/google/oss-rebuild/tree/main/internal/api/apiservice): `internal/api/apiservice`
- [Agent API](https://github.com/google/oss-rebuild/blob/main/cmd/agent-api/main.go): `cmd/agent-api/main.go`
- [Inference Service](https://github.com/google/oss-rebuild/blob/main/internal/api/inferenceservice/infer.go): `internal/api/inferenceservice/infer.go`

### Rebuild Engine

- [Rebuild Workflow](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/rebuild/rebuild.go): `pkg/rebuild/rebuild/rebuild.go`
- [npm Rebuilder](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/npm/rebuild.go): `pkg/rebuild/npm/rebuild.go`
- [PyPI Rebuilder](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/pypi/rebuild.go): `pkg/rebuild/pypi/rebuild.go`
- [Crates.io Rebuilder](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/cratesio/rebuild.go): `pkg/rebuild/cratesio/rebuild.go`
- [Debian Rebuilder](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/debian/rebuild.go): `pkg/rebuild/debian/rebuild.go`
- [Maven Rebuilder](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/maven/rebuild.go): `pkg/rebuild/maven/rebuild.go`
- [Artifact Stabilizer](https://github.com/google/oss-rebuild/blob/main/pkg/stabilize/stabilizer.go): `pkg/stabilize/stabilizer.go`

### Analysis and Automation

- [Rebuild Agent](https://github.com/google/oss-rebuild/blob/main/internal/agent/session.go): `internal/agent/session.go`
- [Network Analyzer](https://github.com/google/oss-rebuild/blob/main/analyzer/network/analyzerservice/analyze.go): `analyzer/network/analyzerservice/analyze.go`
- [System Analyzer](https://github.com/google/oss-rebuild/blob/main/analyzer/system/analyzerservice/analyze.go): `analyzer/system/analyzerservice/analyze.go`
- [Package Feed](https://github.com/google/oss-rebuild/blob/main/pkg/feed/tracker.go): `pkg/feed/tracker.go`

### Data and Attestations

- [Attestation Store](https://github.com/google/oss-rebuild/blob/main/pkg/rebuild/rebuild/storage.go): `pkg/rebuild/rebuild/storage.go`
- [Run Database](https://github.com/google/oss-rebuild/blob/main/internal/db/db.go): `internal/db/db.go`
- [Snapshot Service](https://github.com/google/oss-rebuild/blob/main/internal/snapshot/snapshot.go): `internal/snapshot/snapshot.go`

### Other components

- **Package User**
- **Upstream Ecosystems**

## Connections

- Package User → Rebuild CLI: requests rebuild data (evidence: `README.md`)
- Package User → Web Dashboard: explores rebuilds (evidence: `README.md`)
- Rebuild CLI → Attestation Store: reads rebuild data (evidence: `README.md`)
- Web Dashboard → Snapshot Service: reads snapshot data (evidence: `cmd/dashboard/main.go`)
- Core API → API Operations: routes requests (evidence: `cmd/api/main.go`)
- Core API → Inference Service: configures inference (evidence: `cmd/api/main.go`)
- API Operations → Rebuild Workflow: serves rebuild operations (evidence: `README.md`)
- Agent API → Rebuild Agent: serves agent operations (evidence: `cmd/agent-api/main.go`)
- Rebuild Agent → Rebuild Workflow: iterates rebuild work (evidence: `internal/agent/session.go`)
- Rebuild Workflow → npm Rebuilder: supports ecosystem builds (evidence: `README.md`)
- Rebuild Workflow → PyPI Rebuilder: supports ecosystem builds (evidence: `README.md`)
- Rebuild Workflow → Crates.io Rebuilder: supports ecosystem builds (evidence: `README.md`)
- Rebuild Workflow → Debian Rebuilder: supports rebuilds
- Rebuild Workflow → Maven Rebuilder: supports rebuilds
- Upstream Ecosystems → Rebuild Workflow: provides package inputs (evidence: `README.md`)
- Rebuild Workflow → Attestation Store: publishes attestations (evidence: `README.md`)
- Upstream Ecosystems → Attestation Store: artifact comparison (evidence: `README.md`)
- Package Feed → Network Analyzer: enqueues analysis
- Package Feed → System Analyzer: enqueues analysis
- Network Analyzer → Attestation Store: writes analysis attestations
- System Analyzer → Attestation Store: writes analysis attestations
- API Operations → Run Database: persists run state
- Package User → Attestation Store: verifies signatures (evidence: `README.md`)
