# hugoborrego/depguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/hugoborrego/depguard-ai
- Repository: https://github.com/hugoborrego/depguard-ai

## Overview

DepGuard AI is a Node.js dependency analyzer with a browser interface and FastAPI backend. Users submit a package.json or GitHub repository; the backend gathers package and vulnerability data, applies deterministic rules, optionally adds AI context, and returns a findings report. The graph preserves the documented npm, OSV, GitHub, health, and streamed-progress capabilities. Several frontend connections and unsampled service details are documented rather than verified from source, so those links are dashed with no evidence path.

Main entry points: [`backend/app/services/analyzer.py`](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/analyzer.py) (Analysis orchestrator), [`frontend/src/hooks/useAnalysis.ts`](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/hooks/useAnalysis.ts) (Analysis state), [`backend/app/routers/analyze.py`](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/routers/analyze.py) (Analysis endpoints), [`frontend/src/lib/api.ts`](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Analysis interface"]
  node_github_form["GitHub form<br/>[GitHubForm.tsx]"]
  node_upload_form["Upload form<br/>[UploadForm.tsx]"]
  node_analysis_hook["Analysis state<br/>[useAnalysis.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_report_view["Findings and summary<br/>[FindingsTable.tsx]"]
  node_filters["Finding filters<br/>[FiltersBar.tsx]"]
  node_export["Report export<br/>[ExportButton.tsx]"]
  node_health_hook["Health status<br/>[useHealth.ts]"]
end

subgraph group_api["API entry"]
  node_analyze_router["Analysis endpoints<br/>[analyze.py]"]
  node_health_router["Health endpoint<br/>[health.py]"]
  node_report_schema["Report contract<br/>[report.py]"]
end

subgraph group_analysis["Analysis pipeline"]
  node_github_fetch["Manifest collection<br/>[github.py]"]
  node_package_parser["Manifest parsing<br/>[package_parser.py]"]
  node_analyzer["Analysis orchestrator<br/>[analyzer.py]"]
  node_rules["Deterministic rules<br/>[rules.py]"]
end

subgraph group_integrations["External data"]
  node_npm_registry["npm package data<br/>[npm_registry.py]"]
  node_osv["Vulnerability lookup<br/>[osv.py]"]
  node_llm["Optional AI analysis<br/>[llm_analyzer.py]"]
end

subgraph group_shared["Shared runtime"]
  node_http_client["HTTP, retry, cache<br/>[http_client.py]"]
  node_semver["Version utilities<br/>[semver.py]"]
end

node_user(("User"))
node_github_service["GitHub"]
node_npm_service["npm Registry"]
node_osv_service["OSV.dev"]
node_anthropic_service["Anthropic Claude"]
node_browser(("Browser"))

node_user -.->|"enters repository"| node_github_form
node_user -.->|"uploads manifest"| node_upload_form
node_github_form -.->|"starts analysis"| node_analysis_hook
node_upload_form -.->|"starts analysis"| node_analysis_hook
node_analysis_hook -.->|"requests analysis"| node_api_client
node_api_client -.->|"calls API"| node_analyze_router
node_analyze_router -->|"finds manifests"| node_github_fetch
node_analyze_router -->|"parses upload"| node_package_parser
node_analyze_router -->|"runs analysis"| node_analyzer
node_github_fetch -.->|"fetches manifests"| node_github_service
node_analyzer -->|"uses parsed manifests"| node_package_parser
node_analyzer -->|"queries package data"| node_npm_registry
node_analyzer -->|"queries vulnerabilities"| node_osv
node_analyzer -->|"evaluates findings"| node_rules
node_analyzer -.->|"adds optional context"| node_llm
node_npm_registry -.->|"queries registry"| node_npm_service
node_osv -.->|"queries advisories"| node_osv_service
node_llm -.->|"sends batches"| node_anthropic_service
node_npm_registry -->|"uses HTTP client"| node_http_client
node_osv -->|"uses HTTP client"| node_http_client
node_github_fetch -->|"uses HTTP client"| node_http_client
node_npm_registry -->|"compares versions"| node_semver
node_osv -->|"checks ranges"| node_semver
node_rules -->|"evaluates ranges"| node_semver
node_analyze_router -.->|"returns report"| node_report_schema
node_report_schema -.->|"provides findings"| node_api_client
node_analysis_hook -.->|"displays findings"| node_report_view
node_analysis_hook -.->|"filters findings"| node_filters
node_analysis_hook -.->|"exports report"| node_export
node_browser -.->|"checks service"| node_health_hook
node_health_hook -.->|"requests health"| node_api_client
node_api_client -.->|"calls health API"| node_health_router

click node_github_form "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/GitHubForm.tsx"
click node_upload_form "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/UploadForm.tsx"
click node_analysis_hook "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/hooks/useAnalysis.ts"
click node_api_client "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/lib/api.ts"
click node_report_view "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/FindingsTable.tsx"
click node_filters "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/FiltersBar.tsx"
click node_export "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/ExportButton.tsx"
click node_health_hook "https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/hooks/useHealth.ts"
click node_analyze_router "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/routers/analyze.py"
click node_health_router "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/routers/health.py"
click node_github_fetch "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/github.py"
click node_package_parser "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/package_parser.py"
click node_analyzer "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/analyzer.py"
click node_npm_registry "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/npm_registry.py"
click node_osv "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/osv.py"
click node_rules "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/rules.py"
click node_llm "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/llm_analyzer.py"
click node_report_schema "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/schemas/report.py"
click node_http_client "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/core/http_client.py"
click node_semver "https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/core/semver.py"

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_github_form,node_upload_form,node_analysis_hook,node_api_client,node_report_view,node_filters,node_export,node_health_hook,node_user,node_browser toneBlue
class node_analyze_router,node_health_router,node_report_schema toneAmber
class node_github_fetch,node_package_parser,node_analyzer,node_rules toneMint
class node_npm_registry,node_osv,node_llm toneRose
class node_http_client,node_semver,node_github_service,node_npm_service,node_osv_service,node_anthropic_service toneIndigo
```

## Components

### Analysis interface

- [GitHub form](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/GitHubForm.tsx): `frontend/src/components/GitHubForm.tsx`
- [Upload form](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/UploadForm.tsx): `frontend/src/components/UploadForm.tsx`
- [Analysis state](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/hooks/useAnalysis.ts): `frontend/src/hooks/useAnalysis.ts`
- [API client](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Findings and summary](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/FindingsTable.tsx): `frontend/src/components/FindingsTable.tsx`
- [Finding filters](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/FiltersBar.tsx): `frontend/src/components/FiltersBar.tsx`
- [Report export](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/components/ExportButton.tsx): `frontend/src/components/ExportButton.tsx`
- [Health status](https://github.com/hugoborrego/depguard-ai/blob/main/frontend/src/hooks/useHealth.ts): `frontend/src/hooks/useHealth.ts`

### API entry

- [Analysis endpoints](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/routers/analyze.py): `backend/app/routers/analyze.py`
- [Health endpoint](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/routers/health.py): `backend/app/routers/health.py`
- [Report contract](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/schemas/report.py): `backend/app/schemas/report.py`

### Analysis pipeline

- [Manifest collection](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/github.py): `backend/app/services/github.py`
- [Manifest parsing](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/package_parser.py): `backend/app/services/package_parser.py`
- [Analysis orchestrator](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/analyzer.py): `backend/app/services/analyzer.py`
- [Deterministic rules](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/rules.py): `backend/app/services/rules.py`

### External data

- [npm package data](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/npm_registry.py): `backend/app/services/npm_registry.py`
- [Vulnerability lookup](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/osv.py): `backend/app/services/osv.py`
- [Optional AI analysis](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/services/llm_analyzer.py): `backend/app/services/llm_analyzer.py`

### Shared runtime

- [HTTP, retry, cache](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/core/http_client.py): `backend/app/core/http_client.py`
- [Version utilities](https://github.com/hugoborrego/depguard-ai/blob/main/backend/app/core/semver.py): `backend/app/core/semver.py`

### Other components

- **User**
- **GitHub**
- **npm Registry**
- **OSV.dev**
- **Anthropic Claude**
- **Browser**

## Connections

- User → GitHub form: enters repository
- User → Upload form: uploads manifest
- GitHub form → Analysis state: starts analysis
- Upload form → Analysis state: starts analysis
- Analysis state → API client: requests analysis
- API client → Analysis endpoints: calls API
- Analysis endpoints → Manifest collection: finds manifests (evidence: `backend/app/routers/analyze.py`)
- Analysis endpoints → Manifest parsing: parses upload (evidence: `backend/app/routers/analyze.py`)
- Analysis endpoints → Analysis orchestrator: runs analysis (evidence: `backend/app/routers/analyze.py`)
- Manifest collection → GitHub: fetches manifests
- Analysis orchestrator → Manifest parsing: uses parsed manifests (evidence: `backend/app/services/analyzer.py`)
- Analysis orchestrator → npm package data: queries package data (evidence: `backend/app/services/analyzer.py`)
- Analysis orchestrator → Vulnerability lookup: queries vulnerabilities (evidence: `backend/app/services/analyzer.py`)
- Analysis orchestrator → Deterministic rules: evaluates findings (evidence: `backend/app/services/analyzer.py`)
- Analysis orchestrator → Optional AI analysis: adds optional context (evidence: `backend/app/services/analyzer.py`)
- npm package data → npm Registry: queries registry
- Vulnerability lookup → OSV.dev: queries advisories
- Optional AI analysis → Anthropic Claude: sends batches (evidence: `backend/app/services/llm_analyzer.py`)
- npm package data → HTTP, retry, cache: uses HTTP client (evidence: `backend/app/services/npm_registry.py`)
- Vulnerability lookup → HTTP, retry, cache: uses HTTP client (evidence: `backend/app/services/osv.py`)
- Manifest collection → HTTP, retry, cache: uses HTTP client (evidence: `backend/app/services/github.py`)
- npm package data → Version utilities: compares versions (evidence: `backend/app/services/npm_registry.py`)
- Vulnerability lookup → Version utilities: checks ranges (evidence: `backend/app/services/osv.py`)
- Deterministic rules → Version utilities: evaluates ranges (evidence: `backend/app/services/rules.py`)
- Analysis endpoints → Report contract: returns report (evidence: `backend/app/routers/analyze.py`)
- Report contract → API client: provides findings
- Analysis state → Findings and summary: displays findings
- Analysis state → Finding filters: filters findings
- Analysis state → Report export: exports report
- Browser → Health status: checks service
- Health status → API client: requests health
- API client → Health endpoint: calls health API
