# kit-mrt/arbitration_graphs architecture

> Architecture diagram of the GitHub repository kit-mrt/arbitration_graphs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kit-mrt/arbitration_graphs
- Repository: https://github.com/kit-mrt/arbitration_graphs

## Overview

##### Core Library Components
- Arbitrators (Priority, Random, Cost-based)
- Behavior Components
- Coordinators (Conjunctive, Joint)
- Verification System
- Types and Exceptions

##### GUI Components
- Web Server (Crow-based)
- WebSocket Server
- Static WebApp Files
- SVG Renderer

##### Demo Application
- A "PacMan Demo" container showing:
- Environment Model
- Agent Behaviors
- Cost Estimator
- Verifier
- Game Engine Integration

Design Guidelines:

##### Use a Layered Architecture

- Demo      |

- GUI      |

- Core Library  |

##### Specific Elements

a. Core Layer:

- Core Library      |

- Arbitrators  |     |

- Behaviors   |     |

- Verification |     |

b. GUI Layer:

- GUI           |

- Web Server   |     |

- WebApp UI    |     |

##### Important Details to Highlight
- Header-only nature of the core library
- Websocket communication between GUI and core
- Verification flow for behavior safety
- Hierarchical structure of arbitrators
- External dependency connections (glog, yaml-cpp, etc.)

- ▢ Core Component
- ◇ Optional Component
- → Direct Dependency
- ⟶ Data Flow
- ⟵⟶ Bidirectional Communication

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Library"]
        direction TB
        Arbitrators["Arbitrators"]
        Behaviors["Behavior Components"]
        Coordinators["Coordinators"]
        Verification["Verification System"]
        Types["Types & Exceptions"]

        subgraph Arb["Arbitrator Types"]
            direction TB
            Priority["Priority Arbitrator"]
            Random["Random Arbitrator"]
            Cost["Cost Arbitrator"]
        end

        subgraph Coord["Coordinator Types"]
            direction TB
            Conjunctive["Conjunctive Coordinator"]
            Joint["Joint Coordinator"]
        end

        Arbitrators --> Arb
        Coordinators --> Coord
    end

    subgraph GUI["GUI Layer"]
        direction TB
        WebServer["Web Server"]
        WebSocket["WebSocket Server"]
        WebApp["Static WebApp"]
        SVGRenderer["SVG Renderer"]

        WebServer --> WebSocket
        WebSocket --> WebApp
        WebApp --> SVGRenderer
    end

    subgraph Demo["PacMan Demo"]
        direction TB
        EnvModel["Environment Model"]
        Agent["PacMan Agent"]
        CostEst["Cost Estimator"]
        DemoVerifier["Verifier"]

        subgraph Behaviors["Agent Behaviors"]
            direction TB
            AvoidGhost["Avoid Ghost"]
            ChaseGhost["Chase Ghost"]
            EatDot["Eat Closest Dot"]
            MoveRandom["Move Randomly"]
            StayPlace["Stay in Place"]
        end

        Agent --> Behaviors
        Agent --> CostEst
        Agent --> DemoVerifier
        EnvModel --> Agent
    end

    GUI --> Core
    Demo --> Core
    Demo --> GUI

    classDef core fill:#e1f5fe,stroke:#01579b
    classDef gui fill:#e8f5e9,stroke:#1b5e20
    classDef demo fill:#fff3e0,stroke:#e65100
    
    class Core,Arbitrators,Behaviors,Coordinators,Verification,Types,Arb,Coord,Priority,Random,Cost,Conjunctive,Joint core
    class GUI,WebServer,WebSocket,WebApp,SVGRenderer gui
    class Demo,EnvModel,Agent,CostEst,DemoVerifier,Behaviors,AvoidGhost,ChaseGhost,EatDot,MoveRandom,StayPlace demo

    click Priority "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/priority_arbitrator.hpp"
    click Random "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/random_arbitrator.hpp"
    click Cost "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/cost_arbitrator.hpp"
    click Behaviors "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/behavior.hpp"
    click Conjunctive "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/conjunctive_coordinator.hpp"
    click Joint "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/joint_coordinator.hpp"
    click Verification "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/verification.hpp"
    click Types "https://github.com/KIT-MRT/arbitration_graphs/blob/main/include/arbitration_graphs/types.hpp"
    click WebServer "https://github.com/KIT-MRT/arbitration_graphs/blob/main/gui/include/arbitration_graphs/gui/web_server.hpp"
    click WebApp "https://github.com/KIT-MRT/arbitration_graphs/tree/main/gui/app/arbitration_graphs/"
    click SVGRenderer "https://github.com/KIT-MRT/arbitration_graphs/blob/main/gui/app/arbitration_graphs/svg.css"
    click EnvModel "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/environment_model.hpp"
    click Agent "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/pacman_agent.hpp"
    click CostEst "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/cost_estimator.hpp"
    click DemoVerifier "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/verifier.hpp"
    click AvoidGhost "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/avoid_ghost_behavior.hpp"
    click ChaseGhost "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/chase_ghost_behavior.hpp"
    click EatDot "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/eat_closest_dot_behavior.hpp"
    click MoveRandom "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/move_randomly_behavior.hpp"
    click StayPlace "https://github.com/KIT-MRT/arbitration_graphs/blob/main/demo/include/demo/stay_in_place_behavior.hpp"
```
