# lola-sanchez-arup/city2graph-primeras-pruebas architecture

> Architecture diagram of the GitHub repository lola-sanchez-arup/city2graph-primeras-pruebas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lola-sanchez-arup/city2graph-primeras-pruebas
- Repository: https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas

## Overview

##### Project Type and Purpose
- This is an open-source geospatial data processing & graph-construction pipeline aimed at transforming urban resource datasets (fire hydrants, swimming pools, lagoons, etc.) into analyzable graphs for emergency services planning, risk analysis, route optimization, and interactive mapping.
- It is not a traditional full-stack app; rather it is a data-centric tool that reads GeoJSON sources, applies spatial graph algorithms, and outputs serialized graphs and visualizations.

##### File Structure Analysis
- data/
- Raw GeoJSON files (hidrantes.geojson, piscinas.geojson, laguna.geojson).
- Placeholder for future datasets (otros_datasets/).
- scripts/
- conexion_hidrantes_piscinas.py → builds a KNN graph via City2Graph + PyG.
- conexion_hidrantes_laguna_folium.py → builds a proximity graph via NetworkX + Folium.
- outputs/
- Serialized graph artifacts (.pt, .json, .pt).
- Static/interactive visualizations (.png, .html).
- requirements.txt → defines Python dependencies (GeoPandas, City2Graph, NetworkX, torch-geometric, Folium, etc.)

##### Key Architectural Patterns & Components
a. Data Ingestion Layer
- GeoPandas reads GeoJSON → produces GeoDataFrames.
b. Graph Construction Layer
- City2Graph for K-nearest neighbors graph.
- NetworkX for distance-threshold proximity graph.
c. Feature Engineering & Serialization
- StandardScaler for normalization.
- torch_geometric.data.Data for PyG graph objects.
- JSON for categorical mappings.
d. Visualization Layer
- Matplotlib/seaborn (static PNG).
- Folium (interactive HTML).
e. Artifacts Store
- outputs/ directory as a data sink.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Data Sources Layer
    subgraph "Data Sources"
        direction TB
        DS["data/"]:::data
        HGeo["hidrantes.geojson"]:::data
        PGeo["piscinas.geojson"]:::data
        LGeo["laguna.geojson"]:::data
        DS --> HGeo
        DS --> PGeo
        DS --> LGeo
    end

    %% New Dataset Connector
    ND["New Dataset Connector"]:::data --> DS

    %% Processing Layer
    subgraph "Processing Modules"
        direction TB
        KP["conexion_hidrantes_piscinas.py"]:::proc
        KL["conexion_hidrantes_laguna_folium.py"]:::proc
    end

    HGeo -->|reads GeoJSON → GeoDataFrame| KP
    PGeo -->|reads GeoJSON → GeoDataFrame| KP
    HGeo -->|reads GeoJSON → GeoDataFrame| KL
    LGeo -->|reads GeoJSON → GeoDataFrame| KL

    %% Tools & Frameworks
    subgraph "Libraries & Frameworks"
        direction TB
        GP["GeoPandas"]:::lib
        CG["City2Graph"]:::lib
        NX["NetworkX"]:::lib
        SS["StandardScaler"]:::lib
        TG["PyTorch Geometric"]:::lib
        MF["Matplotlib/Seaborn"]:::lib
        FO["Folium"]:::lib
        RT["requirements.txt"]:::config
    end

    KP -->|KNN graph| CG
    KP -->|uses| GP
    KP -->|normalizes| SS
    KP -->|serializes| TG
    KP -->|plots static| MF

    KL -->|proximity graph| NX
    KL -->|uses| GP
    KL -->|generates map| FO

    KP --> RT
    KL --> RT
    GP --> RT
    CG --> RT
    NX --> RT
    SS --> RT
    TG --> RT
    MF --> RT
    FO --> RT

    %% Visualization & Artifacts Store
    subgraph "Artifacts Store / Outputs"
        direction TB
        OS["outputs/"]:::output
        ScalerPT["scaler.pt"]:::output
        GraphPT["hidrantes_piscinas_graph.pt"]:::output
        JSONMap["category_mappings.json"]:::output
        PNGs["static_plots.png"]:::output
        HTMLMap["mapa_hidrantes_laguna.html"]:::output
    end

    KP -->|edge_index, x → .pt| GraphPT
    KP -->|scaler → .pt| ScalerPT
    KP -->|mappings → .json| JSONMap
    KP -->|plot → .png| PNGs
    KL -->|map → .html| HTMLMap

    ScalerPT --> OS
    GraphPT --> OS
    JSONMap --> OS
    PNGs --> OS
    HTMLMap --> OS

    %% Click Events
    click DS "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/tree/main/data/"
    click HGeo "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/data/hidrantes.geojson"
    click PGeo "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/data/piscinas.geojson"
    click LGeo "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/data/laguna.geojson"
    click KP "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/scripts/conexion_hidrantes_piscinas.py"
    click KL "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/scripts/conexion_hidrantes_laguna_folium.py"
    click ScalerPT "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/outputs/scaler.pt"
    click GraphPT "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/outputs/hidrantes_piscinas_graph.pt"
    click JSONMap "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/outputs/category_mappings.json"
    click HTMLMap "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/outputs/mapa_hidrantes_laguna.html"
    click OS "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/tree/main/outputs/"
    click RT "https://github.com/lola-sanchez-arup/city2graph-primeras-pruebas/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#AED6F1,stroke:#2980B9,color:#154360,stroke-width:2px
    classDef proc fill:#A9DFBF,stroke:#27AE60,color:#145A32,stroke-width:2px
    classDef lib fill:#F9E79F,stroke:#D68910,color:#7D6608,stroke-width:2px
    classDef output fill:#D7BDE2,stroke:#8E44AD,color:#4A235A,stroke-width:2px
    classDef config fill:#F5B7B1,stroke:#C0392B,color:#78281F,stroke-width:2px
```
