# virajcommits/poeltlsolver architecture

> Architecture diagram of the GitHub repository virajcommits/poeltlsolver, 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/virajcommits/poeltlsolver
- Repository: https://github.com/virajcommits/poeltlsolver

## Overview

##### Main Components
- Frontend Component:
- React Application – The interactive user interface for the extension.
- Chrome Extensions API – Provides additional integration and packaging for a Chrome extension.
- UI Elements – Components like PlayerGuesser, App, loaders, and styling modules.
- Backend Component:
- Flask API (with poeltl.py in the backend directory) – Exposes endpoints such as /sync and /guess.
- Python Libraries: Pandas (for data processing), Requests (for API calls), and Flask-CORS (for cross-origin requests).
- External Service:
- SportsData API – Supplies real-time NBA player data.
- Supporting Elements:
- Data Flow & Logging – Detailed logging within the Flask backend for debugging.
- Environment & Configuration – Environment variables (API_KEY, SECRET_KEY) stored within .env and configuration files for both Node and Python environments.

##### Relationships and Interactions
- The Chrome extension’s popup (React frontend) acts as the entry point for user interactions.
- The React app (found in the “poeltl” directory) sends API requests (using Axios) to the Flask backend.
- The Flask backend processes requests, executes data manipulation (using Pandas), and communicates with the external SportsData API.
- The processed data (filtered player suggestions and real-time stats) is then returned from the backend to the React frontend for display.
- Logging and debugging flows are maintained via detailed console and server logs.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Decoupling of the frontend (user interface and user interaction) from the backend (data fetching and processing).
- Client-Server Architecture: The React frontend functions as the client issuing HTTP requests to the Flask server back end.
- Component-Based UI: The frontend’s modular React components (e.g., PlayerGuesser, App) enhance maintainability.
- Use of Environment Variables & External Configuration: Securely managing sensitive API keys and deployment settings.
- Cross-Origin Communication: Handled through Flask-CORS ensuring smooth integration between the browser extension and backend services.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: React, Styled Components, Axios, Chrome Extensions API.
- Backend: Flask, Pandas, Requests, Flask-CORS.
- Others: Optionally Docker for containerization, and standard version control via Git & GitHub.

##### Essential Elements
- “Chrome Extension / React Frontend” – Include subcomponents such as PlayerGuesser and App.
- “Flask Backend API” – Include endpoints (/sync and /guess), data processing modules, and logging.
- “External SportsData API” – Show external API calls (with appropriate headers, cookies, etc.).
- Distinguishing Features:
- Additional Notes:
- A note on environment configuration (e.g., use of .env files, API keys, and developer logging).
- Build or deployment steps (like the Docker note in the Technology Stack).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    U["NBA Fan"]:::user

    %% Frontend Subgraph
    subgraph "Chrome Extension / React Frontend"
        FE["React App"]:::frontend
        PG["PlayerGuesser Component"]:::frontend
        APP["App Component"]:::frontend
        APIUI["Chrome Extensions API & UI Assets"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Flask Backend API"
        FB["Flask API (poeltl.py)"]:::backend
        SYNC["/sync Endpoint"]:::backend
        GUESS["/guess Endpoint"]:::backend
        DP["Data Processing & Logging"]:::backend
    end

    %% External Service
    ES["External SportsData API"]:::external

    %% Data Flow
    U -->|"interacts"| FE
    FE -->|"sends HTTP requests"| FB
    FB -->|"handles"| SYNC
    FB -->|"handles"| GUESS
    FB -->|"processes"| DP
    FB -->|"calls"| ES
    ES -->|"returns data"| FB
    FB -->|"sends data back"| FE

    %% Frontend Internal Composition
    FE -->|"composes"| PG
    FE -->|"composes"| APP
    FE -->|"loads assets from"| APIUI

    %% Click Events
    click FE "https://github.com/virajcommits/poeltlsolver/tree/main/poeltl"
    click APIUI "https://github.com/virajcommits/poeltlsolver/tree/main/poeltl/public"
    click FB "https://github.com/virajcommits/poeltlsolver/blob/main/backend/poeltl.py"
    click DP "https://github.com/virajcommits/poeltlsolver/blob/main/backend/poeltl.py"
    click PG "https://github.com/virajcommits/poeltlsolver/blob/main/poeltl/src/PlayerGuesser.js"
    click APP "https://github.com/virajcommits/poeltlsolver/blob/main/poeltl/src/App.js"

    %% Styles
    classDef user fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef frontend fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef backend fill:#a9dfbf,stroke:#196f3d,stroke-width:2px;
    classDef external fill:#f5b7b1,stroke:#922b21,stroke-width:2px;
```
