# maxrindia/jettone-copy-trading- architecture

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

- Interactive diagram: https://gitdiagram.com/maxrindia/jettone-copy-trading-
- Repository: https://github.com/maxrindia/jettone-copy-trading-

## Overview

Jettone is an Alice Blue copy-trading platform: an owner configures demat accounts and master/follower strategies, then the live engine detects master orders, validates and sizes copies, dispatches them to child accounts, and records outcomes. The web app also exposes order, reconciliation, dashboard/P&L, and reliability controls. The README documents the product workflow; source excerpts and the SOURCE INDEX establish the main runtime wiring. Some API, reliability, and UI implementation details were not sampled, so uncertain links are omitted.

Main entry points: [`backend/app/services/runtime/engine_loop.py`](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/runtime/engine_loop.py) (Runtime engine), [`frontend/src/app/api/v1/[...path]/route.ts`](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/api/v1/%5B...path%5D/route.ts) (API proxy), [`backend/app/services/copy_engine/pipeline.py`](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/pipeline.py) (Copy execution pipeline), [`backend/app/services/pnl/service.py`](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/pnl/service.py) (P&L service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_account_ui["Demat accounts<br/>[page.tsx]"]
  node_strategy_ui["Group strategies<br/>[page.tsx]"]
  node_dashboard_ui["Trading dashboard<br/>[page.tsx]"]
  node_orders_ui["Order manager<br/>[page.tsx]"]
  node_recon_ui["Reconciliation view<br/>[page.tsx]"]
  node_web_proxy["API proxy<br/>[route.ts]"]
end

subgraph group_api["API and account setup"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_api_routes["API routes"]
  node_account_models["Account records<br/>[accounts.py]"]
  node_strategy_models["Strategy records<br/>[strategies.py]"]
end

subgraph group_trading["Live trading"]
  node_engine["Runtime engine<br/>[engine_loop.py]"]
  node_broker_manager["Broker manager<br/>[manager.py]"]
  node_alice_client["Alice Blue client<br/>[client.py]"]
  node_detector["Master order detector<br/>[detector.py]"]
  node_copy_pipeline["Copy execution pipeline<br/>[pipeline.py]"]
  node_copy_calculator["Copy sizing<br/>[calculator.py]"]
  node_alice_blue["Alice Blue broker"]
end

subgraph group_state["Persistence and insights"]
  node_pnl_service["P&amp;L service<br/>[service.py]"]
  node_pnl_calculator["P&amp;L calculator<br/>[calculator.py]"]
  node_database_layer["Database access<br/>[database.py]"]
  node_orders_audit["Orders and audit records<br/>[trades.py]"]
  node_system_events["System event records<br/>[audit.py]"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis cache and pub/sub<br/>[redis.py]")]
end

subgraph group_ops["Safety and monitoring"]
  node_reliability["Reconciliation and recovery"]
  node_notifier["Event notifier<br/>[notifier.py]"]
  node_telegram["Telegram alerts<br/>[telegram.py]"]
end

node_owner(("Platform owner"))

node_owner -->|"adds accounts"| node_account_ui
node_owner -->|"configures strategy"| node_strategy_ui
node_owner -->|"reviews activity"| node_dashboard_ui
node_owner -->|"reviews executions"| node_orders_ui
node_owner -->|"checks positions"| node_recon_ui
node_account_ui -.->|"sends API requests"| node_web_proxy
node_strategy_ui -.->|"sends API requests"| node_web_proxy
node_dashboard_ui -.->|"requests dashboard data"| node_web_proxy
node_orders_ui -.->|"requests order data"| node_web_proxy
node_recon_ui -.->|"requests reconciliation"| node_web_proxy
node_web_proxy -->|"proxies requests"| node_fastapi
node_fastapi -->|"registers routes"| node_api_routes
node_api_routes -.->|"manages accounts"| node_account_models
node_api_routes -.->|"manages strategies"| node_strategy_models
node_fastapi -->|"starts runtime"| node_engine
node_engine -->|"uses account clients"| node_broker_manager
node_broker_manager -->|"creates clients"| node_alice_client
node_alice_client -.->|"sends broker requests"| node_alice_blue
node_engine -->|"processes order events"| node_detector
node_engine -->|"dispatches copies"| node_copy_pipeline
node_copy_pipeline -->|"calculates quantities"| node_copy_calculator
node_copy_pipeline -->|"places child orders"| node_alice_client
node_engine -.->|"persists order events"| node_orders_audit
node_copy_pipeline -.->|"records executions"| node_orders_audit
node_dashboard_ui -->|"displays P&amp;L"| node_pnl_service
node_pnl_service -->|"calculates P&amp;L"| node_pnl_calculator
node_pnl_service -.->|"reads broker data"| node_alice_client
node_recon_ui -->|"requests safety audit"| node_reliability
node_engine -->|"runs recovery loops"| node_reliability
node_pnl_service -->|"alerts mismatches"| node_notifier
node_notifier -->|"persists events"| node_system_events
node_notifier -->|"dispatches alerts"| node_telegram
node_database_layer -->|"connects to"| node_postgres
node_engine -.->|"uses runtime messaging"| node_redis

click node_account_ui "https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/demat/page.tsx"
click node_strategy_ui "https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/group-strategy/page.tsx"
click node_dashboard_ui "https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/page.tsx"
click node_orders_ui "https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/orders/page.tsx"
click node_recon_ui "https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/reconciliation/page.tsx"
click node_web_proxy "https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/api/v1/%5B...path%5D/route.ts"
click node_fastapi "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/maxrindia/jettone-copy-trading-/tree/main/backend/app/api"
click node_account_models "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/accounts.py"
click node_strategy_models "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/strategies.py"
click node_engine "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/runtime/engine_loop.py"
click node_broker_manager "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/alice_blue/manager.py"
click node_alice_client "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/alice_blue/client.py"
click node_detector "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/detector.py"
click node_copy_pipeline "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/pipeline.py"
click node_copy_calculator "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/calculator.py"
click node_pnl_service "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/pnl/service.py"
click node_pnl_calculator "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/pnl/calculator.py"
click node_reliability "https://github.com/maxrindia/jettone-copy-trading-/tree/main/backend/app/services/reliability"
click node_notifier "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/monitoring/notifier.py"
click node_telegram "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/monitoring/telegram.py"
click node_database_layer "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/core/database.py"
click node_orders_audit "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/trades.py"
click node_system_events "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/audit.py"
click node_redis "https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/core/redis.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_account_ui,node_strategy_ui,node_dashboard_ui,node_orders_ui,node_recon_ui,node_web_proxy toneBlue
class node_fastapi,node_api_routes,node_account_models,node_strategy_models toneAmber
class node_engine,node_broker_manager,node_alice_client,node_detector,node_copy_pipeline,node_copy_calculator,node_alice_blue toneMint
class node_pnl_service,node_pnl_calculator,node_database_layer,node_orders_audit,node_system_events,node_postgres,node_redis toneRose
class node_reliability,node_notifier,node_telegram,node_owner toneIndigo
```

## Components

### Web application

- [Demat accounts](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/demat/page.tsx): `frontend/src/app/(app)/demat/page.tsx`
- [Group strategies](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/group-strategy/page.tsx): `frontend/src/app/(app)/group-strategy/page.tsx`
- [Trading dashboard](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/page.tsx): `frontend/src/app/(app)/page.tsx`
- [Order manager](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/orders/page.tsx): `frontend/src/app/(app)/orders/page.tsx`
- [Reconciliation view](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/(app)/reconciliation/page.tsx): `frontend/src/app/(app)/reconciliation/page.tsx`
- [API proxy](https://github.com/maxrindia/jettone-copy-trading-/blob/main/frontend/src/app/api/v1/%5B...path%5D/route.ts): `frontend/src/app/api/v1/[...path]/route.ts`

### API and account setup

- [FastAPI application](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/main.py): `backend/app/main.py`
- [API routes](https://github.com/maxrindia/jettone-copy-trading-/tree/main/backend/app/api): `backend/app/api`
- [Account records](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/accounts.py): `backend/app/models/accounts.py`
- [Strategy records](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/strategies.py): `backend/app/models/strategies.py`

### Live trading

- [Runtime engine](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/runtime/engine_loop.py): `backend/app/services/runtime/engine_loop.py`
- [Broker manager](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/alice_blue/manager.py): `backend/app/services/alice_blue/manager.py`
- [Alice Blue client](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/alice_blue/client.py): `backend/app/services/alice_blue/client.py`
- [Master order detector](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/detector.py): `backend/app/services/copy_engine/detector.py`
- [Copy execution pipeline](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/pipeline.py): `backend/app/services/copy_engine/pipeline.py`
- [Copy sizing](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/copy_engine/calculator.py): `backend/app/services/copy_engine/calculator.py`
- **Alice Blue broker**

### Persistence and insights

- [P&L service](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/pnl/service.py): `backend/app/services/pnl/service.py`
- [P&L calculator](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/pnl/calculator.py): `backend/app/services/pnl/calculator.py`
- [Database access](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Orders and audit records](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/trades.py): `backend/app/models/trades.py`
- [System event records](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/models/audit.py): `backend/app/models/audit.py`
- **PostgreSQL**
- [Redis cache and pub/sub](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/core/redis.py): `backend/app/core/redis.py`

### Safety and monitoring

- [Reconciliation and recovery](https://github.com/maxrindia/jettone-copy-trading-/tree/main/backend/app/services/reliability): `backend/app/services/reliability`
- [Event notifier](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/monitoring/notifier.py): `backend/app/services/monitoring/notifier.py`
- [Telegram alerts](https://github.com/maxrindia/jettone-copy-trading-/blob/main/backend/app/services/monitoring/telegram.py): `backend/app/services/monitoring/telegram.py`

### Other components

- **Platform owner**

## Connections

- Platform owner → Demat accounts: adds accounts
- Platform owner → Group strategies: configures strategy
- Platform owner → Trading dashboard: reviews activity
- Platform owner → Order manager: reviews executions
- Platform owner → Reconciliation view: checks positions
- Demat accounts → API proxy: sends API requests
- Group strategies → API proxy: sends API requests
- Trading dashboard → API proxy: requests dashboard data
- Order manager → API proxy: requests order data
- Reconciliation view → API proxy: requests reconciliation
- API proxy → FastAPI application: proxies requests
- FastAPI application → API routes: registers routes (evidence: `backend/app/main.py`)
- API routes → Account records: manages accounts (evidence: `backend/app/api/dashboard.py`)
- API routes → Strategy records: manages strategies (evidence: `backend/app/api/dashboard.py`)
- FastAPI application → Runtime engine: starts runtime (evidence: `backend/app/main.py`)
- Runtime engine → Broker manager: uses account clients (evidence: `backend/app/services/runtime/engine_loop.py`)
- Broker manager → Alice Blue client: creates clients (evidence: `backend/app/services/alice_blue/manager.py`)
- Alice Blue client → Alice Blue broker: sends broker requests
- Runtime engine → Master order detector: processes order events (evidence: `backend/app/services/runtime/engine_loop.py`)
- Runtime engine → Copy execution pipeline: dispatches copies (evidence: `backend/app/services/runtime/engine_loop.py`)
- Copy execution pipeline → Copy sizing: calculates quantities (evidence: `backend/app/services/copy_engine/pipeline.py`)
- Copy execution pipeline → Alice Blue client: places child orders (evidence: `backend/app/services/copy_engine/pipeline.py`)
- Runtime engine → Orders and audit records: persists order events (evidence: `backend/app/services/runtime/engine_loop.py`)
- Copy execution pipeline → Orders and audit records: records executions (evidence: `backend/app/services/copy_engine/pipeline.py`)
- Trading dashboard → P&L service: displays P&L
- P&L service → P&L calculator: calculates P&L (evidence: `backend/app/services/pnl/service.py`)
- P&L service → Alice Blue client: reads broker data
- Reconciliation view → Reconciliation and recovery: requests safety audit
- Runtime engine → Reconciliation and recovery: runs recovery loops (evidence: `backend/app/services/runtime/engine_loop.py`)
- P&L service → Event notifier: alerts mismatches (evidence: `backend/app/services/pnl/service.py`)
- Event notifier → System event records: persists events (evidence: `backend/app/services/monitoring/notifier.py`)
- Event notifier → Telegram alerts: dispatches alerts (evidence: `backend/app/services/monitoring/notifier.py`)
- Database access → PostgreSQL: connects to (evidence: `backend/app/core/database.py`)
- Runtime engine → Redis cache and pub/sub: uses runtime messaging
