# adarshp521/torofolio architecture

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

- Interactive diagram: https://gitdiagram.com/adarshp521/torofolio
- Repository: https://github.com/adarshp521/torofolio

## Overview

ToroFolio is a browser-based trading terminal backed by a Flask service. The main user flow is authentication, selecting/searching a ticker, viewing market data and analysis, then recording trades and syncing account state. The README also documents watchlists, holdings, AI rules, profile assets, and CSV auditing. Several product details are documented but their implementation is unsampled; those relationships are cited to the README rather than inferred from filenames.

Main entry points: [`server.py`](https://github.com/adarshp521/torofolio/blob/main/server.py) (HTTP API), [`app.js`](https://github.com/adarshp521/torofolio/blob/main/app.js) (Client Orchestrator), [`index.html`](https://github.com/adarshp521/torofolio/blob/main/index.html) (Trading Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Trading Client"]
  node_ui["Trading Interface<br/>[index.html]"]
  node_client_app["Client Orchestrator<br/>[app.js]"]
  node_auth["Authentication<br/>[app.js]"]
  node_client_state[("Client State<br/>[app.js]")]
  node_watchlist["Watchlist &amp; Search<br/>[app.js]"]
  node_execution["Trade Execution<br/>[app.js]"]
end

subgraph group_analysis["Market Analysis"]
  node_chart["Chart &amp; Timeframes<br/>[app.js]"]
  node_fundamentals["Stock Fundamentals<br/>[app.js]"]
  node_advisor["Trade Advisor<br/>[app.js]"]
end

subgraph group_backend["Backend Service"]
  node_api["HTTP API<br/>[server.py]"]
  node_auth_api["Account API<br/>[server.py]"]
  node_market_api["Market Data API<br/>[server.py]"]
  node_ai_rules["AI Rules &amp; Logs<br/>[server.py]"]
  node_profile["Profile &amp; Avatar<br/>[server.py]"]
end

subgraph group_persistence["Persistence"]
  node_database[("SQLite Database<br/>[server.py]")]
  node_audit["CSV Audit Log<br/>[server.py]"]
end

node_user(("Trader"))
node_external_market{{"Yahoo Finance"}}
node_finnhub{{"Finnhub"}}
node_cloud_auth{{"Firebase / OAuth"}}

node_user -->|"uses"| node_ui
node_ui -->|"renders"| node_client_app
node_client_app -->|"checks session"| node_auth
node_client_app -->|"loads and saves"| node_client_state
node_client_app -->|"handles search"| node_watchlist
node_watchlist -->|"requests search"| node_api
node_client_app -->|"selects ticker"| node_chart
node_chart -->|"requests market data"| node_api
node_api -->|"routes requests"| node_market_api
node_market_api -->|"fetches quotes and history"| node_external_market
node_market_api -.->|"supports live data"| node_finnhub
node_chart -->|"shows metrics"| node_fundamentals
node_fundamentals -->|"requests fundamentals"| node_api
node_advisor -->|"informs trades"| node_execution
node_client_app -->|"records trades"| node_execution
node_execution -->|"syncs account state"| node_api
node_api -->|"routes account actions"| node_auth_api
node_auth_api -->|"reads and writes users"| node_database
node_api -->|"routes rule actions"| node_ai_rules
node_ai_rules -->|"stores rules and logs"| node_database
node_api -->|"routes profile updates"| node_profile
node_profile -->|"stores profile data"| node_database
node_profile -.->|"logs profile updates"| node_audit
node_auth -.->|"supports SSO"| node_cloud_auth
node_client_state -->|"syncs state"| node_database

click node_ui "https://github.com/adarshp521/torofolio/blob/main/index.html"
click node_client_app "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_auth "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_client_state "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_watchlist "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_chart "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_fundamentals "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_advisor "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_execution "https://github.com/adarshp521/torofolio/blob/main/app.js"
click node_api "https://github.com/adarshp521/torofolio/blob/main/server.py"
click node_auth_api "https://github.com/adarshp521/torofolio/blob/main/server.py"
click node_market_api "https://github.com/adarshp521/torofolio/blob/main/server.py"
click node_ai_rules "https://github.com/adarshp521/torofolio/blob/main/server.py"
click node_profile "https://github.com/adarshp521/torofolio/blob/main/server.py"
click node_database "https://github.com/adarshp521/torofolio/blob/main/server.py"
click node_audit "https://github.com/adarshp521/torofolio/blob/main/server.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_ui,node_client_app,node_auth,node_client_state,node_watchlist,node_execution toneBlue
class node_chart,node_fundamentals,node_advisor toneAmber
class node_api,node_auth_api,node_market_api,node_ai_rules,node_profile toneMint
class node_database,node_audit toneRose
class node_user,node_external_market,node_finnhub,node_cloud_auth toneIndigo
```

## Components

### Trading Client

- [Trading Interface](https://github.com/adarshp521/torofolio/blob/main/index.html): `index.html`
- [Client Orchestrator](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`
- [Authentication](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`
- [Client State](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`
- [Watchlist & Search](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`
- [Trade Execution](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`

### Market Analysis

- [Chart & Timeframes](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`
- [Stock Fundamentals](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`
- [Trade Advisor](https://github.com/adarshp521/torofolio/blob/main/app.js): `app.js`

### Backend Service

- [HTTP API](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`
- [Account API](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`
- [Market Data API](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`
- [AI Rules & Logs](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`
- [Profile & Avatar](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`

### Persistence

- [SQLite Database](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`
- [CSV Audit Log](https://github.com/adarshp521/torofolio/blob/main/server.py): `server.py`

### Other components

- **Trader**
- **Yahoo Finance**
- **Finnhub**
- **Firebase / OAuth**

## Connections

- Trader → Trading Interface: uses (evidence: `README.md`)
- Trading Interface → Client Orchestrator: renders (evidence: `README.md`)
- Client Orchestrator → Authentication: checks session (evidence: `README.md`)
- Client Orchestrator → Client State: loads and saves (evidence: `README.md`)
- Client Orchestrator → Watchlist & Search: handles search (evidence: `app.js`)
- Watchlist & Search → HTTP API: requests search (evidence: `app.js`)
- Client Orchestrator → Chart & Timeframes: selects ticker (evidence: `README.md`)
- Chart & Timeframes → HTTP API: requests market data (evidence: `README.md`)
- HTTP API → Market Data API: routes requests (evidence: `server.py`)
- Market Data API → Yahoo Finance: fetches quotes and history (evidence: `server.py`)
- Market Data API → Finnhub: supports live data (evidence: `README.md`)
- Chart & Timeframes → Stock Fundamentals: shows metrics (evidence: `README.md`)
- Stock Fundamentals → HTTP API: requests fundamentals (evidence: `README.md`)
- Trade Advisor → Trade Execution: informs trades (evidence: `README.md`)
- Client Orchestrator → Trade Execution: records trades (evidence: `app.js`)
- Trade Execution → HTTP API: syncs account state (evidence: `README.md`)
- HTTP API → Account API: routes account actions (evidence: `server.py`)
- Account API → SQLite Database: reads and writes users (evidence: `server.py`)
- HTTP API → AI Rules & Logs: routes rule actions (evidence: `server.py`)
- AI Rules & Logs → SQLite Database: stores rules and logs (evidence: `server.py`)
- HTTP API → Profile & Avatar: routes profile updates (evidence: `server.py`)
- Profile & Avatar → SQLite Database: stores profile data (evidence: `server.py`)
- Profile & Avatar → CSV Audit Log: logs profile updates (evidence: `README.md`)
- Authentication → Firebase / OAuth: supports SSO (evidence: `README.md`)
- Client State → SQLite Database: syncs state (evidence: `README.md`)
