# kvale-io/repobot-clean architecture

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

- Interactive diagram: https://gitdiagram.com/kvale-io/repobot-clean
- Repository: https://github.com/kvale-io/repobot-clean

## Overview

#### Purpose and Runtime

RepoBot is a standalone repository-intelligence system: a public Next.js site backed exclusively by MySQL, with reviewed repository records, controlled taxonomy, deterministic qualification, and separately modeled relationships/graph views. It uses Node 24, Next.js/TypeScript, MySQL 8.4, and GitHub repository metadata. Production is deployed by Hostinger from `main`; CI runs in GitHub Actions.

Key entry points: `src/app/page.tsx`, `src/app/catalog/page.tsx`, `src/app/graph/page.tsx`, `src/server/operator/server.ts`, and workflow scripts in `scripts/`.

#### Public Application and Discovery Surface

Next App Router pages render the catalog, individual repository records, relationship graph, agent/anatomy content, knowledge content, and recycling-yard discovery surface. Shared visual/SEO shell is centralized in `src/app/layout.tsx`, `src/components/site-header.tsx`, and `src/components/structured-data.tsx`.

Public routes read authoritative published data rather than CSV/JSON repository fixtures. Machine-facing discovery includes `src/app/robots.ts`, `src/app/sitemap.ts`, and `src/app/llms.txt/route.ts`.

#### Repository Authority and Persistence Boundary

MySQL is the sole runtime authority; versioned normalized schema is established by `database/001_repository_system.sql` and `database/002_permanent_repository_ingestion.sql`. Database connectivity and table definitions are isolated in `src/server/db/config.ts`, `src/server/db/pool.ts`, and `src/server/db/tables.ts`.

Store modules provide persistence boundaries for repositories, intake, revisions, qualification, releases, sources, and public recycling queries, e.g. `src/server/db/repository-store.ts`, `src/server/db/intake-store.ts`, and `src/server/db/release-store.ts`. CSV files under `data/` are intake/policy inputs, not application fallback data.

#### Controlled Ingestion and Editorial Pipeline

Repository publication is an audited stateful pipeline: CSV intake creates staged candidates; identity handling deduplicates them; deterministic rules qualify candidates; editorial packets are exported/imported; prepared releases atomically publish or exactly roll back. Primary orchestration lives in `src/server/services/intake-batch.ts`, `src/server/services/qualify-candidate.ts`, and `src/server/services/publication.ts`.

Operational entry points are `scripts/intake-csv.ts`, `scripts/qualify-run.ts`, `scripts/export-claude-packets.ts`, `scripts/import-claude-drafts.ts`, and release scripts under `scripts/release-*.ts`. Claude is constrained to editorial draft exchange, with contract validation in `src/core/editorial/claude-contract.ts` and `src/server/services/claude-editorial.ts`; no AI provider is required at runtime.

#### Domain Validation and Policy Layers

Schemas and rules protect each major transition and prevent unreviewed data crossing into public views. Intake identity/schema, qualification rules, publication idempotency, and verification policy are defined in `src/core/intake/identity.ts`, `src/core/qualification/rules-v1.ts`, `src/core/publication/idempotency.ts`, and `src/core/verification/policy.ts`.

Taxonomy and relationships are independent controlled layers, represented by `src/core/taxonomy/schema-v2.ts`, `src/core/relationships/schema-v2.ts`, and `src/core/relationships/public-v2.ts`. This separation distinguishes approved repository classifications from evidence-verified claims and architectural links.

#### Graph, Catalog, and Public Projections

Catalog query/load/publication modules transform authoritative records into public listing and detail models: `src/core/catalog/load.ts`, `src/core/catalog/query-v2.ts`, and `src/components/repository-detail-v2.tsx`. The public recycling yard is a constrained discovery projection through `src/core/recycling/public-query.ts` and `src/components/recycling-yard.tsx`.

The Seven-role NodeScape graph has dedicated model, search, terminology, and presentation layers: `src/core/graph/model-v2.ts`, `src/core/graph/nodescape-v2.ts`, and `src/components/repo-graph-nodescape.tsx`. Graph UI does not redefine source relationships; it presents the controlled graph/relationship models.

#### Operator and External-Service Boundary

The operator service exposes controlled sessions, routing, candidate review, intake, and actions via `src/server/operator/server.ts`, `src/server/operator/router.ts`, and `src/server/services/operator-actions.ts`. GitHub access is bounded to source metadata acquisition in `src/server/github/repository-source.ts`.

Release quality is enforced by `.github/workflows/release-gate.yml`, which provisions disposable MySQL and validates migrations, clean data boundaries, tests, type checks, build, and production dependency audit. Destructive ingestion verification is intentionally constrained by `scripts/verify-ingestion-foundation.ts`.

Main entry points: [`src/server/db/repository-store.ts`](https://github.com/kvale-io/repobot-clean/blob/main/src/server/db/repository-store.ts) (Repository stores), [`src/app/page.tsx`](https://github.com/kvale-io/repobot-clean/blob/main/src/app/page.tsx) (Next.js public routes), [`src/server/services/intake-batch.ts`](https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/intake-batch.ts) (Intake and qualification), [`scripts/intake-csv.ts`](https://github.com/kvale-io/repobot-clean/blob/main/scripts/intake-csv.ts) (Operational scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public application"]
  node_next_app["Next.js public routes<br/>App Router<br/>[page.tsx]"]
  node_site_shell["Site shell and SEO<br/>shared UI<br/>[layout.tsx]"]
  node_discovery_routes["Machine discovery<br/>route handlers<br/>[robots.ts]"]
end

subgraph group_domain["Domain models and projections"]
  node_catalog_projection["Catalog projections<br/>query and view models<br/>[load.ts]"]
  node_recycling_projection["Recycling-yard projection<br/>constrained discovery query<br/>[public-query.ts]"]
  node_relationship_models["Taxonomy and relationships<br/>controlled schemas<br/>[schema-v2.ts]"]
  node_nodescape_graph["NodeScape graph<br/>graph model and UI<br/>[model-v2.ts]"]
end

subgraph group_pipeline["Editorial pipeline"]
  node_policy_rules["Transition policy<br/>domain rules<br/>[rules-v1.ts]"]
  node_intake_qualification["Intake and qualification<br/>pipeline service<br/>[intake-batch.ts]"]
  node_editorial_exchange["Editorial draft exchange<br/>review service"]
  node_publication["Atomic publication<br/>release service<br/>[publication.ts]"]
end

subgraph group_persistence["Persistence and operations"]
  node_operator_service["Operator service<br/>controlled API<br/>[server.ts]"]
  node_workflow_scripts["Operational scripts<br/>CLI workflows<br/>[intake-csv.ts]"]
  node_store_layer["Repository stores<br/>persistence boundary"]
  node_mysql[("MySQL authority<br/>MySQL 8.4")]
  node_release_gate["Release gate<br/>GitHub Actions<br/>[release-gate.yml]"]
end

node_visitors(("Visitors and crawlers<br/>external users"))
node_github{{"GitHub metadata<br/>external source"}}
node_hostinger{{"Hostinger production<br/>deployment target"}}

node_visitors -->|"browse"| node_next_app
node_visitors -->|"discover"| node_discovery_routes
node_next_app -->|"renders in"| node_site_shell
node_next_app -->|"loads catalog"| node_catalog_projection
node_next_app -->|"loads discovery"| node_recycling_projection
node_next_app -->|"renders graph"| node_nodescape_graph
node_discovery_routes -->|"indexes published data"| node_catalog_projection
node_catalog_projection -->|"reads"| node_store_layer
node_recycling_projection -->|"reads"| node_store_layer
node_nodescape_graph -->|"presents"| node_relationship_models
node_relationship_models -->|"controlled records"| node_store_layer
node_workflow_scripts -->|"runs"| node_intake_qualification
node_operator_service -->|"controls"| node_intake_qualification
node_intake_qualification -->|"enforces"| node_policy_rules
node_intake_qualification -->|"stages candidates"| node_store_layer
node_github -->|"metadata"| node_intake_qualification
node_workflow_scripts -->|"exchanges packets"| node_editorial_exchange
node_editorial_exchange -->|"stores reviewed drafts"| node_store_layer
node_workflow_scripts -->|"releases"| node_publication
node_publication -->|"idempotency checks"| node_policy_rules
node_publication -->|"publishes or rolls back"| node_store_layer
node_store_layer -->|"persists"| node_mysql
node_release_gate -.->|"provisions disposable instance"| node_mysql
node_release_gate -->|"gates deployment from main"| node_hostinger
node_hostinger -.->|"hosts"| node_next_app

click node_next_app "https://github.com/kvale-io/repobot-clean/blob/main/src/app/page.tsx"
click node_site_shell "https://github.com/kvale-io/repobot-clean/blob/main/src/app/layout.tsx"
click node_discovery_routes "https://github.com/kvale-io/repobot-clean/blob/main/src/app/robots.ts"
click node_catalog_projection "https://github.com/kvale-io/repobot-clean/blob/main/src/core/catalog/load.ts"
click node_recycling_projection "https://github.com/kvale-io/repobot-clean/blob/main/src/core/recycling/public-query.ts"
click node_relationship_models "https://github.com/kvale-io/repobot-clean/blob/main/src/core/relationships/schema-v2.ts"
click node_nodescape_graph "https://github.com/kvale-io/repobot-clean/blob/main/src/core/graph/model-v2.ts"
click node_policy_rules "https://github.com/kvale-io/repobot-clean/blob/main/src/core/qualification/rules-v1.ts"
click node_intake_qualification "https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/intake-batch.ts"
click node_editorial_exchange "https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/claude-editorial.ts"
click node_publication "https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/publication.ts"
click node_operator_service "https://github.com/kvale-io/repobot-clean/blob/main/src/server/operator/server.ts"
click node_workflow_scripts "https://github.com/kvale-io/repobot-clean/blob/main/scripts/intake-csv.ts"
click node_store_layer "https://github.com/kvale-io/repobot-clean/blob/main/src/server/db/repository-store.ts"
click node_mysql "https://github.com/kvale-io/repobot-clean/blob/main/database/001_repository_system.sql"
click node_github "https://github.com/kvale-io/repobot-clean/blob/main/src/server/github/repository-source.ts"
click node_release_gate "https://github.com/kvale-io/repobot-clean/blob/main/.github/workflows/release-gate.yml"

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_next_app,node_site_shell,node_discovery_routes toneBlue
class node_catalog_projection,node_recycling_projection,node_relationship_models,node_nodescape_graph toneAmber
class node_policy_rules,node_intake_qualification,node_editorial_exchange,node_publication toneMint
class node_operator_service,node_workflow_scripts,node_store_layer,node_mysql,node_release_gate toneRose
class node_visitors,node_github,node_hostinger toneNeutral
```

## Components

### Public application

- [Next.js public routes](https://github.com/kvale-io/repobot-clean/blob/main/src/app/page.tsx): App Router · Catalog, records, graph, content, and discovery pages. · `src/app/page.tsx`
- [Site shell and SEO](https://github.com/kvale-io/repobot-clean/blob/main/src/app/layout.tsx): shared UI · `src/app/layout.tsx`
- [Machine discovery](https://github.com/kvale-io/repobot-clean/blob/main/src/app/robots.ts): route handlers · Robots, sitemap, and LLM discovery outputs. · `src/app/robots.ts`

### Domain models and projections

- [Catalog projections](https://github.com/kvale-io/repobot-clean/blob/main/src/core/catalog/load.ts): query and view models · Builds published listing and repository detail models. · `src/core/catalog/load.ts`
- [Recycling-yard projection](https://github.com/kvale-io/repobot-clean/blob/main/src/core/recycling/public-query.ts): constrained discovery query · `src/core/recycling/public-query.ts`
- [Taxonomy and relationships](https://github.com/kvale-io/repobot-clean/blob/main/src/core/relationships/schema-v2.ts): controlled schemas · Separates approved classifications, claims, and architectural links. · `src/core/relationships/schema-v2.ts`
- [NodeScape graph](https://github.com/kvale-io/repobot-clean/blob/main/src/core/graph/model-v2.ts): graph model and UI · Presents controlled relationship models without redefining them. · `src/core/graph/model-v2.ts`

### Editorial pipeline

- [Transition policy](https://github.com/kvale-io/repobot-clean/blob/main/src/core/qualification/rules-v1.ts): domain rules · Identity, qualification, publication, and verification controls. · `src/core/qualification/rules-v1.ts`
- [Intake and qualification](https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/intake-batch.ts): pipeline service · Stages CSV candidates, deduplicates identity, and applies deterministic rules. · `src/server/services/intake-batch.ts`
- [Editorial draft exchange](https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/claude-editorial.ts): review service · Validates constrained Claude packet imports and exports. · `src/server/services/claude-editorial.ts`
- [Atomic publication](https://github.com/kvale-io/repobot-clean/blob/main/src/server/services/publication.ts): release service · Publishes prepared releases or rolls them back exactly. · `src/server/services/publication.ts`

### Persistence and operations

- [Operator service](https://github.com/kvale-io/repobot-clean/blob/main/src/server/operator/server.ts): controlled API · Sessions, review routing, intake, and operational actions. · `src/server/operator/server.ts`
- [Operational scripts](https://github.com/kvale-io/repobot-clean/blob/main/scripts/intake-csv.ts): CLI workflows · CSV intake, qualification, editorial exchange, releases, and verification. · `scripts/intake-csv.ts`
- [Repository stores](https://github.com/kvale-io/repobot-clean/blob/main/src/server/db/repository-store.ts): persistence boundary · Stores repositories, intake, revisions, qualification, releases, and sources. · `src/server/db/repository-store.ts`
- [MySQL authority](https://github.com/kvale-io/repobot-clean/blob/main/database/001_repository_system.sql): MySQL 8.4 · Sole runtime authority for published and pipeline state. · `database/001_repository_system.sql`
- [Release gate](https://github.com/kvale-io/repobot-clean/blob/main/.github/workflows/release-gate.yml): GitHub Actions · Validates disposable-MySQL migrations, boundaries, checks, build, and dependency audit. · `.github/workflows/release-gate.yml`

### Other components

- **Visitors and crawlers**: external users
- [GitHub metadata](https://github.com/kvale-io/repobot-clean/blob/main/src/server/github/repository-source.ts): external source · Bounded repository-source metadata acquisition. · `src/server/github/repository-source.ts`
- **Hostinger production**: deployment target · Deploys the main branch.

## Connections

- Visitors and crawlers → Next.js public routes: browse
- Visitors and crawlers → Machine discovery: discover
- Next.js public routes → Site shell and SEO: renders in
- Next.js public routes → Catalog projections: loads catalog
- Next.js public routes → Recycling-yard projection: loads discovery
- Next.js public routes → NodeScape graph: renders graph
- Machine discovery → Catalog projections: indexes published data
- Catalog projections → Repository stores: reads
- Recycling-yard projection → Repository stores: reads
- NodeScape graph → Taxonomy and relationships: presents
- Taxonomy and relationships → Repository stores: controlled records
- Operational scripts → Intake and qualification: runs
- Operator service → Intake and qualification: controls
- Intake and qualification → Transition policy: enforces
- Intake and qualification → Repository stores: stages candidates
- GitHub metadata → Intake and qualification: metadata
- Operational scripts → Editorial draft exchange: exchanges packets
- Editorial draft exchange → Repository stores: stores reviewed drafts
- Operational scripts → Atomic publication: releases
- Atomic publication → Transition policy: idempotency checks
- Atomic publication → Repository stores: publishes or rolls back
- Repository stores → MySQL authority: persists
- Release gate → MySQL authority: provisions disposable instance
- Release gate → Hostinger production: gates deployment from main
- Hostinger production → Next.js public routes: hosts
