# lunahernandez/chesstournamentanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/lunahernandez/chesstournamentanalysis
- Repository: https://github.com/lunahernandez/chesstournamentanalysis

## Overview

##### Main Components
a. Data Source & Ingestion:
- Data Folder: Holds the raw chess games in PGN format (e.g., data/games.pgn).
- Python Scripts: Under the “python” directory, these scripts (such as pgn_to_csv.py, pgn_to_mongo.py, and create_collections.py) are responsible for:
- Converting PGN files to CSV formats.
- Importing data into databases (likely MongoDB, given the “pgn_to_mongo.py” script).
b. Dashboard Application:
- Dashboard-tips: Contains a web application (app.py) along with its Dockerfile, static assets (styles.css), and a dedicated README. This component likely serves a user interface for delivering insights or “tips” based on analysis.
c. Interactive Analysis:
- Notebooks: Jupyter Notebooks (Analysis.ipynb, Analysis_Jorge.ipynb) indicate an environment for exploratory data analysis.
d. Containerization & Orchestration:
- Docker Files: There are Dockerfiles inside both “dashboard-tips” and “python”, suggesting containerized services.
- docker-compose.yml: At the project root, it is likely used to run these containers together, ensuring they communicate as needed.
e. Static Resources & Documentation:
- Images (likely for visual assets) and the global README.md that describes the key CSV files (moves.csv, details.csv, players.csv, openings.csv) which form the basis of the analysis.

##### Relationships and Interactions
- Data Flow:
- Raw PGN data from the “data” directory is the raw source.
- The “python” container takes this data and performs ETL processes:
- Converting secure formats (PGN to CSV).
- Importing into MongoDB (if applicable) or preparing collections.
- The processed data (CSV files, database collections, etc.) then feeds the Dashboard application.
- Service Interactions:
- The “dashboard-tips” container likely queries the processed and/or stored data to provide real-time or on-demand insights.
- Notebooks might use the processed outputs (CSV or direct database connections) for deeper interactive analysis.
- Docker Compose Orchestration:
- Use docker-compose.yml as the central orchestration tool to connect the containers (Python ETL processes, dashboard application, and possibly a database service).

##### Architectural Patterns to Highlight
- Microservices/Containerized Architecture:
- Each major responsibility (data processing, dashboard serving) is encapsulated within its own container.
- ETL Pipeline:
- The scripts in the “python” folder form an ETL pipeline shifting data from raw PGN files to processed CSV/database collections.
- Separation of Concerns:
- The project neatly separates data processing from data presentation and interactive analysis.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Raw Data Ingestion
    subgraph "Raw Data Ingestion"
        A["PGN Data Source"]:::datasource
    end

    %% ETL Pipeline
    subgraph "ETL Pipeline"
        C["Python Container & Environment"]:::container
        B1["pgn_to_csv.py"]:::script
        B2["pgn_to_mongo.py"]:::script
        B3["create_collections.py"]:::script
    end

    %% Processed Data Output
    subgraph "Processed Data"
        D["Processed Data (CSV & DB)"]:::output
    end

    %% Dashboard Components
    subgraph "Dashboard"
        E1["Dashboard Dockerfile"]:::dashboardAsset
        E3["Dashboard Styles"]:::dashboardAsset
        E4["Dashboard Requirements"]:::dashboardAsset
        E2["Dashboard Service (App)"]:::dashboardService
    end

    %% Interactive Analysis
    subgraph "Interactive Analysis"
        G1["Analysis Notebook"]:::notebook
        G2["Analysis Jorge Notebook"]:::notebook
    end

    %% Orchestration Layer
    subgraph "Orchestration"
        H["Docker Compose Orchestration"]:::orchestration
    end

    %% Data Flow Arrows
    A -->|"ingests"| C
    C -->|"runs"| B1
    C -->|"runs"| B2
    C -->|"runs"| B3
    B1 -->|"produces"| D
    B2 -->|"produces"| D
    B3 -->|"produces"| D
    D -->|"feeds"| E2
    D -->|"supplies"| G1
    D -->|"supplies"| G2

    %% Orchestration Connections
    H -->|"orchestrates"| C
    H -->|"orchestrates"| E1
    H -->|"orchestrates"| E3
    H -->|"orchestrates"| E4

    %% Dashboard Internal Connections
    E1 -->|"configures"| E2
    E3 -->|"appliedTo"| E2
    E4 -->|"installs"| E2

    %% Click Events
    click A "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/data/games.pgn"
    click B1 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/python/pgn_to_csv.py"
    click B2 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/python/pgn_to_mongo.py"
    click B3 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/python/create_collections.py"
    click C "https://github.com/lunahernandez/chesstournamentanalysis/tree/main/python/Dockerfile"
    click E1 "https://github.com/lunahernandez/chesstournamentanalysis/tree/main/dashboard-tips/Dockerfile"
    click E2 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/dashboard-tips/app.py"
    click E3 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/dashboard-tips/styles.css"
    click E4 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/dashboard-tips/requirements.txt"
    click G1 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/notebooks/Analysis.ipynb"
    click G2 "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/notebooks/Analysis_Jorge.ipynb"
    click H "https://github.com/lunahernandez/chesstournamentanalysis/blob/main/docker-compose.yml"

    %% Styles
    classDef datasource fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef container fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef script fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef output fill:#277da1,stroke:#333,stroke-width:2px;
    classDef dashboardAsset fill:#f94144,stroke:#333,stroke-width:2px;
    classDef dashboardService fill:#577590,stroke:#333,stroke-width:2px;
    classDef notebook fill:#43aa8b,stroke:#333,stroke-width:2px;
    classDef orchestration fill:#f3722c,stroke:#333,stroke-width:2px;
```
