# svuillaume/forticnapp-forensicaiagent architecture

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

- Interactive diagram: https://gitdiagram.com/svuillaume/forticnapp-forensicaiagent
- Repository: https://github.com/svuillaume/forticnapp-forensicaiagent

## Overview

FortiCNAPP AI Agent is a local chat and investigation application: a user submits a question, the app selects a configured model provider, and the agent coordinates tools before returning a report. Distinct capabilities include tenant LQL/API investigations, compliance findings, CodeSec scans, TLS crypto checks, and knowledge wikis; browser history and result dashboards present completed work. Edges follow explicit README statements and sampled call sites. Several subsystems are documented but their full wiring was not sampled, so those links are dashed where the relationship is unverified.

Main entry points: [`backend.py`](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/backend.py) (MCP and gateway), [`app.py`](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/app.py) (Local web app), [`agent.py`](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/agent.py) (Agent loop), [`lql/mcp_server.py`](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/mcp_server.py) (LQL MCP tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_webapp["Local web app<br/>[app.py]"]
  node_chat["Chat page<br/>[index.html]"]
  node_dash["Result dashboards<br/>[dashboard.js]"]
  node_history[("Chat history<br/>[history.js]")]
end

subgraph group_agent["Agent and tools"]
  node_agentloop["Agent loop<br/>[agent.py]"]
  node_ledger["Evidence ledger<br/>[ledger.py]"]
  node_backend["MCP and gateway<br/>[backend.py]"]
end

subgraph group_tenant["Tenant investigation"]
  node_mcp["LQL MCP tools<br/>[mcp_server.py]"]
  node_sources["LQL grounding<br/>[lql_sources.py]"]
  node_forensic["Read-only API tools<br/>[forensic_tools.py]"]
  node_frameworks["Compliance frameworks<br/>[frameworks.py]"]
end

subgraph group_assurance["Security assurance"]
  node_codesec["CodeSec scans<br/>[codesec.py]"]
  node_tls["TLS crypto checks<br/>[tlscheck.py]"]
  node_wiki["Knowledge wikis<br/>[wiki.py]"]
end

subgraph group_config["Access and providers"]
  node_creds["Tenant credentials<br/>[creds.py]"]
  node_providers["Model providers<br/>[providers.py]"]
  node_auth["Admin authentication<br/>[auth.py]"]
end

node_user(("User"))
node_modelservice{{"Model API"}}
node_forti{{"FortiCNAPP API"}}
node_scanners{{"lacework scanners"}}
node_openssl{{"OpenSSL"}}

node_user -->|"asks"| node_chat
node_chat -.->|"sends requests"| node_webapp
node_webapp -->|"runs questions"| node_agentloop
node_agentloop -->|"requests tools"| node_backend
node_backend -->|"calls model"| node_modelservice
node_agentloop -->|"checks claims"| node_ledger
node_agentloop -.->|"returns results"| node_dash
node_dash -->|"shows tables"| node_user
node_chat -->|"stores chats"| node_history
node_backend -->|"connects tools"| node_mcp
node_mcp -->|"grounds queries"| node_sources
node_mcp -->|"exposes tools"| node_forensic
node_webapp -->|"requests findings"| node_frameworks
node_backend -->|"provides tools"| node_frameworks
node_mcp -->|"queries tenant"| node_forti
node_creds -->|"validates key"| node_forti
node_creds -->|"configures environment"| node_mcp
node_backend -->|"uses direct APIs"| node_providers
node_providers -->|"sends requests"| node_modelservice
node_webapp -->|"checks sessions"| node_auth
node_webapp -->|"starts scans"| node_codesec
node_codesec -->|"uses scanner credentials"| node_creds
node_codesec -->|"runs scans"| node_scanners
node_backend -->|"runs tool"| node_tls
node_tls -->|"probes handshakes"| node_openssl
node_backend -->|"offers wiki tools"| node_wiki
node_agentloop -->|"imports checker"| node_tls

click node_webapp "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/app.py"
click node_chat "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/index.html"
click node_dash "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/dashboard.js"
click node_history "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/history.js"
click node_agentloop "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/agent.py"
click node_ledger "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/ledger.py"
click node_backend "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/backend.py"
click node_mcp "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/mcp_server.py"
click node_sources "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/lql_sources.py"
click node_forensic "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/forensic_tools.py"
click node_frameworks "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/frameworks.py"
click node_creds "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/creds.py"
click node_providers "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/providers.py"
click node_auth "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/auth.py"
click node_codesec "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/codesec.py"
click node_tls "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/tlscheck.py"
click node_wiki "https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/wiki.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_webapp,node_chat,node_dash,node_history,node_user toneBlue
class node_agentloop,node_ledger,node_backend toneAmber
class node_mcp,node_sources,node_forensic,node_frameworks,node_modelservice,node_forti toneMint
class node_codesec,node_tls,node_wiki toneRose
class node_creds,node_providers,node_auth,node_scanners,node_openssl toneIndigo
```

## Components

### Chat experience

- [Local web app](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/app.py): `app.py`
- [Chat page](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/index.html): `index.html`
- [Result dashboards](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/dashboard.js): `dashboard.js`
- [Chat history](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/history.js): `history.js`

### Agent and tools

- [Agent loop](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/agent.py): `agent.py`
- [Evidence ledger](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/ledger.py): `ledger.py`
- [MCP and gateway](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/backend.py): `backend.py`

### Tenant investigation

- [LQL MCP tools](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/mcp_server.py): `lql/mcp_server.py`
- [LQL grounding](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/lql_sources.py): `lql/lql_sources.py`
- [Read-only API tools](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/lql/forensic_tools.py): `lql/forensic_tools.py`
- [Compliance frameworks](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/frameworks.py): `frameworks.py`

### Security assurance

- [CodeSec scans](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/codesec.py): `codesec.py`
- [TLS crypto checks](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/tlscheck.py): `tlscheck.py`
- [Knowledge wikis](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/wiki.py): `wiki.py`

### Access and providers

- [Tenant credentials](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/creds.py): `creds.py`
- [Model providers](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/providers.py): `providers.py`
- [Admin authentication](https://github.com/svuillaume/forticnapp-forensicaiagent/blob/main/auth.py): `auth.py`

### Other components

- **User**
- **Model API**
- **FortiCNAPP API**
- **lacework scanners**
- **OpenSSL**

## Connections

- User → Chat page: asks (evidence: `README.md`)
- Chat page → Local web app: sends requests
- Local web app → Agent loop: runs questions (evidence: `app.py`)
- Agent loop → MCP and gateway: requests tools (evidence: `backend.py`)
- MCP and gateway → Model API: calls model (evidence: `backend.py`)
- Agent loop → Evidence ledger: checks claims (evidence: `agent.py`)
- Agent loop → Result dashboards: returns results
- Result dashboards → User: shows tables (evidence: `README.md`)
- Chat page → Chat history: stores chats (evidence: `README.md`)
- MCP and gateway → LQL MCP tools: connects tools (evidence: `backend.py`)
- LQL MCP tools → LQL grounding: grounds queries (evidence: `lql/mcp_server.py`)
- LQL MCP tools → Read-only API tools: exposes tools (evidence: `lql/mcp_server.py`)
- Local web app → Compliance frameworks: requests findings (evidence: `app.py`)
- MCP and gateway → Compliance frameworks: provides tools (evidence: `backend.py`)
- LQL MCP tools → FortiCNAPP API: queries tenant (evidence: `lql/mcp_server.py`)
- Tenant credentials → FortiCNAPP API: validates key (evidence: `creds.py`)
- Tenant credentials → LQL MCP tools: configures environment (evidence: `creds.py`)
- MCP and gateway → Model providers: uses direct APIs (evidence: `backend.py`)
- Model providers → Model API: sends requests (evidence: `providers.py`)
- Local web app → Admin authentication: checks sessions (evidence: `app.py`)
- Local web app → CodeSec scans: starts scans (evidence: `app.py`)
- CodeSec scans → Tenant credentials: uses scanner credentials (evidence: `codesec.py`)
- CodeSec scans → lacework scanners: runs scans (evidence: `README.md`)
- MCP and gateway → TLS crypto checks: runs tool (evidence: `backend.py`)
- TLS crypto checks → OpenSSL: probes handshakes (evidence: `tlscheck.py`)
- MCP and gateway → Knowledge wikis: offers wiki tools (evidence: `backend.py`)
- Agent loop → TLS crypto checks: imports checker (evidence: `agent.py`)
