# zak-7869/research-agent architecture

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

- Interactive diagram: https://gitdiagram.com/zak-7869/research-agent
- Repository: https://github.com/zak-7869/research-agent

## Overview

Briefing Desk is a web research agent: a user submits a topic and search depth, the backend plans queries, searches the web, and drafts a cited report, which the UI displays with source links and queries. The backend also exposes health and Prometheus metrics endpoints; monitoring configuration exists in the repository, but its scrape wiring was not sampled. The workflow and API edges are supported by excerpts; deployment manifests and unsampled monitoring behavior are not mapped.

Main entry points: [`frontend/app/page.js`](https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js) (Briefing Desk), [`backend/app/main.py`](https://github.com/zak-7869/research-agent/blob/main/backend/app/main.py) (Research API), [`backend/app/agent.py`](https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py) (Research workflow), [`frontend/app/api/research/route.js`](https://github.com/zak-7869/research-agent/blob/main/frontend/app/api/research/route.js) (Research proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_briefing_ui["Briefing Desk<br/>[page.js]"]
  node_research_proxy["Research proxy<br/>[route.js]"]
  node_report["Cited report<br/>[page.js]"]
  node_results["Sources and queries<br/>[page.js]"]
end

subgraph group_api["API and workflow"]
  node_research_api["Research API<br/>[main.py]"]
  node_workflow["Research workflow<br/>[agent.py]"]
end

subgraph group_research["Research stages"]
  node_planner["Query planner<br/>[agent.py]"]
  node_searcher["Web search<br/>[agent.py]"]
  node_writer["Report writer<br/>[agent.py]"]
end

subgraph group_observability["Observability"]
  node_metrics["API metrics<br/>[main.py]"]
  node_prometheus_config["Prometheus configuration<br/>[prometheus.yml]"]
end

node_user(("Research user"))
node_groq{{"Groq LLM"}}
node_tavily{{"Tavily search"}}

node_user -->|"submits topic"| node_briefing_ui
node_briefing_ui -->|"posts request"| node_research_proxy
node_research_proxy -->|"forwards request"| node_research_api
node_research_api -->|"runs research"| node_workflow
node_workflow -->|"dispatches"| node_planner
node_planner -->|"passes queries"| node_searcher
node_searcher -->|"passes sources"| node_writer
node_planner -->|"requests queries"| node_groq
node_searcher -->|"searches web"| node_tavily
node_writer -->|"drafts report"| node_groq
node_workflow -->|"returns results"| node_research_api
node_research_api -->|"records requests"| node_metrics
node_briefing_ui -->|"renders report"| node_report
node_briefing_ui -->|"renders sources"| node_results

click node_briefing_ui "https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js"
click node_research_proxy "https://github.com/zak-7869/research-agent/blob/main/frontend/app/api/research/route.js"
click node_research_api "https://github.com/zak-7869/research-agent/blob/main/backend/app/main.py"
click node_workflow "https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py"
click node_planner "https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py"
click node_searcher "https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py"
click node_writer "https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py"
click node_report "https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js"
click node_results "https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js"
click node_metrics "https://github.com/zak-7869/research-agent/blob/main/backend/app/main.py"
click node_prometheus_config "https://github.com/zak-7869/research-agent/blob/main/monitoring/prometheus.yml"

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_briefing_ui,node_research_proxy,node_report,node_results,node_user toneBlue
class node_research_api,node_workflow toneAmber
class node_planner,node_searcher,node_writer toneMint
class node_metrics,node_prometheus_config toneRose
class node_groq,node_tavily toneIndigo
```

## Components

### User interface

- [Briefing Desk](https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js): `frontend/app/page.js`
- [Research proxy](https://github.com/zak-7869/research-agent/blob/main/frontend/app/api/research/route.js): `frontend/app/api/research/route.js`
- [Cited report](https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js): `frontend/app/page.js`
- [Sources and queries](https://github.com/zak-7869/research-agent/blob/main/frontend/app/page.js): `frontend/app/page.js`

### API and workflow

- [Research API](https://github.com/zak-7869/research-agent/blob/main/backend/app/main.py): `backend/app/main.py`
- [Research workflow](https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py): `backend/app/agent.py`

### Research stages

- [Query planner](https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py): `backend/app/agent.py`
- [Web search](https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py): `backend/app/agent.py`
- [Report writer](https://github.com/zak-7869/research-agent/blob/main/backend/app/agent.py): `backend/app/agent.py`

### Observability

- [API metrics](https://github.com/zak-7869/research-agent/blob/main/backend/app/main.py): `backend/app/main.py`
- [Prometheus configuration](https://github.com/zak-7869/research-agent/blob/main/monitoring/prometheus.yml): `monitoring/prometheus.yml`

### Other components

- **Research user**
- **Groq LLM**
- **Tavily search**

## Connections

- Research user → Briefing Desk: submits topic (evidence: `frontend/app/page.js`)
- Briefing Desk → Research proxy: posts request (evidence: `frontend/app/page.js`)
- Research proxy → Research API: forwards request (evidence: `frontend/app/api/research/route.js`)
- Research API → Research workflow: runs research (evidence: `backend/app/main.py`)
- Research workflow → Query planner: dispatches (evidence: `backend/app/agent.py`)
- Query planner → Web search: passes queries (evidence: `backend/app/agent.py`)
- Web search → Report writer: passes sources (evidence: `backend/app/agent.py`)
- Query planner → Groq LLM: requests queries (evidence: `backend/app/agent.py`)
- Web search → Tavily search: searches web (evidence: `backend/app/agent.py`)
- Report writer → Groq LLM: drafts report (evidence: `backend/app/agent.py`)
- Research workflow → Research API: returns results (evidence: `backend/app/main.py`)
- Research API → API metrics: records requests (evidence: `backend/app/main.py`)
- Briefing Desk → Cited report: renders report (evidence: `frontend/app/page.js`)
- Briefing Desk → Sources and queries: renders sources (evidence: `frontend/app/page.js`)
