# sajanibandara/final-year-project architecture

> Architecture diagram of the GitHub repository sajanibandara/final-year-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sajanibandara/final-year-project
- Repository: https://github.com/sajanibandara/final-year-project

## Overview

MOBIGUARD simulates attacks against a mobility-aware software-defined vehicular network, detects them with signature-based defenses, and exposes results through an analytics GUI. The main workflow is simulation → attack/detection events and metrics → GUI analysis; separate ML pipelines support detection research and an optional Fabric bridge records selected events on-chain. The README documents the simulation capabilities, while source excerpts show GUI service routing and bridge dispatch. Unsampled subsystem links are included only where the README supports them; other uncertain wiring is omitted.

Main entry points: [`scratch/routing.cc`](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/routing.cc) (NS-3 Simulation), [`gui/backend/service.py`](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/service.py) (Results Service), [`gui/frontend/js/app.js`](https://github.com/sajanibandara/final-year-project/blob/n12/gui/frontend/js/app.js) (Dashboard UI), [`gui/backend/parser.py`](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/parser.py) (CSV Parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Network Simulation"]
  node_routing["NS-3 Simulation<br/>[routing.cc]"]
  node_mobility["Mobility Optimization<br/>[optimization.py]"]
  node_attackstate["Attack Setup"]
  node_results["Metrics CSVs<br/>[routing.cc]"]
end

subgraph group_defense["Detection and Defense"]
  node_delay["Time-Delay Attacks"]
  node_tcam["TCAM Attacks"]
  node_hf["Forwarding Attacks<br/>[hf_attack_helper.h]"]
  node_signatures["Detection Signatures<br/>[s1_detection.h]"]
  node_crypto["Crypto Integrity<br/>[crypto_layer.h]"]
  node_blockchainstub["Blockchain Simulation"]
end

subgraph group_gui["Results Dashboard"]
  node_frontend["Dashboard UI<br/>[app.js]"]
  node_lab["Attack Lab<br/>[lab.js]"]
  node_guiapi["GUI API<br/>[app.py]"]
  node_service["Results Service<br/>[service.py]"]
  node_catalog["Run Catalog<br/>[catalog.py]"]
  node_parser["CSV Parser<br/>[parser.py]"]
  node_schema["Metric Schema<br/>[schema.py]"]
  node_snapshot["Snapshot Service"]
end

subgraph group_ml["Detection Research"]
  node_federated["Federated LSTM<br/>[fed_aggregator.py]"]
  node_preprocessor["LSTM Preprocessing<br/>[preprocessor.py]"]
  node_sfto["SFTO Benchmark<br/>[run_pipeline.py]"]
end

subgraph group_blockchain["Fabric Audit"]
  node_bridge["Fabric Bridge<br/>[index.js]"]
  node_tailers["CSV Tailers<br/>[trust.js]"]
  node_fabricclient["Fabric Client<br/>[fabric-client.js]"]
end

node_operator(("Experimenter"))
node_fabric[("Hyperledger Fabric")]

node_operator -->|"runs experiments"| node_routing
node_routing -.->|"uses route optimization"| node_mobility
node_routing -->|"arms attacks"| node_attackstate
node_routing -->|"simulates delays"| node_delay
node_routing -->|"simulates TCAM attacks"| node_tcam
node_routing -->|"simulates forwarding attacks"| node_hf
node_routing -->|"runs detection signatures"| node_signatures
node_routing -->|"applies integrity layer"| node_crypto
node_routing -->|"records simulation events"| node_blockchainstub
node_routing -->|"writes metrics"| node_results
node_operator -->|"views results"| node_frontend
node_frontend -->|"initializes panel"| node_lab
node_frontend -.->|"uses API routes"| node_guiapi
node_guiapi -->|"delegates requests"| node_service
node_service -->|"indexes runs"| node_catalog
node_service -->|"parses run files"| node_parser
node_parser -->|"validates layout"| node_schema
node_service -.->|"supports snapshot mode"| node_snapshot
node_results -->|"catalogs CSV files"| node_catalog
node_results -->|"decodes selected runs"| node_parser
node_preprocessor -->|"prepares training data"| node_federated
node_operator -->|"runs benchmark"| node_sfto
node_bridge -->|"starts tailers"| node_tailers
node_bridge -->|"registers network"| node_fabricclient
node_tailers -->|"submits and queries"| node_fabricclient
node_fabricclient -->|"invokes transactions"| node_fabric

click node_routing "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/routing.cc"
click node_mobility "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/optimization.py"
click node_attackstate "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/attack_declaration.h"
click node_delay "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/selective_time_delay.h"
click node_tcam "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/tcam_attack_helper.h"
click node_hf "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/hf_attack_helper.h"
click node_signatures "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/s1_detection.h"
click node_crypto "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/crypto_layer.h"
click node_blockchainstub "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/bc_blockchain_helper.h"
click node_results "https://github.com/sajanibandara/final-year-project/blob/n12/scratch/routing.cc"
click node_frontend "https://github.com/sajanibandara/final-year-project/blob/n12/gui/frontend/js/app.js"
click node_lab "https://github.com/sajanibandara/final-year-project/blob/n12/gui/frontend/js/lab.js"
click node_guiapi "https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/app.py"
click node_service "https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/service.py"
click node_catalog "https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/catalog.py"
click node_parser "https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/parser.py"
click node_schema "https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/schema.py"
click node_snapshot "https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/snapshot_service.py"
click node_federated "https://github.com/sajanibandara/final-year-project/blob/n12/lstm_pipeline/src/fed_aggregator.py"
click node_preprocessor "https://github.com/sajanibandara/final-year-project/blob/n12/lstm_pipeline/src/preprocessor.py"
click node_sfto "https://github.com/sajanibandara/final-year-project/blob/n12/sfto_pipeline/src/run_pipeline.py"
click node_bridge "https://github.com/sajanibandara/final-year-project/blob/n12/blockchain/bridge/index.js"
click node_tailers "https://github.com/sajanibandara/final-year-project/blob/n12/blockchain/bridge/tailers/trust.js"
click node_fabricclient "https://github.com/sajanibandara/final-year-project/blob/n12/blockchain/bridge/fabric-client.js"

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_routing,node_mobility,node_attackstate,node_results toneBlue
class node_delay,node_tcam,node_hf,node_signatures,node_crypto,node_blockchainstub,node_fabric toneAmber
class node_frontend,node_lab,node_guiapi,node_service,node_catalog,node_parser,node_schema,node_snapshot toneMint
class node_federated,node_preprocessor,node_sfto toneRose
class node_bridge,node_tailers,node_fabricclient,node_operator toneIndigo
```

## Components

### Network Simulation

- [NS-3 Simulation](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/routing.cc): `scratch/routing.cc`
- [Mobility Optimization](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/optimization.py): `scratch/optimization.py`
- [Attack Setup](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/attack_declaration.h): `scratch/attack_declaration.h`
- [Metrics CSVs](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/routing.cc): `scratch/routing.cc`

### Detection and Defense

- [Time-Delay Attacks](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/selective_time_delay.h): `scratch/selective_time_delay.h`
- [TCAM Attacks](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/tcam_attack_helper.h): `scratch/tcam_attack_helper.h`
- [Forwarding Attacks](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/hf_attack_helper.h): `scratch/hf_attack_helper.h`
- [Detection Signatures](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/s1_detection.h): `scratch/s1_detection.h`
- [Crypto Integrity](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/crypto_layer.h): `scratch/crypto_layer.h`
- [Blockchain Simulation](https://github.com/sajanibandara/final-year-project/blob/n12/scratch/bc_blockchain_helper.h): `scratch/bc_blockchain_helper.h`

### Results Dashboard

- [Dashboard UI](https://github.com/sajanibandara/final-year-project/blob/n12/gui/frontend/js/app.js): `gui/frontend/js/app.js`
- [Attack Lab](https://github.com/sajanibandara/final-year-project/blob/n12/gui/frontend/js/lab.js): `gui/frontend/js/lab.js`
- [GUI API](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/app.py): `gui/backend/app.py`
- [Results Service](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/service.py): `gui/backend/service.py`
- [Run Catalog](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/catalog.py): `gui/backend/catalog.py`
- [CSV Parser](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/parser.py): `gui/backend/parser.py`
- [Metric Schema](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/schema.py): `gui/backend/schema.py`
- [Snapshot Service](https://github.com/sajanibandara/final-year-project/blob/n12/gui/backend/snapshot_service.py): `gui/backend/snapshot_service.py`

### Detection Research

- [Federated LSTM](https://github.com/sajanibandara/final-year-project/blob/n12/lstm_pipeline/src/fed_aggregator.py): `lstm_pipeline/src/fed_aggregator.py`
- [LSTM Preprocessing](https://github.com/sajanibandara/final-year-project/blob/n12/lstm_pipeline/src/preprocessor.py): `lstm_pipeline/src/preprocessor.py`
- [SFTO Benchmark](https://github.com/sajanibandara/final-year-project/blob/n12/sfto_pipeline/src/run_pipeline.py): `sfto_pipeline/src/run_pipeline.py`

### Fabric Audit

- [Fabric Bridge](https://github.com/sajanibandara/final-year-project/blob/n12/blockchain/bridge/index.js): `blockchain/bridge/index.js`
- [CSV Tailers](https://github.com/sajanibandara/final-year-project/blob/n12/blockchain/bridge/tailers/trust.js): `blockchain/bridge/tailers/trust.js`
- [Fabric Client](https://github.com/sajanibandara/final-year-project/blob/n12/blockchain/bridge/fabric-client.js): `blockchain/bridge/fabric-client.js`

### Other components

- **Experimenter**
- **Hyperledger Fabric**

## Connections

- Experimenter → NS-3 Simulation: runs experiments (evidence: `README.md`)
- NS-3 Simulation → Mobility Optimization: uses route optimization
- NS-3 Simulation → Attack Setup: arms attacks (evidence: `README.md`)
- NS-3 Simulation → Time-Delay Attacks: simulates delays (evidence: `README.md`)
- NS-3 Simulation → TCAM Attacks: simulates TCAM attacks (evidence: `README.md`)
- NS-3 Simulation → Forwarding Attacks: simulates forwarding attacks (evidence: `README.md`)
- NS-3 Simulation → Detection Signatures: runs detection signatures (evidence: `README.md`)
- NS-3 Simulation → Crypto Integrity: applies integrity layer (evidence: `README.md`)
- NS-3 Simulation → Blockchain Simulation: records simulation events (evidence: `README.md`)
- NS-3 Simulation → Metrics CSVs: writes metrics (evidence: `README.md`)
- Experimenter → Dashboard UI: views results (evidence: `gui/frontend/js/app.js`)
- Dashboard UI → Attack Lab: initializes panel (evidence: `gui/frontend/js/app.js`)
- Dashboard UI → GUI API: uses API routes
- GUI API → Results Service: delegates requests (evidence: `gui/backend/app.py`)
- Results Service → Run Catalog: indexes runs (evidence: `gui/backend/service.py`)
- Results Service → CSV Parser: parses run files (evidence: `gui/backend/service.py`)
- CSV Parser → Metric Schema: validates layout (evidence: `gui/backend/parser.py`)
- Results Service → Snapshot Service: supports snapshot mode (evidence: `gui/backend/snapshot_service.py`)
- Metrics CSVs → Run Catalog: catalogs CSV files (evidence: `gui/backend/catalog.py`)
- Metrics CSVs → CSV Parser: decodes selected runs
- LSTM Preprocessing → Federated LSTM: prepares training data (evidence: `lstm_pipeline/src/fed_aggregator.py`)
- Experimenter → SFTO Benchmark: runs benchmark (evidence: `sfto_pipeline/src/run_pipeline.py`)
- Fabric Bridge → CSV Tailers: starts tailers (evidence: `blockchain/bridge/index.js`)
- Fabric Bridge → Fabric Client: registers network (evidence: `blockchain/bridge/index.js`)
- CSV Tailers → Fabric Client: submits and queries (evidence: `blockchain/bridge/tailers/trust.js`)
- Fabric Client → Hyperledger Fabric: invokes transactions (evidence: `blockchain/bridge/fabric-client.js`)
