# alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph architecture

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

- Interactive diagram: https://gitdiagram.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph
- Repository: https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph

## Overview

This repository implements an ETL and semantic-integration workflow for Barcelona Bicing and CAMS air-quality data. A capture script requests both feeds and records raw payloads and provenance; processing then normalizes and validates each source, performs spatial and time-based matching, and writes integrated CSV datasets. The project also documents an RDF/OWL/SOSA vocabulary and a reproducible analysis notebook. The package modules are excerpted, but the ontology and notebook contents are not; links to those capabilities rely on README statements, so their internal behavior is not expanded here.

Main entry points: [`E2_extraccion/scripts/procesar_datos.py`](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/scripts/procesar_datos.py) (Processing runner), [`E2_extraccion/notebooks/E2_extraccion_limpieza.ipynb`](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/notebooks/E2_extraccion_limpieza.ipynb) (Reproducible analysis), [`E2_extraccion/src/bcn_kg/extraccion.py`](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/extraccion.py) (Feed extraction), [`E2_extraccion/modelo/vocab.ttl`](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/vocab.ttl) (RDF vocabulary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Data capture"]
  node_capture_runner["Capture cycle<br/>[capturar.py]"]
  node_extract["Feed extraction<br/>[extraccion.py]"]
  node_raw_data[("Raw JSON feeds")]
  node_provenance["Capture provenance<br/>[procedencia.csv]"]
end

subgraph group_transform["ETL and linking"]
  node_process_runner["Processing runner<br/>[procesar_datos.py]"]
  node_clean["Normalize and validate<br/>[limpieza.py]"]
  node_spatial_link["Spatial station link<br/>[enlace.py]"]
  node_temporal_link["Temporal observation link<br/>[enlace.py]"]
  node_processed_data[("Processed datasets")]
end

subgraph group_semantic["Semantic model"]
  node_ontology["RDF vocabulary<br/>[vocab.ttl]"]
  node_ontology_rationale["Ontology specification"]
  node_field_mapping["Semantic field mapping<br/>[mapeo_campos.csv]"]
  node_diagram["Model diagram<br/>[diagrama.py]"]
end

subgraph group_analysis["Analysis outputs"]
  node_notebook["Reproducible analysis"]
  node_report["Analysis report"]
end

node_operator(("Pipeline operator"))
node_citybikes{{"CityBikes API"}}
node_openmeteo{{"Open-Meteo API"}}

node_operator -->|"starts"| node_capture_runner
node_capture_runner -->|"calls"| node_extract
node_extract -->|"requests feed"| node_citybikes
node_extract -->|"requests feed"| node_openmeteo
node_extract -->|"writes raw JSON"| node_raw_data
node_capture_runner -->|"records capture"| node_provenance
node_operator -.->|"starts"| node_process_runner
node_process_runner -->|"reads feeds"| node_raw_data
node_process_runner -->|"calls"| node_clean
node_process_runner -->|"calls"| node_spatial_link
node_process_runner -->|"calls"| node_temporal_link
node_process_runner -->|"writes CSVs"| node_processed_data
node_notebook -->|"uses extraction"| node_extract
node_notebook -->|"uses cleaning"| node_clean
node_notebook -->|"uses linking"| node_spatial_link
node_notebook -->|"documents vocabulary"| node_ontology
node_ontology_rationale -->|"specifies model"| node_ontology
node_field_mapping -->|"maps terms"| node_ontology
node_diagram -->|"illustrates vocabulary"| node_ontology
node_notebook -->|"exports report"| node_report

click node_capture_runner "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/scripts/capturar.py"
click node_extract "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/extraccion.py"
click node_raw_data "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/tree/main/E2_extraccion/data/raw"
click node_provenance "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/data/processed/procedencia.csv"
click node_process_runner "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/scripts/procesar_datos.py"
click node_clean "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/limpieza.py"
click node_spatial_link "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/enlace.py"
click node_temporal_link "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/enlace.py"
click node_processed_data "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/tree/main/E2_extraccion/data/processed"
click node_ontology "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/vocab.ttl"
click node_ontology_rationale "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/modelo_tentativo.md"
click node_field_mapping "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/mapeo_campos.csv"
click node_diagram "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/diagrama.py"
click node_notebook "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/notebooks/E2_extraccion_limpieza.ipynb"
click node_report "https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/notebooks/E2_extraccion_limpieza.html"

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_capture_runner,node_extract,node_raw_data,node_provenance toneBlue
class node_process_runner,node_clean,node_spatial_link,node_temporal_link,node_processed_data toneAmber
class node_ontology,node_ontology_rationale,node_field_mapping,node_diagram,node_citybikes,node_openmeteo toneMint
class node_notebook,node_report toneRose
class node_operator toneIndigo
```

## Components

### Data capture

- [Capture cycle](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/scripts/capturar.py): `E2_extraccion/scripts/capturar.py`
- [Feed extraction](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/extraccion.py): `E2_extraccion/src/bcn_kg/extraccion.py`
- [Raw JSON feeds](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/tree/main/E2_extraccion/data/raw): `E2_extraccion/data/raw`
- [Capture provenance](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/data/processed/procedencia.csv): `E2_extraccion/data/processed/procedencia.csv`

### ETL and linking

- [Processing runner](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/scripts/procesar_datos.py): `E2_extraccion/scripts/procesar_datos.py`
- [Normalize and validate](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/limpieza.py): `E2_extraccion/src/bcn_kg/limpieza.py`
- [Spatial station link](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/enlace.py): `E2_extraccion/src/bcn_kg/enlace.py`
- [Temporal observation link](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/enlace.py): `E2_extraccion/src/bcn_kg/enlace.py`
- [Processed datasets](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/tree/main/E2_extraccion/data/processed): `E2_extraccion/data/processed`

### Semantic model

- [RDF vocabulary](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/vocab.ttl): `E2_extraccion/modelo/vocab.ttl`
- [Ontology specification](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/modelo_tentativo.md): `E2_extraccion/modelo/modelo_tentativo.md`
- [Semantic field mapping](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/modelo/mapeo_campos.csv): `E2_extraccion/modelo/mapeo_campos.csv`
- [Model diagram](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/src/bcn_kg/diagrama.py): `E2_extraccion/src/bcn_kg/diagrama.py`

### Analysis outputs

- [Reproducible analysis](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/notebooks/E2_extraccion_limpieza.ipynb): `E2_extraccion/notebooks/E2_extraccion_limpieza.ipynb`
- [Analysis report](https://github.com/alexdgutierrezcordova-nila/smartcity-bcn-knowledge-graph/blob/main/E2_extraccion/notebooks/E2_extraccion_limpieza.html): `E2_extraccion/notebooks/E2_extraccion_limpieza.html`

### Other components

- **Pipeline operator**
- **CityBikes API**
- **Open-Meteo API**

## Connections

- Pipeline operator → Capture cycle: starts (evidence: `E2_extraccion/scripts/capturar.py`)
- Capture cycle → Feed extraction: calls (evidence: `E2_extraccion/scripts/capturar.py`)
- Feed extraction → CityBikes API: requests feed (evidence: `E2_extraccion/src/bcn_kg/extraccion.py`)
- Feed extraction → Open-Meteo API: requests feed (evidence: `E2_extraccion/src/bcn_kg/extraccion.py`)
- Feed extraction → Raw JSON feeds: writes raw JSON (evidence: `E2_extraccion/src/bcn_kg/extraccion.py`)
- Capture cycle → Capture provenance: records capture (evidence: `E2_extraccion/scripts/capturar.py`)
- Pipeline operator → Processing runner: starts
- Processing runner → Raw JSON feeds: reads feeds (evidence: `E2_extraccion/scripts/procesar_datos.py`)
- Processing runner → Normalize and validate: calls (evidence: `E2_extraccion/scripts/procesar_datos.py`)
- Processing runner → Spatial station link: calls (evidence: `E2_extraccion/scripts/procesar_datos.py`)
- Processing runner → Temporal observation link: calls (evidence: `E2_extraccion/scripts/procesar_datos.py`)
- Processing runner → Processed datasets: writes CSVs (evidence: `E2_extraccion/scripts/procesar_datos.py`)
- Reproducible analysis → Feed extraction: uses extraction
- Reproducible analysis → Normalize and validate: uses cleaning
- Reproducible analysis → Spatial station link: uses linking
- Reproducible analysis → RDF vocabulary: documents vocabulary (evidence: `README.md`)
- Ontology specification → RDF vocabulary: specifies model (evidence: `README.md`)
- Semantic field mapping → RDF vocabulary: maps terms (evidence: `README.md`)
- Model diagram → RDF vocabulary: illustrates vocabulary (evidence: `E2_extraccion/src/bcn_kg/diagrama.py`)
- Reproducible analysis → Analysis report: exports report (evidence: `README.md`)
