# noho/dayu-agent-r architecture

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

- Interactive diagram: https://gitdiagram.com/noho/dayu-agent-r
- Repository: https://github.com/noho/dayu-agent-r

## Overview

Dayu is a CLI-centered financial-analysis agent: users initialize a workspace, ingest filings and materials, then ask single-turn or interactive questions and manage sessions. Its finance workflows cover market-specific downloads, uploads, document preprocessing, storage, and financial search; the agent side combines an Engine, Host-managed runs and sessions, and document/web tools. The README documents the user-visible workflow, while source-index references support selected internal connections. Several finance and Host subsystems are unsampled, so their internal links are intentionally limited.

Main entry points: [`dayu/engine/agent.py`](https://github.com/noho/dayu-agent-r/blob/main/dayu/engine/agent.py) (Agent Engine), [`dayu/cli/main.py`](https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/main.py) (Dayu CLI), [`dayu/fins/pipelines`](https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/pipelines) (Market Pipelines), [`dayu/tools`](https://github.com/noho/dayu-agent-r/tree/main/dayu/tools) (Document and Web Tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Workspace"]
  node_cli["Dayu CLI<br/>[main.py]"]
  node_workspace["Workspace Config<br/>[init_workspace.py]"]
  node_fin_commands["Finance Commands<br/>[fins.py]"]
  node_session_commands["Session Commands<br/>[session.py]"]
end

subgraph group_finance["Financial Documents"]
  node_fin_runtime["Ingestion Runtime"]
  node_market_pipelines["Market Pipelines"]
  node_downloaders["Market Downloaders"]
  node_upload_processing["Upload Processing"]
  node_doc_processing["Document Processing"]
  node_fin_processors["Filing Analysis"]
  node_fin_storage[("Financial Repository")]
  node_fin_tools["Financial Tools"]
end

subgraph group_agent["Agent Execution"]
  node_scene_context["Ticker Context<br/>[scene_context.py]"]
  node_engine["Agent Engine<br/>[agent.py]"]
  node_openai_runner["OpenAI Runner<br/>[runner.py]"]
end

subgraph group_host["Host and Tools"]
  node_host_api["Host API<br/>[api.py]"]
  node_host_ingest["Event Ingest<br/>[engine_ingest.py]"]
  node_host_store[("Durable State<br/>[transaction.py]")]
  node_tool_layer["Document and Web Tools"]
  node_web_fetch["Web Fetch"]
end

node_user(("Analyst"))
node_result["Analysis Output"]
node_providers(("Market and Model Providers"))

node_user -->|"runs commands"| node_cli
node_cli -->|"initializes config"| node_workspace
node_cli -->|"dispatches finance"| node_fin_commands
node_cli -->|"dispatches sessions"| node_session_commands
node_fin_commands -.->|"starts jobs"| node_fin_runtime
node_fin_runtime -->|"runs workflows"| node_market_pipelines
node_market_pipelines -->|"requests filings"| node_downloaders
node_market_pipelines -->|"invokes upload"| node_upload_processing
node_market_pipelines -->|"persists documents"| node_fin_storage
node_upload_processing -->|"converts documents"| node_doc_processing
node_doc_processing -.->|"supplies parsed text"| node_fin_processors
node_fin_processors -.->|"publishes results"| node_fin_storage
node_fin_tools -->|"reads filings"| node_fin_storage
node_user -->|"asks questions"| node_engine
node_engine -.->|"calls model"| node_openai_runner
node_engine -.->|"runs through Host"| node_host_api
node_host_api -->|"ingests events"| node_host_ingest
node_host_ingest -.->|"records state"| node_host_store
node_engine -.->|"invokes tools"| node_tool_layer
node_tool_layer -.->|"provides finance tools"| node_fin_tools
node_tool_layer -->|"fetches web pages"| node_web_fetch
node_scene_context -.->|"resolves company info"| node_providers
node_downloaders -.->|"downloads filings"| node_providers
node_openai_runner -.->|"requests completion"| node_providers
node_engine -->|"streams answer"| node_result
node_session_commands -->|"manages sessions"| node_host_api

click node_cli "https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/main.py"
click node_workspace "https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/init_workspace.py"
click node_fin_commands "https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/commands/fins.py"
click node_session_commands "https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/commands/session.py"
click node_fin_runtime "https://github.com/noho/dayu-agent-r/blob/main/dayu/fins/ingestion_runtime.py"
click node_market_pipelines "https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/pipelines"
click node_downloaders "https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/downloaders"
click node_upload_processing "https://github.com/noho/dayu-agent-r/blob/main/dayu/fins/pipelines/docling_upload_service.py"
click node_doc_processing "https://github.com/noho/dayu-agent-r/tree/main/dayu/documents/processors"
click node_fin_processors "https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/processors"
click node_fin_storage "https://github.com/noho/dayu-agent-r/blob/main/dayu/fins/storage/_fs_storage_infra.py"
click node_fin_tools "https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/tools"
click node_scene_context "https://github.com/noho/dayu-agent-r/blob/main/dayu/service/scene_context.py"
click node_engine "https://github.com/noho/dayu-agent-r/blob/main/dayu/engine/agent.py"
click node_openai_runner "https://github.com/noho/dayu-agent-r/blob/main/dayu/engine/runners/openai/runner.py"
click node_host_api "https://github.com/noho/dayu-agent-r/blob/main/dayu/host/api.py"
click node_host_ingest "https://github.com/noho/dayu-agent-r/blob/main/dayu/host/engine_ingest.py"
click node_host_store "https://github.com/noho/dayu-agent-r/blob/main/dayu/host/durable/transaction.py"
click node_tool_layer "https://github.com/noho/dayu-agent-r/tree/main/dayu/tools"
click node_web_fetch "https://github.com/noho/dayu-agent-r/blob/main/dayu/tools/web/web_fetch_orchestrator.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_cli,node_workspace,node_fin_commands,node_session_commands toneBlue
class node_fin_runtime,node_market_pipelines,node_downloaders,node_upload_processing,node_doc_processing,node_fin_processors,node_fin_storage,node_fin_tools toneAmber
class node_scene_context,node_engine,node_openai_runner toneMint
class node_host_api,node_host_ingest,node_host_store,node_tool_layer,node_web_fetch toneRose
class node_user,node_result,node_providers toneIndigo
```

## Components

### CLI and Workspace

- [Dayu CLI](https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/main.py): `dayu/cli/main.py`
- [Workspace Config](https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/init_workspace.py): `dayu/cli/init_workspace.py`
- [Finance Commands](https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/commands/fins.py): `dayu/cli/commands/fins.py`
- [Session Commands](https://github.com/noho/dayu-agent-r/blob/main/dayu/cli/commands/session.py): `dayu/cli/commands/session.py`

### Financial Documents

- [Ingestion Runtime](https://github.com/noho/dayu-agent-r/blob/main/dayu/fins/ingestion_runtime.py): `dayu/fins/ingestion_runtime.py`
- [Market Pipelines](https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/pipelines): `dayu/fins/pipelines`
- [Market Downloaders](https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/downloaders): `dayu/fins/downloaders`
- [Upload Processing](https://github.com/noho/dayu-agent-r/blob/main/dayu/fins/pipelines/docling_upload_service.py): `dayu/fins/pipelines/docling_upload_service.py`
- [Document Processing](https://github.com/noho/dayu-agent-r/tree/main/dayu/documents/processors): `dayu/documents/processors`
- [Filing Analysis](https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/processors): `dayu/fins/processors`
- [Financial Repository](https://github.com/noho/dayu-agent-r/blob/main/dayu/fins/storage/_fs_storage_infra.py): `dayu/fins/storage/_fs_storage_infra.py`
- [Financial Tools](https://github.com/noho/dayu-agent-r/tree/main/dayu/fins/tools): `dayu/fins/tools`

### Agent Execution

- [Ticker Context](https://github.com/noho/dayu-agent-r/blob/main/dayu/service/scene_context.py): `dayu/service/scene_context.py`
- [Agent Engine](https://github.com/noho/dayu-agent-r/blob/main/dayu/engine/agent.py): `dayu/engine/agent.py`
- [OpenAI Runner](https://github.com/noho/dayu-agent-r/blob/main/dayu/engine/runners/openai/runner.py): `dayu/engine/runners/openai/runner.py`

### Host and Tools

- [Host API](https://github.com/noho/dayu-agent-r/blob/main/dayu/host/api.py): `dayu/host/api.py`
- [Event Ingest](https://github.com/noho/dayu-agent-r/blob/main/dayu/host/engine_ingest.py): `dayu/host/engine_ingest.py`
- [Durable State](https://github.com/noho/dayu-agent-r/blob/main/dayu/host/durable/transaction.py): `dayu/host/durable/transaction.py`
- [Document and Web Tools](https://github.com/noho/dayu-agent-r/tree/main/dayu/tools): `dayu/tools`
- [Web Fetch](https://github.com/noho/dayu-agent-r/blob/main/dayu/tools/web/web_fetch_orchestrator.py): `dayu/tools/web/web_fetch_orchestrator.py`

### Other components

- **Analyst**
- **Analysis Output**
- **Market and Model Providers**

## Connections

- Analyst → Dayu CLI: runs commands (evidence: `README.md`)
- Dayu CLI → Workspace Config: initializes config (evidence: `README.md`)
- Dayu CLI → Finance Commands: dispatches finance (evidence: `dayu/cli/main.py`)
- Dayu CLI → Session Commands: dispatches sessions (evidence: `dayu/cli/main.py`)
- Finance Commands → Ingestion Runtime: starts jobs
- Ingestion Runtime → Market Pipelines: runs workflows (evidence: `dayu/fins/ingestion_runtime.py`)
- Market Pipelines → Market Downloaders: requests filings (evidence: `dayu/fins/pipelines/cn_pipeline.py`)
- Market Pipelines → Upload Processing: invokes upload (evidence: `dayu/fins/pipelines/cn_pipeline.py`)
- Market Pipelines → Financial Repository: persists documents (evidence: `dayu/fins/pipelines/cn_pipeline.py`)
- Upload Processing → Document Processing: converts documents (evidence: `dayu/fins/pipelines/docling_upload_service.py`)
- Document Processing → Filing Analysis: supplies parsed text (evidence: `dayu/fins/processors/sec_xbrl_query.py`)
- Filing Analysis → Financial Repository: publishes results
- Financial Tools → Financial Repository: reads filings (evidence: `dayu/fins/tools/search_engine.py`)
- Analyst → Agent Engine: asks questions (evidence: `README.md`)
- Agent Engine → OpenAI Runner: calls model
- Agent Engine → Host API: runs through Host
- Host API → Event Ingest: ingests events (evidence: `dayu/host/engine_ingest.py`)
- Event Ingest → Durable State: records state (evidence: `dayu/host/engine_ingest.py`)
- Agent Engine → Document and Web Tools: invokes tools
- Document and Web Tools → Financial Tools: provides finance tools
- Document and Web Tools → Web Fetch: fetches web pages (evidence: `dayu/tools/web/web_fetch_orchestrator.py`)
- Ticker Context → Market and Model Providers: resolves company info
- Market Downloaders → Market and Model Providers: downloads filings
- OpenAI Runner → Market and Model Providers: requests completion
- Agent Engine → Analysis Output: streams answer (evidence: `README.md`)
- Session Commands → Host API: manages sessions (evidence: `dayu/cli/commands/session.py`)
