# akash-selvaraj/sigil-network-mesh-maker architecture

> Architecture diagram of the GitHub repository akash-selvaraj/sigil-network-mesh-maker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akash-selvaraj/sigil-network-mesh-maker
- Repository: https://github.com/akash-selvaraj/sigil-network-mesh-maker

## Overview

##### Project type and purpose
- This is a full-stack web application called “Sigil”:
- Frontend: Next.js + React + Tailwind CSS
- Backend: Python server (Flask or FastAPI in app.py) running Reinforcement Learning (RL) agents
- Purpose: In flood scenarios, collect and analyze mobile network speed data using RL agents to suggest optimal hotspots, then display the results on an interactive map.

##### File structure
- Top level
- Configuration: .eslintrc.json, tsconfig.json, tailwind.config.ts, next.config.mjs, postcss.config.mjs
- Project Document, README, .gitignore, VSCode settings
- backend/
- app.py – Python server entry point, defines HTTP endpoints
- dqn_agent.py, q_learning_agent.py – two RL algorithms for hotspot selection
- image.py – utilities for generating or processing heatmap images
- requirements.txt – Python dependencies
- src/app/ (Next.js “app router”)
- layout.tsx – shared page layout
- page.tsx – main UI, fetches data from backend
- Components/HeatMap.tsx – displays the RL-generated heatmap overlay
- Components/SubmitData.tsx – form or button to trigger data collection or analysis
- globals.css, fonts/ – styling
- package.json / lockfiles – Node dependencies (axios, next, react, tailwind, etc.)

##### Extract architecture insights from README
- Frontend communicates over HTTP (REST or JSON) with the Python backend.
- RL agents are invoked on-demand to analyze new data or re-train policies.
- No external database mentioned; data persistence may be in-memory or flat files.
- Emphasis on real-time responsiveness and visual map overlays.

##### Main components & their interactions
a. User’s Web Browser (React/Next.js)
b. Next.js Frontend Server (Node.js)
c. Python RL Backend Server (Flask/FastAPI)
d. RL Modules
- Q-Learning Agent
- DQN Agent
e. Heatmap Generator (image.py)
f. (Optional) Data Store or Cache (in-memory or disk)
g. External Services (e.g., mobile speed API, if any)
h. Network (HTTP/JSON)

- Data flow:
1. User visits Next.js UI → Next.js serves React page
2. User triggers data fetch/analysis (SubmitData) → Frontend issues HTTP POST/GET to backend endpoint (/analyze, /heatmap)
3. Backend app.py receives request → selects RL agent (DQN or Q-Learning) → processes input data → generates heatmap image or JSON of hotspot coordinates
4. Backend responds with JSON or URL to generated heatmap
5. Frontend receives response → HeatMap component renders overlay
6. User sees updated hotspot suggestions

##### Architectural patterns & design principles
- Separation of concerns: UI vs. analysis logic
- Modular RL code: interchangeable agent modules
- Stateless HTTP API for triggering analysis
- Component-based frontend (Next.js app router + React)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    Browser["User's Browser"]:::ui

    %% Frontend Layer
    subgraph "Frontend Layer"
        NextServer["Next.js Frontend (Node.js)"]:::api
        HeatMap["HeatMap Component"]:::ui
        SubmitData["SubmitData Component"]:::ui
        Layout["layout.tsx"]:::ui
        Page["page.tsx"]:::ui
        Styles["globals.css & fonts"]:::ui
        ConfigFE["Configuration Files"]:::config
    end

    %% Backend Layer
    subgraph "Backend Layer"
        PythonServer["Python RL Backend (Flask/FastAPI)"]:::api
        ReqBackend["requirements.txt"]:::config
        subgraph "RL Modules"
            QAgent["Q-Learning Agent"]:::compute
            DQNAgent["DQN Agent"]:::compute
            ImageGen["Heatmap Generator"]:::compute
        end
    end

    %% Data Flows
    Browser -->|"loads UI (HTTP/JSON)"| NextServer
    Browser -->|"interacts"| SubmitData
    SubmitData -->|"POST /analyze"| NextServer
    NextServer -->|"POST /analyze (HTTP/JSON)"| PythonServer
    PythonServer -->|"selectAgent()"| QAgent
    PythonServer -->|"selectAgent()"| DQNAgent
    QAgent -->|"generate heatmap data"| ImageGen
    DQNAgent -->|"generate heatmap data"| ImageGen
    ImageGen -->|"heatmap JSON/URL"| PythonServer
    PythonServer -->|"response (HTTP/JSON)"| NextServer
    NextServer -->|"render overlay"| HeatMap
    NextServer -->|"use layout"| Layout
    NextServer -->|"use page.tsx"| Page
    NextServer -->|"use styles/fonts"| Styles
    ConfigFE --- NextServer
    ReqBackend --- PythonServer

    %% Click Events
    click NextServer "https://github.com/akash-selvaraj/sigil-network-mesh-maker/tree/master/src/app/"
    click ConfigFE "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/package.json"
    click Layout "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/src/app/layout.tsx"
    click Page "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/src/app/page.tsx"
    click HeatMap "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/src/app/Components/HeatMap.tsx"
    click SubmitData "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/src/app/Components/SubmitData.tsx"
    click Styles "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/src/app/globals.css"
    click PythonServer "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/backend/app.py"
    click ReqBackend "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/backend/requirements.txt"
    click QAgent "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/backend/q_learning_agent.py"
    click DQNAgent "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/backend/dqn_agent.py"
    click ImageGen "https://github.com/akash-selvaraj/sigil-network-mesh-maker/blob/master/backend/image.py"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef api fill:#D0F5D6,stroke:#2c662d,color:#2c662d
    classDef compute fill:#FFE0B2,stroke:#e65100,color:#e65100
    classDef config fill:#EEEEEE,stroke:#888888,color:#555555
```
