# brianwestphal/glassbox architecture

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

- Interactive diagram: https://gitdiagram.com/brianwestphal/glassbox
- Repository: https://github.com/brianwestphal/glassbox

## Overview

Glassbox is a local code-review application for inspecting AI-generated or other repository changes, attaching structured feedback, and handing that feedback back to an AI tool. The main loop starts from a Git repository or comparison input, builds review diffs, presents them in the browser, persists annotations, and exports Markdown for the fixer; reviews can then be reopened and updated. The graph also preserves documented image and ground-truth review, AI analysis, review notes, plugins, themes, and history. Some feature links use README documentation because their implementation was not sampled.

Main entry points: [`src/db/queries.ts`](https://github.com/brianwestphal/glassbox/blob/main/src/db/queries.ts) (Review persistence), [`src/client/app.tsx`](https://github.com/brianwestphal/glassbox/blob/main/src/client/app.tsx) (Browser application), [`src/review-open/commit-review.ts`](https://github.com/brianwestphal/glassbox/blob/main/src/review-open/commit-review.ts) (Open commit review), [`src/git/diff.ts`](https://github.com/brianwestphal/glassbox/blob/main/src/git/diff.ts) (Diff generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_review["Review creation"]
  node_cli["CLI entry<br/>[cli.ts]"]
  node_review_open["Open commit review<br/>[commit-review.ts]"]
  node_git_diff["Diff generation<br/>[diff.ts]"]
  node_git_repo["Git repository access<br/>[repo.ts]"]
  node_review_update["Review update<br/>[review-update.ts]"]
  node_server["Local server<br/>[server.ts]"]
end

subgraph group_interface["Review interface"]
  node_web_app["Browser application<br/>[app.tsx]"]
  node_diff_view["Diff and image viewer<br/>[index.tsx]"]
  node_sidebar["File navigation<br/>[index.tsx]"]
  node_api["Typed API<br/>[index.ts]"]
  node_routes["HTTP routes<br/>[api.ts]"]
end

subgraph group_feedback["Feedback and state"]
  node_annotations["Annotations<br/>[annotations.ts]"]
  node_review_notes["AI review notes<br/>[store.ts]"]
  node_database[("Review database<br/>[connection.ts]")]
  node_queries["Review persistence<br/>[queries.ts]"]
  node_export["Feedback export<br/>[generate.ts]"]
end

subgraph group_assistance["AI and extensions"]
  node_analysis["AI analysis pipeline"]
  node_ai_config["AI configuration<br/>[config.ts]"]
  node_analysis_ui["Analysis controls<br/>[analysisEngine.ts]"]
  node_plugins["Content plugins<br/>[index.ts]"]
end

subgraph group_extras["Review capabilities"]
  node_ground_truth["Ground-truth comparison<br/>[manifest.ts]"]
  node_history["Review history<br/>[reviewHistory.tsx]"]
  node_themes["Theme management<br/>[themeManager.tsx]"]
end

node_developer(("Developer"))
node_ai_tool(("AI coding tool"))

node_developer -->|"starts review"| node_cli
node_cli -.->|"requests diffs"| node_git_diff
node_cli -.->|"launches"| node_server
node_review_open -->|"resolves commit"| node_git_repo
node_review_open -->|"gets diffs"| node_git_diff
node_review_open -->|"saves review"| node_queries
node_git_diff -->|"runs Git"| node_git_repo
node_review_update -->|"refreshes diffs"| node_git_diff
node_review_update -->|"updates review"| node_queries
node_server -->|"mounts routes"| node_routes
node_server -->|"initializes"| node_plugins
node_developer -->|"reviews changes"| node_web_app
node_web_app -->|"requests data"| node_api
node_web_app -->|"loads files"| node_sidebar
node_web_app -->|"loads analysis"| node_analysis_ui
node_api -.->|"calls API"| node_routes
node_routes -->|"reads and writes"| node_queries
node_developer -->|"adds feedback"| node_annotations
node_annotations -.->|"persists annotations"| node_queries
node_queries -->|"queries"| node_database
node_developer -->|"shares feedback"| node_export
node_export -->|"provides instructions"| node_ai_tool
node_ai_tool -->|"applies fixes"| node_developer
node_analysis_ui -->|"starts and polls"| node_api
node_analysis -->|"stores scores"| node_database
node_ai_config -.->|"configures models"| node_analysis
node_review_notes -->|"reads review context"| node_queries
node_plugins -.->|"renders diagram content"| node_developer
node_ground_truth -->|"compares renders"| node_developer
node_history -->|"loads past reviews"| node_queries
node_themes -->|"manages themes"| node_api
node_developer -->|"opens commit"| node_review_open

click node_cli "https://github.com/brianwestphal/glassbox/blob/main/src/cli.ts"
click node_review_open "https://github.com/brianwestphal/glassbox/blob/main/src/review-open/commit-review.ts"
click node_git_diff "https://github.com/brianwestphal/glassbox/blob/main/src/git/diff.ts"
click node_git_repo "https://github.com/brianwestphal/glassbox/blob/main/src/git/repo.ts"
click node_review_update "https://github.com/brianwestphal/glassbox/blob/main/src/review-update.ts"
click node_server "https://github.com/brianwestphal/glassbox/blob/main/src/server.ts"
click node_web_app "https://github.com/brianwestphal/glassbox/blob/main/src/client/app.tsx"
click node_diff_view "https://github.com/brianwestphal/glassbox/blob/main/src/client/diff/index.tsx"
click node_sidebar "https://github.com/brianwestphal/glassbox/blob/main/src/client/sidebar/index.tsx"
click node_api "https://github.com/brianwestphal/glassbox/blob/main/src/api/index.ts"
click node_routes "https://github.com/brianwestphal/glassbox/blob/main/src/routes/api.ts"
click node_annotations "https://github.com/brianwestphal/glassbox/blob/main/src/api/annotations.ts"
click node_review_notes "https://github.com/brianwestphal/glassbox/blob/main/src/review-notes/store.ts"
click node_database "https://github.com/brianwestphal/glassbox/blob/main/src/db/connection.ts"
click node_queries "https://github.com/brianwestphal/glassbox/blob/main/src/db/queries.ts"
click node_export "https://github.com/brianwestphal/glassbox/blob/main/src/export/generate.ts"
click node_analysis "https://github.com/brianwestphal/glassbox/blob/main/src/ai/analysis-pipeline.ts"
click node_ai_config "https://github.com/brianwestphal/glassbox/blob/main/src/ai/config.ts"
click node_analysis_ui "https://github.com/brianwestphal/glassbox/blob/main/src/client/analysisEngine.ts"
click node_plugins "https://github.com/brianwestphal/glassbox/blob/main/src/plugins/index.ts"
click node_ground_truth "https://github.com/brianwestphal/glassbox/blob/main/src/ground-truth/manifest.ts"
click node_history "https://github.com/brianwestphal/glassbox/blob/main/src/components/reviewHistory.tsx"
click node_themes "https://github.com/brianwestphal/glassbox/blob/main/src/client/settings/themeManager.tsx"

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_review_open,node_git_diff,node_git_repo,node_review_update,node_server toneBlue
class node_web_app,node_diff_view,node_sidebar,node_api,node_routes toneAmber
class node_annotations,node_review_notes,node_database,node_queries,node_export toneMint
class node_analysis,node_ai_config,node_analysis_ui,node_plugins toneRose
class node_ground_truth,node_history,node_themes,node_developer,node_ai_tool toneIndigo
```

## Components

### Review creation

- [CLI entry](https://github.com/brianwestphal/glassbox/blob/main/src/cli.ts): `src/cli.ts`
- [Open commit review](https://github.com/brianwestphal/glassbox/blob/main/src/review-open/commit-review.ts): `src/review-open/commit-review.ts`
- [Diff generation](https://github.com/brianwestphal/glassbox/blob/main/src/git/diff.ts): `src/git/diff.ts`
- [Git repository access](https://github.com/brianwestphal/glassbox/blob/main/src/git/repo.ts): `src/git/repo.ts`
- [Review update](https://github.com/brianwestphal/glassbox/blob/main/src/review-update.ts): `src/review-update.ts`
- [Local server](https://github.com/brianwestphal/glassbox/blob/main/src/server.ts): `src/server.ts`

### Review interface

- [Browser application](https://github.com/brianwestphal/glassbox/blob/main/src/client/app.tsx): `src/client/app.tsx`
- [Diff and image viewer](https://github.com/brianwestphal/glassbox/blob/main/src/client/diff/index.tsx): `src/client/diff/index.tsx`
- [File navigation](https://github.com/brianwestphal/glassbox/blob/main/src/client/sidebar/index.tsx): `src/client/sidebar/index.tsx`
- [Typed API](https://github.com/brianwestphal/glassbox/blob/main/src/api/index.ts): `src/api/index.ts`
- [HTTP routes](https://github.com/brianwestphal/glassbox/blob/main/src/routes/api.ts): `src/routes/api.ts`

### Feedback and state

- [Annotations](https://github.com/brianwestphal/glassbox/blob/main/src/api/annotations.ts): `src/api/annotations.ts`
- [AI review notes](https://github.com/brianwestphal/glassbox/blob/main/src/review-notes/store.ts): `src/review-notes/store.ts`
- [Review database](https://github.com/brianwestphal/glassbox/blob/main/src/db/connection.ts): `src/db/connection.ts`
- [Review persistence](https://github.com/brianwestphal/glassbox/blob/main/src/db/queries.ts): `src/db/queries.ts`
- [Feedback export](https://github.com/brianwestphal/glassbox/blob/main/src/export/generate.ts): `src/export/generate.ts`

### AI and extensions

- [AI analysis pipeline](https://github.com/brianwestphal/glassbox/blob/main/src/ai/analysis-pipeline.ts): `src/ai/analysis-pipeline.ts`
- [AI configuration](https://github.com/brianwestphal/glassbox/blob/main/src/ai/config.ts): `src/ai/config.ts`
- [Analysis controls](https://github.com/brianwestphal/glassbox/blob/main/src/client/analysisEngine.ts): `src/client/analysisEngine.ts`
- [Content plugins](https://github.com/brianwestphal/glassbox/blob/main/src/plugins/index.ts): `src/plugins/index.ts`

### Review capabilities

- [Ground-truth comparison](https://github.com/brianwestphal/glassbox/blob/main/src/ground-truth/manifest.ts): `src/ground-truth/manifest.ts`
- [Review history](https://github.com/brianwestphal/glassbox/blob/main/src/components/reviewHistory.tsx): `src/components/reviewHistory.tsx`
- [Theme management](https://github.com/brianwestphal/glassbox/blob/main/src/client/settings/themeManager.tsx): `src/client/settings/themeManager.tsx`

### Other components

- **Developer**
- **AI coding tool**

## Connections

- Developer → CLI entry: starts review (evidence: `README.md`)
- CLI entry → Diff generation: requests diffs
- CLI entry → Local server: launches
- Open commit review → Git repository access: resolves commit (evidence: `src/review-open/commit-review.ts`)
- Open commit review → Diff generation: gets diffs (evidence: `src/review-open/commit-review.ts`)
- Open commit review → Review persistence: saves review (evidence: `src/review-open/commit-review.ts`)
- Diff generation → Git repository access: runs Git (evidence: `src/git/diff.ts`)
- Review update → Diff generation: refreshes diffs (evidence: `src/review-update.ts`)
- Review update → Review persistence: updates review (evidence: `src/review-update.ts`)
- Local server → HTTP routes: mounts routes (evidence: `src/server.ts`)
- Local server → Content plugins: initializes (evidence: `src/server.ts`)
- Developer → Browser application: reviews changes (evidence: `README.md`)
- Browser application → Typed API: requests data (evidence: `src/client/app.tsx`)
- Browser application → File navigation: loads files (evidence: `src/client/app.tsx`)
- Browser application → Analysis controls: loads analysis (evidence: `src/client/app.tsx`)
- Typed API → HTTP routes: calls API
- HTTP routes → Review persistence: reads and writes
- Developer → Annotations: adds feedback (evidence: `README.md`)
- Annotations → Review persistence: persists annotations
- Review persistence → Review database: queries (evidence: `src/db/queries.ts`)
- Developer → Feedback export: shares feedback (evidence: `README.md`)
- Feedback export → AI coding tool: provides instructions (evidence: `README.md`)
- AI coding tool → Developer: applies fixes (evidence: `README.md`)
- Analysis controls → Typed API: starts and polls (evidence: `src/client/analysisEngine.ts`)
- AI analysis pipeline → Review database: stores scores (evidence: `src/ai/analysis-pipeline.ts`)
- AI configuration → AI analysis pipeline: configures models (evidence: `src/ai/analysis-pipeline.ts`)
- AI review notes → Review persistence: reads review context
- Content plugins → Developer: renders diagram content (evidence: `README.md`)
- Ground-truth comparison → Developer: compares renders (evidence: `README.md`)
- Review history → Review persistence: loads past reviews (evidence: `src/components/reviewHistory.tsx`)
- Theme management → Typed API: manages themes (evidence: `src/client/settings/themeManager.tsx`)
- Developer → Open commit review: opens commit (evidence: `src/review-open/commit-review.ts`)
