# aashish1-1-1/loadbalancer architecture

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

- Interactive diagram: https://gitdiagram.com/aashish1-1-1/loadbalancer
- Repository: https://github.com/aashish1-1-1/loadbalancer

## Overview

Project Type: This is an embedded systems project implementing a load balancer on ESP8266 microcontroller hardware with different load balancing algorithms.

##### Hardware Layer
- ESP8266 Microcontroller (Central component)
- WiFi Module (integrated with ESP8266)

##### Software Components
- Three Load Balancing Algorithms:
- Least Connection (LeastConn)
- Round Robin (Roundrobin)
- Weighted Round Robin (WeightedRr)
- Web Server Component (based on server/HTML.c)
- Static Web Interface (server/static/index.html)

##### External Components
- Client Devices (accessing the load balancer)
- Backend Servers (that receive distributed traffic)

##### Component Representation
- Use rectangles for hardware components (ESP8266)
- Use rounded rectangles for software components (algorithms)
- Use cloud symbols for client devices

##### Specific Elements
- WiFi connection symbol for ESP8266
- Status feedback loop to algorithms

##### Important Notes to Highlight
- A note about the separate algorithm implementations due to ESP8266 stack limitations
- Web interface component for monitoring
- WiFi configuration requirement

##### Flow Indicators
- Request flow from clients
- Algorithm selection path
- Distribution to backend servers
- Response path back to clients

##### Additional Details
- Version/algorithm labels
- Configuration points (WiFi SSID/password)

Special Considerations:
- Hardware limitations that led to separate algorithm implementations
- Relationship between the web server component and the load balancing logic
- Where configuration happens (WiFi settings)

Remember to include a small monitoring/status section showing how the web interface provides visibility into the load balancer's operation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Network
        WIFI((WiFi Network))
        CLIENT1[Client Device 1]
        CLIENT2[Client Device 2]
        CLIENT3[Client Device 3]
    end

    subgraph "ESP8266 Load Balancer"
        ESP[ESP8266 Controller]
        
        subgraph "Load Balancing Algorithms"
            LEAST[Least Connection]
            RR[Round Robin]
            WRR[Weighted Round Robin]
        end
        
        WEB[Web Server Component]
        STATIC[Static Web Interface]
    end

    subgraph "Backend Servers"
        SERVER1[(Server 1)]
        SERVER2[(Server 2)]
        SERVER3[(Server 3)]
    end

    %% Client Connections
    CLIENT1 --> WIFI
    CLIENT2 --> WIFI
    CLIENT3 --> WIFI
    WIFI --> ESP

    %% Algorithm Connections
    ESP --> LEAST
    ESP --> RR
    ESP --> WRR

    %% Web Component Connections
    ESP --> WEB
    WEB --> STATIC

    %% Server Distribution
    LEAST --> SERVER1
    LEAST --> SERVER2
    LEAST --> SERVER3
    RR --> SERVER1
    RR --> SERVER2
    RR --> SERVER3
    WRR --> SERVER1
    WRR --> SERVER2
    WRR --> SERVER3

    %% Click Events
    click LEAST "https://github.com/Aashish1-1-1/LoadBalancer/blob/main/src/LeastConn/LeastConn.ino"
    click RR "https://github.com/Aashish1-1-1/LoadBalancer/blob/main/src/Roundrobin/Roundrobin.ino"
    click WRR "https://github.com/Aashish1-1-1/LoadBalancer/blob/main/src/WeightedRr/WeightedRr.ino"
    click WEB "https://github.com/Aashish1-1-1/LoadBalancer/blob/main/server/HTML.c"
    click STATIC "https://github.com/Aashish1-1-1/LoadBalancer/blob/main/server/static/index.html"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef network fill:#e1f5fe,stroke:#0288d1
    classDef algorithm fill:#e8f5e9,stroke:#2e7d32
    classDef server fill:#fff3e0,stroke:#ef6c00
    classDef hardware fill:#f3e5f5,stroke:#7b1fa2
    classDef web fill:#fff8e1,stroke:#ffa000

    class WIFI,CLIENT1,CLIENT2,CLIENT3 network
    class LEAST,RR,WRR algorithm
    class SERVER1,SERVER2,SERVER3 server
    class ESP hardware
    class WEB,STATIC web

    %% Notes
    note["Note: Algorithms are separated due to ESP8266 stack limitations"]
    note2["Hardware Limitations: Memory constraints affect concurrent connections"]
```
