# bounceur/cupcarbon architecture

> Architecture diagram of the GitHub repository bounceur/cupcarbon, 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/bounceur/cupcarbon
- Repository: https://github.com/bounceur/cupcarbon

## Overview

##### Main System Components

a) User Interface Layer:
- Main GUI components (found in src/cupcarbon/)
- Components like ConsoleWindow, EnergyDrawWindow, MqttWindow, PythonWindow, and SenScriptWindow

b) Simulation Core Layer:
- Center this as the main processing unit
- Simulation engine (src/simulation/)
- To IoTSimulation and WisenSimulation components

c) Device Management Layer:
- Device hierarchy from src/device/
- Components like:
- Base stations
- Sensor nodes
- IoT nodes
- Mobile devices

d) Radio Communication Layer:
- Radio modules (src/radio_module/)
- Different protocols (LoRa, WiFi, ZigBee)
- Interference models

e) Scripting and Programming Layer:
- SenScript engine (src/senscript/)
- Command processing system
- To Python integration

##### Key Relationships to Highlight

a) Data Flow:
- How data flows from sensors through radio modules
- How simulation events propagate

b) Control Flow:
- How user actions translate to simulation events
- How scripts control device behavior

##### External Integrations

- OpenStreetMap integration (src/map/)
- MQTT broker connections
- External event handling system
- Use cloud symbols for external services

##### Supporting Systems

- Mathematical/geometric processing units
- Security components
- Logging and monitoring systems

##### Implementation Details

a) Use standardized symbols:
- Rectangles for processing units
- Hexagons for decision points
- Clouds for external services

- UI components: Blue
- Core simulation: Green
- Network components: Orange
- External services: Gray
- Security components: Red

c) Layer organization:
- In clear hierarchical layers
- Cross-cutting concerns
- Clear boundaries between subsystems

##### Technical Details

- Java3D visualization components
- OpenCL integration points
- Apache components integration
- Network protocol implementations
- Sensor unit implementations

Remember to indicate the asynchronous nature of IoT communications and show how the simulation engine handles concurrent events and multiple protocol implementations.

This architecture should emphasize the platform's ability to simulate IoT and WSN scenarios while showing the extensibility points for adding new devices, protocols, and simulation scenarios.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef ui fill:#a8d1f0,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef device fill:#FFB366,stroke:#333
    classDef radio fill:#FF9999,stroke:#333
    classDef script fill:#FFFF99,stroke:#333
    classDef map fill:#DEB887,stroke:#333
    classDef security fill:#FF6666,stroke:#333
    classDef network fill:#E6E6FA,stroke:#333
    classDef external fill:#D3D3D3,stroke:#333

    %% Main Application
    CC["CupCarbon"]:::core
    CV["Version Control"]:::core

    %% Layers
    subgraph UI
        CW["Console Window"]:::ui
        EDW["Energy Draw Window"]:::ui
        MW["MQTT Window"]:::ui
        PW["Python Window"]:::ui
        SW["SenScript Window"]:::ui
    end

    subgraph SimCore
        Sim["Main Simulation"]:::core
        IoTSim["IoT Simulation"]:::core
        WSim["Wisen Simulation"]:::core
    end

    subgraph DeviceLayer
        DLM["Device List Manager"]:::device
        BS["Base Station"]:::device
        SN["Sensor Node"]:::device
        IoTN["IoT Node"]:::device
        MD["Mobile Device"]:::device
    end

    subgraph RadioComm
        LoRa["LoRa Module"]:::radio
        WiFi["WiFi Module"]:::radio
        ZigBee["ZigBee Module"]:::radio
    end

    subgraph ScriptSystem
        SE["SenScript Engine"]:::script
        SC["Script Commands"]:::script
        SF["Script Functions"]:::script
    end

    subgraph MapSystem
        WM["World Map"]:::map
        ML["Map Layer"]:::map
    end

    subgraph Security
        BF["Blowfish"]:::security
        Hash["Hash Function"]:::security
    end

    subgraph Network
        NL["Network Loader"]:::network
        NP["Network Parameters"]:::network
    end

    subgraph External
        MQTT["MQTT Module"]:::external
        Weather["Natural Events"]:::external
    end

    %% Relationships
    CC --> CV
    CC --> UI
    CC --> SimCore
    SimCore --> DeviceLayer
    DeviceLayer --> RadioComm
    DeviceLayer --> ScriptSystem
    DeviceLayer --> MapSystem
    IoTN --> MQTT
    MapSystem --> NP
    NL --> DeviceLayer
    SE --> SC
    SC --> SF
    
    %% Click Events
    click CC "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/CupCarbon.java"
    click CV "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/CupCarbonVersion.java"
    click CW "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/ConsoleWindow.java"
    click EDW "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/EnergyDrawWindow.java"
    click MW "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/MqttWindow.java"
    click PW "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/PythonWindow.java"
    click SW "https://github.com/bounceur/CupCarbon/blob/master/src/cupcarbon/SenScriptWindow.java"
    click Sim "https://github.com/bounceur/CupCarbon/blob/master/src/simulation/Simulation.java"
    click IoTSim "https://github.com/bounceur/CupCarbon/blob/master/src/simulation/IoTSimulation.java"
    click WSim "https://github.com/bounceur/CupCarbon/blob/master/src/simulation/WisenSimulation.java"
    click DLM "https://github.com/bounceur/CupCarbon/blob/master/src/device/DeviceList.java"
    click BS "https://github.com/bounceur/CupCarbon/blob/master/src/device/BaseStation.java"
    click SN "https://github.com/bounceur/CupCarbon/blob/master/src/device/SensorNode.java"
    click IoTN "https://github.com/bounceur/CupCarbon/blob/master/src/device/IoTNode.java"
    click MD "https://github.com/bounceur/CupCarbon/blob/master/src/device/Mobile.java"
    click LoRa "https://github.com/bounceur/CupCarbon/blob/master/src/radio_module/RadioModule_Lora.java"
    click WiFi "https://github.com/bounceur/CupCarbon/blob/master/src/radio_module/RadioModule_Wifi.java"
    click ZigBee "https://github.com/bounceur/CupCarbon/blob/master/src/radio_module/RadioModule_ZigBee.java"
    click SE "https://github.com/bounceur/CupCarbon/blob/master/src/senscript/SenScript.java"
    click SC "https://github.com/bounceur/CupCarbon/blob/master/src/senscript/Command.java"
    click SF "https://github.com/bounceur/CupCarbon/blob/master/src/senscript_functions/ScriptFunctions.java"
    click WM "https://github.com/bounceur/CupCarbon/blob/master/src/map/WorldMap.java"
    click ML "https://github.com/bounceur/CupCarbon/blob/master/src/map/MapLayer.java"
    click BF "https://github.com/bounceur/CupCarbon/blob/master/src/security/Blowfish.java"
    click Hash "https://github.com/bounceur/CupCarbon/blob/master/src/security/SuperFastHash.java"
    click NL "https://github.com/bounceur/CupCarbon/blob/master/src/device/NetworkLoader.java"
    click NP "https://github.com/bounceur/CupCarbon/blob/master/src/map/NetworkParameters.java"
    click MQTT "https://github.com/bounceur/CupCarbon/blob/master/src/device/IoTMqttModule.java"
    click Weather "https://github.com/bounceur/CupCarbon/blob/master/src/natural_events/Weather.java"
```
