# thed2lab/adaptlil architecture

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

- Interactive diagram: https://gitdiagram.com/thed2lab/adaptlil
- Repository: https://github.com/thed2lab/adaptlil

## Overview

##### Main System Components

a) Java Backend (src/adaptlil/)
- Eye Tracking Integration (gazepoint/ directory)
- Adaptation Engine (adaptations/ directory)
- WebSocket Server (websocket/ directory)
- HTTP Server (http/ directory)

b) Python Server (python/)
- Deep Learning Models
- Flask Server
- Model Training & Evaluation

c) Frontend Visualization (resources/visualization_web/)
- Web Interface
- D3.js Visualizations
- WebSocket Client

##### Key Relationships to Highlight

a) Data Flow:
- Eye Tracker → Java Backend (Gazepoint API)
- Java Backend → Python Server (Deep Learning inference)
- Python Server → Java Backend (Adaptation decisions)
- Java Backend → Frontend (WebSocket adaptations)

b) Control Flow:
- Frontend ↔ Java Backend (WebSocket communication)
- Java Backend ↔ Python Server (HTTP/REST communication)

##### Detailed Component Breakdown

Java Backend:
- GazepointSocket
- AdaptationMediator
- VisualizationWebsocket
- Data Processing Pipeline
- Buffer Management

Python Server:
- Flask API
- Model Loading
- Inference Engine
- Deep Learning Models
- LSTM
- Transformer

Frontend:
- Visualization Components
- WebSocket Client
- Adaptation Renderer
- User Interface

##### Technical Specifications

A technical specifications section showing:
- Java ≥ 11
- Python ≥ 3.9, < 3.11
- CUDA 11+
- WebSocket Protocol
- HTTP/REST APIs

##### Additional Elements

Callouts for:
- Scalability points
- Error handling paths
- Configuration management
- Model loading/switching capability

Remember to highlight the system's unique features:
- Real-time gaze processing
- Adaptive visualization changes
- Deep learning integration
- Multiple adaptation types
- WebSocket-based updates

This will create a comprehensive yet clear representation of the AdaptLIL system architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "System Overview"
        subgraph "Java Backend"
            ET["Eye Tracking Integration"]:::realtime
            AE["Adaptation Engine"]:::processing
            WS["WebSocket Server"]:::server
            HS["HTTP Server"]:::server
            AM["Adaptation Mediator"]:::control
            DPC["Data Processing Classes"]:::processing
            BM["Buffer Management"]:::processing
            EC["Environment Config"]:::config
        end

        subgraph "Python Server"
            FS["Flask Server"]:::server
            DLM["Deep Learning Models"]:::ml
            MT["Model Training"]:::ml
            ME["Model Evaluation"]:::ml
            IE["Inference Engine"]:::ml
        end

        subgraph "Frontend"
            WI["Web Interface"]:::ui
            WSC["WebSocket Client"]:::client
            VC["Visualization Components"]:::ui
        end
    end

    %% Data Flow Connections
    ET --> AM
    AM --> WS
    WS --> WSC
    WSC --> VC
    HS <--> FS
    FS <--> DLM
    AM --> BM
    BM --> DPC
    DPC --> AE
    AE --> WS
    MT --> DLM
    ME --> DLM

    %% Component Styling
    classDef realtime fill:#ff7f50
    classDef processing fill:#87ceeb
    classDef server fill:#98fb98
    classDef control fill:#dda0dd
    classDef ml fill:#f0e68c
    classDef ui fill:#e6e6fa
    classDef client fill:#ffdab9
    classDef config fill:#d3d3d3

    %% Click Events
    click ET "https://github.com/TheD2Lab/AdaptLIL/tree/master/src/adaptlil/gazepoint/"
    click AE "https://github.com/TheD2Lab/AdaptLIL/tree/master/src/adaptlil/adaptations/"
    click WS "https://github.com/TheD2Lab/AdaptLIL/tree/master/src/adaptlil/websocket/"
    click HS "https://github.com/TheD2Lab/AdaptLIL/tree/master/src/adaptlil/http/"
    click FS "https://github.com/TheD2Lab/AdaptLIL/blob/master/python/FlaskServer.py"
    click DLM "https://github.com/TheD2Lab/AdaptLIL/tree/master/python/deep_learning_models/"
    click MT "https://github.com/TheD2Lab/AdaptLIL/blob/master/python/model_train.py"
    click ME "https://github.com/TheD2Lab/AdaptLIL/blob/master/python/modelEvalScript.py"
    click WI "https://github.com/TheD2Lab/AdaptLIL/tree/master/src/adaptlil/resources/visualization_web/"
    click WSC "https://github.com/TheD2Lab/AdaptLIL/blob/master/src/adaptlil/resources/visualization_web/scripts/websocket.js"
    click VC "https://github.com/TheD2Lab/AdaptLIL/blob/master/src/adaptlil/resources/visualization_web/scripts/VisualizationAdaptations.js"
    click AM "https://github.com/TheD2Lab/AdaptLIL/blob/master/src/adaptlil/mediator/AdaptationMediator.java"
    click DPC "https://github.com/TheD2Lab/AdaptLIL/tree/master/src/adaptlil/data_classes/"
    click BM "https://github.com/TheD2Lab/AdaptLIL/blob/master/src/adaptlil/buffer/AsyncBuffer.java"
    click EC "https://github.com/TheD2Lab/AdaptLIL/blob/master/src/adaptlil/EnvironmentConfig.java"

    %% Legend
    subgraph Legend
        L1["Real-time Components"]:::realtime
        L2["Processing Components"]:::processing
        L3["Server Components"]:::server
        L4["Control Components"]:::control
        L5["ML Components"]:::ml
        L6["UI Components"]:::ui
        L7["Client Components"]:::client
        L8["Configuration"]:::config
    end
```
