# rootfish-io/discountsforsteam architecture

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

- Interactive diagram: https://gitdiagram.com/rootfish-io/discountsforsteam
- Repository: https://github.com/rootfish-io/discountsforsteam

## Overview

Discounts For Steam presents Steam game deals from a PostgreSQL-backed API. The main user workflow loads paginated games in the React app, fetches them from the FastAPI endpoint, and renders the results. A separate ingestion path fetches deal pages from CheapShark and upserts them into the database; the scheduler invokes that updater, though the backend lifespan currently leaves its scheduler task commented out. The README is empty, so capabilities and links here are limited to the provided tree and source excerpts.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/App.tsx) (Page state), [`backend/database.py`](https://github.com/rootfish-io/discountsforsteam/blob/main/backend/database.py) (Database pool), [`frontend/src/components/GameList.tsx`](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameList.tsx) (Game list), [`backend/main.py`](https://github.com/rootfish-io/discountsforsteam/blob/main/backend/main.py) (FastAPI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_frontend_entry["React entry<br/>[main.tsx]"]
  node_app["Page state<br/>[App.tsx]"]
  node_header["Brand header<br/>[Header.tsx]"]
  node_search["Search controls<br/>[SearchGame.tsx]"]
  node_pagination["Pagination<br/>[Pagination.tsx]"]
  node_skeleton["Loading view<br/>[GameSkeleton.tsx]"]
  node_game_list["Game list<br/>[GameList.tsx]"]
  node_game_item["Deal card<br/>[GameItem.tsx]"]
  node_game_types["Game types<br/>[game.ts]"]
end

subgraph group_api["API service"]
  node_api_service["FastAPI service<br/>[main.py]"]
end

subgraph group_ingest["Deal ingestion"]
  node_scheduler["Update scheduler<br/>[scheduler.py]"]
  node_updater["Deal updater<br/>[update_games.py]"]
end

subgraph group_storage["Data storage"]
  node_db_access["Database pool<br/>[database.py]"]
end

node_visitor(("Visitor"))
node_postgres[("PostgreSQL")]
node_cheapshark["CheapShark API"]

node_visitor -->|"opens app"| node_frontend_entry
node_frontend_entry -->|"renders"| node_app
node_app -->|"renders"| node_header
node_app -->|"renders"| node_search
node_app -->|"renders"| node_pagination
node_app -->|"renders"| node_skeleton
node_app -->|"renders"| node_game_list
node_pagination -->|"calls callback"| node_app
node_game_list -->|"renders"| node_game_item
node_app -->|"uses types"| node_game_types
node_game_list -->|"uses types"| node_game_types
node_game_item -->|"uses types"| node_game_types
node_app -->|"fetches games"| node_api_service
node_api_service -->|"queries pool"| node_db_access
node_api_service -->|"connects and closes"| node_db_access
node_db_access -->|"opens pool"| node_postgres
node_scheduler -->|"runs update"| node_updater
node_updater -->|"fetches deals"| node_cheapshark
node_updater -->|"upserts and prunes"| node_db_access

click node_frontend_entry "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/main.tsx"
click node_app "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/App.tsx"
click node_header "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/Header.tsx"
click node_search "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/SearchGame.tsx"
click node_pagination "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/Pagination.tsx"
click node_skeleton "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameSkeleton.tsx"
click node_game_list "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameList.tsx"
click node_game_item "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameItem.tsx"
click node_game_types "https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/types/game.ts"
click node_api_service "https://github.com/rootfish-io/discountsforsteam/blob/main/backend/main.py"
click node_scheduler "https://github.com/rootfish-io/discountsforsteam/blob/main/backend/tasks/scheduler.py"
click node_updater "https://github.com/rootfish-io/discountsforsteam/blob/main/backend/tasks/update_games.py"
click node_db_access "https://github.com/rootfish-io/discountsforsteam/blob/main/backend/database.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_frontend_entry,node_app,node_header,node_search,node_pagination,node_skeleton,node_game_list,node_game_item,node_game_types toneBlue
class node_api_service,node_postgres toneAmber
class node_scheduler,node_updater,node_cheapshark toneMint
class node_db_access toneRose
class node_visitor toneIndigo
```

## Components

### Web interface

- [React entry](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Page state](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Brand header](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/Header.tsx): `frontend/src/components/Header.tsx`
- [Search controls](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/SearchGame.tsx): `frontend/src/components/SearchGame.tsx`
- [Pagination](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/Pagination.tsx): `frontend/src/components/Pagination.tsx`
- [Loading view](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameSkeleton.tsx): `frontend/src/components/GameSkeleton.tsx`
- [Game list](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameList.tsx): `frontend/src/components/GameList.tsx`
- [Deal card](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/components/GameItem.tsx): `frontend/src/components/GameItem.tsx`
- [Game types](https://github.com/rootfish-io/discountsforsteam/blob/main/frontend/src/types/game.ts): `frontend/src/types/game.ts`

### API service

- [FastAPI service](https://github.com/rootfish-io/discountsforsteam/blob/main/backend/main.py): `backend/main.py`

### Deal ingestion

- [Update scheduler](https://github.com/rootfish-io/discountsforsteam/blob/main/backend/tasks/scheduler.py): `backend/tasks/scheduler.py`
- [Deal updater](https://github.com/rootfish-io/discountsforsteam/blob/main/backend/tasks/update_games.py): `backend/tasks/update_games.py`

### Data storage

- [Database pool](https://github.com/rootfish-io/discountsforsteam/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Visitor**
- **PostgreSQL**
- **CheapShark API**

## Connections

- Visitor → React entry: opens app (evidence: `frontend/src/main.tsx`)
- React entry → Page state: renders (evidence: `frontend/src/main.tsx`)
- Page state → Brand header: renders (evidence: `frontend/src/App.tsx`)
- Page state → Search controls: renders (evidence: `frontend/src/App.tsx`)
- Page state → Pagination: renders (evidence: `frontend/src/App.tsx`)
- Page state → Loading view: renders (evidence: `frontend/src/App.tsx`)
- Page state → Game list: renders (evidence: `frontend/src/App.tsx`)
- Pagination → Page state: calls callback (evidence: `frontend/src/components/Pagination.tsx`)
- Game list → Deal card: renders (evidence: `frontend/src/components/GameList.tsx`)
- Page state → Game types: uses types (evidence: `frontend/src/App.tsx`)
- Game list → Game types: uses types (evidence: `frontend/src/components/GameList.tsx`)
- Deal card → Game types: uses types (evidence: `frontend/src/components/GameItem.tsx`)
- Page state → FastAPI service: fetches games (evidence: `frontend/src/App.tsx`)
- FastAPI service → Database pool: queries pool (evidence: `backend/main.py`)
- FastAPI service → Database pool: connects and closes (evidence: `backend/main.py`)
- Database pool → PostgreSQL: opens pool (evidence: `backend/database.py`)
- Update scheduler → Deal updater: runs update (evidence: `backend/tasks/scheduler.py`)
- Deal updater → CheapShark API: fetches deals (evidence: `backend/tasks/update_games.py`)
- Deal updater → Database pool: upserts and prunes (evidence: `backend/tasks/update_games.py`)
