# sayak2103/trademl architecture

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

- Interactive diagram: https://gitdiagram.com/sayak2103/trademl
- Repository: https://github.com/sayak2103/trademl

## Overview

TradeML presents a trading interface where users choose a stock, capital, and duration, then view live trading updates and investment status. The React app also includes a marketing homepage and demo. The documented runtime is split between a Node.js WebSocket backend and a Flask model-inference server; the repository also contains reinforcement-learning training code and a stock-trading environment. The available excerpts show frontend routing, component composition, and socket connection, but not the backend or Flask request handlers, so those links are limited to documented or unverified relationships.

Main entry points: [`frontend/src/components/HomePage.jsx`](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/HomePage.jsx) (Home page), [`frontend/src/App.jsx`](https://github.com/sayak2103/trademl/blob/main/frontend/src/App.jsx) (App routes), [`rl_modules/utils.py`](https://github.com/sayak2103/trademl/blob/main/rl_modules/utils.py) (Market data and training), [`frontend/src/components/TradeArena.jsx`](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TradeArena.jsx) (Trade arena)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React application"]
  node_app["App routes<br/>[App.jsx]"]
  node_demo["Demo video<br/>[Demo.jsx]"]
  node_arena["Trade arena<br/>[TradeArena.jsx]"]
  node_query["Trade parameters<br/>[QueryForm.jsx]"]
  node_window["Live trade view<br/>[TradeWindow.jsx]"]
end

subgraph group_backend["Trading services"]
  node_node["Node trading server<br/>[app.js]"]
  node_flask["Flask inference server<br/>[app.py]"]
end

subgraph group_learning["Reinforcement learning"]
  node_utils["Market data and training<br/>[utils.py]"]
  node_policy["DQN policy trainer<br/>[policy_train.py]"]
  node_environment["Stock environment<br/>[environment.py]"]
end

subgraph group_homepage["Homepage content"]
  node_home["Home page<br/>[HomePage.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_features["Features"]
  node_howworks["How it works"]
  node_testimonials["Testimonials"]
  node_calltoaction["Call to action"]
  node_footer["Footer<br/>[Footer.jsx]"]
end

node_investor(("Investor"))
node_marketdata[("Alpaca market data")]

node_investor -->|"opens app"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_arena
node_app -->|"routes to"| node_demo
node_home -->|"renders"| node_navbar
node_home -->|"renders"| node_features
node_home -->|"renders"| node_howworks
node_home -->|"renders"| node_testimonials
node_home -->|"renders"| node_calltoaction
node_home -->|"renders"| node_footer
node_arena -->|"renders"| node_query
node_arena -->|"renders"| node_window
node_window -->|"opens socket"| node_node
node_node -.->|"requests inference"| node_flask
node_utils -->|"fetches bars"| node_marketdata
node_utils -->|"sets data"| node_environment
node_utils -->|"trains policy"| node_policy
node_policy -->|"steps environment"| node_environment
node_flask -.->|"serves trained model"| node_policy

click node_app "https://github.com/sayak2103/trademl/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/HomePage.jsx"
click node_navbar "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/Navbar.jsx"
click node_features "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/FeaturesSection.jsx"
click node_howworks "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/HowItWorksSection.jsx"
click node_testimonials "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TestimonialsSection.jsx"
click node_calltoaction "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/CallToActionSection.jsx"
click node_footer "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/Footer.jsx"
click node_demo "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/Demo.jsx"
click node_arena "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TradeArena.jsx"
click node_query "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/QueryForm.jsx"
click node_window "https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TradeWindow.jsx"
click node_node "https://github.com/sayak2103/trademl/blob/main/main_server/app.js"
click node_flask "https://github.com/sayak2103/trademl/blob/main/flask_Server/app.py"
click node_utils "https://github.com/sayak2103/trademl/blob/main/rl_modules/utils.py"
click node_policy "https://github.com/sayak2103/trademl/blob/main/rl_modules/my_packages/policy_train.py"
click node_environment "https://github.com/sayak2103/trademl/blob/main/rl_modules/my_packages/environment.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_app,node_demo,node_arena,node_query,node_window toneBlue
class node_node,node_flask,node_marketdata toneAmber
class node_utils,node_policy,node_environment toneMint
class node_home,node_navbar,node_features,node_howworks,node_testimonials,node_calltoaction,node_footer toneRose
class node_investor toneIndigo
```

## Components

### React application

- [App routes](https://github.com/sayak2103/trademl/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Demo video](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/Demo.jsx): `frontend/src/components/Demo.jsx`
- [Trade arena](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TradeArena.jsx): `frontend/src/components/TradeArena.jsx`
- [Trade parameters](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/QueryForm.jsx): `frontend/src/components/QueryForm.jsx`
- [Live trade view](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TradeWindow.jsx): `frontend/src/components/TradeWindow.jsx`

### Trading services

- [Node trading server](https://github.com/sayak2103/trademl/blob/main/main_server/app.js): `main_server/app.js`
- [Flask inference server](https://github.com/sayak2103/trademl/blob/main/flask_Server/app.py): `flask_Server/app.py`

### Reinforcement learning

- [Market data and training](https://github.com/sayak2103/trademl/blob/main/rl_modules/utils.py): `rl_modules/utils.py`
- [DQN policy trainer](https://github.com/sayak2103/trademl/blob/main/rl_modules/my_packages/policy_train.py): `rl_modules/my_packages/policy_train.py`
- [Stock environment](https://github.com/sayak2103/trademl/blob/main/rl_modules/my_packages/environment.py): `rl_modules/my_packages/environment.py`

### Homepage content

- [Home page](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/HomePage.jsx): `frontend/src/components/HomePage.jsx`
- [Navigation](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Features](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/FeaturesSection.jsx): `frontend/src/components/FeaturesSection.jsx`
- [How it works](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/HowItWorksSection.jsx): `frontend/src/components/HowItWorksSection.jsx`
- [Testimonials](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/TestimonialsSection.jsx): `frontend/src/components/TestimonialsSection.jsx`
- [Call to action](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/CallToActionSection.jsx): `frontend/src/components/CallToActionSection.jsx`
- [Footer](https://github.com/sayak2103/trademl/blob/main/frontend/src/components/Footer.jsx): `frontend/src/components/Footer.jsx`

### Other components

- **Investor**
- **Alpaca market data**

## Connections

- Investor → App routes: opens app (evidence: `README.md`)
- App routes → Home page: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Trade arena: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Demo video: routes to (evidence: `frontend/src/App.jsx`)
- Home page → Navigation: renders (evidence: `frontend/src/components/HomePage.jsx`)
- Home page → Features: renders (evidence: `frontend/src/components/HomePage.jsx`)
- Home page → How it works: renders (evidence: `frontend/src/components/HomePage.jsx`)
- Home page → Testimonials: renders (evidence: `frontend/src/components/HomePage.jsx`)
- Home page → Call to action: renders (evidence: `frontend/src/components/HomePage.jsx`)
- Home page → Footer: renders (evidence: `frontend/src/components/HomePage.jsx`)
- Trade arena → Trade parameters: renders (evidence: `frontend/src/components/TradeArena.jsx`)
- Trade arena → Live trade view: renders (evidence: `frontend/src/components/TradeArena.jsx`)
- Live trade view → Node trading server: opens socket (evidence: `frontend/src/components/TradeWindow.jsx`)
- Node trading server → Flask inference server: requests inference
- Market data and training → Alpaca market data: fetches bars (evidence: `rl_modules/utils.py`)
- Market data and training → Stock environment: sets data (evidence: `rl_modules/utils.py`)
- Market data and training → DQN policy trainer: trains policy (evidence: `rl_modules/utils.py`)
- DQN policy trainer → Stock environment: steps environment (evidence: `rl_modules/my_packages/policy_train.py`)
- Flask inference server → DQN policy trainer: serves trained model
