# princeyadaviiit/dda-v2 architecture

> Architecture diagram of the GitHub repository princeyadaviiit/dda-v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/princeyadaviiit/dda-v2
- Repository: https://github.com/princeyadaviiit/dda-v2

## Overview

DDA Agent is a signal-only forex and gold analysis system. Its principal workflow fetches TradingView market data, validates and normalizes it, runs six analytical agents, applies confluence and deterministic risk checks, then records signal/audit results and exposes them through the API, dashboard, and optional Telegram alerts. The graph preserves the documented analysis stages and major dashboard/health capabilities. Some internal calls and dashboard-to-API wiring are not shown in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`backend/core/orchestrator.py`](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/core/orchestrator.py) (Scan Orchestrator), [`backend/services/health_service.py`](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/health_service.py) (Health Monitoring), [`backend/api/routes.py`](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/api/routes.py) (REST API), [`backend/database/repository.py`](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/database/repository.py) (Persistence Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Market Inputs"]
  node_mcp["MCP Client"]
  node_tv_adapter["TradingView Adapter"]
  node_normalizer["Market Normalizer<br/>[normalizer.py]"]
end

subgraph group_analysis["Analysis Pipeline"]
  node_orchestrator["Scan Orchestrator<br/>[orchestrator.py]"]
  node_scout["Scout Agent<br/>[scout.py]"]
  node_news["News Agent<br/>[news.py]"]
  node_sentiment["Sentiment Agent<br/>[sentiment.py]"]
  node_charts["Charts Agent<br/>[charts.py]"]
  node_indicators["Technical Structure<br/>[structure.py]"]
  node_decision["Decision Agent<br/>[decision.py]"]
  node_ai_worker["AI Reasoning Worker"]
  node_risk["Risk Agent<br/>[risk.py]"]
end

subgraph group_delivery["Signals and Delivery"]
  node_signal_engine["Signal Validation<br/>[signal_engine.py]"]
  node_execution_gateway["Execution Safety Gate"]
  node_repository["Persistence Repository<br/>[repository.py]"]
  node_database[("SQLite Store<br/>[db.py]")]
  node_telegram["Telegram Service"]
end

subgraph group_platform["API and Dashboard"]
  node_api["REST API<br/>[routes.py]"]
  node_websocket["Live WebSocket<br/>[websocket.py]"]
  node_dashboard["Financial Dashboard<br/>[page.tsx]"]
  node_dashboard_api["Dashboard API Client<br/>[api.ts]"]
end

subgraph group_operations["Health and State"]
  node_health["Health Monitoring<br/>[health_service.py]"]
  node_state["Pipeline State<br/>[state_machine.py]"]
end

node_tradingview(("TradingView"))
node_telegram_api(("Telegram API"))
node_user(("Operator"))

node_orchestrator -->|"fetches data"| node_tv_adapter
node_tv_adapter -->|"calls tools"| node_mcp
node_mcp -->|"requests market data"| node_tradingview
node_orchestrator -->|"normalizes data"| node_normalizer
node_orchestrator -->|"runs analysis"| node_scout
node_orchestrator -->|"runs analysis"| node_news
node_orchestrator -->|"runs analysis"| node_sentiment
node_orchestrator -->|"runs analysis"| node_charts
node_charts -->|"uses indicators"| node_indicators
node_orchestrator -->|"runs synthesis"| node_decision
node_decision -->|"delegates reasoning"| node_ai_worker
node_ai_worker -.->|"requests synthesis"| node_user
node_orchestrator -->|"runs risk gate"| node_risk
node_orchestrator -->|"validates confluence"| node_signal_engine
node_orchestrator -->|"stores scan results"| node_repository
node_signal_engine -.->|"records signals"| node_repository
node_repository -->|"reads and writes"| node_database
node_telegram -->|"sends alerts"| node_telegram_api
node_orchestrator -.->|"dispatches signals"| node_telegram
node_execution_gateway -->|"blocks orders"| node_user
node_user -->|"views terminal"| node_dashboard
node_dashboard -.->|"requests data"| node_dashboard_api
node_dashboard_api -.->|"calls backend"| node_api
node_api -->|"queries records"| node_repository
node_api -->|"probes health"| node_health
node_api -.->|"streams updates"| node_websocket
node_orchestrator -->|"updates pipeline"| node_state
node_health -->|"probes connection"| node_tv_adapter
node_health -->|"probes engine"| node_ai_worker
node_health -->|"checks status"| node_telegram
node_health -->|"checks mode"| node_execution_gateway

click node_mcp "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/adapters/mcp_stdio_client.py"
click node_tv_adapter "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/adapters/tradingview_mcp_client.py"
click node_normalizer "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/adapters/normalizer.py"
click node_orchestrator "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/core/orchestrator.py"
click node_scout "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/scout.py"
click node_news "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/news.py"
click node_sentiment "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/sentiment.py"
click node_charts "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/charts.py"
click node_indicators "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/indicators/structure.py"
click node_decision "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/decision.py"
click node_ai_worker "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/ai_reasoning_worker.py"
click node_risk "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/risk.py"
click node_signal_engine "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/signal_engine.py"
click node_execution_gateway "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/execution_gateway.py"
click node_repository "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/database/repository.py"
click node_database "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/database/db.py"
click node_telegram "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/telegram_service.py"
click node_api "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/api/routes.py"
click node_websocket "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/api/websocket.py"
click node_dashboard "https://github.com/princeyadaviiit/dda-v2/blob/main/dashboard/src/app/page.tsx"
click node_dashboard_api "https://github.com/princeyadaviiit/dda-v2/blob/main/dashboard/src/lib/api.ts"
click node_health "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/health_service.py"
click node_state "https://github.com/princeyadaviiit/dda-v2/blob/main/backend/core/state_machine.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_mcp,node_tv_adapter,node_normalizer,node_tradingview toneBlue
class node_orchestrator,node_scout,node_news,node_sentiment,node_charts,node_indicators,node_decision,node_ai_worker,node_risk toneAmber
class node_signal_engine,node_execution_gateway,node_repository,node_database,node_telegram,node_telegram_api toneMint
class node_api,node_websocket,node_dashboard,node_dashboard_api toneRose
class node_health,node_state,node_user toneIndigo
```

## Components

### Market Inputs

- [MCP Client](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/adapters/mcp_stdio_client.py): `backend/adapters/mcp_stdio_client.py`
- [TradingView Adapter](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/adapters/tradingview_mcp_client.py): `backend/adapters/tradingview_mcp_client.py`
- [Market Normalizer](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/adapters/normalizer.py): `backend/adapters/normalizer.py`

### Analysis Pipeline

- [Scan Orchestrator](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/core/orchestrator.py): `backend/core/orchestrator.py`
- [Scout Agent](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/scout.py): `backend/agents/scout.py`
- [News Agent](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/news.py): `backend/agents/news.py`
- [Sentiment Agent](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/sentiment.py): `backend/agents/sentiment.py`
- [Charts Agent](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/charts.py): `backend/agents/charts.py`
- [Technical Structure](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/indicators/structure.py): `backend/indicators/structure.py`
- [Decision Agent](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/decision.py): `backend/agents/decision.py`
- [AI Reasoning Worker](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/ai_reasoning_worker.py): `backend/services/ai_reasoning_worker.py`
- [Risk Agent](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/agents/risk.py): `backend/agents/risk.py`

### Signals and Delivery

- [Signal Validation](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/signal_engine.py): `backend/services/signal_engine.py`
- [Execution Safety Gate](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/execution_gateway.py): `backend/services/execution_gateway.py`
- [Persistence Repository](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/database/repository.py): `backend/database/repository.py`
- [SQLite Store](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/database/db.py): `backend/database/db.py`
- [Telegram Service](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/telegram_service.py): `backend/services/telegram_service.py`

### API and Dashboard

- [REST API](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/api/routes.py): `backend/api/routes.py`
- [Live WebSocket](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/api/websocket.py): `backend/api/websocket.py`
- [Financial Dashboard](https://github.com/princeyadaviiit/dda-v2/blob/main/dashboard/src/app/page.tsx): `dashboard/src/app/page.tsx`
- [Dashboard API Client](https://github.com/princeyadaviiit/dda-v2/blob/main/dashboard/src/lib/api.ts): `dashboard/src/lib/api.ts`

### Health and State

- [Health Monitoring](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/services/health_service.py): `backend/services/health_service.py`
- [Pipeline State](https://github.com/princeyadaviiit/dda-v2/blob/main/backend/core/state_machine.py): `backend/core/state_machine.py`

### Other components

- **TradingView**
- **Telegram API**
- **Operator**

## Connections

- Scan Orchestrator → TradingView Adapter: fetches data (evidence: `backend/core/orchestrator.py`)
- TradingView Adapter → MCP Client: calls tools (evidence: `backend/adapters/tradingview_mcp_client.py`)
- MCP Client → TradingView: requests market data (evidence: `README.md`)
- Scan Orchestrator → Market Normalizer: normalizes data (evidence: `backend/core/orchestrator.py`)
- Scan Orchestrator → Scout Agent: runs analysis (evidence: `README.md`)
- Scan Orchestrator → News Agent: runs analysis (evidence: `README.md`)
- Scan Orchestrator → Sentiment Agent: runs analysis (evidence: `README.md`)
- Scan Orchestrator → Charts Agent: runs analysis (evidence: `README.md`)
- Charts Agent → Technical Structure: uses indicators (evidence: `backend/agents/charts.py`)
- Scan Orchestrator → Decision Agent: runs synthesis (evidence: `README.md`)
- Decision Agent → AI Reasoning Worker: delegates reasoning (evidence: `backend/agents/decision.py`)
- AI Reasoning Worker → Operator: requests synthesis
- Scan Orchestrator → Risk Agent: runs risk gate (evidence: `README.md`)
- Scan Orchestrator → Signal Validation: validates confluence (evidence: `README.md`)
- Scan Orchestrator → Persistence Repository: stores scan results (evidence: `backend/core/orchestrator.py`)
- Signal Validation → Persistence Repository: records signals
- Persistence Repository → SQLite Store: reads and writes (evidence: `backend/database/repository.py`)
- Telegram Service → Telegram API: sends alerts (evidence: `backend/services/telegram_service.py`)
- Scan Orchestrator → Telegram Service: dispatches signals
- Execution Safety Gate → Operator: blocks orders (evidence: `README.md`)
- Operator → Financial Dashboard: views terminal (evidence: `README.md`)
- Financial Dashboard → Dashboard API Client: requests data
- Dashboard API Client → REST API: calls backend
- REST API → Persistence Repository: queries records (evidence: `backend/api/routes.py`)
- REST API → Health Monitoring: probes health (evidence: `backend/api/routes.py`)
- REST API → Live WebSocket: streams updates (evidence: `backend/api/routes.py`)
- Scan Orchestrator → Pipeline State: updates pipeline (evidence: `backend/core/orchestrator.py`)
- Health Monitoring → TradingView Adapter: probes connection (evidence: `backend/services/health_service.py`)
- Health Monitoring → AI Reasoning Worker: probes engine (evidence: `backend/services/health_service.py`)
- Health Monitoring → Telegram Service: checks status (evidence: `backend/services/health_service.py`)
- Health Monitoring → Execution Safety Gate: checks mode (evidence: `backend/services/health_service.py`)
