# igorkoeppe/projeto_plataforma_financeira architecture

> Architecture diagram of the GitHub repository igorkoeppe/projeto_plataforma_financeira, 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/igorkoeppe/projeto_plataforma_financeira
- Repository: https://github.com/igorkoeppe/projeto_plataforma_financeira

## Overview

Market Replay is an educational finance platform with two linked experiences: historical prediction gameplay earns virtual capital, which users can then invest in a paper-trading portfolio; a news hub and topic finder complement both. The FastAPI app serves the browser client, routes API workflows, and initializes SQLite and background news caching. Edges follow excerpted calls, SOURCE INDEX references, or README-documented behavior; unsampled implementation details are not inferred.

Main entry points: [`app/main.py`](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/main.py) (API Application), [`app/db.py`](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/db.py) (SQLite Store), [`app/session.py`](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/session.py) (Anonymous Sessions), [`app/routers/events.py`](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/events.py) (Replay Events)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Sessions"]
  node_browser["Web Client<br/>[app.js]"]
  node_api["API Application<br/>[main.py]"]
  node_sessions["Anonymous Sessions<br/>[session.py]"]
  node_contracts["API Schemas<br/>[schemas.py]"]
end

subgraph group_replay["Historical Replay"]
  node_events["Replay Events<br/>[events.py]"]
  node_game["Rewards and Progress<br/>[game_logic.py]"]
  node_stats["Player Statistics<br/>[stats.py]"]
  node_eventdata["Historical Event Archive<br/>[seed_data.py]"]
end

subgraph group_trading["Paper Trading"]
  node_trade["Trade Orders and Portfolio<br/>[trade.py]"]
  node_pricing["Live Pricing<br/>[pricing.py]"]
  node_market["Market Quotes and History<br/>[market.py]"]
end

subgraph group_news["News and Discovery"]
  node_newsapi["News Hub<br/>[news.py]"]
  node_newsworker["News Cache Worker"]
  node_analogs["News Topic Finder<br/>[analogs.py]"]
  node_similarity["Similarity Search<br/>[similarity.py]"]
  node_embeddings["Event Embeddings<br/>[embeddings_data.py]"]
end

subgraph group_storage["Persistence and Data"]
  node_sqlite[("SQLite Store<br/>[db.py]")]
end

node_player(("Learner"))
node_yahoo["Yahoo Finance"]

node_player -->|"uses"| node_browser
node_browser -->|"requests"| node_api
node_api -->|"serves"| node_browser
node_api -->|"resolves sessions"| node_sessions
node_api -->|"initializes"| node_sqlite
node_api -->|"seeds events"| node_eventdata
node_api -->|"mounts router"| node_events
node_api -->|"mounts router"| node_stats
node_api -->|"mounts router"| node_trade
node_api -->|"mounts router"| node_newsapi
node_api -->|"mounts router"| node_analogs
node_api -->|"mounts router"| node_market
node_api -->|"starts worker"| node_newsworker
node_events -->|"reads and writes"| node_sqlite
node_events -->|"computes rewards"| node_game
node_events -->|"gets player ID"| node_sessions
node_stats -->|"reads stats"| node_sqlite
node_stats -->|"gets player ID"| node_sessions
node_eventdata -->|"seeds archive"| node_sqlite
node_eventdata -->|"uses vectors"| node_embeddings
node_trade -->|"updates holdings"| node_sqlite
node_trade -->|"gets player ID"| node_sessions
node_trade -->|"gets live price"| node_pricing
node_pricing -.->|"fetches prices"| node_yahoo
node_market -.->|"gets market data"| node_yahoo
node_newsworker -->|"fetches headlines"| node_yahoo
node_newsworker -->|"caches articles"| node_sqlite
node_newsapi -->|"reads news"| node_sqlite
node_newsapi -->|"gets player ID"| node_sessions
node_analogs -->|"loads news"| node_sqlite
node_analogs -->|"ranks matches"| node_similarity

click node_browser "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/frontend/app.js"
click node_api "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/main.py"
click node_sessions "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/session.py"
click node_contracts "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/schemas.py"
click node_events "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/events.py"
click node_game "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/game_logic.py"
click node_stats "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/stats.py"
click node_eventdata "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/seed_data.py"
click node_trade "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/trade.py"
click node_pricing "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/pricing.py"
click node_market "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/market.py"
click node_newsapi "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/news.py"
click node_newsworker "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/background_tasks.py"
click node_analogs "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/analogs.py"
click node_similarity "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/similarity.py"
click node_embeddings "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/embeddings_data.py"
click node_sqlite "https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/db.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_browser,node_api,node_sessions,node_contracts toneBlue
class node_events,node_game,node_stats,node_eventdata toneAmber
class node_trade,node_pricing,node_market toneMint
class node_newsapi,node_newsworker,node_analogs,node_similarity,node_embeddings toneRose
class node_sqlite,node_player,node_yahoo toneIndigo
```

## Components

### App and Sessions

- [Web Client](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/frontend/app.js): `frontend/app.js`
- [API Application](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/main.py): `app/main.py`
- [Anonymous Sessions](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/session.py): `app/session.py`
- [API Schemas](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/schemas.py): `app/schemas.py`

### Historical Replay

- [Replay Events](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/events.py): `app/routers/events.py`
- [Rewards and Progress](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/game_logic.py): `app/services/game_logic.py`
- [Player Statistics](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/stats.py): `app/routers/stats.py`
- [Historical Event Archive](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/seed_data.py): `app/seed_data.py`

### Paper Trading

- [Trade Orders and Portfolio](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/trade.py): `app/routers/trade.py`
- [Live Pricing](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/pricing.py): `app/services/pricing.py`
- [Market Quotes and History](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/market.py): `app/routers/market.py`

### News and Discovery

- [News Hub](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/news.py): `app/routers/news.py`
- [News Cache Worker](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/background_tasks.py): `app/services/background_tasks.py`
- [News Topic Finder](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/routers/analogs.py): `app/routers/analogs.py`
- [Similarity Search](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/services/similarity.py): `app/services/similarity.py`
- [Event Embeddings](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/embeddings_data.py): `app/embeddings_data.py`

### Persistence and Data

- [SQLite Store](https://github.com/igorkoeppe/projeto_plataforma_financeira/blob/main/app/db.py): `app/db.py`

### Other components

- **Learner**
- **Yahoo Finance**

## Connections

- Learner → Web Client: uses (evidence: `README.md`)
- Web Client → API Application: requests (evidence: `README.md`)
- API Application → Web Client: serves (evidence: `app/main.py`)
- API Application → Anonymous Sessions: resolves sessions (evidence: `app/main.py`)
- API Application → SQLite Store: initializes (evidence: `app/main.py`)
- API Application → Historical Event Archive: seeds events (evidence: `app/main.py`)
- API Application → Replay Events: mounts router (evidence: `app/main.py`)
- API Application → Player Statistics: mounts router (evidence: `app/main.py`)
- API Application → Trade Orders and Portfolio: mounts router (evidence: `app/main.py`)
- API Application → News Hub: mounts router (evidence: `app/main.py`)
- API Application → News Topic Finder: mounts router (evidence: `app/main.py`)
- API Application → Market Quotes and History: mounts router (evidence: `app/main.py`)
- API Application → News Cache Worker: starts worker (evidence: `app/main.py`)
- Replay Events → SQLite Store: reads and writes (evidence: `app/routers/events.py`)
- Replay Events → Rewards and Progress: computes rewards (evidence: `app/routers/events.py`)
- Replay Events → Anonymous Sessions: gets player ID (evidence: `app/routers/events.py`)
- Player Statistics → SQLite Store: reads stats (evidence: `app/routers/stats.py`)
- Player Statistics → Anonymous Sessions: gets player ID (evidence: `app/routers/stats.py`)
- Historical Event Archive → SQLite Store: seeds archive (evidence: `app/seed_data.py`)
- Historical Event Archive → Event Embeddings: uses vectors (evidence: `app/seed_data.py`)
- Trade Orders and Portfolio → SQLite Store: updates holdings (evidence: `app/routers/trade.py`)
- Trade Orders and Portfolio → Anonymous Sessions: gets player ID (evidence: `app/routers/trade.py`)
- Trade Orders and Portfolio → Live Pricing: gets live price (evidence: `app/routers/trade.py`)
- Live Pricing → Yahoo Finance: fetches prices (evidence: `README.md`)
- Market Quotes and History → Yahoo Finance: gets market data (evidence: `README.md`)
- News Cache Worker → Yahoo Finance: fetches headlines (evidence: `app/services/background_tasks.py`)
- News Cache Worker → SQLite Store: caches articles (evidence: `app/services/background_tasks.py`)
- News Hub → SQLite Store: reads news (evidence: `app/routers/news.py`)
- News Hub → Anonymous Sessions: gets player ID (evidence: `app/routers/news.py`)
- News Topic Finder → SQLite Store: loads news (evidence: `app/routers/analogs.py`)
- News Topic Finder → Similarity Search: ranks matches (evidence: `app/routers/analogs.py`)
