# sharone-12/failsafeai architecture

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

- Interactive diagram: https://gitdiagram.com/sharone-12/failsafeai
- Repository: https://github.com/sharone-12/failsafeai

## Overview

FailSafe AI accepts a GitHub repository, streams a multi-stage AI code review, and presents findings, exploit scenarios, and suggested patches. The graph separates the browser workflow, API/auth boundary, repository-context preparation, and analysis/report stages. Backend implementation detail is sampled only in part; pipeline sequencing and several capabilities are therefore represented from the README, not treated as inspected source.

Main entry points: [`frontend/src/components/AnalysisPanel.jsx`](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/AnalysisPanel.jsx) (Live report panel), [`frontend/src/hooks/useSSEAnalysis.js`](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/hooks/useSSEAnalysis.js) (SSE analysis state), [`app.py`](https://github.com/sharone-12/failsafeai/blob/main/app.py) (FastAPI service), [`frontend/src/App.jsx`](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/App.jsx) (Application shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_app["Application shell<br/>[App.jsx]"]
  node_repo_input["Repository input<br/>[RepoInput.jsx]"]
  node_analysis_panel["Live report panel<br/>[AnalysisPanel.jsx]"]
  node_agent_cards["Agent status cards<br/>[AgentCards.jsx]"]
  node_bugs_view["Bug findings<br/>[BugsTab.jsx]"]
  node_vulns_view["Vulnerability findings<br/>[VulnsTab.jsx]"]
  node_attacks_view["Attack timelines<br/>[AttacksTab.jsx]"]
  node_fixes_view["Suggested fixes<br/>[FixesTab.jsx]"]
  node_summary_view["Scan summary<br/>[SummaryCard.jsx]"]
  node_sse_hook["SSE analysis state<br/>[useSSEAnalysis.js]"]
  node_github_auth["GitHub auth state<br/>[useGithubAuth.js]"]
end

subgraph group_api["API and identity"]
  node_backend["FastAPI service<br/>[app.py]"]
  node_serverless["Serverless entry<br/>[index.py]"]
end

subgraph group_context["Repository context"]
  node_fetch_repo["Fetch repository files<br/>[app.py]"]
  node_prepare_context["Chunk and build context<br/>[app.py]"]
end

subgraph group_analysis["Analysis and results"]
  node_bug_agent["Bug detection<br/>[app.py]"]
  node_vuln_agent["Vulnerability scan<br/>[app.py]"]
  node_attack_sim["Attack simulation<br/>[app.py]"]
  node_fix_generator["Fix generation<br/>[app.py]"]
end

node_developer(("Developer"))
node_github["GitHub API"]
node_llm["LLM provider"]

node_developer -->|"enters repository"| node_repo_input
node_app -->|"renders"| node_repo_input
node_app -->|"starts analysis"| node_sse_hook
node_app -->|"uses auth state"| node_github_auth
node_repo_input -.->|"submits URL"| node_sse_hook
node_sse_hook -->|"opens SSE stream"| node_backend
node_github_auth -->|"uses auth routes"| node_backend
node_serverless -->|"imports app"| node_backend
node_backend -->|"runs pipeline"| node_fetch_repo
node_fetch_repo -->|"fetches repo tree"| node_github
node_fetch_repo -->|"passes source files"| node_prepare_context
node_prepare_context -->|"provides code context"| node_bug_agent
node_prepare_context -->|"provides code context"| node_vuln_agent
node_bug_agent -.->|"requests analysis"| node_llm
node_vuln_agent -.->|"requests analysis"| node_llm
node_vuln_agent -->|"supplies findings"| node_attack_sim
node_prepare_context -->|"grounds scenarios"| node_attack_sim
node_bug_agent -->|"supplies bug findings"| node_fix_generator
node_vuln_agent -->|"supplies vulnerabilities"| node_fix_generator
node_fix_generator -.->|"requests patches"| node_llm
node_backend -->|"streams stage results"| node_sse_hook
node_sse_hook -->|"provides live state"| node_analysis_panel
node_analysis_panel -->|"renders status"| node_agent_cards
node_analysis_panel -->|"renders findings"| node_bugs_view
node_analysis_panel -->|"renders findings"| node_vulns_view
node_analysis_panel -->|"renders timelines"| node_attacks_view
node_analysis_panel -->|"renders patches"| node_fixes_view
node_analysis_panel -->|"renders summary"| node_summary_view

click node_app "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/App.jsx"
click node_repo_input "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/RepoInput.jsx"
click node_analysis_panel "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/AnalysisPanel.jsx"
click node_agent_cards "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/AgentCards.jsx"
click node_bugs_view "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/BugsTab.jsx"
click node_vulns_view "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/VulnsTab.jsx"
click node_attacks_view "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/AttacksTab.jsx"
click node_fixes_view "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/FixesTab.jsx"
click node_summary_view "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/SummaryCard.jsx"
click node_sse_hook "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/hooks/useSSEAnalysis.js"
click node_github_auth "https://github.com/sharone-12/failsafeai/blob/main/frontend/src/hooks/useGithubAuth.js"
click node_backend "https://github.com/sharone-12/failsafeai/blob/main/app.py"
click node_serverless "https://github.com/sharone-12/failsafeai/blob/main/api/index.py"
click node_fetch_repo "https://github.com/sharone-12/failsafeai/blob/main/app.py"
click node_prepare_context "https://github.com/sharone-12/failsafeai/blob/main/app.py"
click node_bug_agent "https://github.com/sharone-12/failsafeai/blob/main/app.py"
click node_vuln_agent "https://github.com/sharone-12/failsafeai/blob/main/app.py"
click node_attack_sim "https://github.com/sharone-12/failsafeai/blob/main/app.py"
click node_fix_generator "https://github.com/sharone-12/failsafeai/blob/main/app.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_app,node_repo_input,node_analysis_panel,node_agent_cards,node_bugs_view,node_vulns_view,node_attacks_view,node_fixes_view,node_summary_view,node_sse_hook,node_github_auth toneBlue
class node_backend,node_serverless toneAmber
class node_fetch_repo,node_prepare_context,node_github toneMint
class node_bug_agent,node_vuln_agent,node_attack_sim,node_fix_generator toneRose
class node_developer,node_llm toneIndigo
```

## Components

### Browser experience

- [Application shell](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Repository input](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/RepoInput.jsx): `frontend/src/components/RepoInput.jsx`
- [Live report panel](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/AnalysisPanel.jsx): `frontend/src/components/AnalysisPanel.jsx`
- [Agent status cards](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/AgentCards.jsx): `frontend/src/components/AgentCards.jsx`
- [Bug findings](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/BugsTab.jsx): `frontend/src/components/ResultTabs/BugsTab.jsx`
- [Vulnerability findings](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/VulnsTab.jsx): `frontend/src/components/ResultTabs/VulnsTab.jsx`
- [Attack timelines](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/AttacksTab.jsx): `frontend/src/components/ResultTabs/AttacksTab.jsx`
- [Suggested fixes](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/ResultTabs/FixesTab.jsx): `frontend/src/components/ResultTabs/FixesTab.jsx`
- [Scan summary](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/components/SummaryCard.jsx): `frontend/src/components/SummaryCard.jsx`
- [SSE analysis state](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/hooks/useSSEAnalysis.js): `frontend/src/hooks/useSSEAnalysis.js`
- [GitHub auth state](https://github.com/sharone-12/failsafeai/blob/main/frontend/src/hooks/useGithubAuth.js): `frontend/src/hooks/useGithubAuth.js`

### API and identity

- [FastAPI service](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`
- [Serverless entry](https://github.com/sharone-12/failsafeai/blob/main/api/index.py): `api/index.py`

### Repository context

- [Fetch repository files](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`
- [Chunk and build context](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`

### Analysis and results

- [Bug detection](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`
- [Vulnerability scan](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`
- [Attack simulation](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`
- [Fix generation](https://github.com/sharone-12/failsafeai/blob/main/app.py): `app.py`

### Other components

- **Developer**
- **GitHub API**
- **LLM provider**

## Connections

- Developer → Repository input: enters repository (evidence: `README.md`)
- Application shell → Repository input: renders
- Application shell → SSE analysis state: starts analysis (evidence: `frontend/src/App.jsx`)
- Application shell → GitHub auth state: uses auth state (evidence: `frontend/src/App.jsx`)
- Repository input → SSE analysis state: submits URL
- SSE analysis state → FastAPI service: opens SSE stream (evidence: `README.md`)
- GitHub auth state → FastAPI service: uses auth routes (evidence: `README.md`)
- Serverless entry → FastAPI service: imports app (evidence: `api/index.py`)
- FastAPI service → Fetch repository files: runs pipeline (evidence: `app.py`)
- Fetch repository files → GitHub API: fetches repo tree (evidence: `app.py`)
- Fetch repository files → Chunk and build context: passes source files (evidence: `README.md`)
- Chunk and build context → Bug detection: provides code context (evidence: `README.md`)
- Chunk and build context → Vulnerability scan: provides code context (evidence: `README.md`)
- Bug detection → LLM provider: requests analysis (evidence: `README.md`)
- Vulnerability scan → LLM provider: requests analysis (evidence: `README.md`)
- Vulnerability scan → Attack simulation: supplies findings (evidence: `README.md`)
- Chunk and build context → Attack simulation: grounds scenarios (evidence: `README.md`)
- Bug detection → Fix generation: supplies bug findings (evidence: `README.md`)
- Vulnerability scan → Fix generation: supplies vulnerabilities (evidence: `README.md`)
- Fix generation → LLM provider: requests patches (evidence: `README.md`)
- FastAPI service → SSE analysis state: streams stage results (evidence: `README.md`)
- SSE analysis state → Live report panel: provides live state (evidence: `frontend/src/App.jsx`)
- Live report panel → Agent status cards: renders status (evidence: `frontend/src/components/AnalysisPanel.jsx`)
- Live report panel → Bug findings: renders findings (evidence: `frontend/src/components/AnalysisPanel.jsx`)
- Live report panel → Vulnerability findings: renders findings (evidence: `frontend/src/components/AnalysisPanel.jsx`)
- Live report panel → Attack timelines: renders timelines (evidence: `frontend/src/components/AnalysisPanel.jsx`)
- Live report panel → Suggested fixes: renders patches (evidence: `frontend/src/components/AnalysisPanel.jsx`)
- Live report panel → Scan summary: renders summary (evidence: `frontend/src/components/AnalysisPanel.jsx`)
