# mercurial20/loremapper architecture

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

- Interactive diagram: https://gitdiagram.com/mercurial20/loremapper
- Repository: https://github.com/mercurial20/loremapper

## Overview

Loremapper is a browser-based fantasy map editor. Users create or open a planet or flat map, generate or sculpt terrain, add geographic and story features, inspect the result, and save or export it locally. The graph preserves the documented generation, editing, projection, fog-of-war, and asset capabilities. Several subsystem connections rely on the source index or README rather than inspected implementation details; those limits are reflected in the cited evidence.

Main entry points: [`src/store/docStore.ts`](https://github.com/mercurial20/loremapper/blob/main/src/store/docStore.ts) (Document state), [`src/App.tsx`](https://github.com/mercurial20/loremapper/blob/main/src/App.tsx) (Editor shell), [`src/tools/ToolController.ts`](https://github.com/mercurial20/loremapper/blob/main/src/tools/ToolController.ts) (Editing tools), [`src/editor/geography.ts`](https://github.com/mercurial20/loremapper/blob/main/src/editor/geography.ts) (Geography editing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Editor experience"]
  node_app["Editor shell<br/>[App.tsx]"]
  node_creation["Map creation<br/>[NewMap.tsx]"]
  node_tools["Editing tools<br/>[ToolController.ts]"]
  node_inspector["Feature inspector"]
  node_assets["Asset library<br/>[AssetPanel.tsx]"]
end

subgraph group_terrain["Terrain and geography"]
  node_terrainmodel["Terrain model<br/>[TerrainModel.ts]"]
  node_generation["World generation<br/>[generator.ts]"]
  node_geoediting["Geography editing<br/>[geography.ts]"]
  node_hydrology["Water features<br/>[lakes.ts]"]
end

subgraph group_mapdata["Map data and storage"]
  node_document["Map document<br/>[types.ts]"]
  node_docstore["Document state<br/>[docStore.ts]"]
  node_projectstorage["Project persistence<br/>[projects.ts]"]
  node_browserdb[("Browser database<br/>[db.ts]")]
end

subgraph group_presentation["Rendering and export"]
  node_renderer["Map renderer<br/>[MapRenderer.ts]"]
  node_mapview["Map view<br/>[MapView.tsx]"]
  node_projection["Projections<br/>[projections.ts]"]
  node_export["Map export<br/>[exporter.ts]"]
  node_projectedexport["Projected export<br/>[projectedExport.ts]"]
end

subgraph group_platform["Shared services"]
  node_analytics["Usage analytics<br/>[analytics.ts]"]
end

node_user(("Mapmaker"))

node_user -->|"uses"| node_app
node_app -->|"opens"| node_creation
node_creation -.->|"configures"| node_generation
node_generation -.->|"builds terrain"| node_terrainmodel
node_app -.->|"hosts editing"| node_tools
node_tools -.->|"commits edits"| node_docstore
node_tools -->|"uses"| node_geoediting
node_geoediting -->|"edits terrain"| node_terrainmodel
node_geoediting -.->|"uses"| node_hydrology
node_inspector -.->|"reads selection"| node_docstore
node_docstore -->|"stores"| node_document
node_docstore -->|"tracks edits"| node_analytics
node_projectstorage -->|"persists projects"| node_browserdb
node_app -->|"displays"| node_mapview
node_mapview -.->|"renders map"| node_renderer
node_renderer -.->|"draws terrain"| node_terrainmodel
node_user -.->|"adds artwork"| node_assets
node_user -.->|"exports map"| node_export
node_export -.->|"supports projections"| node_projectedexport
node_projectedexport -->|"projects map"| node_projection
node_user -.->|"chooses view"| node_projection
node_user -.->|"edits document"| node_docstore

click node_app "https://github.com/mercurial20/loremapper/blob/main/src/App.tsx"
click node_creation "https://github.com/mercurial20/loremapper/blob/main/src/ui/NewMap.tsx"
click node_tools "https://github.com/mercurial20/loremapper/blob/main/src/tools/ToolController.ts"
click node_inspector "https://github.com/mercurial20/loremapper/blob/main/src/ui/panels/SelectionInspector.tsx"
click node_terrainmodel "https://github.com/mercurial20/loremapper/blob/main/src/terrain/TerrainModel.ts"
click node_generation "https://github.com/mercurial20/loremapper/blob/main/src/terrain/generator.ts"
click node_geoediting "https://github.com/mercurial20/loremapper/blob/main/src/editor/geography.ts"
click node_hydrology "https://github.com/mercurial20/loremapper/blob/main/src/terrain/lakes.ts"
click node_document "https://github.com/mercurial20/loremapper/blob/main/src/model/types.ts"
click node_docstore "https://github.com/mercurial20/loremapper/blob/main/src/store/docStore.ts"
click node_projectstorage "https://github.com/mercurial20/loremapper/blob/main/src/persistence/projects.ts"
click node_browserdb "https://github.com/mercurial20/loremapper/blob/main/src/persistence/db.ts"
click node_renderer "https://github.com/mercurial20/loremapper/blob/main/src/render/MapRenderer.ts"
click node_mapview "https://github.com/mercurial20/loremapper/blob/main/src/ui/MapView.tsx"
click node_projection "https://github.com/mercurial20/loremapper/blob/main/src/core/projections.ts"
click node_export "https://github.com/mercurial20/loremapper/blob/main/src/editor/exporter.ts"
click node_projectedexport "https://github.com/mercurial20/loremapper/blob/main/src/editor/projectedExport.ts"
click node_assets "https://github.com/mercurial20/loremapper/blob/main/src/ui/panels/AssetPanel.tsx"
click node_analytics "https://github.com/mercurial20/loremapper/blob/main/src/analytics.ts"

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_app,node_creation,node_tools,node_inspector,node_assets toneBlue
class node_terrainmodel,node_generation,node_geoediting,node_hydrology toneAmber
class node_document,node_docstore,node_projectstorage,node_browserdb toneMint
class node_renderer,node_mapview,node_projection,node_export,node_projectedexport toneRose
class node_analytics,node_user toneIndigo
```

## Components

### Editor experience

- [Editor shell](https://github.com/mercurial20/loremapper/blob/main/src/App.tsx): `src/App.tsx`
- [Map creation](https://github.com/mercurial20/loremapper/blob/main/src/ui/NewMap.tsx): `src/ui/NewMap.tsx`
- [Editing tools](https://github.com/mercurial20/loremapper/blob/main/src/tools/ToolController.ts): `src/tools/ToolController.ts`
- [Feature inspector](https://github.com/mercurial20/loremapper/blob/main/src/ui/panels/SelectionInspector.tsx): `src/ui/panels/SelectionInspector.tsx`
- [Asset library](https://github.com/mercurial20/loremapper/blob/main/src/ui/panels/AssetPanel.tsx): `src/ui/panels/AssetPanel.tsx`

### Terrain and geography

- [Terrain model](https://github.com/mercurial20/loremapper/blob/main/src/terrain/TerrainModel.ts): `src/terrain/TerrainModel.ts`
- [World generation](https://github.com/mercurial20/loremapper/blob/main/src/terrain/generator.ts): `src/terrain/generator.ts`
- [Geography editing](https://github.com/mercurial20/loremapper/blob/main/src/editor/geography.ts): `src/editor/geography.ts`
- [Water features](https://github.com/mercurial20/loremapper/blob/main/src/terrain/lakes.ts): `src/terrain/lakes.ts`

### Map data and storage

- [Map document](https://github.com/mercurial20/loremapper/blob/main/src/model/types.ts): `src/model/types.ts`
- [Document state](https://github.com/mercurial20/loremapper/blob/main/src/store/docStore.ts): `src/store/docStore.ts`
- [Project persistence](https://github.com/mercurial20/loremapper/blob/main/src/persistence/projects.ts): `src/persistence/projects.ts`
- [Browser database](https://github.com/mercurial20/loremapper/blob/main/src/persistence/db.ts): `src/persistence/db.ts`

### Rendering and export

- [Map renderer](https://github.com/mercurial20/loremapper/blob/main/src/render/MapRenderer.ts): `src/render/MapRenderer.ts`
- [Map view](https://github.com/mercurial20/loremapper/blob/main/src/ui/MapView.tsx): `src/ui/MapView.tsx`
- [Projections](https://github.com/mercurial20/loremapper/blob/main/src/core/projections.ts): `src/core/projections.ts`
- [Map export](https://github.com/mercurial20/loremapper/blob/main/src/editor/exporter.ts): `src/editor/exporter.ts`
- [Projected export](https://github.com/mercurial20/loremapper/blob/main/src/editor/projectedExport.ts): `src/editor/projectedExport.ts`

### Shared services

- [Usage analytics](https://github.com/mercurial20/loremapper/blob/main/src/analytics.ts): `src/analytics.ts`

### Other components

- **Mapmaker**

## Connections

- Mapmaker → Editor shell: uses
- Editor shell → Map creation: opens (evidence: `src/App.tsx`)
- Map creation → World generation: configures
- World generation → Terrain model: builds terrain
- Editor shell → Editing tools: hosts editing
- Editing tools → Document state: commits edits (evidence: `src/tools/ToolController.ts`)
- Editing tools → Geography editing: uses (evidence: `src/tools/ToolController.ts`)
- Geography editing → Terrain model: edits terrain (evidence: `src/editor/geography.ts`)
- Geography editing → Water features: uses
- Feature inspector → Document state: reads selection (evidence: `src/ui/panels/SelectionInspector.tsx`)
- Document state → Map document: stores (evidence: `src/store/docStore.ts`)
- Document state → Usage analytics: tracks edits (evidence: `src/store/docStore.ts`)
- Project persistence → Browser database: persists projects (evidence: `src/persistence/projects.ts`)
- Editor shell → Map view: displays (evidence: `src/App.tsx`)
- Map view → Map renderer: renders map
- Map renderer → Terrain model: draws terrain
- Mapmaker → Asset library: adds artwork
- Mapmaker → Map export: exports map
- Map export → Projected export: supports projections (evidence: `src/editor/projectedExport.ts`)
- Projected export → Projections: projects map (evidence: `src/editor/projectedExport.ts`)
- Mapmaker → Projections: chooses view
- Mapmaker → Document state: edits document
