# rivian/ai-sast architecture

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

- Interactive diagram: https://gitdiagram.com/rivian/ai-sast
- Repository: https://github.com/rivian/ai-sast

## Overview

AI-SAST scans repository code with a configurable AI backend, optionally validates findings, and produces reports or PR comments. Its principal workflow is PR-triggered diff scanning or a manual full scan; a separate feedback workflow stores developer labels for use as context in later scans. The graph preserves the major documented scan, validation, reporting, feedback, and backend capabilities. Some wiring is based on the source index or README because the relevant implementation was not fully excerpted; uncertain connections are omitted.

Main entry points: [`src/core/scanner.py`](https://github.com/rivian/ai-sast/blob/main/src/core/scanner.py) (Code scanner), [`src/main/pr_scan.py`](https://github.com/rivian/ai-sast/blob/main/src/main/pr_scan.py) (PR scan), [`src/core/validator.py`](https://github.com/rivian/ai-sast/blob/main/src/core/validator.py) (Finding validator), [`src/main/full_scan.py`](https://github.com/rivian/ai-sast/blob/main/src/main/full_scan.py) (Full scan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Scan entry points"]
  node_prscan["PR scan<br/>[pr_scan.py]"]
  node_fullscan["Full scan<br/>[full_scan.py]"]
  node_feedbackjob["Feedback collection"]
end

subgraph group_analysis["Analysis pipeline"]
  node_scanner["Code scanner<br/>[scanner.py]"]
  node_validator["Finding validator<br/>[validator.py]"]
  node_report["Report generator<br/>[report.py]"]
  node_config["Scan configuration<br/>[config.py]"]
end

subgraph group_providers["AI and context"]
  node_vertex["Vertex AI client<br/>[vertex.py]"]
  node_bedrock["Bedrock client<br/>[bedrock.py]"]
  node_ollama["Ollama client<br/>[ollama.py]"]
  node_jira["Jira context<br/>[jira.py]"]
  node_vector["Vector integration<br/>[vector.py]"]
  node_notifications["Notifications<br/>[notifications.py]"]
end

subgraph group_feedback["Feedback and storage"]
  node_feedback["Feedback client<br/>[feedback.py]"]
  node_sqlite[("SQLite scan store<br/>[scan_database.py]")]
  node_databricks[("Databricks store<br/>[databricks.py]")]
end

node_developer(("Developer"))
node_github(("GitHub repository"))

node_developer -->|"opens PR"| node_github
node_github -->|"triggers scan"| node_prscan
node_developer -->|"starts manually"| node_fullscan
node_github -.->|"provides repository"| node_fullscan
node_github -->|"triggers collection"| node_feedbackjob
node_prscan -->|"scans changed files"| node_scanner
node_fullscan -->|"scans repository"| node_scanner
node_prscan -->|"validates findings"| node_validator
node_prscan -->|"generates report"| node_report
node_fullscan -->|"generates report"| node_report
node_prscan -->|"posts comments"| node_github
node_scanner -->|"reads settings"| node_config
node_validator -->|"reads settings"| node_config
node_scanner -->|"uses backend"| node_vertex
node_scanner -->|"uses backend"| node_bedrock
node_scanner -->|"uses backend"| node_ollama
node_validator -->|"uses backend"| node_vertex
node_validator -->|"uses backend"| node_bedrock
node_validator -->|"uses backend"| node_ollama
node_scanner -->|"fetches context"| node_jira
node_scanner -.->|"loads context"| node_feedback
node_validator -->|"loads context"| node_feedback
node_feedbackjob -->|"stores labels"| node_feedback
node_feedback -->|"selects backend"| node_sqlite
node_feedback -->|"selects backend"| node_databricks
node_prscan -->|"stores findings"| node_sqlite
node_fullscan -->|"stores findings"| node_sqlite
node_prscan -.->|"sends alerts"| node_notifications
node_scanner -.->|"uses embeddings"| node_vector

click node_prscan "https://github.com/rivian/ai-sast/blob/main/src/main/pr_scan.py"
click node_fullscan "https://github.com/rivian/ai-sast/blob/main/src/main/full_scan.py"
click node_feedbackjob "https://github.com/rivian/ai-sast/blob/main/src/main/collect_feedback.py"
click node_scanner "https://github.com/rivian/ai-sast/blob/main/src/core/scanner.py"
click node_validator "https://github.com/rivian/ai-sast/blob/main/src/core/validator.py"
click node_report "https://github.com/rivian/ai-sast/blob/main/src/core/report.py"
click node_config "https://github.com/rivian/ai-sast/blob/main/src/core/config.py"
click node_vertex "https://github.com/rivian/ai-sast/blob/main/src/core/vertex.py"
click node_bedrock "https://github.com/rivian/ai-sast/blob/main/src/integrations/bedrock.py"
click node_ollama "https://github.com/rivian/ai-sast/blob/main/src/integrations/ollama.py"
click node_jira "https://github.com/rivian/ai-sast/blob/main/src/integrations/jira.py"
click node_vector "https://github.com/rivian/ai-sast/blob/main/src/integrations/vector.py"
click node_notifications "https://github.com/rivian/ai-sast/blob/main/src/integrations/notifications.py"
click node_feedback "https://github.com/rivian/ai-sast/blob/main/src/integrations/feedback.py"
click node_sqlite "https://github.com/rivian/ai-sast/blob/main/src/integrations/scan_database.py"
click node_databricks "https://github.com/rivian/ai-sast/blob/main/src/integrations/databricks.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_prscan,node_fullscan,node_feedbackjob toneBlue
class node_scanner,node_validator,node_report,node_config toneAmber
class node_vertex,node_bedrock,node_ollama,node_jira,node_vector,node_notifications toneMint
class node_feedback,node_sqlite,node_databricks toneRose
class node_developer,node_github toneIndigo
```

## Components

### Scan entry points

- [PR scan](https://github.com/rivian/ai-sast/blob/main/src/main/pr_scan.py): `src/main/pr_scan.py`
- [Full scan](https://github.com/rivian/ai-sast/blob/main/src/main/full_scan.py): `src/main/full_scan.py`
- [Feedback collection](https://github.com/rivian/ai-sast/blob/main/src/main/collect_feedback.py): `src/main/collect_feedback.py`

### Analysis pipeline

- [Code scanner](https://github.com/rivian/ai-sast/blob/main/src/core/scanner.py): `src/core/scanner.py`
- [Finding validator](https://github.com/rivian/ai-sast/blob/main/src/core/validator.py): `src/core/validator.py`
- [Report generator](https://github.com/rivian/ai-sast/blob/main/src/core/report.py): `src/core/report.py`
- [Scan configuration](https://github.com/rivian/ai-sast/blob/main/src/core/config.py): `src/core/config.py`

### AI and context

- [Vertex AI client](https://github.com/rivian/ai-sast/blob/main/src/core/vertex.py): `src/core/vertex.py`
- [Bedrock client](https://github.com/rivian/ai-sast/blob/main/src/integrations/bedrock.py): `src/integrations/bedrock.py`
- [Ollama client](https://github.com/rivian/ai-sast/blob/main/src/integrations/ollama.py): `src/integrations/ollama.py`
- [Jira context](https://github.com/rivian/ai-sast/blob/main/src/integrations/jira.py): `src/integrations/jira.py`
- [Vector integration](https://github.com/rivian/ai-sast/blob/main/src/integrations/vector.py): `src/integrations/vector.py`
- [Notifications](https://github.com/rivian/ai-sast/blob/main/src/integrations/notifications.py): `src/integrations/notifications.py`

### Feedback and storage

- [Feedback client](https://github.com/rivian/ai-sast/blob/main/src/integrations/feedback.py): `src/integrations/feedback.py`
- [SQLite scan store](https://github.com/rivian/ai-sast/blob/main/src/integrations/scan_database.py): `src/integrations/scan_database.py`
- [Databricks store](https://github.com/rivian/ai-sast/blob/main/src/integrations/databricks.py): `src/integrations/databricks.py`

### Other components

- **Developer**
- **GitHub repository**

## Connections

- Developer → GitHub repository: opens PR (evidence: `README.md`)
- GitHub repository → PR scan: triggers scan (evidence: `README.md`)
- Developer → Full scan: starts manually (evidence: `README.md`)
- GitHub repository → Full scan: provides repository
- GitHub repository → Feedback collection: triggers collection (evidence: `README.md`)
- PR scan → Code scanner: scans changed files (evidence: `src/main/pr_scan.py`)
- Full scan → Code scanner: scans repository (evidence: `src/main/full_scan.py`)
- PR scan → Finding validator: validates findings (evidence: `src/main/pr_scan.py`)
- PR scan → Report generator: generates report (evidence: `src/main/pr_scan.py`)
- Full scan → Report generator: generates report (evidence: `src/main/full_scan.py`)
- PR scan → GitHub repository: posts comments (evidence: `README.md`)
- Code scanner → Scan configuration: reads settings (evidence: `src/core/scanner.py`)
- Finding validator → Scan configuration: reads settings (evidence: `src/core/validator.py`)
- Code scanner → Vertex AI client: uses backend (evidence: `src/core/scanner.py`)
- Code scanner → Bedrock client: uses backend (evidence: `src/core/scanner.py`)
- Code scanner → Ollama client: uses backend (evidence: `src/core/scanner.py`)
- Finding validator → Vertex AI client: uses backend (evidence: `src/core/validator.py`)
- Finding validator → Bedrock client: uses backend (evidence: `src/core/validator.py`)
- Finding validator → Ollama client: uses backend (evidence: `src/core/validator.py`)
- Code scanner → Jira context: fetches context (evidence: `src/core/scanner.py`)
- Code scanner → Feedback client: loads context (evidence: `src/core/scanner.py`)
- Finding validator → Feedback client: loads context (evidence: `src/core/validator.py`)
- Feedback collection → Feedback client: stores labels (evidence: `src/main/collect_feedback.py`)
- Feedback client → SQLite scan store: selects backend (evidence: `src/integrations/feedback.py`)
- Feedback client → Databricks store: selects backend (evidence: `src/integrations/feedback.py`)
- PR scan → SQLite scan store: stores findings (evidence: `src/main/pr_scan.py`)
- Full scan → SQLite scan store: stores findings (evidence: `src/main/full_scan.py`)
- PR scan → Notifications: sends alerts (evidence: `src/main/pr_scan.py`)
- Code scanner → Vector integration: uses embeddings
