# joma-dahalan/da7lan-ai architecture

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

- Interactive diagram: https://gitdiagram.com/joma-dahalan/da7lan-ai
- Repository: https://github.com/joma-dahalan/da7lan-ai

## Overview

Da7lan Trading is a Telegram bot that gates gold-market reports behind a trial or subscription. Users choose a report in Telegram; the bot checks access, dispatches the selected analysis, and returns its text. The analysis module fetches TwelveData market data and provides technical, pattern, divergence, supply/demand, session, and recommendation reports. Subscription state and activation codes persist in JSON files. The excerpts show bot dispatch and API requests; finer internal report dependencies are not fully visible.

Main entry points: [`da7lan_trading/main.py`](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py) (Report Dispatch), [`da7lan_trading/analysis.py`](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py) (Market Data Fetching), [`da7lan_trading/users.json`](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/users.json) (User Records), [`da7lan_trading/codes.json`](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/codes.json) (Activation Codes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Telegram Bot"]
  node_bot_handlers["Bot Handlers<br/>[main.py]"]
  node_report_dispatch["Report Dispatch<br/>[main.py]"]
end

subgraph group_access["Access Management"]
  node_access_control["Trial &amp; Subscriptions<br/>[main.py]"]
  node_user_store[("User Records<br/>[users.json]")]
  node_code_store[("Activation Codes<br/>[codes.json]")]
end

subgraph group_analysis["Gold Analysis"]
  node_market_data["Market Data Fetching<br/>[analysis.py]"]
  node_technical_reports["Trading Reports<br/>[analysis.py]"]
  node_pattern_reports["Patterns &amp; Divergence<br/>[analysis.py]"]
  node_supply_demand["Supply &amp; Demand<br/>[analysis.py]"]
  node_session_reports["Session Analysis<br/>[analysis.py]"]
  node_ai_reports["AI &amp; Behavior Reports<br/>[analysis.py]"]
  node_recommendations["Market Decisions<br/>[analysis.py]"]
end

subgraph group_integrations["Data Integrations"]
  node_telegram["Telegram Platform"]
  node_twelvedata["TwelveData API"]
end

node_traders(("Telegram Users"))

node_traders -->|"send requests"| node_telegram
node_telegram -->|"deliver updates"| node_bot_handlers
node_bot_handlers -->|"check access"| node_access_control
node_access_control -->|"read and write"| node_user_store
node_access_control -->|"validate and update"| node_code_store
node_bot_handlers -->|"dispatch selection"| node_report_dispatch
node_report_dispatch -->|"request report"| node_technical_reports
node_report_dispatch -->|"request report"| node_pattern_reports
node_report_dispatch -->|"request report"| node_supply_demand
node_report_dispatch -->|"request report"| node_session_reports
node_report_dispatch -->|"request report"| node_ai_reports
node_report_dispatch -->|"request decision"| node_recommendations
node_market_data -->|"fetch prices and candles"| node_twelvedata
node_technical_reports -.->|"fetch candles"| node_market_data
node_pattern_reports -->|"fetch candles"| node_market_data

click node_bot_handlers "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py"
click node_access_control "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py"
click node_user_store "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/users.json"
click node_code_store "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/codes.json"
click node_report_dispatch "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py"
click node_market_data "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py"
click node_technical_reports "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py"
click node_pattern_reports "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py"
click node_supply_demand "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py"
click node_session_reports "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py"
click node_ai_reports "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py"
click node_recommendations "https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.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_bot_handlers,node_report_dispatch,node_traders toneBlue
class node_access_control,node_user_store,node_code_store toneAmber
class node_market_data,node_technical_reports,node_pattern_reports,node_supply_demand,node_session_reports,node_ai_reports,node_recommendations toneMint
class node_telegram,node_twelvedata toneRose
```

## Components

### Telegram Bot

- [Bot Handlers](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py): `da7lan_trading/main.py`
- [Report Dispatch](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py): `da7lan_trading/main.py`

### Access Management

- [Trial & Subscriptions](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/main.py): `da7lan_trading/main.py`
- [User Records](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/users.json): `da7lan_trading/users.json`
- [Activation Codes](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/codes.json): `da7lan_trading/codes.json`

### Gold Analysis

- [Market Data Fetching](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`
- [Trading Reports](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`
- [Patterns & Divergence](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`
- [Supply & Demand](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`
- [Session Analysis](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`
- [AI & Behavior Reports](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`
- [Market Decisions](https://github.com/joma-dahalan/da7lan-ai/blob/main/da7lan_trading/analysis.py): `da7lan_trading/analysis.py`

### Data Integrations

- **Telegram Platform**
- **TwelveData API**

### Other components

- **Telegram Users**

## Connections

- Telegram Users → Telegram Platform: send requests
- Telegram Platform → Bot Handlers: deliver updates (evidence: `da7lan_trading/main.py`)
- Bot Handlers → Trial & Subscriptions: check access (evidence: `da7lan_trading/main.py`)
- Trial & Subscriptions → User Records: read and write (evidence: `da7lan_trading/main.py`)
- Trial & Subscriptions → Activation Codes: validate and update (evidence: `da7lan_trading/main.py`)
- Bot Handlers → Report Dispatch: dispatch selection (evidence: `da7lan_trading/main.py`)
- Report Dispatch → Trading Reports: request report (evidence: `da7lan_trading/main.py`)
- Report Dispatch → Patterns & Divergence: request report (evidence: `da7lan_trading/main.py`)
- Report Dispatch → Supply & Demand: request report (evidence: `da7lan_trading/main.py`)
- Report Dispatch → Session Analysis: request report (evidence: `da7lan_trading/main.py`)
- Report Dispatch → AI & Behavior Reports: request report (evidence: `da7lan_trading/main.py`)
- Report Dispatch → Market Decisions: request decision (evidence: `da7lan_trading/main.py`)
- Market Data Fetching → TwelveData API: fetch prices and candles (evidence: `da7lan_trading/analysis.py`)
- Trading Reports → Market Data Fetching: fetch candles (evidence: `da7lan_trading/analysis.py`)
- Patterns & Divergence → Market Data Fetching: fetch candles (evidence: `da7lan_trading/analysis.py`)
