# quentinwach/image-ranker architecture

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

- Interactive diagram: https://gitdiagram.com/quentinwach/image-ranker
- Repository: https://github.com/quentinwach/image-ranker

## Overview

Key Components to Include:

##### Frontend Layer
- Static assets component (CSS, images, and audio files)
- Templates component (HTML files)

##### Backend Layer
- Flask Web Server component
- TrueSkill ELO Engine component
- File System Interface component for local image handling

##### Data Flow Layer
- Image Storage (Local File System)
- Ranking Data Storage (CSV export/import)

**┌─────────────────────────────────────────────┐**
- Web Browser                 │
- ┘
- ↕
**┌─────────────────────────────────────────────┐**
- Flask Web Server              │
- ┌─────────────┐        ┌───────────────┐  │
- Templates  │        │Static Assets   │  │
- (HTML)     │        │(CSS/MP3/Images)│  │
- ┘        └───────────────┘  │
- ┘
- ↕
**┌─────────────────────────────────────────────┐**
- TrueSkill ELO Engine            │
- (μ/σ calculation and global updates)    │
- ┘
- ↕
**┌─────────────────────────────────────────────┐**
- Local File System Interface         │
- ┌─────────────┐        ┌───────────────┐ │
- Images     │        │ CSV Rankings  │ │
- Directory  │        │ Export/Import │ │
- ┘        └───────────────┘ │
- ┘

##### Core Algorithms
- μ (mu) calculation
- σ (sigma) calculation
- Global ranking updates
- Sequential elimination option
- Smart shuffle mechanism

- User interactions (image comparisons)
- Ranking data updates
- File system operations
- CSV export/import paths

##### A small metrics/monitoring section showing
- Ranking progress
- Uncertainty levels
- Shuffle status

- Image comparison flow
- Ranking update process
- Shuffle mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Web Server Layer"
        Flask["Flask Web Server"]:::server
        Templates["HTML Templates"]:::templates
        Static["Static Assets"]:::static
        CSS["CSS Files"]:::static
        Audio["Audio Files"]:::static
    end

    subgraph "Core Processing"
        ELO["TrueSkill ELO Engine"]:::core
        subgraph "Algorithm Components"
            MU["μ Calculation"]:::algo
            SIGMA["σ Calculation"]:::algo
            UPDATE["Global Updates"]:::algo
            SHUFFLE["Smart Shuffle"]:::algo
            SEQ["Sequential Elimination"]:::algo
        end
    end

    subgraph "Storage Layer"
        FSI["File System Interface"]:::storage
        Images["Image Directory"]:::storage
        CSV["CSV Rankings"]:::storage
    end

    %% Connections
    Browser <--> Flask
    Flask --> Templates
    Flask --> Static
    Static --> CSS
    Static --> Audio
    Flask <--> ELO
    ELO --> MU
    ELO --> SIGMA
    ELO --> UPDATE
    ELO --> SHUFFLE
    ELO --> SEQ
    ELO <--> FSI
    FSI --> Images
    FSI --> CSV

    %% Styling
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef templates fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef static fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef core fill:#98FB98,stroke:#333,stroke-width:2px
    classDef algo fill:#F0FFF0,stroke:#333,stroke-width:1px
    classDef storage fill:#FFE4B5,stroke:#333,stroke-width:2px

    %% Click Events
    click Flask "https://github.com/QuentinWach/image-ranker/blob/main/app.py"
    click ELO "https://github.com/QuentinWach/image-ranker/blob/main/elo.py"
    click Static "https://github.com/QuentinWach/image-ranker/tree/main/static/"
    click CSS "https://github.com/QuentinWach/image-ranker/blob/main/static/style.css"
    click Audio "https://github.com/QuentinWach/image-ranker/blob/main/static/click.mp3"
    click Images "https://github.com/QuentinWach/image-ranker/tree/main/static/images/"
    click Templates "https://github.com/QuentinWach/image-ranker/tree/main/templates/"
    click Templates "https://github.com/QuentinWach/image-ranker/blob/main/templates/index.html"

    %% Legend
    subgraph Legend
        L1["Web Components"]:::templates
        L2["Processing Components"]:::core
        L3["Storage Components"]:::storage
    end
```
