# shrx404/audit-agent architecture

> Architecture diagram of the GitHub repository shrx404/audit-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shrx404/audit-agent
- Repository: https://github.com/shrx404/audit-agent

## Overview

Audit Agent is an audit-memory copilot: auditors browse and upload evidence, analyze a finding against historical records, inspect cited evidence and memories, then review and confirm an outcome for future recall. The frontend workspace calls the FastAPI backend through its typed API client. The README documents document extraction/indexing, recurrence detection, readiness checks, and deterministic scoring; sampled backend excerpts confirm upload, ask, analysis, and feedback routes, but do not expose every internal analysis step. The graph omits uncertain internal wiring.

Main entry points: [`frontend/src/app/page.tsx`](https://github.com/shrx404/audit-agent/blob/main/frontend/src/app/page.tsx) (Workspace), [`backend/main.py`](https://github.com/shrx404/audit-agent/blob/main/backend/main.py) (FastAPI routes), [`backend/agent/ask.py`](https://github.com/shrx404/audit-agent/blob/main/backend/agent/ask.py) (Question answering), [`backend/memory/client.py`](https://github.com/shrx404/audit-agent/blob/main/backend/memory/client.py) (Memory wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Audit workspace"]
  node_page["Workspace<br/>[page.tsx]"]
  node_sources_ui["Source explorer"]
  node_chat_ui["Chat window<br/>[ChatWindow.tsx]"]
  node_memory_ui["Evidence panel<br/>[MemoryPanel.tsx]"]
  node_confirm_ui["Confirmation form"]
  node_api_client["Typed API client<br/>[api.ts]"]
end

subgraph group_backend["Audit workflows"]
  node_api_server["FastAPI routes<br/>[main.py]"]
  node_upload["Evidence ingestion<br/>[main.py]"]
  node_analysis["Finding analysis"]
  node_readiness["Readiness checks<br/>[readiness.py]"]
  node_feedback["Audit feedback<br/>[state.py]"]
end

subgraph group_agent["Agent services"]
  node_ask["Question answering<br/>[ask.py]"]
  node_agent_llm["Structured inference<br/>[llm.py]"]
  node_memory_client["Memory wrapper<br/>[client.py]"]
  node_omniroute_client["OmniRoute client<br/>[llm_client.py]"]
end

subgraph group_integrations["External services"]
  node_hindsight[("Hindsight memory")]
  node_groq{{"Groq inference"}}
  node_omniroute{{"OmniRoute service"}}
end

node_auditor(("Auditor"))

node_auditor -->|"uses"| node_page
node_page -->|"renders"| node_sources_ui
node_page -->|"renders"| node_chat_ui
node_page -->|"renders"| node_memory_ui
node_page -->|"renders"| node_confirm_ui
node_page -->|"requests"| node_api_client
node_api_client -->|"HTTP calls"| node_api_server
node_api_server -->|"handles uploads"| node_upload
node_api_server -->|"answers questions"| node_ask
node_api_server -->|"analyzes findings"| node_analysis
node_api_server -->|"gets readiness"| node_readiness
node_api_server -->|"records feedback"| node_feedback
node_upload -->|"retains evidence"| node_memory_client
node_ask -->|"recalls memories"| node_memory_client
node_ask -->|"generates answer"| node_agent_llm
node_memory_client -->|"reads and writes"| node_hindsight
node_agent_llm -->|"calls model"| node_groq
node_omniroute_client -.->|"routes completions"| node_omniroute
node_omniroute_client -.->|"fallback calls"| node_groq

click node_page "https://github.com/shrx404/audit-agent/blob/main/frontend/src/app/page.tsx"
click node_sources_ui "https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/left-panel/SourceDataCorpus.tsx"
click node_chat_ui "https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/middle-panel/ChatWindow.tsx"
click node_memory_ui "https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/right-panel/MemoryPanel.tsx"
click node_confirm_ui "https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/ConfirmationForm.tsx"
click node_api_client "https://github.com/shrx404/audit-agent/blob/main/frontend/src/lib/api.ts"
click node_api_server "https://github.com/shrx404/audit-agent/blob/main/backend/main.py"
click node_upload "https://github.com/shrx404/audit-agent/blob/main/backend/main.py"
click node_analysis "https://github.com/shrx404/audit-agent/tree/main/backend/agent"
click node_readiness "https://github.com/shrx404/audit-agent/blob/main/backend/agent/readiness.py"
click node_feedback "https://github.com/shrx404/audit-agent/blob/main/backend/agent/state.py"
click node_ask "https://github.com/shrx404/audit-agent/blob/main/backend/agent/ask.py"
click node_agent_llm "https://github.com/shrx404/audit-agent/blob/main/backend/agent/llm.py"
click node_memory_client "https://github.com/shrx404/audit-agent/blob/main/backend/memory/client.py"
click node_omniroute_client "https://github.com/shrx404/audit-agent/blob/main/omniroute/services/llm_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_page,node_sources_ui,node_chat_ui,node_memory_ui,node_confirm_ui,node_api_client toneBlue
class node_api_server,node_upload,node_analysis,node_readiness,node_feedback toneAmber
class node_ask,node_agent_llm,node_memory_client,node_omniroute_client toneMint
class node_hindsight,node_groq,node_omniroute toneRose
class node_auditor toneIndigo
```

## Components

### Audit workspace

- [Workspace](https://github.com/shrx404/audit-agent/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Source explorer](https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/left-panel/SourceDataCorpus.tsx): `frontend/src/components/left-panel/SourceDataCorpus.tsx`
- [Chat window](https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/middle-panel/ChatWindow.tsx): `frontend/src/components/middle-panel/ChatWindow.tsx`
- [Evidence panel](https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/right-panel/MemoryPanel.tsx): `frontend/src/components/right-panel/MemoryPanel.tsx`
- [Confirmation form](https://github.com/shrx404/audit-agent/blob/main/frontend/src/components/ConfirmationForm.tsx): `frontend/src/components/ConfirmationForm.tsx`
- [Typed API client](https://github.com/shrx404/audit-agent/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Audit workflows

- [FastAPI routes](https://github.com/shrx404/audit-agent/blob/main/backend/main.py): `backend/main.py`
- [Evidence ingestion](https://github.com/shrx404/audit-agent/blob/main/backend/main.py): `backend/main.py`
- [Finding analysis](https://github.com/shrx404/audit-agent/tree/main/backend/agent): `backend/agent`
- [Readiness checks](https://github.com/shrx404/audit-agent/blob/main/backend/agent/readiness.py): `backend/agent/readiness.py`
- [Audit feedback](https://github.com/shrx404/audit-agent/blob/main/backend/agent/state.py): `backend/agent/state.py`

### Agent services

- [Question answering](https://github.com/shrx404/audit-agent/blob/main/backend/agent/ask.py): `backend/agent/ask.py`
- [Structured inference](https://github.com/shrx404/audit-agent/blob/main/backend/agent/llm.py): `backend/agent/llm.py`
- [Memory wrapper](https://github.com/shrx404/audit-agent/blob/main/backend/memory/client.py): `backend/memory/client.py`
- [OmniRoute client](https://github.com/shrx404/audit-agent/blob/main/omniroute/services/llm_client.py): `omniroute/services/llm_client.py`

### External services

- **Hindsight memory**
- **Groq inference**
- **OmniRoute service**

### Other components

- **Auditor**

## Connections

- Auditor → Workspace: uses
- Workspace → Source explorer: renders
- Workspace → Chat window: renders
- Workspace → Evidence panel: renders
- Workspace → Confirmation form: renders
- Workspace → Typed API client: requests
- Typed API client → FastAPI routes: HTTP calls
- FastAPI routes → Evidence ingestion: handles uploads
- FastAPI routes → Question answering: answers questions
- FastAPI routes → Finding analysis: analyzes findings
- FastAPI routes → Readiness checks: gets readiness
- FastAPI routes → Audit feedback: records feedback
- Evidence ingestion → Memory wrapper: retains evidence
- Question answering → Memory wrapper: recalls memories
- Question answering → Structured inference: generates answer
- Memory wrapper → Hindsight memory: reads and writes
- Structured inference → Groq inference: calls model
- OmniRoute client → OmniRoute service: routes completions
- OmniRoute client → Groq inference: fallback calls
