# srinivas26k/network_project architecture

> Architecture diagram of the GitHub repository srinivas26k/network_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/srinivas26k/network_project
- Repository: https://github.com/srinivas26k/network_project

## Overview

##### Project Type and Purpose
- From the README and file tree, this is a single‐page, full‐stack web application built with Streamlit.
- Purpose: Interactive network analysis for scientists—including graph generation, statistical/ML insights, visualization, and report export.

##### File Structure
- Top level:
- Python entry scripts: app.py, mod.py, mod1.py, mod2.py (mod2.py is the Streamlit launcher)
- Core modules: clustering.py, utila1.py, utils.py
- Static assets under lib/:
– tom‐select (enhanced selects)
– vis‐9.1.2 (network visualizations via vis.js)
– bindings/utils.js (custom JS helpers)
- config: requirements.txt, .devcontainer/, LICENSE, .gitignore
- Patterns:
- Layered architecture – UI (Streamlit) calls into domain modules (analysis, clustering, utils).
- Modules grouped by responsibility (visualization vs. algorithmic logic).

##### Extract Architecture Insights from README
- UI built with Streamlit, enriched by JS/CSS libs under lib/.
- Business logic leverages NetworkX, Plotly, scikit‐learn, and other ML/statistics libs.
- Data flows: Upload → Ingestion → Analysis → Visualization → Export.

a. Main Components
1. Client (Web Browser) – where the user interacts
2. Streamlit Server (mod2.py / app.py) – serves pages & handles events
3. Static Assets (lib/) – tom‐select, vis.js, CSS, JS bindings
4. Domain Modules – Python packages for:
- Data Ingestion (CSV, Excel, TXT loaders in utils.py)
- Random Graph Generator (utila1.py)
- Network Analysis (clustering.py, mod.py, mod1.py)
- ML Insights (scikit‐learn calls inside clustering.py or utils)
- Visualization (Plotly + PyVis hooks via lib/vis-9.1.2)
- Report Export (PDF/DOCX via python-docx or reportlab)
5. External Libraries – NetworkX, Plotly, scikit-learn, Pandas, Streamlit
b. Relationships & Interactions
- Browser ↔ Streamlit Server: HTTP / WebSocket events
- Streamlit Server → Static Assets: serves JS/CSS to client
- Streamlit Server → Domain Modules: function calls for data loading, analysis, ML, and export
- Domain Modules → External Libraries: invoke algorithm implementations
- Streamlit Server ↔ Export Module: triggers downloads of CSV, GraphML, PDF, DOCX
c. Architectural Patterns & Principles
- Layered Architecture (UI → Application Logic → Domain Logic → External Services)
- Modular Design: each Python module has a single responsibility (separation of concerns)
- Plugin-style static assets for UI enhancement
d. Key Technologies & Frameworks
- Python 3.8+, Streamlit (UI), NetworkX (graph operations), Plotly & vis.js (visualization), scikit‐learn (ML), Pandas (data), python-docx/reportlab (export), tom-select (UI enhancement)

##### Be Detailed and Exhaustive
- Break the backend into all individual Python modules, show which libraries each module calls.
- Data flow from “File Upload” → “utils.py loader” → “NetworkX graph object” → “Plotly/vis.js renderer” → “Browser Canvas”.
- “Random Graph Generator” and “AI-Powered Labeler” as separate submodules under Domain Logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Zone
    subgraph "Frontend Zone"
        direction TB
        Browser["Web Browser"]:::frontend
        subgraph "Static Assets" 
            direction TB
            TOM["tom-select.css"]:::frontend
            VIS["vis-network.css"]:::frontend
            JSHelpers["utils.js"]:::frontend
        end
    end

    %% Backend Zone
    subgraph "Backend Zone"
        direction TB
        StreamlitServer["Streamlit Server (mod2.py)"]:::backend
        AppEntry["App Entry Point (app.py)"]:::backend

        subgraph "Domain Modules"
            direction TB
            DataIngest["Data Ingestion Module (utils.py)"]:::domain
            RandGen["Random Graph Generator (utila1.py)"]:::domain
            NetAnalysis["Network Analysis Module (clustering.py)"]:::domain
            AuxCore["Core Logic (mod.py)"]:::domain
            AuxExt["Extended Analysis (mod1.py)"]:::domain
        end

        FileUpload[(File Upload)]:::data
        NXGraph[(NetworkX Graph Object)]:::data
        Export[(Export: CSV/GraphML/PDF/DOCX)]:::data
    end

    %% External Libraries
    subgraph "External Libraries"
        direction TB
        SL["Streamlit"]:::external
        NX["NetworkX"]:::external
        PY["Pandas"]:::external
        PL["Plotly"]:::external
        SK["scikit-learn"]:::external
        RD["python-docx/reportlab"]:::external
    end

    %% Connections
    Browser <-->|"HTTP/WebSocket"| StreamlitServer
    StreamlitServer -->|serves| TOM
    StreamlitServer -->|serves| VIS
    StreamlitServer -->|serves| JSHelpers

    FileUpload -->|upload| StreamlitServer
    StreamlitServer -->|call| DataIngest
    DataIngest -->|creates| NXGraph

    StreamlitServer -->|call| RandGen
    StreamlitServer -->|call| NetAnalysis
    StreamlitServer -->|call| AuxCore
    StreamlitServer -->|call| AuxExt

    DataIngest -->|uses| PY
    RandGen -->|uses| NX
    NetAnalysis -->|uses| NX
    NetAnalysis -->|uses| PL
    RandGen -->|uses| SK
    AuxCore -->|uses| SK
    AuxExt -->|uses| SK

    NXGraph -->|render| Browser
    StreamlitServer -->|render| PL

    StreamlitServer -->|trigger| Export
    Export -->|generate| RD

    StreamlitServer -->|uses| SL

    %% Click Events
    click StreamlitServer "https://github.com/srinivas26k/network_project/blob/main/mod2.py"
    click AppEntry "https://github.com/srinivas26k/network_project/blob/main/app.py"
    click DataIngest "https://github.com/srinivas26k/network_project/blob/main/utils.py"
    click RandGen "https://github.com/srinivas26k/network_project/blob/main/utila1.py"
    click NetAnalysis "https://github.com/srinivas26k/network_project/blob/main/clustering.py"
    click AuxCore "https://github.com/srinivas26k/network_project/blob/main/mod.py"
    click AuxExt "https://github.com/srinivas26k/network_project/blob/main/mod1.py"
    click TOM "https://github.com/srinivas26k/network_project/blob/main/lib/tom-select/tom-select.css"
    click VIS "https://github.com/srinivas26k/network_project/blob/main/lib/vis-9.1.2/vis-network.css"
    click JSHelpers "https://github.com/srinivas26k/network_project/blob/main/lib/bindings/utils.js"
    click SL "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click NX "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click PY "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click PL "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click SK "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click RD "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click SL "https://github.com/srinivas26k/network_project/blob/main/requirements.txt"
    click AppEntry "https://github.com/srinivas26k/network_project/blob/main/README.md"
    click Sl "https://github.com/srinivas26k/network_project/blob/main/info.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#DFF5D9,stroke:#28a745,color:#28a745;
    classDef domain fill:#FFE7C1,stroke:#FF8C00,color:#FF8C00;
    classDef external fill:#E2E2E2,stroke:#6A737D,color:#6A737D;
    classDef data fill:#FFF5C3,stroke:#DBAB09,color:#DBAB09;
```
