# tejaslad111009/tradingapp architecture

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

- Interactive diagram: https://gitdiagram.com/tejaslad111009/tradingapp
- Repository: https://github.com/tejaslad111009/tradingapp

## Overview

This is a Streamlit stock-trading app. Users register or log in, manage wallet funds, browse stock data, trade shares, and review portfolio performance. The main runtime entry point initializes the app and routes pages; views call controllers, which apply trading rules and use models and stock-data services. Models manage user, wallet, and portfolio state in local JSON files, as documented in the README. The graph preserves documented dashboard, charting, history, and diagnostics capabilities; several page-routing details and unsampled implementations are supported only by README or index references.

Main entry points: [`controllers/trading_controller.py`](https://github.com/tejaslad111009/tradingapp/blob/main/controllers/trading_controller.py) (Trading Controllers), [`main.py`](https://github.com/tejaslad111009/tradingapp/blob/main/main.py) (Streamlit App), [`utils/stock_api.py`](https://github.com/tejaslad111009/tradingapp/blob/main/utils/stock_api.py) (Stock Data Service), [`views/auth_view.py`](https://github.com/tejaslad111009/tradingapp/blob/main/views/auth_view.py) (Authentication UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Views"]
  node_main["Streamlit App<br/>[main.py]"]
  node_auth["Authentication UI<br/>[auth_view.py]"]
  node_walletui["Wallet UI<br/>[wallet_view.py]"]
  node_tradingui["Trading UI<br/>[trading_view.py]"]
  node_dashboard["Dashboard<br/>[dashboard_view.py]"]
end

subgraph group_business["Trading Logic"]
  node_controller["Trading Controllers"]
end

subgraph group_domain["Domain Models"]
  node_users[("User Accounts<br/>[user.py]")]
  node_wallet[("Wallet and Transactions<br/>[wallet.py]")]
  node_portfolio[("Portfolio Holdings<br/>[portfolio.py]")]
end

subgraph group_market["Market Data"]
  node_stockapi["Stock Data Service<br/>[stock_api.py]"]
  node_client["Alpha Vantage Client<br/>[api_client.py]"]
end

subgraph group_operations["Diagnostics and Config"]
  node_diagnostics["API Diagnostics<br/>[diagnostics.py]"]
  node_settings["App Settings<br/>[settings.py]"]
end

node_user(("Trader"))
node_yfinance["YFinance"]
node_exchange["Exchange Rate API"]

node_user -->|"uses"| node_main
node_main -->|"routes to"| node_auth
node_main -->|"routes to"| node_walletui
node_main -->|"routes to"| node_tradingui
node_main -->|"shows"| node_dashboard
node_auth -->|"invokes"| node_controller
node_walletui -->|"invokes"| node_controller
node_tradingui -->|"invokes"| node_controller
node_main -->|"requests portfolio"| node_controller
node_controller -->|"manages accounts"| node_users
node_controller -->|"updates funds"| node_wallet
node_controller -->|"updates holdings"| node_portfolio
node_controller -->|"gets prices"| node_stockapi
node_dashboard -->|"reads holdings"| node_portfolio
node_stockapi -->|"fetches prices"| node_client
node_stockapi -->|"gets rates"| node_exchange
node_stockapi -.->|"uses fallback"| node_yfinance
node_main -->|"runs checks"| node_diagnostics
node_diagnostics -->|"checks API"| node_client
node_controller -.->|"uses defaults"| node_settings

click node_main "https://github.com/tejaslad111009/tradingapp/blob/main/main.py"
click node_auth "https://github.com/tejaslad111009/tradingapp/blob/main/views/auth_view.py"
click node_walletui "https://github.com/tejaslad111009/tradingapp/blob/main/views/wallet_view.py"
click node_tradingui "https://github.com/tejaslad111009/tradingapp/blob/main/views/trading_view.py"
click node_dashboard "https://github.com/tejaslad111009/tradingapp/blob/main/views/dashboard_view.py"
click node_controller "https://github.com/tejaslad111009/tradingapp/blob/main/controllers/trading_controller.py"
click node_users "https://github.com/tejaslad111009/tradingapp/blob/main/models/user.py"
click node_wallet "https://github.com/tejaslad111009/tradingapp/blob/main/models/wallet.py"
click node_portfolio "https://github.com/tejaslad111009/tradingapp/blob/main/models/portfolio.py"
click node_stockapi "https://github.com/tejaslad111009/tradingapp/blob/main/utils/stock_api.py"
click node_client "https://github.com/tejaslad111009/tradingapp/blob/main/utils/api_client.py"
click node_diagnostics "https://github.com/tejaslad111009/tradingapp/blob/main/utils/diagnostics.py"
click node_settings "https://github.com/tejaslad111009/tradingapp/blob/main/config/settings.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_main,node_auth,node_walletui,node_tradingui,node_dashboard toneBlue
class node_controller toneAmber
class node_users,node_wallet,node_portfolio,node_exchange toneMint
class node_stockapi,node_client toneRose
class node_diagnostics,node_settings,node_user,node_yfinance toneIndigo
```

## Components

### App and Views

- [Streamlit App](https://github.com/tejaslad111009/tradingapp/blob/main/main.py): `main.py`
- [Authentication UI](https://github.com/tejaslad111009/tradingapp/blob/main/views/auth_view.py): `views/auth_view.py`
- [Wallet UI](https://github.com/tejaslad111009/tradingapp/blob/main/views/wallet_view.py): `views/wallet_view.py`
- [Trading UI](https://github.com/tejaslad111009/tradingapp/blob/main/views/trading_view.py): `views/trading_view.py`
- [Dashboard](https://github.com/tejaslad111009/tradingapp/blob/main/views/dashboard_view.py): `views/dashboard_view.py`

### Trading Logic

- [Trading Controllers](https://github.com/tejaslad111009/tradingapp/blob/main/controllers/trading_controller.py): `controllers/trading_controller.py`

### Domain Models

- [User Accounts](https://github.com/tejaslad111009/tradingapp/blob/main/models/user.py): `models/user.py`
- [Wallet and Transactions](https://github.com/tejaslad111009/tradingapp/blob/main/models/wallet.py): `models/wallet.py`
- [Portfolio Holdings](https://github.com/tejaslad111009/tradingapp/blob/main/models/portfolio.py): `models/portfolio.py`

### Market Data

- [Stock Data Service](https://github.com/tejaslad111009/tradingapp/blob/main/utils/stock_api.py): `utils/stock_api.py`
- [Alpha Vantage Client](https://github.com/tejaslad111009/tradingapp/blob/main/utils/api_client.py): `utils/api_client.py`

### Diagnostics and Config

- [API Diagnostics](https://github.com/tejaslad111009/tradingapp/blob/main/utils/diagnostics.py): `utils/diagnostics.py`
- [App Settings](https://github.com/tejaslad111009/tradingapp/blob/main/config/settings.py): `config/settings.py`

### Other components

- **Trader**
- **YFinance**
- **Exchange Rate API**

## Connections

- Trader → Streamlit App: uses (evidence: `README.md`)
- Streamlit App → Authentication UI: routes to (evidence: `README.md`)
- Streamlit App → Wallet UI: routes to (evidence: `README.md`)
- Streamlit App → Trading UI: routes to (evidence: `main.py`)
- Streamlit App → Dashboard: shows (evidence: `README.md`)
- Authentication UI → Trading Controllers: invokes (evidence: `views/auth_view.py`)
- Wallet UI → Trading Controllers: invokes (evidence: `views/wallet_view.py`)
- Trading UI → Trading Controllers: invokes (evidence: `views/trading_view.py`)
- Streamlit App → Trading Controllers: requests portfolio (evidence: `main.py`)
- Trading Controllers → User Accounts: manages accounts (evidence: `controllers/trading_controller.py`)
- Trading Controllers → Wallet and Transactions: updates funds (evidence: `controllers/trading_controller.py`)
- Trading Controllers → Portfolio Holdings: updates holdings (evidence: `controllers/trading_controller.py`)
- Trading Controllers → Stock Data Service: gets prices (evidence: `controllers/trading_controller.py`)
- Dashboard → Portfolio Holdings: reads holdings (evidence: `views/dashboard_view.py`)
- Stock Data Service → Alpha Vantage Client: fetches prices (evidence: `utils/stock_api.py`)
- Stock Data Service → Exchange Rate API: gets rates (evidence: `utils/stock_api.py`)
- Stock Data Service → YFinance: uses fallback
- Streamlit App → API Diagnostics: runs checks (evidence: `main.py`)
- API Diagnostics → Alpha Vantage Client: checks API (evidence: `utils/diagnostics.py`)
- Trading Controllers → App Settings: uses defaults
