# ravi-rayv/urban-land-use-analysis architecture

> Architecture diagram of the GitHub repository ravi-rayv/urban-land-use-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ravi-rayv/urban-land-use-analysis
- Repository: https://github.com/ravi-rayv/urban-land-use-analysis

## Overview

#### Purpose and execution model
A Python 3.8+ batch pipeline that gathers location/keyword-targeted Twitter/X posts, writes tabular output, then converts the collected social signals into geospatial visualizations for urban land-use interpretation. It is script-driven rather than a service:
- Collection entry point: `src/tweet_collector.py`
- Visualization entry point: `src/geo_visualizer.py`

#### Configuration boundary
Repository-root settings separate environment-specific inputs from processing logic:
- `config.py` supplies Twitter credentials, shapefile location, and output CSV path.
- `constants.py` defines geographic search radii and keyword vocabulary.
These are the primary controls for query scope, authentication, and local input/output locations.

#### Tweet collection stage
`src/tweet_collector.py` is the upstream acquisition component. It combines configured locations and keywords into Twitter/X API searches, supports multiple authentication approaches (Bearer token, X-API-Key, direct token fallback), and processes results in batches to limit memory use. Its durable handoff is a CSV containing query metadata, date, author, text, engagement counts, URL, and errors.
- Sources: `src/tweet_collector.py`, `config.py`, `constants.py`
- External dependency: Twitter/X API and its token/rate-limit behavior.

#### Tabular data handoff
The CSV is the architectural boundary between remote collection and local spatial analysis. Collector output is configured through `config.py`; the visualizer consumes that data independently, enabling visualization reruns without API access.
- Paths: `src/tweet_collector.py`, `src/geo_visualizer.py`, `config.py`

#### Geospatial processing and map generation
`src/geo_visualizer.py` loads collected tweet records, extracts/uses geographic positions and engagement-related measures, and produces map artifacts. It supports density, interpolation, aggregation, territory, clustering, temporal, sentiment, keyword, and composite views, including KDE, contours, hexbin, raster, Voronoi, IDW, and hotspot representations.
- Core path: `src/geo_visualizer.py`
- Output boundary: PNG maps under the configured output area.

#### Geographic reference boundary
A city boundary shapefile is an optional local geospatial dependency. When supplied, it is overlaid on generated maps; when absent, visualization uses the tweet-data extent. This keeps analysis runnable with only collected data while allowing authoritative municipal/context boundaries.
- Configuration: `config.py`
- Consumer: `src/geo_visualizer.py`

#### Shared support and runtime
`src/utils.py` holds cross-cutting utilities used by pipeline scripts. The runtime is local Python with dependencies installed from `requirements.txt`; material libraries are expected to cover HTTP/API access, tabular processing, GIS/shapefile handling, numerical spatial analysis, and plotting.
- Paths: `src/utils.py`, `requirements.txt`, `src/__init__.py`

Main entry points: [`src/tweet_collector.py`](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/tweet_collector.py) (Tweet Collector), [`src/geo_visualizer.py`](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/geo_visualizer.py) (Geo Visualizer), [`config.py`](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/config.py) (Settings), [`requirements.txt`](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/requirements.txt) (Dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Configuration &amp; Runtime"]
  node_config["Settings<br/>Python config<br/>[config.py]"]
  node_constants["Search Constants<br/>Python constants<br/>[constants.py]"]
  node_requirements["Dependencies<br/>Python requirements<br/>[requirements.txt]"]
  node_utils["Shared Utilities<br/>Python module<br/>[utils.py]"]
  node_package_init["Source Package<br/>Python package<br/>[__init__.py]"]
end

subgraph group_collection["Tweet Collection"]
  node_collector["Tweet Collector<br/>batch script<br/>[tweet_collector.py]"]
  node_twitter_api{{"Twitter/X API<br/>external API"}}
end

subgraph group_analysis["Geospatial Analysis"]
  node_visualizer["Geo Visualizer<br/>batch script<br/>[geo_visualizer.py]"]
  node_spatial_processing["Spatial Analysis<br/>processing layer<br/>[geo_visualizer.py]"]
  node_city_shapefile["City Boundary Shapefile<br/>local GIS input"]
  node_map_pngs["PNG Map Artifacts<br/>visualization output"]
end

node_tweet_csv[("Collected Tweets CSV<br/>tabular handoff")]

node_requirements -->|"provides runtime libraries"| node_collector
node_requirements -->|"provides runtime libraries"| node_visualizer
node_config -->|"credentials and CSV location"| node_collector
node_constants -->|"locations, radii, keywords"| node_collector
node_utils -->|"shared support"| node_collector
node_utils -->|"shared support"| node_visualizer
node_collector -->|"authenticated searches"| node_twitter_api
node_twitter_api -->|"posts and API limits"| node_collector
node_collector -->|"writes batch results"| node_tweet_csv
node_config -.->|"configures output path"| node_tweet_csv
node_tweet_csv -->|"independent local input"| node_visualizer
node_config -->|"shapefile and output locations"| node_visualizer
node_visualizer -->|"loads records and derives measures"| node_spatial_processing
node_city_shapefile -.->|"optional boundary overlay"| node_spatial_processing
node_spatial_processing -->|"renders map views"| node_map_pngs

click node_config "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/config.py"
click node_constants "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/constants.py"
click node_requirements "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/requirements.txt"
click node_utils "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/utils.py"
click node_collector "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/tweet_collector.py"
click node_visualizer "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/geo_visualizer.py"
click node_spatial_processing "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/geo_visualizer.py"
click node_package_init "https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/__init__.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_config,node_constants,node_requirements,node_utils,node_package_init toneBlue
class node_collector,node_twitter_api toneAmber
class node_visualizer,node_spatial_processing,node_city_shapefile,node_map_pngs toneMint
class node_tweet_csv toneNeutral
```

## Components

### Configuration & Runtime

- [Settings](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/config.py): Python config · Credentials and local input/output locations. · `config.py`
- [Search Constants](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/constants.py): Python constants · Geographic radii and keyword vocabulary. · `constants.py`
- [Dependencies](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/requirements.txt): Python requirements · Local runtime libraries for API, data, GIS, and plotting. · `requirements.txt`
- [Shared Utilities](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/utils.py): Python module · `src/utils.py`
- [Source Package](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/__init__.py): Python package · `src/__init__.py`

### Tweet Collection

- [Tweet Collector](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/tweet_collector.py): batch script · Builds and executes location/keyword Twitter searches in batches. · `src/tweet_collector.py`
- **Twitter/X API**: external API · Remote post source with token and rate-limit behavior.

### Geospatial Analysis

- [Geo Visualizer](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/geo_visualizer.py): batch script · Generates spatial and thematic map views from collected records. · `src/geo_visualizer.py`
- [Spatial Analysis](https://github.com/ravi-rayv/urban-land-use-analysis/blob/main/src/geo_visualizer.py): processing layer · Applies density, interpolation, aggregation, clustering, temporal, sentiment, and keyword methods. · `src/geo_visualizer.py`
- **City Boundary Shapefile**: local GIS input · Optional reference overlay; tweet extent is used when absent.
- **PNG Map Artifacts**: visualization output · Generated maps in the configured output area.

### Other components

- **Collected Tweets CSV**: tabular handoff · Posts, query metadata, engagement, URLs, and errors.

## Connections

- Dependencies → Tweet Collector: provides runtime libraries
- Dependencies → Geo Visualizer: provides runtime libraries
- Settings → Tweet Collector: credentials and CSV location
- Search Constants → Tweet Collector: locations, radii, keywords
- Shared Utilities → Tweet Collector: shared support
- Shared Utilities → Geo Visualizer: shared support
- Tweet Collector → Twitter/X API: authenticated searches
- Twitter/X API → Tweet Collector: posts and API limits
- Tweet Collector → Collected Tweets CSV: writes batch results
- Settings → Collected Tweets CSV: configures output path
- Collected Tweets CSV → Geo Visualizer: independent local input
- Settings → Geo Visualizer: shapefile and output locations
- Geo Visualizer → Spatial Analysis: loads records and derives measures
- City Boundary Shapefile → Spatial Analysis: optional boundary overlay
- Spatial Analysis → PNG Map Artifacts: renders map views
