# uber/h3 architecture

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

- Interactive diagram: https://gitdiagram.com/uber/h3
- Repository: https://github.com/uber/h3

## Overview

H3 is a C geospatial indexing library that maps latitude/longitude to hierarchical hexagonal cell indexes and supports operations on those cells. The documented command-line workflow converts a location to a cell, then reports its boundary or center; the library also covers neighborhoods, hierarchy, polygon filling, and geometry. The tree and excerpts show the core indexing, grid, and geometry modules, plus a website explorer. Some CLI and library implementation details were not sampled, so their connections are documented at the product level rather than inferred from filenames.

Main entry points: [`src/h3lib/lib/h3Index.c`](https://github.com/uber/h3/blob/master/src/h3lib/lib/h3Index.c) (Cell indexes), [`website/src/components/explorer/map.jsx`](https://github.com/uber/h3/blob/master/website/src/components/explorer/map.jsx) (Hex map layers), [`src/h3lib/lib/algos.c`](https://github.com/uber/h3/blob/master/src/h3lib/lib/algos.c) (Grid algorithms), [`website/src/components/explorer/index.tsx`](https://github.com/uber/h3/blob/master/website/src/components/explorer/index.tsx) (Explorer interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command-line tools"]
  node_cli_tools["H3 CLI<br/>[latLngToCell.c]"]
  node_cell_boundary_cli["Boundary CLI<br/>[cellToBoundary.c]"]
  node_cell_center_cli["Center CLI<br/>[cellToLatLng.c]"]
end

subgraph group_indexing["Indexing and grids"]
  node_h3_index["Cell indexes<br/>[h3Index.c]"]
  node_face_projection["Face projection<br/>[faceijk.c]"]
  node_base_cells["Base cells<br/>[baseCells.c]"]
  node_grid_algorithms["Grid algorithms<br/>[algos.c]"]
  node_local_coordinates["Local coordinates<br/>[localij.c]"]
  node_directed_edges["Directed edges<br/>[directedEdge.c]"]
  node_iterators["Cell iterators<br/>[iterators.c]"]
end

subgraph group_geometry["Geospatial operations"]
  node_latlng["Coordinate utilities<br/>[latLng.c]"]
  node_cell_area["Area metrics<br/>[area.c]"]
  node_polygon_fill["Polygon filling<br/>[polyfill.c]"]
  node_polygon_geometry["Polygon geometry<br/>[polygon.c]"]
  node_multi_polygon["Cell boundaries<br/>[cellsToMultiPoly.c]"]
  node_linked_geometry["Linked geometry<br/>[linkedGeo.c]"]
end

subgraph group_explorer["Web explorer"]
  node_explorer["Explorer interface<br/>[index.tsx]"]
  node_explorer_map["Hex map layers<br/>[map.jsx]"]
  node_hex_generation["Visible hex generation<br/>[useHex.ts]"]
  node_input_parser["Input parsing<br/>[parseInput.ts]"]
end

node_user(("User"))
node_h3_js["h3-js binding"]

node_user -->|"requests cell"| node_cli_tools
node_cli_tools -.->|"converts location"| node_h3_index
node_user -->|"requests boundary"| node_cell_boundary_cli
node_cell_boundary_cli -.->|"reads cell index"| node_h3_index
node_user -->|"requests center"| node_cell_center_cli
node_cell_center_cli -.->|"reads cell index"| node_h3_index
node_h3_index -->|"uses projection"| node_face_projection
node_h3_index -->|"uses base cells"| node_base_cells
node_grid_algorithms -->|"uses neighbors"| node_base_cells
node_grid_algorithms -->|"uses cell indexes"| node_h3_index
node_local_coordinates -.->|"uses cell indexes"| node_h3_index
node_directed_edges -.->|"uses cell indexes"| node_h3_index
node_iterators -.->|"iterates cells"| node_h3_index
node_h3_index -->|"projects coordinates"| node_face_projection
node_explorer -->|"parses input"| node_input_parser
node_explorer -->|"renders map"| node_explorer_map
node_explorer_map -->|"uses hex layers"| node_hex_generation
node_hex_generation -->|"fills polygons"| node_h3_js
node_explorer_map -.->|"shows map"| node_user
node_polygon_fill -.->|"processes polygons"| node_polygon_geometry
node_multi_polygon -.->|"builds boundaries"| node_linked_geometry
node_cell_area -.->|"uses coordinates"| node_latlng

click node_cli_tools "https://github.com/uber/h3/blob/master/src/apps/filters/latLngToCell.c"
click node_cell_boundary_cli "https://github.com/uber/h3/blob/master/src/apps/filters/cellToBoundary.c"
click node_cell_center_cli "https://github.com/uber/h3/blob/master/src/apps/filters/cellToLatLng.c"
click node_h3_index "https://github.com/uber/h3/blob/master/src/h3lib/lib/h3Index.c"
click node_face_projection "https://github.com/uber/h3/blob/master/src/h3lib/lib/faceijk.c"
click node_base_cells "https://github.com/uber/h3/blob/master/src/h3lib/lib/baseCells.c"
click node_grid_algorithms "https://github.com/uber/h3/blob/master/src/h3lib/lib/algos.c"
click node_local_coordinates "https://github.com/uber/h3/blob/master/src/h3lib/lib/localij.c"
click node_directed_edges "https://github.com/uber/h3/blob/master/src/h3lib/lib/directedEdge.c"
click node_iterators "https://github.com/uber/h3/blob/master/src/h3lib/lib/iterators.c"
click node_latlng "https://github.com/uber/h3/blob/master/src/h3lib/lib/latLng.c"
click node_cell_area "https://github.com/uber/h3/blob/master/src/h3lib/lib/area.c"
click node_polygon_fill "https://github.com/uber/h3/blob/master/src/h3lib/lib/polyfill.c"
click node_polygon_geometry "https://github.com/uber/h3/blob/master/src/h3lib/lib/polygon.c"
click node_multi_polygon "https://github.com/uber/h3/blob/master/src/h3lib/lib/cellsToMultiPoly.c"
click node_linked_geometry "https://github.com/uber/h3/blob/master/src/h3lib/lib/linkedGeo.c"
click node_explorer "https://github.com/uber/h3/blob/master/website/src/components/explorer/index.tsx"
click node_explorer_map "https://github.com/uber/h3/blob/master/website/src/components/explorer/map.jsx"
click node_hex_generation "https://github.com/uber/h3/blob/master/website/src/components/explorer/useHex.ts"
click node_input_parser "https://github.com/uber/h3/blob/master/website/src/components/explorer/parseInput.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_cli_tools,node_cell_boundary_cli,node_cell_center_cli,node_user toneBlue
class node_h3_index,node_face_projection,node_base_cells,node_grid_algorithms,node_local_coordinates,node_directed_edges,node_iterators toneAmber
class node_latlng,node_cell_area,node_polygon_fill,node_polygon_geometry,node_multi_polygon,node_linked_geometry toneMint
class node_explorer,node_explorer_map,node_hex_generation,node_input_parser toneRose
class node_h3_js toneIndigo
```

## Components

### Command-line tools

- [H3 CLI](https://github.com/uber/h3/blob/master/src/apps/filters/latLngToCell.c): `src/apps/filters/latLngToCell.c`
- [Boundary CLI](https://github.com/uber/h3/blob/master/src/apps/filters/cellToBoundary.c): `src/apps/filters/cellToBoundary.c`
- [Center CLI](https://github.com/uber/h3/blob/master/src/apps/filters/cellToLatLng.c): `src/apps/filters/cellToLatLng.c`

### Indexing and grids

- [Cell indexes](https://github.com/uber/h3/blob/master/src/h3lib/lib/h3Index.c): `src/h3lib/lib/h3Index.c`
- [Face projection](https://github.com/uber/h3/blob/master/src/h3lib/lib/faceijk.c): `src/h3lib/lib/faceijk.c`
- [Base cells](https://github.com/uber/h3/blob/master/src/h3lib/lib/baseCells.c): `src/h3lib/lib/baseCells.c`
- [Grid algorithms](https://github.com/uber/h3/blob/master/src/h3lib/lib/algos.c): `src/h3lib/lib/algos.c`
- [Local coordinates](https://github.com/uber/h3/blob/master/src/h3lib/lib/localij.c): `src/h3lib/lib/localij.c`
- [Directed edges](https://github.com/uber/h3/blob/master/src/h3lib/lib/directedEdge.c): `src/h3lib/lib/directedEdge.c`
- [Cell iterators](https://github.com/uber/h3/blob/master/src/h3lib/lib/iterators.c): `src/h3lib/lib/iterators.c`

### Geospatial operations

- [Coordinate utilities](https://github.com/uber/h3/blob/master/src/h3lib/lib/latLng.c): `src/h3lib/lib/latLng.c`
- [Area metrics](https://github.com/uber/h3/blob/master/src/h3lib/lib/area.c): `src/h3lib/lib/area.c`
- [Polygon filling](https://github.com/uber/h3/blob/master/src/h3lib/lib/polyfill.c): `src/h3lib/lib/polyfill.c`
- [Polygon geometry](https://github.com/uber/h3/blob/master/src/h3lib/lib/polygon.c): `src/h3lib/lib/polygon.c`
- [Cell boundaries](https://github.com/uber/h3/blob/master/src/h3lib/lib/cellsToMultiPoly.c): `src/h3lib/lib/cellsToMultiPoly.c`
- [Linked geometry](https://github.com/uber/h3/blob/master/src/h3lib/lib/linkedGeo.c): `src/h3lib/lib/linkedGeo.c`

### Web explorer

- [Explorer interface](https://github.com/uber/h3/blob/master/website/src/components/explorer/index.tsx): `website/src/components/explorer/index.tsx`
- [Hex map layers](https://github.com/uber/h3/blob/master/website/src/components/explorer/map.jsx): `website/src/components/explorer/map.jsx`
- [Visible hex generation](https://github.com/uber/h3/blob/master/website/src/components/explorer/useHex.ts): `website/src/components/explorer/useHex.ts`
- [Input parsing](https://github.com/uber/h3/blob/master/website/src/components/explorer/parseInput.ts): `website/src/components/explorer/parseInput.ts`

### Other components

- **User**
- **h3-js binding**

## Connections

- User → H3 CLI: requests cell (evidence: `README.md`)
- H3 CLI → Cell indexes: converts location
- User → Boundary CLI: requests boundary (evidence: `README.md`)
- Boundary CLI → Cell indexes: reads cell index
- User → Center CLI: requests center (evidence: `README.md`)
- Center CLI → Cell indexes: reads cell index
- Cell indexes → Face projection: uses projection (evidence: `src/h3lib/lib/h3Index.c`)
- Cell indexes → Base cells: uses base cells (evidence: `src/h3lib/lib/h3Index.c`)
- Grid algorithms → Base cells: uses neighbors (evidence: `src/h3lib/lib/algos.c`)
- Grid algorithms → Cell indexes: uses cell indexes (evidence: `src/h3lib/lib/algos.c`)
- Local coordinates → Cell indexes: uses cell indexes
- Directed edges → Cell indexes: uses cell indexes
- Cell iterators → Cell indexes: iterates cells
- Cell indexes → Face projection: projects coordinates (evidence: `src/h3lib/lib/faceijk.c`)
- Explorer interface → Input parsing: parses input (evidence: `website/src/components/explorer/index.tsx`)
- Explorer interface → Hex map layers: renders map (evidence: `website/src/components/explorer/index.tsx`)
- Hex map layers → Visible hex generation: uses hex layers (evidence: `website/src/components/explorer/map.jsx`)
- Visible hex generation → h3-js binding: fills polygons (evidence: `website/src/components/explorer/useHex.ts`)
- Hex map layers → User: shows map
- Polygon filling → Polygon geometry: processes polygons
- Cell boundaries → Linked geometry: builds boundaries
- Area metrics → Coordinate utilities: uses coordinates
