# tds2k5/tradelab architecture

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

- Interactive diagram: https://gitdiagram.com/tds2k5/tradelab
- Repository: https://github.com/tds2k5/tradelab

## Overview

TradeLab is a Flask stock-trading simulator: users register or sign in, inspect quotes and portfolio value, then buy or sell shares and review transaction/history views. Flask routes in app.py own these workflows and persist account and portfolio changes through db.py; helpers.py supplies cached quote, search, and historical-market data. The source excerpts confirm these relationships, but the README is empty and much of app.py is unsampled, so uncertain route-to-template and ancillary feature links are omitted.

Main entry points: [`app.py`](https://github.com/tds2k5/tradelab/blob/main/app.py) (Flask workflows), [`db.py`](https://github.com/tds2k5/tradelab/blob/main/db.py) (SQL access), [`helpers.py`](https://github.com/tds2k5/tradelab/blob/main/helpers.py) (Stock search), [`finance.db`](https://github.com/tds2k5/tradelab/blob/main/finance.db) (SQLite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workflows"]
  node_routes["Flask workflows<br/>[app.py]"]
  node_accounts["Account access<br/>[app.py]"]
  node_trading["Buy and sell<br/>[app.py]"]
  node_portfolio["Portfolio view<br/>[app.py]"]
  node_history["Price history<br/>[app.py]"]
end

subgraph group_market["Market data"]
  node_search["Stock search<br/>[helpers.py]"]
  node_quotes["Quote lookup<br/>[helpers.py]"]
  node_market_history["Historical prices<br/>[helpers.py]"]
  node_gainers["Market movers<br/>[helpers.py]"]
end

subgraph group_storage["Persistence"]
  node_sql["SQL access<br/>[db.py]"]
  node_database[("SQLite database<br/>[finance.db]")]
end

subgraph group_client["Browser UI"]
  node_interactions["UI interactions<br/>[interactions.js]"]
end

node_visitor(("Investor"))
node_yfinance{{"Yahoo Finance"}}
node_browser(("Web browser"))

node_visitor -->|"uses"| node_routes
node_routes -->|"handles auth"| node_accounts
node_routes -->|"routes trades"| node_trading
node_routes -->|"renders portfolio"| node_portfolio
node_routes -->|"serves history"| node_history
node_routes -->|"queries"| node_sql
node_trading -->|"updates holdings"| node_sql
node_portfolio -->|"reads holdings"| node_sql
node_accounts -->|"checks users"| node_sql
node_routes -->|"looks up quotes"| node_quotes
node_routes -->|"searches stocks"| node_search
node_history -->|"loads prices"| node_market_history
node_portfolio -.->|"shows movers"| node_gainers
node_quotes -->|"fetches quote"| node_yfinance
node_search -->|"searches listings"| node_yfinance
node_market_history -->|"fetches prices"| node_yfinance
node_gainers -->|"downloads prices"| node_yfinance
node_sql -->|"reads and writes"| node_database
node_browser -.->|"runs scripts"| node_interactions

click node_routes "https://github.com/tds2k5/tradelab/blob/main/app.py"
click node_accounts "https://github.com/tds2k5/tradelab/blob/main/app.py"
click node_trading "https://github.com/tds2k5/tradelab/blob/main/app.py"
click node_portfolio "https://github.com/tds2k5/tradelab/blob/main/app.py"
click node_history "https://github.com/tds2k5/tradelab/blob/main/app.py"
click node_search "https://github.com/tds2k5/tradelab/blob/main/helpers.py"
click node_quotes "https://github.com/tds2k5/tradelab/blob/main/helpers.py"
click node_market_history "https://github.com/tds2k5/tradelab/blob/main/helpers.py"
click node_gainers "https://github.com/tds2k5/tradelab/blob/main/helpers.py"
click node_sql "https://github.com/tds2k5/tradelab/blob/main/db.py"
click node_database "https://github.com/tds2k5/tradelab/blob/main/finance.db"
click node_interactions "https://github.com/tds2k5/tradelab/blob/main/static/interactions.js"

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_routes,node_accounts,node_trading,node_portfolio,node_history,node_browser toneBlue
class node_search,node_quotes,node_market_history,node_gainers toneAmber
class node_sql,node_database toneMint
class node_interactions toneRose
class node_visitor,node_yfinance toneIndigo
```

## Components

### Web workflows

- [Flask workflows](https://github.com/tds2k5/tradelab/blob/main/app.py): `app.py`
- [Account access](https://github.com/tds2k5/tradelab/blob/main/app.py): `app.py`
- [Buy and sell](https://github.com/tds2k5/tradelab/blob/main/app.py): `app.py`
- [Portfolio view](https://github.com/tds2k5/tradelab/blob/main/app.py): `app.py`
- [Price history](https://github.com/tds2k5/tradelab/blob/main/app.py): `app.py`

### Market data

- [Stock search](https://github.com/tds2k5/tradelab/blob/main/helpers.py): `helpers.py`
- [Quote lookup](https://github.com/tds2k5/tradelab/blob/main/helpers.py): `helpers.py`
- [Historical prices](https://github.com/tds2k5/tradelab/blob/main/helpers.py): `helpers.py`
- [Market movers](https://github.com/tds2k5/tradelab/blob/main/helpers.py): `helpers.py`

### Persistence

- [SQL access](https://github.com/tds2k5/tradelab/blob/main/db.py): `db.py`
- [SQLite database](https://github.com/tds2k5/tradelab/blob/main/finance.db): `finance.db`

### Browser UI

- [UI interactions](https://github.com/tds2k5/tradelab/blob/main/static/interactions.js): `static/interactions.js`

### Other components

- **Investor**
- **Yahoo Finance**
- **Web browser**

## Connections

- Investor → Flask workflows: uses (evidence: `app.py`)
- Flask workflows → Account access: handles auth (evidence: `app.py`)
- Flask workflows → Buy and sell: routes trades (evidence: `app.py`)
- Flask workflows → Portfolio view: renders portfolio (evidence: `app.py`)
- Flask workflows → Price history: serves history (evidence: `app.py`)
- Flask workflows → SQL access: queries (evidence: `app.py`)
- Buy and sell → SQL access: updates holdings (evidence: `app.py`)
- Portfolio view → SQL access: reads holdings (evidence: `app.py`)
- Account access → SQL access: checks users (evidence: `app.py`)
- Flask workflows → Quote lookup: looks up quotes (evidence: `app.py`)
- Flask workflows → Stock search: searches stocks (evidence: `app.py`)
- Price history → Historical prices: loads prices (evidence: `app.py`)
- Portfolio view → Market movers: shows movers (evidence: `app.py`)
- Quote lookup → Yahoo Finance: fetches quote (evidence: `helpers.py`)
- Stock search → Yahoo Finance: searches listings (evidence: `helpers.py`)
- Historical prices → Yahoo Finance: fetches prices (evidence: `helpers.py`)
- Market movers → Yahoo Finance: downloads prices (evidence: `helpers.py`)
- SQL access → SQLite database: reads and writes (evidence: `db.py`)
- Web browser → UI interactions: runs scripts
