# openstreetmap/id architecture

> Architecture diagram of the GitHub repository openstreetmap/id, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openstreetmap/id
- Repository: https://github.com/openstreetmap/id

## Overview

##### Main Components Structure

a) Core Application Layer:
- Main components: Context, Graph, History, and Validator
- LocationManager and Preferences as supporting core services

b) Data Model Layer:
- OSM data model (`modules/osm/`) showing entities (Node, Way, Relation)
- To the core Graph component
- Changeset and Tags management systems

c) User Interface Layer:
- Extensive UI components (`modules/ui/`)
- Related UI components:
- Main UI (sidebar, panels, panes)
- Entity editors
- Field controls
- Modal dialogs
- Tools and controls

d) Rendering Layer:
- Renderer components (`modules/renderer/`)
- SVG rendering system (`modules/svg/`)
- To map features and background sources

e) Behavioral Layer:
- Behavior modules (`modules/behavior/`)
- To the modes system (`modules/modes/`)

##### Component Relationships

- Blue: Data flow
- Green: User interaction flow
- Orange: Service calls

##### External Services Integration

- OSM API integration
- Third-party services (Mapillary, KartaView, Nominatim)
- Background tile providers
- Validation services (KeepRight, Osmose)

##### Key Technical Elements

Important technical aspects:
- D3.js rendering integration
- Validation system
- History/undo system
- Presets and tagging schema
- Localization system

##### Additional Details

Annotations for:
- Key file locations
- Configuration points
- Extension points
- Test coverage
- Build process integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        Context["Context"]:::core
        Graph["Graph"]:::core
        History["History"]:::core
        Validator["Validator"]:::core
        LocationMgr["Location Manager"]:::core
        Prefs["Preferences"]:::core
    end

    subgraph DataModel
        Node["Node"]:::data
        Way["Way"]:::data
        Relation["Relation"]:::data
        Changeset["Changeset"]:::data
        Tags["Tags"]:::data
    end

    subgraph RenderingSystem
        MainRenderer["Main Renderer"]:::render
        MapRenderer["Map Renderer"]:::render
        Background["Background"]:::render
        Features["Features"]:::render

        subgraph SVG
            Areas["Areas"]:::svg
            Lines["Lines"]:::svg
            Points["Points"]:::svg
            Labels["Labels"]:::svg
        end
    end

    subgraph Behaviors
        Drag["Drag"]:::behavior
        Draw["Draw"]:::behavior
        Select["Select"]:::behavior
        Hover["Hover"]:::behavior
    end

    subgraph Modes
        Browse["Browse"]:::mode
        DrawArea["Draw Area"]:::mode
        DrawLine["Draw Line"]:::mode
        SelectMode["Select"]:::mode
    end

    subgraph UI
        Sidebar["Sidebar"]:::ui
        Inspector["Inspector"]:::ui
        PresetList["Preset List"]:::ui
        EntityEditor["Entity Editor"]:::ui
        Modal["Modal"]:::ui
    end

    subgraph ExternalServices
        OSMAPI["OSM API"]:::service
        Mapillary["Mapillary"]:::service
        Nominatim["Nominatim"]:::service
        KartaView["KartaView"]:::service
    end

    %% Core relationships
    Context --> Graph
    Context --> History
    Context --> Validator
    Context --> LocationMgr
    Context --> Prefs

    %% Data Model relationships
    Graph --> Node
    Graph --> Way
    Graph --> Relation
    Graph --> Tags
    OSMAPI --> Changeset

    %% Rendering relationships
    MainRenderer --> MapRenderer
    MainRenderer --> Background
    MainRenderer --> Features
    MapRenderer --> Areas
    MapRenderer --> Lines
    MapRenderer --> Points
    MapRenderer --> Labels

    %% Behavior and Mode relationships
    Context --> Behaviors
    Context --> Modes
    Behaviors --> UI
    Modes --> UI

    %% UI relationships
    UI --> Graph
    UI --> OSMAPI

    %% External Service relationships
    Context --> ExternalServices

    %% Styling
    classDef core fill:#2374ab
    classDef data fill:#ffd400
    classDef render fill:#41d3bd
    classDef svg fill:#407899
    classDef behavior fill:#de8f6e
    classDef mode fill:#800080
    classDef ui fill:#90be6d
    classDef service fill:#f94144

    %% Click events
    click Context "https://github.com/openstreetmap/iD/blob/develop/modules/core/context.js"
    click Graph "https://github.com/openstreetmap/iD/blob/develop/modules/core/graph.js"
    click History "https://github.com/openstreetmap/iD/blob/develop/modules/core/history.js"
    click Validator "https://github.com/openstreetmap/iD/blob/develop/modules/core/validator.js"
    click LocationMgr "https://github.com/openstreetmap/iD/blob/develop/modules/core/LocationManager.js"
    click Prefs "https://github.com/openstreetmap/iD/blob/develop/modules/core/preferences.js"
    click Node "https://github.com/openstreetmap/iD/blob/develop/modules/osm/node.js"
    click Way "https://github.com/openstreetmap/iD/blob/develop/modules/osm/way.js"
    click Relation "https://github.com/openstreetmap/iD/blob/develop/modules/osm/relation.js"
    click Changeset "https://github.com/openstreetmap/iD/blob/develop/modules/osm/changeset.js"
    click Tags "https://github.com/openstreetmap/iD/blob/develop/modules/osm/tags.js"
    click MainRenderer "https://github.com/openstreetmap/iD/blob/develop/modules/renderer/index.js"
    click MapRenderer "https://github.com/openstreetmap/iD/blob/develop/modules/renderer/map.js"
    click Background "https://github.com/openstreetmap/iD/blob/develop/modules/renderer/background.js"
    click Features "https://github.com/openstreetmap/iD/blob/develop/modules/renderer/features.js"
    click Areas "https://github.com/openstreetmap/iD/blob/develop/modules/svg/areas.js"
    click Lines "https://github.com/openstreetmap/iD/blob/develop/modules/svg/lines.js"
    click Points "https://github.com/openstreetmap/iD/blob/develop/modules/svg/points.js"
    click Labels "https://github.com/openstreetmap/iD/blob/develop/modules/svg/labels.js"
    click Drag "https://github.com/openstreetmap/iD/blob/develop/modules/behavior/drag.js"
    click Draw "https://github.com/openstreetmap/iD/blob/develop/modules/behavior/draw.js"
    click Select "https://github.com/openstreetmap/iD/blob/develop/modules/behavior/select.js"
    click Hover "https://github.com/openstreetmap/iD/blob/develop/modules/behavior/hover.js"
    click Browse "https://github.com/openstreetmap/iD/blob/develop/modules/modes/browse.js"
    click DrawArea "https://github.com/openstreetmap/iD/blob/develop/modules/modes/draw_area.js"
    click DrawLine "https://github.com/openstreetmap/iD/blob/develop/modules/modes/draw_line.js"
    click SelectMode "https://github.com/openstreetmap/iD/blob/develop/modules/modes/select.js"
    click Sidebar "https://github.com/openstreetmap/iD/blob/develop/modules/ui/sidebar.js"
    click Inspector "https://github.com/openstreetmap/iD/blob/develop/modules/ui/inspector.js"
    click PresetList "https://github.com/openstreetmap/iD/blob/develop/modules/ui/preset_list.js"
    click EntityEditor "https://github.com/openstreetmap/iD/blob/develop/modules/ui/entity_editor.js"
    click Modal "https://github.com/openstreetmap/iD/blob/develop/modules/ui/modal.js"
    click OSMAPI "https://github.com/openstreetmap/iD/blob/develop/modules/services/osm.js"
    click Mapillary "https://github.com/openstreetmap/iD/blob/develop/modules/services/mapillary.js"
    click Nominatim "https://github.com/openstreetmap/iD/blob/develop/modules/services/nominatim.js"
    click KartaView "https://github.com/openstreetmap/iD/blob/develop/modules/services/kartaview.js"
```
