# jeetgajeraa/cryptolab architecture

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

- Interactive diagram: https://gitdiagram.com/jeetgajeraa/cryptolab
- Repository: https://github.com/jeetgajeraa/cryptolab

## Overview

Crypt-Lab is a crypto-trading application with a browser UI, an Express backend, and a Python bot-strategy runner. Users sign up or log in, view live market prices, manage orders and positions, and configure trading bots. The backend also tracks fills and trades and supports wallet, profile, and performance views. The source index and excerpts show key backend and frontend connections; several runtime services and UI pages are listed but unsampled, so their internal links are omitted where not established.

Main entry points: [`frontend/src/App.tsx`](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/App.tsx) (Route application), [`backend/src/app.ts`](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/app.ts) (HTTP application), [`backend/src/controllers/order.controller.ts`](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/order.controller.ts) (Order controller), [`backend/src/services/positionService.ts`](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/positionService.ts) (Position service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web application"]
  node_app["Route application<br/>[App.tsx]"]
  node_authpages["Account pages<br/>[LoginPage.tsx]"]
  node_marketpages["Market pages<br/>[ChartPage.tsx]"]
  node_accountpages["Account views<br/>[ProfilePage.tsx]"]
  node_botpage["Bot controls<br/>[BotPage.tsx]"]
  node_api_client["HTTP client<br/>[axios.tsx]"]
  node_pricehook["Socket prices<br/>[useSocketPrices.ts]"]
end

subgraph group_api["Backend API"]
  node_express["HTTP application<br/>[app.ts]"]
  node_userctrl["Account controller<br/>[user.controller.ts]"]
  node_orderctrl["Order controller"]
  node_botctrl["Bot controller<br/>[bot.controller.ts]"]
  node_tradectrl["Trade controller"]
end

subgraph group_trading["Trading runtime"]
  node_positions["Position service<br/>[positionService.ts]"]
  node_simulator["Order simulator<br/>[orderSimulator.ts]"]
  node_fillprocessor["Fill processor<br/>[fillProcessor.ts]"]
  node_marketstream["Exchange stream"]
  node_redis[("Redis cache<br/>[redisClient.ts]")]
  node_records[("Trading records")]
end

subgraph group_bots["Bot strategies"]
  node_runner["Bot runner<br/>[bot_runner.py]"]
  node_strategies["Strategy implementations"]
end

node_visitor(("Trader"))
node_exchange(("Market feed"))

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_marketpages
node_app -->|"routes to"| node_accountpages
node_app -->|"routes to"| node_botpage
node_app -->|"checks profile"| node_api_client
node_marketpages -->|"uses prices"| node_pricehook
node_pricehook -->|"subscribes"| node_exchange
node_express -->|"routes requests"| node_userctrl
node_express -->|"routes requests"| node_orderctrl
node_express -->|"routes requests"| node_botctrl
node_orderctrl -->|"checks balance"| node_positions
node_orderctrl -->|"reads and writes"| node_records
node_positions -->|"updates fills"| node_records
node_positions -->|"reads prices"| node_redis
node_tradectrl -->|"reads trade data"| node_records
node_marketstream -.->|"caches prices"| node_redis
node_simulator -.->|"processes orders"| node_fillprocessor
node_runner -->|"loads strategies"| node_strategies
node_botctrl -.->|"dispatches bots"| node_runner

click node_app "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/App.tsx"
click node_authpages "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/LoginPage.tsx"
click node_marketpages "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/ChartPage.tsx"
click node_accountpages "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/ProfilePage.tsx"
click node_botpage "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/BotPage.tsx"
click node_api_client "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/api/axios.tsx"
click node_pricehook "https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/hooks/useSocketPrices.ts"
click node_express "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/app.ts"
click node_userctrl "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/user.controller.ts"
click node_orderctrl "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/order.controller.ts"
click node_botctrl "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/bot.controller.ts"
click node_tradectrl "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/trade.controller.ts"
click node_positions "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/positionService.ts"
click node_simulator "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/orderSimulator.ts"
click node_fillprocessor "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/fillProcessor.ts"
click node_marketstream "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/binanceWebSocket.ts"
click node_redis "https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/redisClient.ts"
click node_records "https://github.com/jeetgajeraa/cryptolab/tree/main/backend/src/models"
click node_runner "https://github.com/jeetgajeraa/cryptolab/blob/main/py_services/bot_runner.py"
click node_strategies "https://github.com/jeetgajeraa/cryptolab/tree/main/py_services/strategies"

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_app,node_authpages,node_marketpages,node_accountpages,node_botpage,node_api_client,node_pricehook toneBlue
class node_express,node_userctrl,node_orderctrl,node_botctrl,node_tradectrl toneAmber
class node_positions,node_simulator,node_fillprocessor,node_marketstream,node_redis,node_records toneMint
class node_runner,node_strategies toneRose
class node_visitor,node_exchange toneIndigo
```

## Components

### Web application

- [Route application](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Account pages](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/LoginPage.tsx): `frontend/src/pages/LoginPage.tsx`
- [Market pages](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/ChartPage.tsx): `frontend/src/pages/ChartPage.tsx`
- [Account views](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/ProfilePage.tsx): `frontend/src/pages/ProfilePage.tsx`
- [Bot controls](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/pages/BotPage.tsx): `frontend/src/pages/BotPage.tsx`
- [HTTP client](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/api/axios.tsx): `frontend/src/api/axios.tsx`
- [Socket prices](https://github.com/jeetgajeraa/cryptolab/blob/main/frontend/src/hooks/useSocketPrices.ts): `frontend/src/hooks/useSocketPrices.ts`

### Backend API

- [HTTP application](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Account controller](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/user.controller.ts): `backend/src/controllers/user.controller.ts`
- [Order controller](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/order.controller.ts): `backend/src/controllers/order.controller.ts`
- [Bot controller](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/bot.controller.ts): `backend/src/controllers/bot.controller.ts`
- [Trade controller](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/controllers/trade.controller.ts): `backend/src/controllers/trade.controller.ts`

### Trading runtime

- [Position service](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/positionService.ts): `backend/src/services/positionService.ts`
- [Order simulator](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/orderSimulator.ts): `backend/src/services/orderSimulator.ts`
- [Fill processor](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/fillProcessor.ts): `backend/src/services/fillProcessor.ts`
- [Exchange stream](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/binanceWebSocket.ts): `backend/src/services/binanceWebSocket.ts`
- [Redis cache](https://github.com/jeetgajeraa/cryptolab/blob/main/backend/src/services/redisClient.ts): `backend/src/services/redisClient.ts`
- [Trading records](https://github.com/jeetgajeraa/cryptolab/tree/main/backend/src/models): `backend/src/models`

### Bot strategies

- [Bot runner](https://github.com/jeetgajeraa/cryptolab/blob/main/py_services/bot_runner.py): `py_services/bot_runner.py`
- [Strategy implementations](https://github.com/jeetgajeraa/cryptolab/tree/main/py_services/strategies): `py_services/strategies`

### Other components

- **Trader**
- **Market feed**

## Connections

- Trader → Route application: uses
- Route application → Account pages: routes to (evidence: `frontend/src/App.tsx`)
- Route application → Market pages: routes to (evidence: `frontend/src/App.tsx`)
- Route application → Account views: routes to (evidence: `frontend/src/App.tsx`)
- Route application → Bot controls: routes to (evidence: `frontend/src/App.tsx`)
- Route application → HTTP client: checks profile (evidence: `frontend/src/App.tsx`)
- Market pages → Socket prices: uses prices (evidence: `frontend/src/pages/ChartPage.tsx`)
- Socket prices → Market feed: subscribes (evidence: `frontend/src/hooks/useSocketPrices.ts`)
- HTTP application → Account controller: routes requests (evidence: `backend/src/app.ts`)
- HTTP application → Order controller: routes requests (evidence: `backend/src/app.ts`)
- HTTP application → Bot controller: routes requests (evidence: `backend/src/app.ts`)
- Order controller → Position service: checks balance (evidence: `backend/src/controllers/order.controller.ts`)
- Order controller → Trading records: reads and writes (evidence: `backend/src/controllers/order.controller.ts`)
- Position service → Trading records: updates fills (evidence: `backend/src/services/positionService.ts`)
- Position service → Redis cache: reads prices (evidence: `backend/src/services/positionService.ts`)
- Trade controller → Trading records: reads trade data (evidence: `backend/src/controllers/trade.controller.ts`)
- Exchange stream → Redis cache: caches prices
- Order simulator → Fill processor: processes orders
- Bot runner → Strategy implementations: loads strategies (evidence: `py_services/bot_runner.py`)
- Bot controller → Bot runner: dispatches bots
