# jojohere05/pbl-2 architecture

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

- Interactive diagram: https://gitdiagram.com/jojohere05/pbl-2
- Repository: https://github.com/jojohere05/pbl-2

## Overview

FinGuard scans uploaded or GitHub-hosted repositories, combines secret, dependency, and Terraform findings, evaluates risk, and returns explanations and reports. The API exposes scan, dashboard, feedback, and live-update routes; a separate CLI provides a standalone scan workflow. GitHub App processing is an additional integration branch. The graph follows documented capabilities and indexed references; some API internals and feedback wiring were not shown, so uncertain connections are omitted or marked unverified.

Main entry points: [`api/routes/scan.py`](https://github.com/jojohere05/pbl-2/blob/main/api/routes/scan.py) (Scan API), [`api/main.py`](https://github.com/jojohere05/pbl-2/blob/main/api/main.py) (API Application), [`finguard/main.py`](https://github.com/jojohere05/pbl-2/blob/main/finguard/main.py) (CLI Scanner), [`api/adk_agents/orchestrator_agent.py`](https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/orchestrator_agent.py) (Scan Orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Points"]
  node_api["API Application<br/>[main.py]"]
  node_scan_route["Scan API<br/>[scan.py]"]
  node_dashboard["Dashboard API<br/>[dashboard.py]"]
  node_feedback["Feedback API<br/>[feedback.py]"]
  node_ws["Live Updates<br/>[ws.py]"]
  node_cli["CLI Scanner<br/>[main.py]"]
end

subgraph group_scanning["Scanning and Analysis"]
  node_context["Context Classifier"]
  node_runner["Scan Runner<br/>[runner.py]"]
  node_orchestrator["Scan Orchestrator"]
  node_dependency["Dependency Scanner"]
  node_terraform["Terraform Scanner<br/>[terraform_agent.py]"]
  node_api_secrets["Secret Scanner"]
  node_cli_orchestrator["CLI Orchestrator<br/>[orchestrator.py]"]
  node_cli_dependency["CLI Dependency Scanner"]
  node_cli_terraform["CLI Terraform Scanner<br/>[terraform_agent.py]"]
  node_cli_secrets["CLI Secret Scanner"]
end

subgraph group_results["Results and Learning"]
  node_risk["Risk Engine<br/>[risk_engine.py]"]
  node_explainer["Finding Explainer<br/>[explainer.py]"]
  node_retriever["Rule Retriever<br/>[retriever.py]"]
  node_pdf["PDF Reports<br/>[pdf_generator.py]"]
  node_database[("Scan Database<br/>[database.py]")]
  node_cli_risk["CLI Risk Engine<br/>[risk_engine.py]"]
  node_cli_explainer["CLI Explainer<br/>[explainer.py]"]
  node_cli_retriever["CLI Rule Retriever<br/>[retriever.py]"]
end

subgraph group_github["GitHub Integration"]
  node_github_webhook["GitHub Webhook<br/>[webhook_handler.py]"]
  node_worker["Background Worker"]
  node_github_client["GitHub Client<br/>[github_client.py]"]
end

node_user(("User"))
node_github(("GitHub"))

node_user -->|"uses"| node_api
node_api -->|"routes requests"| node_scan_route
node_api -->|"routes requests"| node_dashboard
node_api -->|"routes requests"| node_feedback
node_api -->|"routes connections"| node_ws
node_scan_route -->|"classifies context"| node_context
node_scan_route -->|"runs scan"| node_runner
node_runner -->|"invokes"| node_orchestrator
node_orchestrator -->|"dispatches"| node_dependency
node_orchestrator -->|"dispatches"| node_terraform
node_orchestrator -->|"dispatches"| node_api_secrets
node_scan_route -->|"scores findings"| node_risk
node_scan_route -->|"explains findings"| node_explainer
node_explainer -->|"retrieves rules"| node_retriever
node_scan_route -->|"generates report"| node_pdf
node_scan_route -->|"saves scans"| node_database
node_dashboard -->|"reads summaries"| node_database
node_scan_route -->|"publishes progress"| node_ws
node_user -->|"runs scan"| node_cli
node_cli -->|"coordinates scan"| node_cli_orchestrator
node_cli_orchestrator -->|"dispatches"| node_cli_dependency
node_cli_orchestrator -->|"dispatches"| node_cli_terraform
node_cli_orchestrator -->|"dispatches"| node_cli_secrets
node_cli -->|"scores findings"| node_cli_risk
node_cli -->|"explains findings"| node_cli_explainer
node_cli_explainer -->|"retrieves rules"| node_cli_retriever
node_github -.->|"sends events"| node_github_webhook
node_github_webhook -->|"queues scans"| node_worker
node_worker -->|"runs scan"| node_runner
node_worker -->|"updates checks"| node_github_client
node_github_client -->|"calls API"| node_github
node_feedback -.->|"updates weights"| node_risk

click node_api "https://github.com/jojohere05/pbl-2/blob/main/api/main.py"
click node_scan_route "https://github.com/jojohere05/pbl-2/blob/main/api/routes/scan.py"
click node_dashboard "https://github.com/jojohere05/pbl-2/blob/main/api/routes/dashboard.py"
click node_feedback "https://github.com/jojohere05/pbl-2/blob/main/api/routes/feedback.py"
click node_ws "https://github.com/jojohere05/pbl-2/blob/main/api/routes/ws.py"
click node_cli "https://github.com/jojohere05/pbl-2/blob/main/finguard/main.py"
click node_context "https://github.com/jojohere05/pbl-2/blob/main/api/context_classifier.py"
click node_runner "https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/runner.py"
click node_orchestrator "https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/orchestrator_agent.py"
click node_dependency "https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/dependency_agent.py"
click node_terraform "https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/terraform_agent.py"
click node_api_secrets "https://github.com/jojohere05/pbl-2/tree/main/api/adk_agents"
click node_cli_orchestrator "https://github.com/jojohere05/pbl-2/blob/main/finguard/agents/orchestrator.py"
click node_cli_dependency "https://github.com/jojohere05/pbl-2/blob/main/finguard/agents/dependency_agent.py"
click node_cli_terraform "https://github.com/jojohere05/pbl-2/blob/main/finguard/agents/terraform_agent.py"
click node_cli_secrets "https://github.com/jojohere05/pbl-2/tree/main/finguard/agents"
click node_risk "https://github.com/jojohere05/pbl-2/blob/main/api/risk_engine.py"
click node_explainer "https://github.com/jojohere05/pbl-2/blob/main/api/rag/explainer.py"
click node_retriever "https://github.com/jojohere05/pbl-2/blob/main/api/rag/retriever.py"
click node_pdf "https://github.com/jojohere05/pbl-2/blob/main/api/report/pdf_generator.py"
click node_database "https://github.com/jojohere05/pbl-2/blob/main/api/database.py"
click node_cli_risk "https://github.com/jojohere05/pbl-2/blob/main/finguard/risk_engine.py"
click node_cli_explainer "https://github.com/jojohere05/pbl-2/blob/main/finguard/rag/explainer.py"
click node_cli_retriever "https://github.com/jojohere05/pbl-2/blob/main/finguard/rag/retriever.py"
click node_github_webhook "https://github.com/jojohere05/pbl-2/blob/main/api/github_app/webhook_handler.py"
click node_worker "https://github.com/jojohere05/pbl-2/blob/main/api/github_app/background_worker.py"
click node_github_client "https://github.com/jojohere05/pbl-2/blob/main/api/github_app/github_client.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_api,node_scan_route,node_dashboard,node_feedback,node_ws,node_cli,node_user toneBlue
class node_context,node_runner,node_orchestrator,node_dependency,node_terraform,node_api_secrets,node_cli_orchestrator,node_cli_dependency,node_cli_terraform,node_cli_secrets toneAmber
class node_risk,node_explainer,node_retriever,node_pdf,node_database,node_cli_risk,node_cli_explainer,node_cli_retriever toneMint
class node_github_webhook,node_worker,node_github_client toneRose
class node_github toneIndigo
```

## Components

### Entry Points

- [API Application](https://github.com/jojohere05/pbl-2/blob/main/api/main.py): `api/main.py`
- [Scan API](https://github.com/jojohere05/pbl-2/blob/main/api/routes/scan.py): `api/routes/scan.py`
- [Dashboard API](https://github.com/jojohere05/pbl-2/blob/main/api/routes/dashboard.py): `api/routes/dashboard.py`
- [Feedback API](https://github.com/jojohere05/pbl-2/blob/main/api/routes/feedback.py): `api/routes/feedback.py`
- [Live Updates](https://github.com/jojohere05/pbl-2/blob/main/api/routes/ws.py): `api/routes/ws.py`
- [CLI Scanner](https://github.com/jojohere05/pbl-2/blob/main/finguard/main.py): `finguard/main.py`

### Scanning and Analysis

- [Context Classifier](https://github.com/jojohere05/pbl-2/blob/main/api/context_classifier.py): `api/context_classifier.py`
- [Scan Runner](https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/runner.py): `api/adk_agents/runner.py`
- [Scan Orchestrator](https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/orchestrator_agent.py): `api/adk_agents/orchestrator_agent.py`
- [Dependency Scanner](https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/dependency_agent.py): `api/adk_agents/dependency_agent.py`
- [Terraform Scanner](https://github.com/jojohere05/pbl-2/blob/main/api/adk_agents/terraform_agent.py): `api/adk_agents/terraform_agent.py`
- [Secret Scanner](https://github.com/jojohere05/pbl-2/tree/main/api/adk_agents): `api/adk_agents`
- [CLI Orchestrator](https://github.com/jojohere05/pbl-2/blob/main/finguard/agents/orchestrator.py): `finguard/agents/orchestrator.py`
- [CLI Dependency Scanner](https://github.com/jojohere05/pbl-2/blob/main/finguard/agents/dependency_agent.py): `finguard/agents/dependency_agent.py`
- [CLI Terraform Scanner](https://github.com/jojohere05/pbl-2/blob/main/finguard/agents/terraform_agent.py): `finguard/agents/terraform_agent.py`
- [CLI Secret Scanner](https://github.com/jojohere05/pbl-2/tree/main/finguard/agents): `finguard/agents`

### Results and Learning

- [Risk Engine](https://github.com/jojohere05/pbl-2/blob/main/api/risk_engine.py): `api/risk_engine.py`
- [Finding Explainer](https://github.com/jojohere05/pbl-2/blob/main/api/rag/explainer.py): `api/rag/explainer.py`
- [Rule Retriever](https://github.com/jojohere05/pbl-2/blob/main/api/rag/retriever.py): `api/rag/retriever.py`
- [PDF Reports](https://github.com/jojohere05/pbl-2/blob/main/api/report/pdf_generator.py): `api/report/pdf_generator.py`
- [Scan Database](https://github.com/jojohere05/pbl-2/blob/main/api/database.py): `api/database.py`
- [CLI Risk Engine](https://github.com/jojohere05/pbl-2/blob/main/finguard/risk_engine.py): `finguard/risk_engine.py`
- [CLI Explainer](https://github.com/jojohere05/pbl-2/blob/main/finguard/rag/explainer.py): `finguard/rag/explainer.py`
- [CLI Rule Retriever](https://github.com/jojohere05/pbl-2/blob/main/finguard/rag/retriever.py): `finguard/rag/retriever.py`

### GitHub Integration

- [GitHub Webhook](https://github.com/jojohere05/pbl-2/blob/main/api/github_app/webhook_handler.py): `api/github_app/webhook_handler.py`
- [Background Worker](https://github.com/jojohere05/pbl-2/blob/main/api/github_app/background_worker.py): `api/github_app/background_worker.py`
- [GitHub Client](https://github.com/jojohere05/pbl-2/blob/main/api/github_app/github_client.py): `api/github_app/github_client.py`

### Other components

- **User**
- **GitHub**

## Connections

- User → API Application: uses (evidence: `README.md`)
- API Application → Scan API: routes requests (evidence: `api/main.py`)
- API Application → Dashboard API: routes requests (evidence: `api/main.py`)
- API Application → Feedback API: routes requests (evidence: `api/main.py`)
- API Application → Live Updates: routes connections (evidence: `api/main.py`)
- Scan API → Context Classifier: classifies context (evidence: `api/routes/scan.py`)
- Scan API → Scan Runner: runs scan (evidence: `api/routes/scan.py`)
- Scan Runner → Scan Orchestrator: invokes (evidence: `api/adk_agents/runner.py`)
- Scan Orchestrator → Dependency Scanner: dispatches (evidence: `api/adk_agents/orchestrator_agent.py`)
- Scan Orchestrator → Terraform Scanner: dispatches (evidence: `api/adk_agents/orchestrator_agent.py`)
- Scan Orchestrator → Secret Scanner: dispatches (evidence: `api/adk_agents/orchestrator_agent.py`)
- Scan API → Risk Engine: scores findings (evidence: `api/routes/scan.py`)
- Scan API → Finding Explainer: explains findings (evidence: `api/routes/scan.py`)
- Finding Explainer → Rule Retriever: retrieves rules (evidence: `api/rag/explainer.py`)
- Scan API → PDF Reports: generates report (evidence: `api/routes/scan.py`)
- Scan API → Scan Database: saves scans (evidence: `api/routes/scan.py`)
- Dashboard API → Scan Database: reads summaries (evidence: `api/routes/dashboard.py`)
- Scan API → Live Updates: publishes progress (evidence: `api/routes/scan.py`)
- User → CLI Scanner: runs scan (evidence: `README.md`)
- CLI Scanner → CLI Orchestrator: coordinates scan (evidence: `finguard/main.py`)
- CLI Orchestrator → CLI Dependency Scanner: dispatches (evidence: `finguard/agents/orchestrator.py`)
- CLI Orchestrator → CLI Terraform Scanner: dispatches (evidence: `finguard/agents/orchestrator.py`)
- CLI Orchestrator → CLI Secret Scanner: dispatches (evidence: `finguard/agents/orchestrator.py`)
- CLI Scanner → CLI Risk Engine: scores findings (evidence: `finguard/main.py`)
- CLI Scanner → CLI Explainer: explains findings (evidence: `finguard/main.py`)
- CLI Explainer → CLI Rule Retriever: retrieves rules (evidence: `finguard/rag/explainer.py`)
- GitHub → GitHub Webhook: sends events (evidence: `README.md`)
- GitHub Webhook → Background Worker: queues scans (evidence: `api/github_app/webhook_handler.py`)
- Background Worker → Scan Runner: runs scan (evidence: `api/github_app/background_worker.py`)
- Background Worker → GitHub Client: updates checks (evidence: `api/github_app/background_worker.py`)
- GitHub Client → GitHub: calls API (evidence: `api/github_app/github_client.py`)
- Feedback API → Risk Engine: updates weights
