# lanofgajanan/cyberspace architecture

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

- Interactive diagram: https://gitdiagram.com/lanofgajanan/cyberspace
- Repository: https://github.com/lanofgajanan/cyberspace

## Overview

City.OS is a browser-based procedural 3D city visualizer. The main workflow selects a registered world profile, generates renderer-neutral city data, builds a Three.js scene, and presents it with interactive camera controls and UI; world switching uses an explicit lifecycle. The README documents the legacy generation stages and the megacity vertical slice. Edges are limited to shown calls/import references or README statements; unsampled implementation details are not inferred.

Main entry points: [`js/main.js`](https://github.com/lanofgajanan/cyberspace/blob/main/js/main.js) (App coordinator), [`js/cities/registry.js`](https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/registry.js) (World registry), [`js/city-generator.js`](https://github.com/lanofgajanan/cyberspace/blob/main/js/city-generator.js) (Legacy city generator), [`js/scene-builder.js`](https://github.com/lanofgajanan/cyberspace/blob/main/js/scene-builder.js) (Scene builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application runtime"]
  node_main["App coordinator<br/>[main.js]"]
  node_lifecycle["World lifecycle<br/>[lifecycle.js]"]
end

subgraph group_worlds["World generation"]
  node_registry["World registry<br/>[registry.js]"]
  node_legacy["Legacy profile<br/>[legacy.js]"]
  node_citygen["Legacy city generator<br/>[city-generator.js]"]
  node_megaprofile["Megacity profile<br/>[megacity.js]"]
  node_megagen["Megacity generator"]
  node_soviet["Soviet city profile<br/>[soviet.js]"]
  node_terrain["Terrain generation<br/>[terrain.js]"]
end

subgraph group_render["Scene rendering"]
  node_scene["Scene builder<br/>[scene-builder.js]"]
  node_streaks["Streak visuals<br/>[streaks.js]"]
  node_glitch["Glitch cubes<br/>[glitch-cubes.js]"]
end

subgraph group_interaction["Camera and controls"]
  node_camera["Camera controls<br/>[camera-controls.js]"]
  node_replay["Camera replay<br/>[camera-replay.js]"]
  node_ui["HUD and settings<br/>[ui.js]"]
end

subgraph group_core["Generation utilities"]
  node_rng["Seeded randomness<br/>[rng.js]"]
  node_frame["Coordinate frame<br/>[frame.js]"]
  node_geometry["Geometry helpers<br/>[geometry.js]"]
  node_spatial["Spatial hash<br/>[spatial-hash.js]"]
  node_colors["Palette helpers<br/>[colors.js]"]
end

node_visitor(("Viewer"))

node_visitor -->|"opens app"| node_main
node_main -->|"selects profile"| node_registry
node_main -->|"creates lifecycle"| node_lifecycle
node_lifecycle -.->|"loads profile"| node_registry
node_registry -->|"registers"| node_legacy
node_registry -->|"registers"| node_megaprofile
node_registry -->|"registers"| node_soviet
node_legacy -->|"uses generator"| node_citygen
node_megaprofile -->|"uses generator"| node_megagen
node_main -->|"builds scene"| node_scene
node_main -->|"generates cubes"| node_glitch
node_citygen -->|"uses randomness"| node_rng
node_citygen -->|"transforms coordinates"| node_frame
node_citygen -->|"queries proximity"| node_spatial
node_citygen -->|"builds geometry"| node_geometry
node_megagen -->|"creates terrain"| node_terrain
node_megagen -->|"seeds generation"| node_rng
node_scene -->|"builds streak data"| node_streaks
node_scene -->|"maps faces"| node_geometry
node_scene -->|"blends palette"| node_colors
node_main -->|"creates controls"| node_camera
node_main -->|"creates replay"| node_replay
node_main -->|"wires interface"| node_ui
node_ui -->|"reads profiles"| node_registry
node_ui -->|"sets presets"| node_camera
node_ui -->|"controls playback"| node_replay

click node_main "https://github.com/lanofgajanan/cyberspace/blob/main/js/main.js"
click node_lifecycle "https://github.com/lanofgajanan/cyberspace/blob/main/js/lifecycle.js"
click node_registry "https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/registry.js"
click node_legacy "https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/legacy.js"
click node_citygen "https://github.com/lanofgajanan/cyberspace/blob/main/js/city-generator.js"
click node_megaprofile "https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/megacity.js"
click node_megagen "https://github.com/lanofgajanan/cyberspace/blob/main/js/megacity-generator.js"
click node_soviet "https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/soviet.js"
click node_terrain "https://github.com/lanofgajanan/cyberspace/blob/main/js/terrain.js"
click node_scene "https://github.com/lanofgajanan/cyberspace/blob/main/js/scene-builder.js"
click node_streaks "https://github.com/lanofgajanan/cyberspace/blob/main/js/streaks.js"
click node_glitch "https://github.com/lanofgajanan/cyberspace/blob/main/js/glitch-cubes.js"
click node_camera "https://github.com/lanofgajanan/cyberspace/blob/main/js/camera-controls.js"
click node_replay "https://github.com/lanofgajanan/cyberspace/blob/main/js/camera-replay.js"
click node_ui "https://github.com/lanofgajanan/cyberspace/blob/main/js/ui.js"
click node_rng "https://github.com/lanofgajanan/cyberspace/blob/main/js/rng.js"
click node_frame "https://github.com/lanofgajanan/cyberspace/blob/main/js/frame.js"
click node_geometry "https://github.com/lanofgajanan/cyberspace/blob/main/js/geometry.js"
click node_spatial "https://github.com/lanofgajanan/cyberspace/blob/main/js/spatial-hash.js"
click node_colors "https://github.com/lanofgajanan/cyberspace/blob/main/js/colors.js"

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_main,node_lifecycle,node_visitor toneBlue
class node_registry,node_legacy,node_citygen,node_megaprofile,node_megagen,node_soviet,node_terrain toneAmber
class node_scene,node_streaks,node_glitch toneMint
class node_camera,node_replay,node_ui toneRose
class node_rng,node_frame,node_geometry,node_spatial,node_colors toneIndigo
```

## Components

### Application runtime

- [App coordinator](https://github.com/lanofgajanan/cyberspace/blob/main/js/main.js): `js/main.js`
- [World lifecycle](https://github.com/lanofgajanan/cyberspace/blob/main/js/lifecycle.js): `js/lifecycle.js`

### World generation

- [World registry](https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/registry.js): `js/cities/registry.js`
- [Legacy profile](https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/legacy.js): `js/cities/legacy.js`
- [Legacy city generator](https://github.com/lanofgajanan/cyberspace/blob/main/js/city-generator.js): `js/city-generator.js`
- [Megacity profile](https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/megacity.js): `js/cities/megacity.js`
- [Megacity generator](https://github.com/lanofgajanan/cyberspace/blob/main/js/megacity-generator.js): `js/megacity-generator.js`
- [Soviet city profile](https://github.com/lanofgajanan/cyberspace/blob/main/js/cities/soviet.js): `js/cities/soviet.js`
- [Terrain generation](https://github.com/lanofgajanan/cyberspace/blob/main/js/terrain.js): `js/terrain.js`

### Scene rendering

- [Scene builder](https://github.com/lanofgajanan/cyberspace/blob/main/js/scene-builder.js): `js/scene-builder.js`
- [Streak visuals](https://github.com/lanofgajanan/cyberspace/blob/main/js/streaks.js): `js/streaks.js`
- [Glitch cubes](https://github.com/lanofgajanan/cyberspace/blob/main/js/glitch-cubes.js): `js/glitch-cubes.js`

### Camera and controls

- [Camera controls](https://github.com/lanofgajanan/cyberspace/blob/main/js/camera-controls.js): `js/camera-controls.js`
- [Camera replay](https://github.com/lanofgajanan/cyberspace/blob/main/js/camera-replay.js): `js/camera-replay.js`
- [HUD and settings](https://github.com/lanofgajanan/cyberspace/blob/main/js/ui.js): `js/ui.js`

### Generation utilities

- [Seeded randomness](https://github.com/lanofgajanan/cyberspace/blob/main/js/rng.js): `js/rng.js`
- [Coordinate frame](https://github.com/lanofgajanan/cyberspace/blob/main/js/frame.js): `js/frame.js`
- [Geometry helpers](https://github.com/lanofgajanan/cyberspace/blob/main/js/geometry.js): `js/geometry.js`
- [Spatial hash](https://github.com/lanofgajanan/cyberspace/blob/main/js/spatial-hash.js): `js/spatial-hash.js`
- [Palette helpers](https://github.com/lanofgajanan/cyberspace/blob/main/js/colors.js): `js/colors.js`

### Other components

- **Viewer**

## Connections

- Viewer → App coordinator: opens app (evidence: `README.md`)
- App coordinator → World registry: selects profile (evidence: `js/main.js`)
- App coordinator → World lifecycle: creates lifecycle (evidence: `js/main.js`)
- World lifecycle → World registry: loads profile
- World registry → Legacy profile: registers (evidence: `js/cities/registry.js`)
- World registry → Megacity profile: registers (evidence: `js/cities/registry.js`)
- World registry → Soviet city profile: registers (evidence: `js/cities/registry.js`)
- Legacy profile → Legacy city generator: uses generator (evidence: `js/cities/legacy.js`)
- Megacity profile → Megacity generator: uses generator (evidence: `js/cities/megacity.js`)
- App coordinator → Scene builder: builds scene (evidence: `js/main.js`)
- App coordinator → Glitch cubes: generates cubes (evidence: `js/main.js`)
- Legacy city generator → Seeded randomness: uses randomness (evidence: `js/city-generator.js`)
- Legacy city generator → Coordinate frame: transforms coordinates (evidence: `js/city-generator.js`)
- Legacy city generator → Spatial hash: queries proximity (evidence: `js/city-generator.js`)
- Legacy city generator → Geometry helpers: builds geometry (evidence: `js/city-generator.js`)
- Megacity generator → Terrain generation: creates terrain (evidence: `js/megacity-generator.js`)
- Megacity generator → Seeded randomness: seeds generation (evidence: `js/megacity-generator.js`)
- Scene builder → Streak visuals: builds streak data (evidence: `js/scene-builder.js`)
- Scene builder → Geometry helpers: maps faces (evidence: `js/scene-builder.js`)
- Scene builder → Palette helpers: blends palette (evidence: `js/scene-builder.js`)
- App coordinator → Camera controls: creates controls (evidence: `js/main.js`)
- App coordinator → Camera replay: creates replay (evidence: `js/main.js`)
- App coordinator → HUD and settings: wires interface (evidence: `js/main.js`)
- HUD and settings → World registry: reads profiles (evidence: `js/ui.js`)
- HUD and settings → Camera controls: sets presets (evidence: `js/ui.js`)
- HUD and settings → Camera replay: controls playback (evidence: `js/ui.js`)
