# urgetolearn/finlens architecture

> Architecture diagram of the GitHub repository urgetolearn/finlens, 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/urgetolearn/finlens
- Repository: https://github.com/urgetolearn/finlens

## Overview

FinLens helps beginners understand current India-focused financial news through a CLI and a story-browser chat. The workflow is user question or story selection → agent conversation loop → model-selected news tools → RSS discovery, source reading, or cross-checking → plain-language explanation and follow-ups. The graph also shows configuration, safety and explanation prompts, the Ollama adapter, concept glossary, and optional Story Time mode. Relationships reflect the shown imports and calls; unsampled UI and CLI details are not expanded beyond the evidence available.

Main entry points: [`app/agent.py`](https://github.com/urgetolearn/finlens/blob/main/app/agent.py) (Tool-using agent), [`app/tools/financial_news.py`](https://github.com/urgetolearn/finlens/blob/main/app/tools/financial_news.py) (News tool dispatcher), [`app/services/ollama.py`](https://github.com/urgetolearn/finlens/blob/main/app/services/ollama.py) (Ollama adapter), [`app/config.py`](https://github.com/urgetolearn/finlens/blob/main/app/config.py) (App settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_cli["CLI<br/>[agent.py]"]
  node_browser["News browser<br/>[ui.py]"]
end

subgraph group_agent["Agent and guidance"]
  node_conversation["Tool-using agent<br/>[agent.py]"]
  node_prompts["Safety and prompts<br/>[prompts.py]"]
  node_briefing["Briefing checks<br/>[agent.py]"]
  node_storytime["Story Time<br/>[agent.py]"]
end

subgraph group_news["News tools"]
  node_tool_dispatch["News tool dispatcher<br/>[financial_news.py]"]
  node_glossary["Concept glossary<br/>[financial_news.py]"]
  node_rss["Daily RSS discovery<br/>[news.py]"]
  node_article["Article reader<br/>[news.py]"]
  node_crosscheck["Feed cross-check<br/>[news.py]"]
end

subgraph group_services["Service adapters"]
  node_settings["App settings<br/>[config.py]"]
  node_ollama["Ollama adapter<br/>[ollama.py]"]
end

node_user(("Beginner"))
node_ollama_service["Ollama service"]
node_publishers["RSS publishers"]
node_source_sites["Publisher pages"]

node_user -->|"asks"| node_cli
node_user -->|"browses"| node_browser
node_cli -->|"invokes"| node_conversation
node_browser -->|"invokes"| node_conversation
node_conversation -->|"uses guidance"| node_prompts
node_conversation -->|"requests replies"| node_ollama
node_ollama -->|"sends chat"| node_ollama_service
node_ollama -->|"reads settings"| node_settings
node_ollama_service -.->|"returns message"| node_ollama
node_conversation -->|"dispatches tools"| node_tool_dispatch
node_tool_dispatch -->|"explains terms"| node_glossary
node_tool_dispatch -->|"fetches stories"| node_rss
node_tool_dispatch -->|"reads selected source"| node_article
node_tool_dispatch -->|"finds candidates"| node_crosscheck
node_rss -->|"requests feeds"| node_publishers
node_crosscheck -->|"requests feeds"| node_publishers
node_article -->|"requests article"| node_source_sites
node_rss -->|"reads settings"| node_settings
node_crosscheck -->|"reads timezone"| node_settings
node_tool_dispatch -->|"selects feeds"| node_settings
node_conversation -->|"checks briefing"| node_briefing
node_briefing -->|"retries response"| node_conversation
node_browser -->|"offers analogy"| node_storytime
node_storytime -->|"generates analogy"| node_conversation

click node_cli "https://github.com/urgetolearn/finlens/blob/main/app/agent.py"
click node_browser "https://github.com/urgetolearn/finlens/blob/main/app/ui.py"
click node_conversation "https://github.com/urgetolearn/finlens/blob/main/app/agent.py"
click node_prompts "https://github.com/urgetolearn/finlens/blob/main/app/prompts.py"
click node_briefing "https://github.com/urgetolearn/finlens/blob/main/app/agent.py"
click node_storytime "https://github.com/urgetolearn/finlens/blob/main/app/agent.py"
click node_tool_dispatch "https://github.com/urgetolearn/finlens/blob/main/app/tools/financial_news.py"
click node_glossary "https://github.com/urgetolearn/finlens/blob/main/app/tools/financial_news.py"
click node_rss "https://github.com/urgetolearn/finlens/blob/main/app/services/news.py"
click node_article "https://github.com/urgetolearn/finlens/blob/main/app/services/news.py"
click node_crosscheck "https://github.com/urgetolearn/finlens/blob/main/app/services/news.py"
click node_settings "https://github.com/urgetolearn/finlens/blob/main/app/config.py"
click node_ollama "https://github.com/urgetolearn/finlens/blob/main/app/services/ollama.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_browser toneBlue
class node_conversation,node_prompts,node_briefing,node_storytime toneAmber
class node_tool_dispatch,node_glossary,node_rss,node_article,node_crosscheck toneMint
class node_settings,node_ollama toneRose
class node_user,node_ollama_service,node_publishers,node_source_sites toneIndigo
```

## Components

### User experience

- [CLI](https://github.com/urgetolearn/finlens/blob/main/app/agent.py): `app/agent.py`
- [News browser](https://github.com/urgetolearn/finlens/blob/main/app/ui.py): `app/ui.py`

### Agent and guidance

- [Tool-using agent](https://github.com/urgetolearn/finlens/blob/main/app/agent.py): `app/agent.py`
- [Safety and prompts](https://github.com/urgetolearn/finlens/blob/main/app/prompts.py): `app/prompts.py`
- [Briefing checks](https://github.com/urgetolearn/finlens/blob/main/app/agent.py): `app/agent.py`
- [Story Time](https://github.com/urgetolearn/finlens/blob/main/app/agent.py): `app/agent.py`

### News tools

- [News tool dispatcher](https://github.com/urgetolearn/finlens/blob/main/app/tools/financial_news.py): `app/tools/financial_news.py`
- [Concept glossary](https://github.com/urgetolearn/finlens/blob/main/app/tools/financial_news.py): `app/tools/financial_news.py`
- [Daily RSS discovery](https://github.com/urgetolearn/finlens/blob/main/app/services/news.py): `app/services/news.py`
- [Article reader](https://github.com/urgetolearn/finlens/blob/main/app/services/news.py): `app/services/news.py`
- [Feed cross-check](https://github.com/urgetolearn/finlens/blob/main/app/services/news.py): `app/services/news.py`

### Service adapters

- [App settings](https://github.com/urgetolearn/finlens/blob/main/app/config.py): `app/config.py`
- [Ollama adapter](https://github.com/urgetolearn/finlens/blob/main/app/services/ollama.py): `app/services/ollama.py`

### Other components

- **Beginner**
- **Ollama service**
- **RSS publishers**
- **Publisher pages**

## Connections

- Beginner → CLI: asks (evidence: `app/agent.py`)
- Beginner → News browser: browses (evidence: `app/ui.py`)
- CLI → Tool-using agent: invokes (evidence: `app/agent.py`)
- News browser → Tool-using agent: invokes (evidence: `app/ui.py`)
- Tool-using agent → Safety and prompts: uses guidance (evidence: `app/agent.py`)
- Tool-using agent → Ollama adapter: requests replies (evidence: `app/agent.py`)
- Ollama adapter → Ollama service: sends chat (evidence: `app/services/ollama.py`)
- Ollama adapter → App settings: reads settings (evidence: `app/services/ollama.py`)
- Ollama service → Ollama adapter: returns message
- Tool-using agent → News tool dispatcher: dispatches tools (evidence: `app/agent.py`)
- News tool dispatcher → Concept glossary: explains terms (evidence: `app/tools/financial_news.py`)
- News tool dispatcher → Daily RSS discovery: fetches stories (evidence: `app/tools/financial_news.py`)
- News tool dispatcher → Article reader: reads selected source (evidence: `app/tools/financial_news.py`)
- News tool dispatcher → Feed cross-check: finds candidates (evidence: `app/tools/financial_news.py`)
- Daily RSS discovery → RSS publishers: requests feeds (evidence: `app/services/news.py`)
- Feed cross-check → RSS publishers: requests feeds (evidence: `app/services/news.py`)
- Article reader → Publisher pages: requests article (evidence: `app/services/news.py`)
- Daily RSS discovery → App settings: reads settings (evidence: `app/services/news.py`)
- Feed cross-check → App settings: reads timezone (evidence: `app/services/news.py`)
- News tool dispatcher → App settings: selects feeds (evidence: `app/tools/financial_news.py`)
- Tool-using agent → Briefing checks: checks briefing (evidence: `app/agent.py`)
- Briefing checks → Tool-using agent: retries response (evidence: `app/agent.py`)
- News browser → Story Time: offers analogy (evidence: `app/ui.py`)
- Story Time → Tool-using agent: generates analogy (evidence: `app/agent.py`)
