# llsourcell/ai_in_finance architecture

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

- Interactive diagram: https://gitdiagram.com/llsourcell/ai_in_finance
- Repository: https://github.com/llsourcell/ai_in_finance

## Overview

StockIT is a browser-based stock-trading game: a player starts a round, trades against an AI and the market as stock prices advance, then sees standings. The React App owns round state, trade and score logic, and chart rendering; Flask supplies historical prices and model predictions from Quandl. The README also documents a responsive interface and offline-capable production assets. The frontend request to Flask is not visible in the sampled App.js excerpts, so that link is shown as unverified; the graph otherwise follows explicit imports, calls, and documented behavior.

Main entry points: [`client/src/App.js`](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/App.js) (Game controller), [`client/src/index.js`](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/index.js) (React entry), [`app.py`](https://github.com/llsourcell/ai_in_finance/blob/master/app.py) (Stock data endpoint), [`client/src/registerServiceWorker.js`](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/registerServiceWorker.js) (Worker registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Game interface"]
  node_entry["React entry<br/>[index.js]"]
  node_game["Game controller<br/>[App.js]"]
  node_trade["Buy / sell controls<br/>[Buttons.js]"]
  node_stockview["Portfolio view<br/>[StockData.js]"]
  node_chartcontrols["Timeline slider<br/>[Slider.js]"]
  node_leaderboard["Leaderboard<br/>[Leaderboard.js]"]
  node_podium["Round podium<br/>[Podium.js]"]
end

subgraph group_backend["Market data service"]
  node_api["Stock data endpoint<br/>[app.py]"]
  node_prediction["Price prediction<br/>[app.py]"]
end

subgraph group_offline["Offline support"]
  node_swregistration["Worker registration"]
  node_worker["Service worker<br/>[service-worker.js]"]
end

node_player(("Player"))
node_quandl["Quandl market data"]

node_player -->|"opens game"| node_entry
node_entry -->|"renders"| node_game
node_game -->|"renders"| node_trade
node_game -->|"renders"| node_stockview
node_game -->|"renders"| node_chartcontrols
node_game -->|"renders"| node_leaderboard
node_game -->|"renders"| node_podium
node_player -->|"trades via"| node_trade
node_player -->|"adjusts timeline"| node_chartcontrols
node_game -.->|"requests prices"| node_api
node_api -->|"fetches history"| node_quandl
node_api -->|"prepares model data"| node_prediction
node_entry -->|"registers"| node_swregistration
node_swregistration -->|"registers worker"| node_worker

click node_entry "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/index.js"
click node_game "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/App.js"
click node_trade "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Buttons.js"
click node_stockview "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/StockData.js"
click node_chartcontrols "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Slider.js"
click node_leaderboard "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Leaderboard.js"
click node_podium "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Podium.js"
click node_api "https://github.com/llsourcell/ai_in_finance/blob/master/app.py"
click node_prediction "https://github.com/llsourcell/ai_in_finance/blob/master/app.py"
click node_swregistration "https://github.com/llsourcell/ai_in_finance/blob/master/client/src/registerServiceWorker.js"
click node_worker "https://github.com/llsourcell/ai_in_finance/blob/master/client/build/service-worker.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_entry,node_game,node_trade,node_stockview,node_chartcontrols,node_leaderboard,node_podium toneBlue
class node_api,node_prediction toneAmber
class node_swregistration,node_worker toneMint
class node_player,node_quandl toneIndigo
```

## Components

### Game interface

- [React entry](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/index.js): `client/src/index.js`
- [Game controller](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/App.js): `client/src/App.js`
- [Buy / sell controls](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Buttons.js): `client/src/components/Buttons.js`
- [Portfolio view](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/StockData.js): `client/src/components/StockData.js`
- [Timeline slider](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Slider.js): `client/src/components/Slider.js`
- [Leaderboard](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Leaderboard.js): `client/src/components/Leaderboard.js`
- [Round podium](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/components/Podium.js): `client/src/components/Podium.js`

### Market data service

- [Stock data endpoint](https://github.com/llsourcell/ai_in_finance/blob/master/app.py): `app.py`
- [Price prediction](https://github.com/llsourcell/ai_in_finance/blob/master/app.py): `app.py`

### Offline support

- [Worker registration](https://github.com/llsourcell/ai_in_finance/blob/master/client/src/registerServiceWorker.js): `client/src/registerServiceWorker.js`
- [Service worker](https://github.com/llsourcell/ai_in_finance/blob/master/client/build/service-worker.js): `client/build/service-worker.js`

### Other components

- **Player**
- **Quandl market data**

## Connections

- Player → React entry: opens game (evidence: `README.md`)
- React entry → Game controller: renders (evidence: `client/src/index.js`)
- Game controller → Buy / sell controls: renders (evidence: `client/src/App.js`)
- Game controller → Portfolio view: renders (evidence: `client/src/App.js`)
- Game controller → Timeline slider: renders (evidence: `client/src/App.js`)
- Game controller → Leaderboard: renders (evidence: `client/src/App.js`)
- Game controller → Round podium: renders (evidence: `client/src/App.js`)
- Player → Buy / sell controls: trades via (evidence: `client/src/components/Buttons.js`)
- Player → Timeline slider: adjusts timeline (evidence: `client/src/components/Slider.js`)
- Game controller → Stock data endpoint: requests prices
- Stock data endpoint → Quandl market data: fetches history (evidence: `app.py`)
- Stock data endpoint → Price prediction: prepares model data (evidence: `app.py`)
- React entry → Worker registration: registers (evidence: `client/src/index.js`)
- Worker registration → Service worker: registers worker (evidence: `client/src/registerServiceWorker.js`)
