# astropilot-ai/denario architecture

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

- Interactive diagram: https://gitdiagram.com/astropilot-ai/denario
- Repository: https://github.com/astropilot-ai/denario

## Overview

#### Purpose and Entry Points
Denario is a Python 3.12+ multi-agent scientific-research assistant. It turns a user’s data/tool description into a research idea, method, computational results, and a LaTeX paper. Primary programmatic entry is the `Denario` API; CLI support also launches the separately packaged GUI application.
- `denario/__init__.py`
- `denario/denario.py`
- `denario/cli.py`

#### Workflow Orchestrator and Project State
The `Denario` façade coordinates the staged workflow: accept or generate data description, idea, methodology, results, and paper. Domain objects model these intermediate artifacts, allowing users to supply Markdown/string content at individual boundaries rather than invoke every generation stage.
- `denario/denario.py`
- `denario/idea.py`
- `denario/method.py`
- `denario/experiment.py`

#### Research Generation Pipeline
Idea, method, and experiment/result generation are distinct stages with dedicated prompt assets. The orchestration boundary separates user/project inputs from LLM-produced research plans and from the external analysis backend that performs research computations.
- `denario/research.py`
- `denario/prompts/idea.py`
- `denario/prompts/method.py`
- `denario/prompts/experiment.py`

#### LLM and Credential Boundary
LLM access is centralized rather than embedded in individual agents. Denario supports OpenAI, Claude, and Gemini credentials; key/configuration handling forms the external-service boundary for all agent calls.
- `denario/llm.py`
- `denario/key_manager.py`
- `denario/config.py`

#### LangGraph Research-Agent Subsystem
The main research-agent implementation uses LangGraph graphs, specialized nodes, and routers. It includes agents for idea development, literature handling, methodology, parameter work, PDF reading, and referee/review tasks. Routers determine graph transitions, while prompts define agent behavior.
- `denario/langgraph_agents/agents_graph.py`
- `denario/langgraph_agents/routers.py`
- `denario/langgraph_agents/literature.py`
- `denario/langgraph_agents/pdf_reader.py`

#### Analysis Execution Backend
Denario delegates scientific analysis execution to the external `cmbagent` ecosystem, described as its research-analysis backend. Denario’s experiment/research layers provide the planned method and project context; backend execution returns results and plots that become paper inputs. This is the material integration boundary, not an in-repository numerical engine.
- `denario/research.py`
- `denario/experiment.py`
- `denario/utils.py`

#### Paper Production Subsystem
A separate agent graph transforms research artifacts and literature context into a manuscript. It has nodes for paper generation, literature/reader operations, parameters, routing, journal selection, and LaTeX rendering. Journal presets and bundled class/style/bibliography files support target publication formats.
- `denario/paper_agents/agents_graph.py`
- `denario/paper_agents/paper_node.py`
- `denario/paper_agents/journal.py`
- `denario/paper_agents/latex.py`
- `denario/paper_agents/LaTeX`

#### Runtime and Deployment
The package runs locally in a Python environment and can be installed with the optional GUI dependency. Docker images package required dependencies including LaTeX; Compose and dev/prod Dockerfiles support containerized execution, volume-mounted projects, and environment-provided API keys. The GUI itself is an external DenarioApp project.
- `pyproject.toml`
- `compose.yaml`
- `docker/Dockerfile.dev`
- `docker/Dockerfile.prod`

Main entry points: [`denario/denario.py`](https://github.com/astropilot-ai/denario/blob/master/denario/denario.py) (Denario API), [`denario/paper_agents/agents_graph.py`](https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/agents_graph.py) (Paper agent graph), [`denario/langgraph_agents/agents_graph.py`](https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/agents_graph.py) (Research agent graph), [`denario/research.py`](https://github.com/astropilot-ai/denario/blob/master/denario/research.py) (Research pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry &amp; Workflow"]
  node_api["Denario API<br/>Python facade<br/>[denario.py]"]
  node_cli["CLI<br/>command entry<br/>[cli.py]"]
  node_artifacts["Research artifacts<br/>domain models<br/>[idea.py]"]
  node_research_flow["Research pipeline<br/>stage orchestrator<br/>[research.py]"]
end

subgraph group_research["Research Agents"]
  node_llm{{"LLM gateway<br/>provider client<br/>[llm.py]"}}
  node_credentials["Credentials &amp; config<br/>configuration boundary<br/>[key_manager.py]"]
  node_research_graph["Research agent graph<br/>LangGraph workflow<br/>[agents_graph.py]"]
  node_routers(("Research routers<br/>graph routing<br/>[routers.py]"))
  node_literature["Literature &amp; PDF agents<br/>specialist agents<br/>[literature.py]"]
  node_research_prompts["Research prompts<br/>prompt assets<br/>[idea.py]"]
end

subgraph group_paper["Paper Production"]
  node_paper_graph["Paper agent graph<br/>LangGraph workflow<br/>[agents_graph.py]"]
  node_paper_node["Manuscript generation<br/>paper node<br/>[paper_node.py]"]
  node_journal["Journal selection<br/>publication presets<br/>[journal.py]"]
  node_latex["LaTeX rendering<br/>document renderer<br/>[latex.py]"]
end

subgraph group_runtime["Runtime &amp; Deployment"]
  node_local["Local Python runtime<br/>Python 3.12+ package<br/>[pyproject.toml]"]
  node_containers["Container deployment<br/>Docker / Compose<br/>[compose.yaml]"]
end

node_cmbagent{{"cmbagent backend<br/>external analysis service"}}
node_gui{{"DenarioApp GUI<br/>external application"}}

node_cli -->|"invokes"| node_api
node_cli -->|"launches"| node_gui
node_api -->|"accepts / produces"| node_artifacts
node_api -->|"orchestrates"| node_research_flow
node_research_flow -->|"plans research"| node_research_graph
node_research_flow -->|"delegates analysis"| node_cmbagent
node_cmbagent -->|"results and plots"| node_artifacts
node_research_graph -->|"routes stages"| node_routers
node_routers -->|"selects specialist"| node_literature
node_research_graph -->|"uses"| node_research_prompts
node_research_graph -->|"agent calls"| node_llm
node_credentials -->|"configures"| node_llm
node_api -->|"creates paper"| node_paper_graph
node_artifacts -->|"research inputs"| node_paper_graph
node_literature -->|"literature context"| node_paper_graph
node_paper_graph -->|"generates draft"| node_paper_node
node_paper_graph -->|"chooses format"| node_journal
node_paper_node -->|"renders manuscript"| node_latex
node_journal -->|"supplies preset"| node_latex
node_local -->|"runs"| node_api
node_containers -->|"packages"| node_local

click node_api "https://github.com/astropilot-ai/denario/blob/master/denario/denario.py"
click node_cli "https://github.com/astropilot-ai/denario/blob/master/denario/cli.py"
click node_artifacts "https://github.com/astropilot-ai/denario/blob/master/denario/idea.py"
click node_research_flow "https://github.com/astropilot-ai/denario/blob/master/denario/research.py"
click node_llm "https://github.com/astropilot-ai/denario/blob/master/denario/llm.py"
click node_credentials "https://github.com/astropilot-ai/denario/blob/master/denario/key_manager.py"
click node_research_graph "https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/agents_graph.py"
click node_routers "https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/routers.py"
click node_literature "https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/literature.py"
click node_research_prompts "https://github.com/astropilot-ai/denario/blob/master/denario/prompts/idea.py"
click node_paper_graph "https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/agents_graph.py"
click node_paper_node "https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/paper_node.py"
click node_journal "https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/journal.py"
click node_latex "https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/latex.py"
click node_local "https://github.com/astropilot-ai/denario/blob/master/pyproject.toml"
click node_containers "https://github.com/astropilot-ai/denario/blob/master/compose.yaml"

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_cli,node_artifacts,node_research_flow toneBlue
class node_llm,node_credentials,node_research_graph,node_routers,node_literature,node_research_prompts toneAmber
class node_paper_graph,node_paper_node,node_journal,node_latex toneMint
class node_local,node_containers toneRose
class node_cmbagent,node_gui toneNeutral
```

## Components

### Entry & Workflow

- [Denario API](https://github.com/astropilot-ai/denario/blob/master/denario/denario.py): Python facade · Primary programmatic workflow entry point. · `denario/denario.py`
- [CLI](https://github.com/astropilot-ai/denario/blob/master/denario/cli.py): command entry · Launches workflows and the separately packaged GUI. · `denario/cli.py`
- [Research artifacts](https://github.com/astropilot-ai/denario/blob/master/denario/idea.py): domain models · Idea, method, and experiment artifacts can be supplied or generated per stage. · `denario/idea.py`
- [Research pipeline](https://github.com/astropilot-ai/denario/blob/master/denario/research.py): stage orchestrator · Generates research plans and delegates computational work. · `denario/research.py`

### Research Agents

- [LLM gateway](https://github.com/astropilot-ai/denario/blob/master/denario/llm.py): provider client · Centralized OpenAI, Claude, and Gemini access. · `denario/llm.py`
- [Credentials & config](https://github.com/astropilot-ai/denario/blob/master/denario/key_manager.py): configuration boundary · Manages provider keys and runtime settings. · `denario/key_manager.py`
- [Research agent graph](https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/agents_graph.py): LangGraph workflow · Coordinates specialized research agents. · `denario/langgraph_agents/agents_graph.py`
- [Research routers](https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/routers.py): graph routing · Selects transitions between agent stages. · `denario/langgraph_agents/routers.py`
- [Literature & PDF agents](https://github.com/astropilot-ai/denario/blob/master/denario/langgraph_agents/literature.py): specialist agents · Handles literature context and PDF reading. · `denario/langgraph_agents/literature.py`
- [Research prompts](https://github.com/astropilot-ai/denario/blob/master/denario/prompts/idea.py): prompt assets · Defines idea, method, and experiment generation behavior. · `denario/prompts/idea.py`

### Paper Production

- [Paper agent graph](https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/agents_graph.py): LangGraph workflow · Transforms research artifacts and literature into a manuscript. · `denario/paper_agents/agents_graph.py`
- [Manuscript generation](https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/paper_node.py): paper node · `denario/paper_agents/paper_node.py`
- [Journal selection](https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/journal.py): publication presets · Selects target journal formatting. · `denario/paper_agents/journal.py`
- [LaTeX rendering](https://github.com/astropilot-ai/denario/blob/master/denario/paper_agents/latex.py): document renderer · Produces the formatted paper using bundled publication assets. · `denario/paper_agents/latex.py`

### Runtime & Deployment

- [Local Python runtime](https://github.com/astropilot-ai/denario/blob/master/pyproject.toml): Python 3.12+ package · `pyproject.toml`
- [Container deployment](https://github.com/astropilot-ai/denario/blob/master/compose.yaml): Docker / Compose · Packages dependencies including LaTeX and supplies API keys via environment. · `compose.yaml`

### Other components

- **cmbagent backend**: external analysis service · Executes planned scientific analysis and returns results and plots.
- **DenarioApp GUI**: external application · Separately packaged optional GUI.

## Connections

- CLI → Denario API: invokes
- CLI → DenarioApp GUI: launches
- Denario API → Research artifacts: accepts / produces
- Denario API → Research pipeline: orchestrates
- Research pipeline → Research agent graph: plans research
- Research pipeline → cmbagent backend: delegates analysis
- cmbagent backend → Research artifacts: results and plots
- Research agent graph → Research routers: routes stages
- Research routers → Literature & PDF agents: selects specialist
- Research agent graph → Research prompts: uses
- Research agent graph → LLM gateway: agent calls
- Credentials & config → LLM gateway: configures
- Denario API → Paper agent graph: creates paper
- Research artifacts → Paper agent graph: research inputs
- Literature & PDF agents → Paper agent graph: literature context
- Paper agent graph → Manuscript generation: generates draft
- Paper agent graph → Journal selection: chooses format
- Manuscript generation → LaTeX rendering: renders manuscript
- Journal selection → LaTeX rendering: supplies preset
- Local Python runtime → Denario API: runs
- Container deployment → Local Python runtime: packages
