# dreamblader/master_duel_pack_scorer architecture

> Architecture diagram of the GitHub repository dreamblader/master_duel_pack_scorer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dreamblader/master_duel_pack_scorer
- Repository: https://github.com/dreamblader/master_duel_pack_scorer

## Overview

##### Main Components
- Entry Point: The __main__.py file acts as the main orchestrator, invoking the various modules.
- Data Layers:
- Input Data: The data folder (containing CSV files for Master Duel progression data) and the cards.db file (which might be used to persist or cross-reference card information).
- Data Acquisition and Processing:
- Scrapper (scrapper.py): Likely responsible for web scraping to obtain additional card pack or pricing information.
- Fetcher (fetcher.py): Potentially works in tandem with the scrapper to retrieve fresh data from external sources.
- Parser (parser.py): Processes raw data (from fetching, scraping, or CSV inputs) and converts this into a structured format.
- Domain Modeling:
- Models directory: Contains modules like card_data.py, enums.py, secret_banner_data.py, and secret_pack_data.py. These represent the core data structures and business logic (e.g., definitions, constants, and domain-specific entities).
- Output and Reporting:
- Writer (writer.py): Likely compiles the processed data and outputs results or scores.
- Utility Functions:
- Utils (utils.py) and web_elements.py: Provide support functions that simplify operations across various modules.

##### Relationships and Data Flow
- The process would typically start in __main__.py, which orchestrates the entire pipeline.
- Data from CSV files and the database (cards.db) form the base input layer.
- The scrapper and fetcher modules gather additional data from external sources, if needed.
- The parser module takes raw inputs (from both CSV/external sources) and uses the domain models to transform them into structured data.
- Once structured, the writer module produces the final report or scoring output based on this data.
- Utility functions are called as needed by each component to handle common tasks.

##### Architectural Patterns and Design Principles
- Modular Design: Each component (acquisition, parsing, modeling, writing) is separated into its own module or file.
- Procedural Pipeline: The code likely flows in a sequential “pipeline”: fetch/scrape → parse → model → write.
- Data-centric Approach: There’s an emphasis on input from files and databases, then transforming that data through standard processes.
- Loose Coupling: While functions across modules call each other, the separation into distinct responsibilities suggests a design focused on maintainability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    MAIN["__main__.py"]:::entry
    subgraph "Data Sources"
        CSV["CSV Files (Master Duel progression CSV)"]:::datasource
        DB["Database (cards.db)"]:::datasource
    end
    subgraph "Data Acquisition"
        SCRAPPER["Scrapper"]:::acquisition
        FETCHER["Fetcher"]:::acquisition
    end
    PARSER["Parser"]:::processing
    subgraph "Domain Models"
        CARD["Card Data"]:::modeling
        ENUMS["Enums"]:::modeling
        SECRET_BANNER["Secret Banner Data"]:::modeling
        SECRET_PACK["Secret Pack Data"]:::modeling
    end
    OUTPUT["Writer"]:::output
    UTILS["Utils"]:::utility
    WEB["Web Elements"]:::utility

    MAIN --> CSV
    MAIN --> DB
    MAIN --> SCRAPPER
    MAIN --> FETCHER

    CSV -->|"feeds"| PARSER
    DB -->|"feeds"| PARSER
    SCRAPPER -->|"supplies"| PARSER
    FETCHER -->|"supplies"| PARSER

    PARSER --> CARD
    PARSER --> ENUMS
    PARSER --> SECRET_BANNER
    PARSER --> SECRET_PACK

    CARD -->|"models data"| OUTPUT
    ENUMS -->|"models data"| OUTPUT
    SECRET_BANNER -->|"models data"| OUTPUT
    SECRET_PACK -->|"models data"| OUTPUT

    UTILS -.-> SCRAPPER
    UTILS -.-> FETCHER
    UTILS -.-> PARSER
    UTILS -.-> OUTPUT

    WEB -.-> SCRAPPER
    WEB -.-> FETCHER
    WEB -.-> PARSER

    classDef entry fill:#ffe6e6,stroke:#d62728,stroke-width:2px;
    classDef datasource fill:#e6f7ff,stroke:#1f77b4,stroke-width:2px;
    classDef acquisition fill:#e6ffe6,stroke:#2ca02c,stroke-width:2px;
    classDef processing fill:#fff2e6,stroke:#ff7f0e,stroke-width:2px;
    classDef modeling fill:#f2e6ff,stroke:#9467bd,stroke-width:2px;
    classDef output fill:#f9e79f,stroke:#ff7f0e,stroke-width:2px;
    classDef utility fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;

    click MAIN "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/__main__.py"
    click CSV "https://github.com/dreamblader/master_duel_pack_scorer/tree/main/data"
    click DB "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/cards.db"
    click SCRAPPER "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/scrapper.py"
    click FETCHER "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/fetcher.py"
    click PARSER "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/parser.py"
    click CARD "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/models/card_data.py"
    click ENUMS "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/models/enums.py"
    click SECRET_BANNER "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/models/secret_banner_data.py"
    click SECRET_PACK "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/models/secret_pack_data.py"
    click OUTPUT "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/writer.py"
    click UTILS "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/utils.py"
    click WEB "https://github.com/dreamblader/master_duel_pack_scorer/blob/main/web_elements.py"
```
