# alti3/hexpicker architecture

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

- Interactive diagram: https://gitdiagram.com/alti3/hexpicker
- Repository: https://github.com/alti3/hexpicker

## Overview

##### Component Breakdown

A. Presentation Layer (Top):
- Components for:
- View Container
- Control Buttons Panel
- Selection Counter Display

B. Application Logic Layer (Middle):
- H3 Cell Manager (handles cell selection and state)
- Polygon Drawing Controller
- Clipboard Integration
- Event Handler System

C. External Services/Libraries Layer (Bottom):
- Leaflet.js
- H3-js Library

##### Connection and Data Flow
- User Interface → Application Logic
- Application Logic → External Libraries
- H3 Cell IDs
- GeoJSON data
- Tile requests

##### Specific Elements
- Tile server connection
- H3 indexing process flow
- Polygon selection mechanism
- Clipboard API integration
- Event propagation paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef browser fill:#e6e6e6,stroke:#333
    classDef ui fill:#b3d9ff,stroke:#333
    classDef logic fill:#90EE90,stroke:#333
    classDef external fill:#d3d3d3,stroke:#333
    classDef data fill:#ffd700,stroke:#333

    %% Browser Container
    subgraph Browser["Web Browser Environment"]
        %% Presentation Layer
        subgraph UI["Presentation Layer"]
            HTML["Frontend Container"]
            MapView["Map View Container"]
            Controls["Control Buttons Panel"]
            Counter["Selection Counter Display"]
        end

        %% Application Logic Layer
        subgraph Logic["Application Logic Layer"]
            H3Manager["H3 Cell Manager"]
            DrawController["Polygon Drawing Controller"]
            Clipboard["Clipboard Integration"]
            EventSystem["Event Handler System"]
        end

        %% External Services Layer
        subgraph External["External Libraries Layer"]
            Leaflet["Leaflet.js"]
            LeafletDraw["Leaflet.draw"]
            H3["H3-js Library"]
        end
    end

    %% Connections
    HTML --> MapView
    HTML --> Controls
    HTML --> Counter
    
    MapView --> H3Manager
    Controls --> DrawController
    DrawController --> H3Manager
    H3Manager --> Clipboard
    EventSystem --> H3Manager
    EventSystem --> DrawController
    
    H3Manager --> H3
    DrawController --> Leaflet
    DrawController --> LeafletDraw
    MapView --> Leaflet

    %% Data Flow
    H3Manager -.->|H3 Cell IDs| Counter
    DrawController -.->|GeoJSON| MapView
    Leaflet -.->|Map Tiles| MapView

    %% Click Events
    click HTML "https://github.com/alti3/HexPicker/blob/master/index.html"

    %% Legend
    subgraph Legend
        UI_Component["UI Component"]:::ui
        Logic_Component["Logic Component"]:::logic
        External_Component["External Library"]:::external
        Data_Flow["Data Flow"]:::data
    end

    %% Apply styles
    class Browser browser
    class HTML,MapView,Controls,Counter ui
    class H3Manager,DrawController,Clipboard,EventSystem logic
    class Leaflet,LeafletDraw,H3 external
    class Legend data
```
