# haithemnasr/meshnet-ai architecture

> Architecture diagram of the GitHub repository haithemnasr/meshnet-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haithemnasr/meshnet-ai
- Repository: https://github.com/haithemnasr/meshnet-ai

## Overview

MeshNet AI simulates disaster-resilient routing across Tunisian mesh networks. Users can trigger a disaster, select a routing approach, and observe message delivery and network KPIs in the dashboard; a separate benchmark compares six algorithms, while training produces DQN/PPO agents. The graph preserves geography, disaster effects, simulation, routing, RL, evaluation, and visualization. Some dashboard and benchmark internals are unsampled, so their links are limited to capabilities documented in the README rather than inferred call chains.

Main entry points: [`src/network/network.py`](https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/network.py) (Mesh network), [`dashboard.py`](https://github.com/haithemnasr/meshnet-ai/blob/main/dashboard.py) (Interactive dashboard), [`comparison_test.py`](https://github.com/haithemnasr/meshnet-ai/blob/main/comparison_test.py) (Algorithm benchmark), [`src/network/message.py`](https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/message.py) (Messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Network simulation"]
  node_network["Mesh network<br/>[network.py]"]
  node_node["Mesh nodes<br/>[node.py]"]
  node_message["Messages<br/>[message.py]"]
end

subgraph group_scenarios["Geography and disasters"]
  node_geo["Tunisia map<br/>[tunisia_map.py]"]
  node_disaster["Disaster scenarios<br/>[disaster.py]"]
end

subgraph group_routing["Routing and learning"]
  node_flooding["Flooding router<br/>[routing.py]"]
  node_baseline["Baseline routers"]
  node_rl_env["RL environment<br/>[stable_rl_env.py]"]
  node_training["Agent training<br/>[train_rl_agents.py]"]
  node_agents["DQN/PPO weights"]
end

subgraph group_product["Dashboard and evaluation"]
  node_dashboard["Interactive dashboard<br/>[dashboard.py]"]
  node_visualizer["Network visualizer<br/>[network_viz.py]"]
  node_benchmark["Algorithm benchmark<br/>[comparison_test.py]"]
  node_metrics[("Dashboard metrics")]
  node_charts["Comparison charts"]
end

node_user(("Operator"))

node_user -->|"operates"| node_dashboard
node_dashboard -->|"builds network"| node_network
node_dashboard -->|"selects scenario"| node_disaster
node_dashboard -->|"runs AI routing"| node_rl_env
node_dashboard -.->|"loads agent"| node_agents
node_dashboard -->|"reads KPIs"| node_metrics
node_dashboard -->|"renders network"| node_visualizer
node_network -->|"manages nodes"| node_node
node_network -->|"creates messages"| node_message
node_node -->|"queues and receives"| node_message
node_disaster -->|"updates failures"| node_network
node_geo -->|"supplies city data"| node_network
node_training -->|"trains agents"| node_rl_env
node_training -->|"uses city data"| node_geo
node_training -->|"saves weights"| node_agents
node_rl_env -->|"observes and steps"| node_network
node_rl_env -->|"advances message"| node_message
node_flooding -->|"forwards messages"| node_network
node_baseline -->|"routes messages"| node_network
node_baseline -->|"updates route"| node_message
node_user -->|"runs comparison"| node_benchmark
node_benchmark -->|"simulates routing"| node_network
node_benchmark -->|"compares baselines"| node_baseline
node_benchmark -->|"evaluates learned agents"| node_agents
node_benchmark -->|"exports metrics"| node_metrics
node_benchmark -->|"saves charts"| node_charts
node_visualizer -->|"reads network state"| node_network
node_visualizer -->|"plots message path"| node_message

click node_network "https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/network.py"
click node_node "https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/node.py"
click node_message "https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/message.py"
click node_flooding "https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/routing.py"
click node_baseline "https://github.com/haithemnasr/meshnet-ai/blob/main/src/ai/baseline_routers.py"
click node_rl_env "https://github.com/haithemnasr/meshnet-ai/blob/main/src/ai/stable_rl_env.py"
click node_geo "https://github.com/haithemnasr/meshnet-ai/blob/main/src/scenarios/tunisia_map.py"
click node_disaster "https://github.com/haithemnasr/meshnet-ai/blob/main/src/scenarios/disaster.py"
click node_training "https://github.com/haithemnasr/meshnet-ai/blob/main/train_rl_agents.py"
click node_agents "https://github.com/haithemnasr/meshnet-ai/tree/main/models"
click node_dashboard "https://github.com/haithemnasr/meshnet-ai/blob/main/dashboard.py"
click node_visualizer "https://github.com/haithemnasr/meshnet-ai/blob/main/src/visualization/network_viz.py"
click node_benchmark "https://github.com/haithemnasr/meshnet-ai/blob/main/comparison_test.py"
click node_metrics "https://github.com/haithemnasr/meshnet-ai/blob/main/data/dashboard_metrics.json"
click node_charts "https://github.com/haithemnasr/meshnet-ai/tree/main/data/results/comparison"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_network,node_node,node_message toneBlue
class node_geo,node_disaster toneAmber
class node_flooding,node_baseline,node_rl_env,node_training,node_agents toneMint
class node_dashboard,node_visualizer,node_benchmark,node_metrics,node_charts toneRose
class node_user toneIndigo
```

## Components

### Network simulation

- [Mesh network](https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/network.py): `src/network/network.py`
- [Mesh nodes](https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/node.py): `src/network/node.py`
- [Messages](https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/message.py): `src/network/message.py`

### Geography and disasters

- [Tunisia map](https://github.com/haithemnasr/meshnet-ai/blob/main/src/scenarios/tunisia_map.py): `src/scenarios/tunisia_map.py`
- [Disaster scenarios](https://github.com/haithemnasr/meshnet-ai/blob/main/src/scenarios/disaster.py): `src/scenarios/disaster.py`

### Routing and learning

- [Flooding router](https://github.com/haithemnasr/meshnet-ai/blob/main/src/network/routing.py): `src/network/routing.py`
- [Baseline routers](https://github.com/haithemnasr/meshnet-ai/blob/main/src/ai/baseline_routers.py): `src/ai/baseline_routers.py`
- [RL environment](https://github.com/haithemnasr/meshnet-ai/blob/main/src/ai/stable_rl_env.py): `src/ai/stable_rl_env.py`
- [Agent training](https://github.com/haithemnasr/meshnet-ai/blob/main/train_rl_agents.py): `train_rl_agents.py`
- [DQN/PPO weights](https://github.com/haithemnasr/meshnet-ai/tree/main/models): `models`

### Dashboard and evaluation

- [Interactive dashboard](https://github.com/haithemnasr/meshnet-ai/blob/main/dashboard.py): `dashboard.py`
- [Network visualizer](https://github.com/haithemnasr/meshnet-ai/blob/main/src/visualization/network_viz.py): `src/visualization/network_viz.py`
- [Algorithm benchmark](https://github.com/haithemnasr/meshnet-ai/blob/main/comparison_test.py): `comparison_test.py`
- [Dashboard metrics](https://github.com/haithemnasr/meshnet-ai/blob/main/data/dashboard_metrics.json): `data/dashboard_metrics.json`
- [Comparison charts](https://github.com/haithemnasr/meshnet-ai/tree/main/data/results/comparison): `data/results/comparison`

### Other components

- **Operator**

## Connections

- Operator → Interactive dashboard: operates
- Interactive dashboard → Mesh network: builds network
- Interactive dashboard → Disaster scenarios: selects scenario
- Interactive dashboard → RL environment: runs AI routing
- Interactive dashboard → DQN/PPO weights: loads agent
- Interactive dashboard → Dashboard metrics: reads KPIs
- Interactive dashboard → Network visualizer: renders network
- Mesh network → Mesh nodes: manages nodes
- Mesh network → Messages: creates messages
- Mesh nodes → Messages: queues and receives
- Disaster scenarios → Mesh network: updates failures
- Tunisia map → Mesh network: supplies city data
- Agent training → RL environment: trains agents
- Agent training → Tunisia map: uses city data
- Agent training → DQN/PPO weights: saves weights
- RL environment → Mesh network: observes and steps
- RL environment → Messages: advances message
- Flooding router → Mesh network: forwards messages
- Baseline routers → Mesh network: routes messages
- Baseline routers → Messages: updates route
- Operator → Algorithm benchmark: runs comparison
- Algorithm benchmark → Mesh network: simulates routing
- Algorithm benchmark → Baseline routers: compares baselines
- Algorithm benchmark → DQN/PPO weights: evaluates learned agents
- Algorithm benchmark → Dashboard metrics: exports metrics
- Algorithm benchmark → Comparison charts: saves charts
- Network visualizer → Mesh network: reads network state
- Network visualizer → Messages: plots message path
