# ivanpan0626/lol-ai-matchup-predictor-with-data-analysis architecture

> Architecture diagram of the GitHub repository ivanpan0626/lol-ai-matchup-predictor-with-data-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivanpan0626/lol-ai-matchup-predictor-with-data-analysis
- Repository: https://github.com/ivanpan0626/lol-ai-matchup-predictor-with-data-analysis

## Overview

##### Main Components

A. Data Collection Layer
- Riot Games API Integration
- Web Scraping Component (BeautifulSoup)

B. Data Processing & AI Layer
- Data Preprocessing Pipeline
- Multiple AI Models:
- XGBoost Model
- Random Forest Model
- Neural Network Model
- Model Storage (*.keras and *.pkl files)

C. Backend Server (Flask)
- API Routes
- Service Layer
- Template Engine (Jinja2)
- Static Assets Handler

D. Frontend Layer
- HTML Templates
- CSS Styling
- JavaScript Components

##### Data Flow
- External APIs → Data Collection → Data Processing → AI Models → Model Storage

##### Request Flow
- User Interface → Flask Routes → Services → AI Models → Response

##### Specific Implementation Details

- Server Components (/server/routes/):
- AI Services (aiServices.py)
- API Services (apiServices.py)
- Data Services (dataServices.py)
- Search Services (searchServices.py)

- AI Models (/server/AIModeling/):
- Matchup Predictor
- Team vs Team Predictor
- Champion Analysis

##### Important Architectural Patterns to Highlight

- Service-Oriented Architecture (SOA)
- Separate services for AI, API, Data, and Search
- MVC Pattern in Flask implementation
- Models (models.py)
- Views (views.py)
- Templates (templates/)
- Data Pipeline Architecture
- From data collection to model training

##### Technical Stack Representation

**Frontend: HTML/CSS/JavaScript**
**↓**
**Web Framework: Flask/Jinja2**
**↓**
**Services Layer: AI/API/Data Services**
**↓**
**Data Processing: Pandas/NumPy**
**↓**
**AI/ML Layer: XGBoost/Random Forest/Neural Networks**
**↓**
**Data Sources: Riot API/Web Scraping**

##### Additional Elements

- Version/state indicators for AI models
- Data storage locations and formats
- Async vs sync operations
- Future implementation points (Celery/Redis)

Remember to:
- Keep the main flow clear and centered
- Related components together
- Use consistent styling for similar components
- Notes for scaling considerations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef external fill:#87CEEB,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef ai fill:#FFD700,stroke:#333
    classDef server fill:#DDA0DD,stroke:#333
    classDef frontend fill:#D3D3D3,stroke:#333
    classDef storage fill:#F4A460,stroke:#333

    %% External Data Sources
    RiotAPI["Riot Games API"]:::external
    WebScraping["Web Scraping\n(BeautifulSoup)"]:::external
    click WebScraping "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/AIModeling/test_NoteBooks/dataScraping.ipynb"

    %% Data Processing Layer
    subgraph DataProcessing["Data Processing Layer"]
        DataPipeline["Data Processing Pipeline"]:::processing
        ProcessedData["Processed Data Storage"]:::storage
    end
    click DataPipeline "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/AIModeling/databook.ipynb"
    click ProcessedData "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/tree/main/server/AIModeling/data/"

    %% AI/ML Layer
    subgraph AILayer["AI/ML Layer"]
        XGBoost["XGBoost Model"]:::ai
        RandomForest["Random Forest Model"]:::ai
        NeuralNetwork["Neural Network Model"]:::ai
        MatchupPredictor["Matchup Predictor"]:::ai
        TeamPredictor["Team vs Team Predictor"]:::ai
    end
    click XGBoost "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/AIModeling/AI_Notebooks/xgboostModel.ipynb"
    click RandomForest "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/data/RandomForestTeamMatchupModel.pkl"
    click NeuralNetwork "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/data/NeuralMatchUpAIModel.keras"
    click MatchupPredictor "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/AIModeling/AI_Notebooks/MatchupAIModel.ipynb"
    click TeamPredictor "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/AIModeling/AI_Notebooks/TeamVTeamAIModel.ipynb"

    %% Server Layer
    subgraph ServerLayer["Flask Server Layer"]
        FlaskCore["Flask Core"]:::server
        Config["Configuration"]:::server
        
        subgraph Services["Service Layer"]
            AIServices["AI Services"]:::server
            APIServices["API Services"]:::server
            DataServices["Data Services"]:::server
            SearchServices["Search Services"]:::server
        end
        
        subgraph MVC["MVC Components"]
            Models["Models"]:::server
            Views["Views"]:::server
            Templates["Templates"]:::server
        end
    end
    click FlaskCore "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/main.py"
    click Config "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/config.py"
    click AIServices "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/aiServices.py"
    click APIServices "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/apiServices.py"
    click DataServices "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/dataServices.py"
    click SearchServices "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/searchServices.py"
    click Models "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/models.py"
    click Views "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/views.py"
    click Templates "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/tree/main/server/routes/templates/"

    %% Frontend Layer
    subgraph FrontendLayer["Frontend Layer"]
        BaseTemplate["Base Template"]:::frontend
        HomePage["Home Page"]:::frontend
        MatchupPages["Matchup Pages"]:::frontend
        Styling["CSS Styling"]:::frontend
    end
    click BaseTemplate "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/templates/base.html"
    click HomePage "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/templates/home.html"
    click MatchupPages "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/templates/matchupsHome.html"
    click Styling "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/static/home.css"

    %% Data Storage
    ChampionData["Champion Data CSV"]:::storage
    ChampionMappings["Champion Mappings JSON"]:::storage
    click ChampionData "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/data/champion_data_df.csv"
    click ChampionMappings "https://github.com/ivanpan0626/LoL-AI-Matchup-Predictor-with-Data-Analysis/blob/main/server/routes/data/championId_dict.json"

    %% Relationships
    RiotAPI --> DataPipeline
    WebScraping --> DataPipeline
    DataPipeline --> ProcessedData
    ProcessedData --> AILayer
    AILayer --> Services
    Services --> MVC
    MVC --> FrontendLayer
    ChampionData --> DataServices
    ChampionMappings --> DataServices

    %% Legend
    subgraph Legend
        ExtLegend["External Services"]:::external
        ProcLegend["Processing Components"]:::processing
        AILegend["AI/ML Components"]:::ai
        ServLegend["Server Components"]:::server
        FrontLegend["Frontend Components"]:::frontend
        StorLegend["Storage Components"]:::storage
    end
```
