# davidmbk/steam-trading-cards architecture

> Architecture diagram of the GitHub repository davidmbk/steam-trading-cards, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/davidmbk/steam-trading-cards
- Repository: https://github.com/davidmbk/steam-trading-cards

## Overview

##### Project Type & Purpose
- This is a stand-alone, open-source CLI application written in Python 3.11.
- It queries the Steam Web API for trading-card set prices and user drop-rate statistics, processes and persists data (Excel, PDF), and presents results via the terminal.

##### Core Architectural Components
a. User Interface (CLI)
- main.py: entry point that bootstraps the tool
- source_code/Interface.py: handles prompts, menus, and user input
b. Authentication & Configuration
- source_code/Auth.py: manages Steam API key, optional proxy/VPN settings, rate-limit compliance
c. Data Retrieval (Steam Web API)
- HTTP client (requests library)
- Routes for fetching game lists, card set prices, badge links, and user stats
d. Data Processing & Business Logic
- source_code/User_data.py: computes level-up costs, cooldown formulas, drop rates
- source_code/database_operation.py: transforms raw JSON into tabular data
e. Persistence & Output
- Excel database generation (pandas/openpyxl)
- PDF/pie-chart creation (matplotlib)
- images/ folder for storing static assets or generated charts
f. External Services

##### Relationships & Data Flows
1) User invokes CLI → 2) Interface module → 3) Auth module (validate settings) →
4) Data Retrieval module (Steam API calls) → 5) Business Logic modules (User_data + database_operation) →
6) Persistence (Excel, PDF) → 7) Interface displays summaries and file locations back to user.

##### Architectural Patterns & Design Principles
- Separation of Concerns: UI, Auth, Data Retrieval, Processing, and Persistence are distinct modules.
- Modular/Layered: each layer depends only on the one below it.

##### Relevant Technologies & Libraries
- Python 3.11
- requests (HTTP client)
- pandas, openpyxl (Excel)
- matplotlib (PDF charts)
- rate-limiting via time.sleep or third-party library (as needed)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "User Interface (CLI)" 
        direction TB
        Main["Main.py - Entry Point"]:::ui
        Interface["Interface.py - CLI Prompts & Menus"]:::ui
    end

    %% Authentication & Configuration
    subgraph "Authentication & Configuration"
        direction TB
        Auth["Auth.py - API Key & Rate-limit Compliance"]:::auth
    end

    %% Data Retrieval Layer
    subgraph "Data Retrieval (Steam Web API)"
        direction TB
        Retrieval["HTTP Client & API Routes"]:::retrieval
    end

    %% Business Logic Layer
    subgraph "Data Processing & Business Logic"
        direction TB
        UserData["User_data.py - Compute Level-up Costs & Drop Rates"]:::business
        DatabaseOp["database_operation.py - Transform & Persist Data"]:::business
    end

    %% Persistence & Output
    subgraph "Persistence & Output"
        direction TB
        Excel[(Excel Workbook Generation)]:::io
        PDF["PDF & Chart Creation"]:::io
        Images["images/"]:::io
    end

    %% External Services
    subgraph "External Services"
        direction TB
        API["Steam Web API"]:::external
    end

    %% Configuration & Docs
    subgraph "Project Configuration & Dependencies"
        direction TB
        Requirements["requirements.txt"]:::config
        License["LICENSE"]:::config
        Readme["README.md"]:::config
    end

    %% Data Flow Arrows
    Main -->|"start CLI"| Interface
    Interface -->|"validate settings"| Auth
    Auth -->|"perform API calls"| Retrieval
    Retrieval -->|"raw JSON response"| UserData
    UserData -->|"computed stats"| DatabaseOp
    DatabaseOp -->|"Excel file path"| Excel
    DatabaseOp -->|"PDF file path & charts"| PDF
    DatabaseOp -->|"store charts"| Images
    Excel -->|"report location"| Interface
    PDF -->|"report location"| Interface

    %% External interaction
    Retrieval -->|"HTTP requests"| API

    %% Click Events
    click Main "https://github.com/davidmbk/steam-trading-cards/blob/main/Main.py"
    click Interface "https://github.com/davidmbk/steam-trading-cards/blob/main/source_code/Interface.py"
    click Auth "https://github.com/davidmbk/steam-trading-cards/blob/main/source_code/Auth.py"
    click UserData "https://github.com/davidmbk/steam-trading-cards/blob/main/source_code/User_data.py"
    click DatabaseOp "https://github.com/davidmbk/steam-trading-cards/blob/main/source_code/database_operation.py"
    click Images "https://github.com/davidmbk/steam-trading-cards/tree/main/images/"
    click Requirements "https://github.com/davidmbk/steam-trading-cards/blob/main/requirements.txt"
    click License "https://github.com/davidmbk/steam-trading-cards/tree/main/LICENSE"
    click Readme "https://github.com/davidmbk/steam-trading-cards/blob/main/README.md"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#0366d6,color:#0366d6
    classDef auth fill:#fff3cd,stroke:#856404,color:#856404
    classDef retrieval fill:#d1ecf1,stroke:#0c5460,color:#0c5460
    classDef business fill:#d4edda,stroke:#155724,color:#155724
    classDef io fill:#ffe5b4,stroke:#c77500,color:#c77500
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
