# rn-ops/scrutiny architecture

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

- Interactive diagram: https://gitdiagram.com/rn-ops/scrutiny
- Repository: https://github.com/rn-ops/scrutiny

## Overview

Scrutiny is a local-first GitHub security scanner. Users submit a repository, browse its paths, and open selected files; workspace state fetches each file and runs local security and structural analysis, accumulating findings and summaries for the dashboard. Users can explicitly request compact Gemini insights, or paste a file for local development-mode analysis. The README documents the legacy per-finding explanation endpoint, but the sampled excerpts do not show its caller; that route is shown without an inferred connection.

Main entry points: [`app/hooks/useScrutinyWorkspace.ts`](https://github.com/rn-ops/scrutiny/blob/master/app/hooks/useScrutinyWorkspace.ts) (Workspace state), [`app/page.tsx`](https://github.com/rn-ops/scrutiny/blob/master/app/page.tsx) (Page composition), [`app/components/ScrutinyDashboard.tsx`](https://github.com/rn-ops/scrutiny/blob/master/app/components/ScrutinyDashboard.tsx) (Scanner dashboard), [`lib/github.ts`](https://github.com/rn-ops/scrutiny/blob/master/lib/github.ts) (GitHub retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Workspace experience"]
  node_page["Page composition<br/>[page.tsx]"]
  node_workspace["Workspace state"]
  node_dashboard["Scanner dashboard"]
  node_viewer["File viewer<br/>[FileViewer.tsx]"]
  node_intelligence_drawer["Call-flow drawer"]
end

subgraph group_analysis["Local analysis"]
  node_analyzer["Security analyzer<br/>[analyzer.ts]"]
  node_file_intelligence["File intelligence"]
end

subgraph group_github["GitHub retrieval"]
  node_scan_route["Repository scan API<br/>[route.ts]"]
  node_file_route["File content API<br/>[route.ts]"]
  node_github_helpers["GitHub retrieval<br/>[github.ts]"]
end

subgraph group_insights["AI insights"]
  node_context_route["Insights API<br/>[route.ts]"]
  node_explain_route["Finding explanation API<br/>[route.ts]"]
end

node_user(("Scanner user"))
node_github_service(("GitHub API"))
node_gemini(("Gemini"))

node_user -->|"uses"| node_page
node_page -->|"creates"| node_workspace
node_page -->|"renders"| node_dashboard
node_workspace -->|"requests tree"| node_scan_route
node_scan_route -->|"fetches tree"| node_github_helpers
node_workspace -->|"requests file"| node_file_route
node_file_route -->|"fetches content"| node_github_helpers
node_github_helpers -->|"queries"| node_github_service
node_workspace -->|"analyzes files"| node_analyzer
node_workspace -->|"builds metadata"| node_file_intelligence
node_dashboard -->|"opens"| node_intelligence_drawer
node_dashboard -.->|"presents file"| node_viewer
node_workspace -->|"sends compact payload"| node_context_route
node_context_route -->|"generates insights"| node_gemini

click node_page "https://github.com/rn-ops/scrutiny/blob/master/app/page.tsx"
click node_workspace "https://github.com/rn-ops/scrutiny/blob/master/app/hooks/useScrutinyWorkspace.ts"
click node_dashboard "https://github.com/rn-ops/scrutiny/blob/master/app/components/ScrutinyDashboard.tsx"
click node_viewer "https://github.com/rn-ops/scrutiny/blob/master/components/FileViewer.tsx"
click node_intelligence_drawer "https://github.com/rn-ops/scrutiny/blob/master/app/components/FileIntelligenceDrawer.tsx"
click node_analyzer "https://github.com/rn-ops/scrutiny/blob/master/lib/analyzer.ts"
click node_file_intelligence "https://github.com/rn-ops/scrutiny/blob/master/lib/fileIntelligence.ts"
click node_scan_route "https://github.com/rn-ops/scrutiny/blob/master/app/api/scan/route.ts"
click node_file_route "https://github.com/rn-ops/scrutiny/blob/master/app/api/file/route.ts"
click node_github_helpers "https://github.com/rn-ops/scrutiny/blob/master/lib/github.ts"
click node_context_route "https://github.com/rn-ops/scrutiny/blob/master/app/api/context/route.ts"
click node_explain_route "https://github.com/rn-ops/scrutiny/blob/master/app/api/explain/route.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_page,node_workspace,node_dashboard,node_viewer,node_intelligence_drawer,node_user toneBlue
class node_analyzer,node_file_intelligence toneAmber
class node_scan_route,node_file_route,node_github_helpers,node_github_service toneMint
class node_context_route,node_explain_route toneRose
class node_gemini toneIndigo
```

## Components

### Workspace experience

- [Page composition](https://github.com/rn-ops/scrutiny/blob/master/app/page.tsx): `app/page.tsx`
- [Workspace state](https://github.com/rn-ops/scrutiny/blob/master/app/hooks/useScrutinyWorkspace.ts): `app/hooks/useScrutinyWorkspace.ts`
- [Scanner dashboard](https://github.com/rn-ops/scrutiny/blob/master/app/components/ScrutinyDashboard.tsx): `app/components/ScrutinyDashboard.tsx`
- [File viewer](https://github.com/rn-ops/scrutiny/blob/master/components/FileViewer.tsx): `components/FileViewer.tsx`
- [Call-flow drawer](https://github.com/rn-ops/scrutiny/blob/master/app/components/FileIntelligenceDrawer.tsx): `app/components/FileIntelligenceDrawer.tsx`

### Local analysis

- [Security analyzer](https://github.com/rn-ops/scrutiny/blob/master/lib/analyzer.ts): `lib/analyzer.ts`
- [File intelligence](https://github.com/rn-ops/scrutiny/blob/master/lib/fileIntelligence.ts): `lib/fileIntelligence.ts`

### GitHub retrieval

- [Repository scan API](https://github.com/rn-ops/scrutiny/blob/master/app/api/scan/route.ts): `app/api/scan/route.ts`
- [File content API](https://github.com/rn-ops/scrutiny/blob/master/app/api/file/route.ts): `app/api/file/route.ts`
- [GitHub retrieval](https://github.com/rn-ops/scrutiny/blob/master/lib/github.ts): `lib/github.ts`

### AI insights

- [Insights API](https://github.com/rn-ops/scrutiny/blob/master/app/api/context/route.ts): `app/api/context/route.ts`
- [Finding explanation API](https://github.com/rn-ops/scrutiny/blob/master/app/api/explain/route.ts): `app/api/explain/route.ts`

### Other components

- **Scanner user**
- **GitHub API**
- **Gemini**

## Connections

- Scanner user → Page composition: uses (evidence: `README.md`)
- Page composition → Workspace state: creates (evidence: `app/page.tsx`)
- Page composition → Scanner dashboard: renders (evidence: `app/page.tsx`)
- Workspace state → Repository scan API: requests tree (evidence: `app/hooks/useScrutinyWorkspace.ts`)
- Repository scan API → GitHub retrieval: fetches tree (evidence: `app/api/scan/route.ts`)
- Workspace state → File content API: requests file (evidence: `app/hooks/useScrutinyWorkspace.ts`)
- File content API → GitHub retrieval: fetches content (evidence: `app/api/file/route.ts`)
- GitHub retrieval → GitHub API: queries (evidence: `lib/github.ts`)
- Workspace state → Security analyzer: analyzes files (evidence: `app/hooks/useScrutinyWorkspace.ts`)
- Workspace state → File intelligence: builds metadata (evidence: `app/hooks/useScrutinyWorkspace.ts`)
- Scanner dashboard → Call-flow drawer: opens (evidence: `app/components/ScrutinyDashboard.tsx`)
- Scanner dashboard → File viewer: presents file
- Workspace state → Insights API: sends compact payload (evidence: `app/hooks/useScrutinyWorkspace.ts`)
- Insights API → Gemini: generates insights (evidence: `README.md`)
