# tescrihuela/tdf architecture

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

- Interactive diagram: https://gitdiagram.com/tescrihuela/tdf
- Repository: https://github.com/tescrihuela/tdf

## Overview

##### Project Type and Purpose
- Type: A full-stack (primarily backend-driven) web dashboard application.
- Purpose: To scrape and process cycling (Tour de France) results from an external website and then calculate and display fantasy scores on a web interface.

##### Main Components
a. Web Server & User Interface:
– Represented by “app.py”: This is the entry point managing HTTP requests and serving the web UI.
– “assets” directory: Contains static resources such as CSS, JavaScript, and images that enhance the dashboard’s frontend.
b. Data Processing & Scraping:
– “tdf.py”: Likely includes logic to scrape results from the Tour de France website.
– “data2021.py”, “data2023.py”, “data2024.py”: These modules probably handle specific data processing or normalization for each year's data.
– “ranking.csv”: Serves as a lightweight data storage holding the current or historical rankings used for score calculations.
c. External Services:
– The project relies on external data from https://tourdefrance2023.fr/ for scraping results.
– The calculated scores are compared with those on https://fantasy.letour.fr/ (mentioned in the README) as part of the fantasy score logic.

##### Relationships and Interactions
- The web server (app.py) acts as the orchestrator: when a user accesses the dashboard, it may trigger data updates by calling functions from “tdf.py” to scrape the latest results.
- The scraped data is then processed by the year-specific modules to ensure that each dataset (2021, 2023, 2024) is accurately handled and integrated.
- Processed data is stored or referenced via “ranking.csv” for score calculations.
- Finally, the computed results are rendered and served on the web interface, using static assets from the “assets” directory.

##### Architectural Patterns and Technologies
- Modular design – Keeping concerns separated for web serving, scraping, and data processing.
- Lightweight persistence – Utilizing a CSV file as a simple database which might be replaced/enhanced in future iterations.
- Clearly delineated coding areas for each year's data suggests ease of maintenance and scalability for handling historical data.
- The project dependencies are managed via “requirements.txt”, indicating the use of common Python libraries (possibly Flask, Requests, or BeautifulSoup).

## Diagram (Mermaid)

```mermaid
flowchart TD
    extTDF("Tour de France 2023 (External Data Source)"):::ext
    tdf("Data Scraping Module (tdf.py)"):::core
    p2021("Data Processor 2021 (data2021.py)"):::core
    p2023("Data Processor 2023 (data2023.py)"):::core
    p2024("Data Processor 2024 (data2024.py)"):::core
    ranking("Data Storage (ranking.csv)"):::storage
    web("Web Server & UI (app.py)"):::core
    assets("Static Assets (assets/)"):::static
    fantasy("Fantasy Score Comparison (fantasy.letour.fr)"):::ext
    req("Dependency Management (requirements.txt)"):::dependency

    extTDF -->|"scrapes"| tdf
    tdf -->|"processes"| p2021
    tdf -->|"processes"| p2023
    tdf -->|"processes"| p2024
    p2021 -->|"stores"| ranking
    p2023 -->|"stores"| ranking
    p2024 -->|"stores"| ranking
    ranking -->|"feeds"| web
    assets -->|"provides"| web
    web -->|"comparesScores"| fantasy
    web -->|"dependsOn"| req

    click web "https://github.com/tescrihuela/tdf/blob/master/app.py"
    click assets "https://github.com/tescrihuela/tdf/tree/master/assets/"
    click tdf "https://github.com/tescrihuela/tdf/blob/master/tdf.py"
    click p2021 "https://github.com/tescrihuela/tdf/blob/master/data2021.py"
    click p2023 "https://github.com/tescrihuela/tdf/blob/master/data2023.py"
    click p2024 "https://github.com/tescrihuela/tdf/blob/master/data2024.py"
    click ranking "https://github.com/tescrihuela/tdf/blob/master/ranking.csv"
    click req "https://github.com/tescrihuela/tdf/blob/master/requirements.txt"

    classDef ext fill:#ffcccc,stroke:#ff0000,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#008000,stroke-width:2px;
    classDef storage fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
    classDef static fill:#cce5ff,stroke:#3399ff,stroke-width:2px;
    classDef dependency fill:#e6e6e6,stroke:#808080,stroke-width:2px;
```
