# saiaravind19/gazebo_terrain_generator architecture

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

- Interactive diagram: https://gitdiagram.com/saiaravind19/gazebo_terrain_generator
- Repository: https://github.com/saiaravind19/gazebo_terrain_generator

## Overview

The product is a browser-based generator for real-world Gazebo terrain. Users configure a map area and spawn point, request generation, then download a ZIP containing a runnable world and its assets. The graph preserves terrain and imagery acquisition, optional building meshes, world assembly, and shared geospatial helpers. Some server orchestration is supported by the SOURCE INDEX rather than complete excerpts, so those edges cite the server file; undocumented links are omitted.

Main entry points: [`scripts/server.py`](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/server.py) (HTTP generation API), [`scripts/utils/gazebo_world_generator.py`](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/gazebo_world_generator.py) (Terrain world assembly), [`scripts/utils/maptile_utils.py`](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/maptile_utils.py) (Tile and bounds math), [`scripts/utils/dem_tiles_downloader.py`](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/dem_tiles_downloader.py) (Elevation tile downloader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Map UI"]
  node_frontend["Map and settings UI<br/>[main.js]"]
end

subgraph group_service["Generation Service"]
  node_server["HTTP generation API<br/>[server.py]"]
  node_output["Generated world and ZIP"]
end

subgraph group_assets["Terrain Assets"]
  node_dem["Elevation tile downloader"]
  node_buildings_dl["Building data downloader"]
  node_terrain["Terrain world assembly"]
  node_heightmap["Heightmap generation"]
  node_ortho["Aerial texture stitching"]
  node_building_mesh["Building mesh generation"]
  node_writer["World file writer<br/>[file_writer.py]"]
  node_templates["SDF and model templates"]
end

subgraph group_shared["Shared Geospatial"]
  node_tile_utils["Tile and bounds math<br/>[maptile_utils.py]"]
  node_image_utils["Tile image stitching<br/>[utils.py]"]
  node_download_utils["Raster tile fetching<br/>[utils.py]"]
  node_config["Generation parameters<br/>[param.py]"]
end

node_user(("Terrain designer"))
node_mapbox["Mapbox data services"]
node_tile_source["Satellite tile source"]

node_user -->|"configures area"| node_frontend
node_frontend -->|"requests generation"| node_server
node_server -->|"downloads elevation"| node_dem
node_server -->|"downloads buildings"| node_buildings_dl
node_server -->|"starts assembly"| node_terrain
node_server -->|"calculates bounds"| node_tile_utils
node_server -->|"fetches tiles"| node_download_utils
node_server -->|"packages download"| node_output
node_dem -->|"converts coordinates"| node_tile_utils
node_dem -->|"fetches elevation"| node_mapbox
node_buildings_dl -->|"uses tile bounds"| node_tile_utils
node_terrain -->|"inherits generation"| node_heightmap
node_terrain -->|"stitches imagery"| node_ortho
node_terrain -->|"creates building mesh"| node_building_mesh
node_terrain -->|"writes world files"| node_writer
node_terrain -->|"uses tile bounds"| node_tile_utils
node_terrain -->|"reads parameters"| node_config
node_heightmap -->|"maps coordinates"| node_tile_utils
node_heightmap -->|"stitches DEM tiles"| node_image_utils
node_writer -->|"loads templates"| node_templates
node_writer -->|"reads template path"| node_config
node_download_utils -->|"fetches imagery"| node_tile_source
node_output -->|"downloads ZIP"| node_user

click node_frontend "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/frontend/js/main.js"
click node_server "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/server.py"
click node_dem "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/dem_tiles_downloader.py"
click node_buildings_dl "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/building_downloader.py"
click node_terrain "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/gazebo_world_generator.py"
click node_heightmap "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/height_map_generator.py"
click node_ortho "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/gazebo_world_generator.py"
click node_building_mesh "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/buildings_generator.py"
click node_writer "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/file_writer.py"
click node_tile_utils "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/maptile_utils.py"
click node_image_utils "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/utils.py"
click node_download_utils "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/utils.py"
click node_config "https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/param.py"
click node_templates "https://github.com/saiaravind19/gazebo_terrain_generator/tree/main/templates"

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_frontend toneBlue
class node_server,node_output toneAmber
class node_dem,node_buildings_dl,node_terrain,node_heightmap,node_ortho,node_building_mesh,node_writer,node_templates toneMint
class node_tile_utils,node_image_utils,node_download_utils,node_config toneRose
class node_user,node_mapbox,node_tile_source toneIndigo
```

## Components

### Map UI

- [Map and settings UI](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/frontend/js/main.js): `scripts/frontend/js/main.js`

### Generation Service

- [HTTP generation API](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/server.py): `scripts/server.py`
- **Generated world and ZIP**

### Terrain Assets

- [Elevation tile downloader](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/dem_tiles_downloader.py): `scripts/utils/dem_tiles_downloader.py`
- [Building data downloader](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/building_downloader.py): `scripts/utils/building_downloader.py`
- [Terrain world assembly](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/gazebo_world_generator.py): `scripts/utils/gazebo_world_generator.py`
- [Heightmap generation](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/height_map_generator.py): `scripts/utils/height_map_generator.py`
- [Aerial texture stitching](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/gazebo_world_generator.py): `scripts/utils/gazebo_world_generator.py`
- [Building mesh generation](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/buildings_generator.py): `scripts/utils/buildings_generator.py`
- [World file writer](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/file_writer.py): `scripts/utils/file_writer.py`
- [SDF and model templates](https://github.com/saiaravind19/gazebo_terrain_generator/tree/main/templates): `templates`

### Shared Geospatial

- [Tile and bounds math](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/maptile_utils.py): `scripts/utils/maptile_utils.py`
- [Tile image stitching](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/utils.py): `scripts/utils/utils.py`
- [Raster tile fetching](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/utils.py): `scripts/utils/utils.py`
- [Generation parameters](https://github.com/saiaravind19/gazebo_terrain_generator/blob/main/scripts/utils/param.py): `scripts/utils/param.py`

### Other components

- **Terrain designer**
- **Mapbox data services**
- **Satellite tile source**

## Connections

- Terrain designer → Map and settings UI: configures area (evidence: `README.md`)
- Map and settings UI → HTTP generation API: requests generation (evidence: `README.md`)
- HTTP generation API → Elevation tile downloader: downloads elevation (evidence: `scripts/server.py`)
- HTTP generation API → Building data downloader: downloads buildings (evidence: `scripts/server.py`)
- HTTP generation API → Terrain world assembly: starts assembly (evidence: `scripts/server.py`)
- HTTP generation API → Tile and bounds math: calculates bounds (evidence: `scripts/server.py`)
- HTTP generation API → Raster tile fetching: fetches tiles (evidence: `scripts/server.py`)
- HTTP generation API → Generated world and ZIP: packages download (evidence: `scripts/server.py`)
- Elevation tile downloader → Tile and bounds math: converts coordinates (evidence: `scripts/utils/dem_tiles_downloader.py`)
- Elevation tile downloader → Mapbox data services: fetches elevation (evidence: `scripts/utils/dem_tiles_downloader.py`)
- Building data downloader → Tile and bounds math: uses tile bounds (evidence: `scripts/utils/building_downloader.py`)
- Terrain world assembly → Heightmap generation: inherits generation (evidence: `scripts/utils/gazebo_world_generator.py`)
- Terrain world assembly → Aerial texture stitching: stitches imagery (evidence: `scripts/utils/gazebo_world_generator.py`)
- Terrain world assembly → Building mesh generation: creates building mesh (evidence: `scripts/utils/gazebo_world_generator.py`)
- Terrain world assembly → World file writer: writes world files (evidence: `scripts/utils/gazebo_world_generator.py`)
- Terrain world assembly → Tile and bounds math: uses tile bounds (evidence: `scripts/utils/gazebo_world_generator.py`)
- Terrain world assembly → Generation parameters: reads parameters (evidence: `scripts/utils/gazebo_world_generator.py`)
- Heightmap generation → Tile and bounds math: maps coordinates (evidence: `scripts/utils/height_map_generator.py`)
- Heightmap generation → Tile image stitching: stitches DEM tiles (evidence: `scripts/utils/height_map_generator.py`)
- World file writer → SDF and model templates: loads templates (evidence: `scripts/utils/file_writer.py`)
- World file writer → Generation parameters: reads template path (evidence: `scripts/utils/file_writer.py`)
- Raster tile fetching → Satellite tile source: fetches imagery
- Generated world and ZIP → Terrain designer: downloads ZIP (evidence: `README.md`)
