# gasimelzamzamy/sonar architecture

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

- Interactive diagram: https://gitdiagram.com/gasimelzamzamy/sonar
- Repository: https://github.com/gasimelzamzamy/sonar

## Overview

This Flask social-network analysis application models users and weighted, undirected connections, then presents network visualizations and analysis through a web interface. The principal workflow is user request → Flask routes → persisted graph/model → selected analysis or graph operation → response and visualization. Documented capabilities include traversal, shortest paths, coloring, centrality, graph editing, and JSON/CSV import and export. The excerpts show route dispatch, graph persistence, algorithms, and rendering; some route details and template contents are unsampled, so uncertain wiring is omitted.

Main entry points: [`app/routes.py`](https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py) (Routes and API), [`app/models.py`](https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py) (NetworkX graph), [`app/algorithms.py`](https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py) (Algorithm dispatch), [`app/__init__.py`](https://github.com/gasimelzamzamy/sonar/blob/main/app/__init__.py) (Flask app setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["Flask app setup<br/>[__init__.py]"]
  node_routes["Routes and API<br/>[routes.py]"]
  node_template["Web template<br/>[base.html]"]
  node_visualization["Interactive graph rendering<br/>[routes.py]"]
end

subgraph group_domain["Graph domain"]
  node_model["Social graph model<br/>[models.py]"]
  node_usernode["User and edge model<br/>[models.py]"]
  node_network["NetworkX graph<br/>[models.py]"]
end

subgraph group_analysis["Network analysis"]
  node_algorithms["Algorithm dispatch<br/>[algorithms.py]"]
  node_paths["Dijkstra and A*<br/>[algorithms.py]"]
  node_traversal["BFS and DFS<br/>[algorithms.py]"]
  node_coloring["Welsh–Powell coloring<br/>[algorithms.py]"]
  node_centrality["Degree centrality<br/>[models.py]"]
end

subgraph group_dataio["Data management"]
  node_store[("Persisted graph<br/>[sonar_data.json]")]
  node_transfer["JSON and CSV transfer<br/>[routes.py]"]
end

node_user(("User"))
node_pyvis["PyVis renderer"]

node_user -->|"opens app"| node_app
node_app -->|"registers routes"| node_routes
node_user -->|"sends requests"| node_routes
node_routes -->|"renders UI"| node_template
node_routes -->|"loads or edits"| node_model
node_model -->|"manages entities"| node_usernode
node_model -->|"updates graph"| node_network
node_model -->|"reads and writes"| node_store
node_routes -->|"dispatches analysis"| node_algorithms
node_algorithms -->|"runs paths"| node_paths
node_algorithms -->|"runs traversal"| node_traversal
node_algorithms -->|"runs coloring"| node_coloring
node_paths -->|"queries graph"| node_network
node_traversal -->|"traverses graph"| node_network
node_coloring -->|"colors graph"| node_network
node_routes -->|"requests influencers"| node_centrality
node_centrality -->|"measures degrees"| node_network
node_routes -->|"handles transfer"| node_transfer
node_transfer -->|"imports or exports"| node_model
node_routes -->|"requests graph HTML"| node_visualization
node_visualization -->|"renders graph data"| node_network
node_visualization -->|"generates HTML"| node_pyvis
node_routes -->|"returns results"| node_user

click node_app "https://github.com/gasimelzamzamy/sonar/blob/main/app/__init__.py"
click node_routes "https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py"
click node_template "https://github.com/gasimelzamzamy/sonar/blob/main/app/templates/base.html"
click node_visualization "https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py"
click node_model "https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py"
click node_usernode "https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py"
click node_network "https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py"
click node_store "https://github.com/gasimelzamzamy/sonar/blob/main/data/sonar_data.json"
click node_algorithms "https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py"
click node_paths "https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py"
click node_traversal "https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py"
click node_coloring "https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py"
click node_centrality "https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py"
click node_transfer "https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py"

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_app,node_routes,node_template,node_visualization,node_user toneBlue
class node_model,node_usernode,node_network toneAmber
class node_algorithms,node_paths,node_traversal,node_coloring,node_centrality toneMint
class node_store,node_transfer toneRose
class node_pyvis toneIndigo
```

## Components

### Web interface

- [Flask app setup](https://github.com/gasimelzamzamy/sonar/blob/main/app/__init__.py): `app/__init__.py`
- [Routes and API](https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py): `app/routes.py`
- [Web template](https://github.com/gasimelzamzamy/sonar/blob/main/app/templates/base.html): `app/templates/base.html`
- [Interactive graph rendering](https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py): `app/routes.py`

### Graph domain

- [Social graph model](https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py): `app/models.py`
- [User and edge model](https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py): `app/models.py`
- [NetworkX graph](https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py): `app/models.py`

### Network analysis

- [Algorithm dispatch](https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py): `app/algorithms.py`
- [Dijkstra and A*](https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py): `app/algorithms.py`
- [BFS and DFS](https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py): `app/algorithms.py`
- [Welsh–Powell coloring](https://github.com/gasimelzamzamy/sonar/blob/main/app/algorithms.py): `app/algorithms.py`
- [Degree centrality](https://github.com/gasimelzamzamy/sonar/blob/main/app/models.py): `app/models.py`

### Data management

- [Persisted graph](https://github.com/gasimelzamzamy/sonar/blob/main/data/sonar_data.json): `data/sonar_data.json`
- [JSON and CSV transfer](https://github.com/gasimelzamzamy/sonar/blob/main/app/routes.py): `app/routes.py`

### Other components

- **User**
- **PyVis renderer**

## Connections

- User → Flask app setup: opens app
- Flask app setup → Routes and API: registers routes
- User → Routes and API: sends requests
- Routes and API → Web template: renders UI
- Routes and API → Social graph model: loads or edits
- Social graph model → User and edge model: manages entities
- Social graph model → NetworkX graph: updates graph
- Social graph model → Persisted graph: reads and writes
- Routes and API → Algorithm dispatch: dispatches analysis
- Algorithm dispatch → Dijkstra and A*: runs paths
- Algorithm dispatch → BFS and DFS: runs traversal
- Algorithm dispatch → Welsh–Powell coloring: runs coloring
- Dijkstra and A* → NetworkX graph: queries graph
- BFS and DFS → NetworkX graph: traverses graph
- Welsh–Powell coloring → NetworkX graph: colors graph
- Routes and API → Degree centrality: requests influencers
- Degree centrality → NetworkX graph: measures degrees
- Routes and API → JSON and CSV transfer: handles transfer
- JSON and CSV transfer → Social graph model: imports or exports
- Routes and API → Interactive graph rendering: requests graph HTML
- Interactive graph rendering → NetworkX graph: renders graph data
- Interactive graph rendering → PyVis renderer: generates HTML
- Routes and API → User: returns results
