# icecc/icecream architecture

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

- Interactive diagram: https://gitdiagram.com/icecc/icecream
- Repository: https://github.com/icecc/icecream

## Overview

##### Main Components Identification

a. Client (client/)
- Handles compilation job submission
- Manages local and remote compilation
- Creates compilation environments

b. Scheduler (scheduler/)
- Central job distribution system
- Load balancing and job assignment
- Network coordination

c. Daemon (daemon/)
- Runs on each node
- Executes compilation tasks
- Manages environments

##### Key Relationships

a. Network Layer:
- UDP broadcast (port 8765) for scheduler discovery
- TCP connections (ports 10245, 8765, 8766) between components
- Compression of data transfer (using lzo)

b. Control Flow:
- Client → Scheduler: Job submission and scheduling requests
- Scheduler → Daemon: Job distribution and load balancing
- Daemon → Client: Results return path

##### Supporting Components

Additional elements:

a. Services Layer (services/)
- Communication protocols
- Platform-specific utilities
- Logging and monitoring

b. Environment Management:
- Cross-compilation support
- Compiler environment packaging
- Native/cross-compiler version handling

##### Monitoring Interface

Integration with:
- Icemon monitoring tool
- Telnet interface (port 8766)
- Statistics collection

##### Notes Section

Annotations for:
- Firewall requirements
- Network optimization recommendations
- Version compatibility considerations
- Security considerations

This system design should help developers understand both the high-level architecture and the specific technical implementation details that make Icecream an effective distributed compilation system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Network
        UDP[("UDP Broadcast<br/>Port 8765")]
        TCP[("TCP Connections<br/>Ports 10245, 8765, 8766")]
        COMP[("Data Compression<br/>(lzo)")]
    end

    subgraph Client
        direction TB
        CMain["Main Client"]:::client
        RComp["Remote Compilation"]:::client
        LComp["Local Compilation"]:::client
        CUtil["Client Utilities"]:::client
    end

    subgraph Scheduler
        direction TB
        SCore["Core Scheduler"]:::scheduler
        JMan["Job Management"]:::scheduler
        CServ["Compile Server"]:::scheduler
        JStat["Job Statistics"]:::scheduler
    end

    subgraph Daemon
        direction TB
        DMain["Main Daemon"]:::daemon
        SHandler["Service Handler"]:::daemon
        EMan["Environment Management"]:::daemon
        WProc["Work Processing"]:::daemon
    end

    subgraph Services
        direction TB
        CommP["Communication Protocol"]:::service
        PlatS["Platform Support"]:::service
        LogS["Logging System"]:::service
        JobS["Job Services"]:::service
        UtilF["Utility Functions"]:::service
    end

    subgraph Environment
        direction TB
        CWrap["Compiler Wrapper"]:::env
        CrossComp["Cross-Compilation Support"]:::env
        ToolChain["Toolchain Management"]:::env
    end

    subgraph Monitoring
        direction TB
        Icemon["Icemon Tool"]:::monitor
        Telnet["Telnet Interface<br/>Port 8766"]:::monitor
        Stats["Statistics Collection"]:::monitor
    end

    %% Relationships
    Client --> UDP
    Client --> TCP
    Scheduler --> TCP
    Daemon --> TCP
    UDP --> Scheduler
    TCP --> COMP
    COMP --> Services

    %% Component Interactions
    Client --> Scheduler
    Scheduler --> Daemon
    Daemon --> Client
    Services --> Client
    Services --> Scheduler
    Services --> Daemon
    Environment --> Daemon
    Monitoring --> Scheduler

    %% Click Events
    click CMain "https://github.com/icecc/icecream/blob/master/client/main.cpp"
    click RComp "https://github.com/icecc/icecream/blob/master/client/remote.cpp"
    click LComp "https://github.com/icecc/icecream/blob/master/client/local.cpp"
    click CUtil "https://github.com/icecc/icecream/blob/master/client/util.cpp"
    click SCore "https://github.com/icecc/icecream/blob/master/scheduler/scheduler.cpp"
    click JMan "https://github.com/icecc/icecream/blob/master/scheduler/job.cpp"
    click CServ "https://github.com/icecc/icecream/blob/master/scheduler/compileserver.cpp"
    click JStat "https://github.com/icecc/icecream/blob/master/scheduler/jobstat.cpp"
    click DMain "https://github.com/icecc/icecream/blob/master/daemon/main.cpp"
    click SHandler "https://github.com/icecc/icecream/blob/master/daemon/serve.cpp"
    click EMan "https://github.com/icecc/icecream/blob/master/daemon/environment.cpp"
    click WProc "https://github.com/icecc/icecream/blob/master/daemon/workit.cpp"
    click CommP "https://github.com/icecc/icecream/blob/master/services/comm.cpp"
    click PlatS "https://github.com/icecc/icecream/blob/master/services/platform.cpp"
    click LogS "https://github.com/icecc/icecream/blob/master/services/logging.cpp"
    click JobS "https://github.com/icecc/icecream/blob/master/services/job.cpp"
    click UtilF "https://github.com/icecc/icecream/blob/master/services/util.cpp"
    click CWrap "https://github.com/icecc/icecream/blob/master/compilerwrapper/compilerwrapper.cpp"

    %% Styling
    classDef client fill:#2196F3,stroke:#1565C0,color:white
    classDef scheduler fill:#4CAF50,stroke:#2E7D32,color:white
    classDef daemon fill:#FF9800,stroke:#EF6C00,color:white
    classDef service fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef env fill:#FFC107,stroke:#FFA000,color:black
    classDef monitor fill:#607D8B,stroke:#37474F,color:white

    %% Legend
    subgraph Legend
        Client_L["Client Component"]:::client
        Scheduler_L["Scheduler Component"]:::scheduler
        Daemon_L["Daemon Component"]:::daemon
        Service_L["Services Layer"]:::service
        Env_L["Environment"]:::env
        Monitor_L["Monitoring"]:::monitor
    end
```
