# santhoshethical-cell/shadow-api-finalv3 architecture

> Architecture diagram of the GitHub repository santhoshethical-cell/shadow-api-finalv3, 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/santhoshethical-cell/shadow-api-finalv3
- Repository: https://github.com/santhoshethical-cell/shadow-api-finalv3

## Overview

Shadow API Scanner Web Application wraps the vendored scanner with authenticated browser-based scans and reporting. A user signs in, configures a scan, and receives live progress and reports; completed scans can then be enriched with component/CVE matches and remediation. The README documents advanced scan options, exports, history, and optional AI analysis. Several backend subsystems are represented from documentation and indexed references rather than inspected implementation; those relationships are kept conservative.

Main entry points: [`backend/app/main.py`](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/main.py) (Web API), [`scanner/shadow_api_scanner/cli.py`](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/cli.py) (Scanner orchestration), [`backend/app/enrichment.py`](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/enrichment.py) (Post-scan enrichment), [`frontend/static/app.js`](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/frontend/static/app.js) (Browser UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_browser["Browser UI<br/>[app.js]"]
  node_advanced["Scan options UI<br/>[advanced.js]"]
  node_api["Web API<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_scan_adapter["Scan adapter<br/>[scanner_adapter.py]"]
  node_scan_service["Scan lifecycle<br/>[scans.py]"]
  node_reports["Reports and exports<br/>[reports.py]"]
  node_storage[("Application storage<br/>[db.py]")]
end

subgraph group_scan["Scanner pipeline"]
  node_scanner_cli["Scanner orchestration<br/>[cli.py]"]
  node_discovery["Endpoint discovery"]
  node_shadow["Shadow API detection<br/>[shadow_detector.py]"]
  node_security["Security validation<br/>[security_tester.py]"]
  node_validators["Validator registry"]
  node_report_gen["Scanner reporting"]
end

subgraph group_enrich["Enrichment and CVEs"]
  node_enrichment["Post-scan enrichment<br/>[enrichment.py]"]
  node_catalog["Component catalog"]
  node_matching["CVE matching<br/>[matching.py]"]
  node_cvedb[("Local CVE database<br/>[cvedb.py]")]
  node_nvd["NVD service<br/>[nvd_client.py]"]
  node_ai["Optional AI analysis<br/>[ai_analysis.py]"]
end

subgraph group_shared["Scanner foundations"]
  node_config["Scan configuration<br/>[config.py]"]
  node_models["Scan results<br/>[models.py]"]
  node_http["HTTP client<br/>[http_client.py]"]
end

node_user(("User"))
node_target(("Scan target"))

node_user -->|"uses"| node_browser
node_browser -->|"sends requests"| node_api
node_advanced -->|"configures scans"| node_browser
node_api -->|"authenticates users"| node_auth
node_api -->|"starts scans"| node_scan_adapter
node_api -->|"tracks scans"| node_scan_service
node_api -->|"builds report views"| node_reports
node_api -->|"loads scan data"| node_storage
node_scan_adapter -.->|"runs scanner"| node_scanner_cli
node_scanner_cli -->|"configures run"| node_config
node_scanner_cli -->|"runs discovery"| node_discovery
node_discovery -.->|"provides endpoints"| node_shadow
node_shadow -.->|"provides endpoints"| node_security
node_shadow -.->|"returns endpoints"| node_scanner_cli
node_scanner_cli -->|"runs validation"| node_security
node_security -->|"delegates validation"| node_validators
node_validators -->|"uses requests"| node_http
node_http -.->|"sends requests"| node_target
node_scanner_cli -->|"generates report"| node_report_gen
node_scanner_cli -.->|"produces results"| node_models
node_api -->|"enriches completed scans"| node_enrichment
node_enrichment -->|"identifies components"| node_catalog
node_enrichment -->|"matches vulnerabilities"| node_matching
node_matching -->|"queries records"| node_cvedb
node_cvedb -->|"updates from NVD"| node_nvd
node_enrichment -->|"requests analysis"| node_ai
node_enrichment -->|"persists results"| node_storage
node_reports -.->|"serves report views"| node_browser

click node_browser "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/frontend/static/app.js"
click node_advanced "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/frontend/static/advanced.js"
click node_api "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/main.py"
click node_auth "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/auth.py"
click node_scan_adapter "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/scanner_adapter.py"
click node_scan_service "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/scans.py"
click node_reports "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/reports.py"
click node_scanner_cli "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/cli.py"
click node_config "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/core/config.py"
click node_models "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/core/models.py"
click node_discovery "https://github.com/santhoshethical-cell/shadow-api-finalv3/tree/main/scanner/shadow_api_scanner/phase1"
click node_shadow "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase2/shadow_detector.py"
click node_security "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase3/security_tester.py"
click node_validators "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase3/validation_orchestrator.py"
click node_report_gen "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase4/report_generator.py"
click node_http "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/utils/http_client.py"
click node_enrichment "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/enrichment.py"
click node_catalog "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/component_catalog.py"
click node_matching "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/matching.py"
click node_cvedb "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/cvedb.py"
click node_nvd "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/nvd_client.py"
click node_ai "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/ai_analysis.py"
click node_storage "https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/db.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_browser,node_advanced,node_api,node_auth,node_scan_adapter,node_scan_service,node_reports,node_storage,node_user toneBlue
class node_scanner_cli,node_discovery,node_shadow,node_security,node_validators,node_report_gen toneAmber
class node_enrichment,node_catalog,node_matching,node_cvedb,node_nvd,node_ai toneMint
class node_config,node_models,node_http toneRose
class node_target toneIndigo
```

## Components

### Web application

- [Browser UI](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/frontend/static/app.js): `frontend/static/app.js`
- [Scan options UI](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/frontend/static/advanced.js): `frontend/static/advanced.js`
- [Web API](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Scan adapter](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/scanner_adapter.py): `backend/app/scanner_adapter.py`
- [Scan lifecycle](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/scans.py): `backend/app/scans.py`
- [Reports and exports](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/reports.py): `backend/app/reports.py`
- [Application storage](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/db.py): `backend/app/db.py`

### Scanner pipeline

- [Scanner orchestration](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/cli.py): `scanner/shadow_api_scanner/cli.py`
- [Endpoint discovery](https://github.com/santhoshethical-cell/shadow-api-finalv3/tree/main/scanner/shadow_api_scanner/phase1): `scanner/shadow_api_scanner/phase1`
- [Shadow API detection](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase2/shadow_detector.py): `scanner/shadow_api_scanner/phase2/shadow_detector.py`
- [Security validation](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase3/security_tester.py): `scanner/shadow_api_scanner/phase3/security_tester.py`
- [Validator registry](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase3/validation_orchestrator.py): `scanner/shadow_api_scanner/phase3/validation_orchestrator.py`
- [Scanner reporting](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/phase4/report_generator.py): `scanner/shadow_api_scanner/phase4/report_generator.py`

### Enrichment and CVEs

- [Post-scan enrichment](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/enrichment.py): `backend/app/enrichment.py`
- [Component catalog](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/component_catalog.py): `backend/app/component_catalog.py`
- [CVE matching](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/matching.py): `backend/app/matching.py`
- [Local CVE database](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/cvedb.py): `backend/app/cvedb.py`
- [NVD service](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/nvd_client.py): `backend/app/nvd_client.py`
- [Optional AI analysis](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/backend/app/ai_analysis.py): `backend/app/ai_analysis.py`

### Scanner foundations

- [Scan configuration](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/core/config.py): `scanner/shadow_api_scanner/core/config.py`
- [Scan results](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/core/models.py): `scanner/shadow_api_scanner/core/models.py`
- [HTTP client](https://github.com/santhoshethical-cell/shadow-api-finalv3/blob/main/scanner/shadow_api_scanner/utils/http_client.py): `scanner/shadow_api_scanner/utils/http_client.py`

### Other components

- **User**
- **Scan target**

## Connections

- User → Browser UI: uses
- Browser UI → Web API: sends requests
- Scan options UI → Browser UI: configures scans
- Web API → Authentication: authenticates users (evidence: `backend/app/main.py`)
- Web API → Scan adapter: starts scans (evidence: `backend/app/main.py`)
- Web API → Scan lifecycle: tracks scans (evidence: `backend/app/main.py`)
- Web API → Reports and exports: builds report views (evidence: `backend/app/main.py`)
- Web API → Application storage: loads scan data (evidence: `backend/app/main.py`)
- Scan adapter → Scanner orchestration: runs scanner
- Scanner orchestration → Scan configuration: configures run (evidence: `scanner/shadow_api_scanner/cli.py`)
- Scanner orchestration → Endpoint discovery: runs discovery (evidence: `scanner/shadow_api_scanner/cli.py`)
- Endpoint discovery → Shadow API detection: provides endpoints (evidence: `scanner/shadow_api_scanner/phase2/shadow_detector.py`)
- Shadow API detection → Security validation: provides endpoints
- Shadow API detection → Scanner orchestration: returns endpoints (evidence: `scanner/shadow_api_scanner/cli.py`)
- Scanner orchestration → Security validation: runs validation (evidence: `scanner/shadow_api_scanner/cli.py`)
- Security validation → Validator registry: delegates validation (evidence: `scanner/shadow_api_scanner/phase3/security_tester.py`)
- Validator registry → HTTP client: uses requests (evidence: `scanner/shadow_api_scanner/phase3/validation_orchestrator.py`)
- HTTP client → Scan target: sends requests
- Scanner orchestration → Scanner reporting: generates report (evidence: `scanner/shadow_api_scanner/cli.py`)
- Scanner orchestration → Scan results: produces results (evidence: `scanner/shadow_api_scanner/cli.py`)
- Web API → Post-scan enrichment: enriches completed scans (evidence: `backend/app/main.py`)
- Post-scan enrichment → Component catalog: identifies components (evidence: `backend/app/enrichment.py`)
- Post-scan enrichment → CVE matching: matches vulnerabilities (evidence: `backend/app/enrichment.py`)
- CVE matching → Local CVE database: queries records (evidence: `backend/app/matching.py`)
- Local CVE database → NVD service: updates from NVD (evidence: `backend/app/cvedb.py`)
- Post-scan enrichment → Optional AI analysis: requests analysis (evidence: `backend/app/enrichment.py`)
- Post-scan enrichment → Application storage: persists results (evidence: `backend/app/enrichment.py`)
- Reports and exports → Browser UI: serves report views
