# dragon-looping/repo-judge architecture

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

- Interactive diagram: https://gitdiagram.com/dragon-looping/repo-judge
- Repository: https://github.com/dragon-looping/repo-judge

## Overview

RepoJudge accepts a public GitHub repository for transparent scoring and returns a validated Scorecard through a REST API and HTML interface. The server orchestrates snapshot ingestion, deterministic criteria checks, and—when selected—an optional Gemma judging pass before merging results. The graph preserves the documented rule categories and the prompt-sanitization layer. Some rule implementations and UI behavior were not excerpted, so their documented capabilities are shown without inferred internal call paths.

Main entry points: [`src/rules/index.ts`](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/index.ts) (Rules engine), [`src/server.ts`](https://github.com/dragon-looping/repo-judge/blob/main/src/server.ts) (Express API), [`src/judge/gemma.ts`](https://github.com/dragon-looping/repo-judge/blob/main/src/judge/gemma.ts) (Gemma judge), [`src/ingest/github.ts`](https://github.com/dragon-looping/repo-judge/blob/main/src/ingest/github.ts) (Snapshot ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["API and interface"]
  node_api["Express API<br/>[server.ts]"]
  node_webui["HTML UI<br/>[app.js]"]
end

subgraph group_ingestion["Repository ingestion"]
  node_snapshot["Snapshot ingestion<br/>[github.ts]"]
end

subgraph group_evaluation["Scoring and judging"]
  node_ruleengine["Rules engine<br/>[index.ts]"]
  node_license["License checks<br/>[license.ts]"]
  node_readmerule["README checks<br/>[readme.ts]"]
  node_ci["CI checks<br/>[ci.ts]"]
  node_commits["Commit checks<br/>[commits.ts]"]
  node_contributors["Contributor checks<br/>[contributors.ts]"]
  node_coc["Conduct checks<br/>[coc.ts]"]
  node_secrets["Secret checks<br/>[secrets.ts]"]
  node_openweight["Open-weight checks<br/>[openweight.ts]"]
  node_prompt["Judge prompts<br/>[prompt.ts]"]
  node_sanitizer["Prompt sanitization<br/>[sanitize.ts]"]
  node_gemma["Gemma judge<br/>[gemma.ts]"]
end

subgraph group_contract["Scorecard contract"]
  node_schema["Data schemas<br/>[schema.ts]"]
  node_merge["Scorecard merge<br/>[merge.ts]"]
  node_scorecard["Validated scorecard<br/>[schema.ts]"]
end

node_organizer(("Organizer"))
node_github["GitHub REST API"]
node_gemini["Gemini hosting API"]

node_organizer -->|"submits URL"| node_api
node_api -->|"serves UI"| node_webui
node_api -->|"builds snapshot"| node_snapshot
node_snapshot -->|"fetches repository data"| node_github
node_api -->|"runs rules"| node_ruleengine
node_ruleengine -->|"checks license"| node_license
node_ruleengine -->|"checks README"| node_readmerule
node_ruleengine -->|"checks CI"| node_ci
node_ruleengine -->|"checks commits"| node_commits
node_ruleengine -->|"checks contributors"| node_contributors
node_ruleengine -->|"checks conduct"| node_coc
node_ruleengine -->|"checks secrets"| node_secrets
node_ruleengine -->|"checks model policy"| node_openweight
node_api -.->|"optional judging"| node_gemma
node_gemma -->|"builds prompts"| node_prompt
node_prompt -->|"sanitizes content"| node_sanitizer
node_gemma -->|"detects injection"| node_sanitizer
node_gemma -->|"requests verdicts"| node_gemini
node_api -->|"merges results"| node_merge
node_merge -->|"validates output"| node_scorecard
node_api -->|"returns scorecard"| node_organizer
node_snapshot -->|"validates snapshot"| node_schema
node_ruleengine -->|"validates checks"| node_schema

click node_api "https://github.com/dragon-looping/repo-judge/blob/main/src/server.ts"
click node_webui "https://github.com/dragon-looping/repo-judge/blob/main/public/app.js"
click node_snapshot "https://github.com/dragon-looping/repo-judge/blob/main/src/ingest/github.ts"
click node_schema "https://github.com/dragon-looping/repo-judge/blob/main/src/schema.ts"
click node_ruleengine "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/index.ts"
click node_license "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/license.ts"
click node_readmerule "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/readme.ts"
click node_ci "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/ci.ts"
click node_commits "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/commits.ts"
click node_contributors "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/contributors.ts"
click node_coc "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/coc.ts"
click node_secrets "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/secrets.ts"
click node_openweight "https://github.com/dragon-looping/repo-judge/blob/main/src/rules/openweight.ts"
click node_prompt "https://github.com/dragon-looping/repo-judge/blob/main/src/judge/prompt.ts"
click node_sanitizer "https://github.com/dragon-looping/repo-judge/blob/main/src/judge/sanitize.ts"
click node_gemma "https://github.com/dragon-looping/repo-judge/blob/main/src/judge/gemma.ts"
click node_merge "https://github.com/dragon-looping/repo-judge/blob/main/src/merge.ts"
click node_scorecard "https://github.com/dragon-looping/repo-judge/blob/main/src/schema.ts"

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_api,node_webui toneBlue
class node_snapshot toneAmber
class node_ruleengine,node_license,node_readmerule,node_ci,node_commits,node_contributors,node_coc,node_secrets,node_openweight,node_prompt,node_sanitizer,node_gemma,node_github,node_gemini toneMint
class node_schema,node_merge,node_scorecard toneRose
class node_organizer toneIndigo
```

## Components

### API and interface

- [Express API](https://github.com/dragon-looping/repo-judge/blob/main/src/server.ts): `src/server.ts`
- [HTML UI](https://github.com/dragon-looping/repo-judge/blob/main/public/app.js): `public/app.js`

### Repository ingestion

- [Snapshot ingestion](https://github.com/dragon-looping/repo-judge/blob/main/src/ingest/github.ts): `src/ingest/github.ts`

### Scoring and judging

- [Rules engine](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/index.ts): `src/rules/index.ts`
- [License checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/license.ts): `src/rules/license.ts`
- [README checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/readme.ts): `src/rules/readme.ts`
- [CI checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/ci.ts): `src/rules/ci.ts`
- [Commit checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/commits.ts): `src/rules/commits.ts`
- [Contributor checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/contributors.ts): `src/rules/contributors.ts`
- [Conduct checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/coc.ts): `src/rules/coc.ts`
- [Secret checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/secrets.ts): `src/rules/secrets.ts`
- [Open-weight checks](https://github.com/dragon-looping/repo-judge/blob/main/src/rules/openweight.ts): `src/rules/openweight.ts`
- [Judge prompts](https://github.com/dragon-looping/repo-judge/blob/main/src/judge/prompt.ts): `src/judge/prompt.ts`
- [Prompt sanitization](https://github.com/dragon-looping/repo-judge/blob/main/src/judge/sanitize.ts): `src/judge/sanitize.ts`
- [Gemma judge](https://github.com/dragon-looping/repo-judge/blob/main/src/judge/gemma.ts): `src/judge/gemma.ts`

### Scorecard contract

- [Data schemas](https://github.com/dragon-looping/repo-judge/blob/main/src/schema.ts): `src/schema.ts`
- [Scorecard merge](https://github.com/dragon-looping/repo-judge/blob/main/src/merge.ts): `src/merge.ts`
- [Validated scorecard](https://github.com/dragon-looping/repo-judge/blob/main/src/schema.ts): `src/schema.ts`

### Other components

- **Organizer**
- **GitHub REST API**
- **Gemini hosting API**

## Connections

- Organizer → Express API: submits URL (evidence: `README.md`)
- Express API → HTML UI: serves UI (evidence: `src/server.ts`)
- Express API → Snapshot ingestion: builds snapshot (evidence: `src/server.ts`)
- Snapshot ingestion → GitHub REST API: fetches repository data (evidence: `README.md`)
- Express API → Rules engine: runs rules (evidence: `src/server.ts`)
- Rules engine → License checks: checks license (evidence: `src/rules/index.ts`)
- Rules engine → README checks: checks README (evidence: `src/rules/index.ts`)
- Rules engine → CI checks: checks CI (evidence: `src/rules/index.ts`)
- Rules engine → Commit checks: checks commits (evidence: `src/rules/index.ts`)
- Rules engine → Contributor checks: checks contributors (evidence: `src/rules/index.ts`)
- Rules engine → Conduct checks: checks conduct (evidence: `src/rules/index.ts`)
- Rules engine → Secret checks: checks secrets (evidence: `src/rules/index.ts`)
- Rules engine → Open-weight checks: checks model policy (evidence: `src/rules/index.ts`)
- Express API → Gemma judge: optional judging (evidence: `src/server.ts`)
- Gemma judge → Judge prompts: builds prompts (evidence: `src/judge/gemma.ts`)
- Judge prompts → Prompt sanitization: sanitizes content (evidence: `src/judge/prompt.ts`)
- Gemma judge → Prompt sanitization: detects injection (evidence: `src/judge/gemma.ts`)
- Gemma judge → Gemini hosting API: requests verdicts (evidence: `README.md`)
- Express API → Scorecard merge: merges results (evidence: `src/server.ts`)
- Scorecard merge → Validated scorecard: validates output (evidence: `src/merge.ts`)
- Express API → Organizer: returns scorecard (evidence: `README.md`)
- Snapshot ingestion → Data schemas: validates snapshot (evidence: `src/ingest/github.ts`)
- Rules engine → Data schemas: validates checks (evidence: `src/rules/index.ts`)
