# bright-fakl/carto-flow architecture

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

- Interactive diagram: https://gitdiagram.com/bright-fakl/carto-flow
- Repository: https://github.com/bright-fakl/carto-flow

## Overview

carto-flow is a Python library that turns geographic vector data and a variable into cartograms. The principal workflow is to provide geographic data and values to a cartogram API, run a style-specific transformation or layout, then inspect or visualize the result. The README documents flow, symbol, and proportional cartograms; the source tree also contains a distinct Voronoi implementation. Shared geographic utilities support spatial preparation. Internal links are limited to relationships named in the SOURCE INDEX; unsampled API wiring is not asserted.

Main entry points: [`src/carto_flow/flow_cartogram/algorithm.py`](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/algorithm.py) (Diffusion engine), [`src/carto_flow/symbol_cartogram/layouts/data_prep.py`](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/data_prep.py) (Layout preparation), [`src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py`](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py) (Mosaic layout), [`src/carto_flow/symbol_cartogram/layouts/layout_result.py`](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/layout_result.py) (Layout result)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flow["Flow cartograms"]
  node_flow_api["Flow API<br/>[api.py]"]
  node_flow_algorithm["Diffusion engine<br/>[algorithm.py]"]
  node_flow_density["Density field<br/>[density.py]"]
  node_flow_velocity["Velocity field<br/>[velocity.py]"]
  node_flow_grid["Spatial grid<br/>[grid.py]"]
  node_flow_result["Cartogram result<br/>[cartogram.py]"]
  node_flow_visuals["Flow visualization<br/>[visualization.py]"]
end

subgraph group_symbols["Symbol cartograms"]
  node_symbol_api["Symbol API<br/>[api.py]"]
  node_symbol_prep["Layout preparation<br/>[data_prep.py]"]
  node_symbol_layouts["Layout strategies"]
  node_mosaic["Mosaic layout<br/>[__init__.py]"]
  node_symbol_result["Layout result<br/>[layout_result.py]"]
  node_symbol_shapes["Symbols and tiles<br/>[symbols.py]"]
  node_symbol_viz["Symbol visualization<br/>[visualization.py]"]
end

subgraph group_proportional["Proportional cartograms"]
  node_proportional_ops["Split and shrink"]
end

subgraph group_voronoi["Voronoi cartograms"]
  node_voronoi_api["Voronoi API<br/>[api.py]"]
  node_voronoi_fields["Relaxation fields"]
  node_voronoi_result["Voronoi result<br/>[result.py]"]
end

subgraph group_geo["Geographic utilities"]
  node_geo_adjacency["Adjacency tools<br/>[adjacency.py]"]
  node_geo_repair["Contiguity repair<br/>[contiguity.py]"]
end

node_user(("Library user"))

node_user -->|"requests morph"| node_flow_api
node_flow_algorithm -->|"uses field"| node_flow_density
node_flow_algorithm -->|"uses field"| node_flow_velocity
node_flow_algorithm -->|"uses grid"| node_flow_grid
node_flow_result -->|"delegates plotting"| node_flow_visuals
node_user -->|"requests layout"| node_symbol_api
node_symbol_api -.->|"prepares data"| node_symbol_prep
node_symbol_layouts -->|"uses preparation"| node_symbol_prep
node_mosaic -->|"uses preparation"| node_symbol_prep
node_mosaic -.->|"repairs contiguity"| node_geo_repair
node_symbol_result -->|"uses symbols"| node_symbol_shapes
node_symbol_result -.->|"supports visualization"| node_symbol_viz
node_user -.->|"requests split or shrink"| node_proportional_ops
node_user -.->|"requests cartogram"| node_voronoi_api
node_voronoi_api -.->|"uses fields"| node_voronoi_fields
node_voronoi_result -->|"checks adjacency"| node_geo_adjacency
node_voronoi_result -.->|"uses field output"| node_voronoi_fields
node_geo_repair -->|"uses adjacency"| node_geo_adjacency

click node_flow_api "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/api.py"
click node_flow_algorithm "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/algorithm.py"
click node_flow_density "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/density.py"
click node_flow_velocity "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/velocity.py"
click node_flow_grid "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/grid.py"
click node_flow_result "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/cartogram.py"
click node_flow_visuals "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/visualization.py"
click node_symbol_api "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/api.py"
click node_symbol_prep "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/data_prep.py"
click node_symbol_layouts "https://github.com/bright-fakl/carto-flow/tree/main/src/carto_flow/symbol_cartogram/layouts"
click node_mosaic "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py"
click node_symbol_result "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/layout_result.py"
click node_symbol_shapes "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/symbols.py"
click node_symbol_viz "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/visualization.py"
click node_proportional_ops "https://github.com/bright-fakl/carto-flow/tree/main/src/carto_flow/proportional_cartogram"
click node_voronoi_api "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/voronoi_cartogram/api.py"
click node_voronoi_fields "https://github.com/bright-fakl/carto-flow/tree/main/src/carto_flow/voronoi_cartogram/fields"
click node_voronoi_result "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/voronoi_cartogram/result.py"
click node_geo_adjacency "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/geo_utils/adjacency.py"
click node_geo_repair "https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/geo_utils/contiguity.py"

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_flow_api,node_flow_algorithm,node_flow_density,node_flow_velocity,node_flow_grid,node_flow_result,node_flow_visuals,node_user toneBlue
class node_symbol_api,node_symbol_prep,node_symbol_layouts,node_mosaic,node_symbol_result,node_symbol_shapes,node_symbol_viz toneAmber
class node_proportional_ops toneMint
class node_voronoi_api,node_voronoi_fields,node_voronoi_result toneRose
class node_geo_adjacency,node_geo_repair toneIndigo
```

## Components

### Flow cartograms

- [Flow API](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/api.py): `src/carto_flow/flow_cartogram/api.py`
- [Diffusion engine](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/algorithm.py): `src/carto_flow/flow_cartogram/algorithm.py`
- [Density field](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/density.py): `src/carto_flow/flow_cartogram/density.py`
- [Velocity field](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/velocity.py): `src/carto_flow/flow_cartogram/velocity.py`
- [Spatial grid](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/grid.py): `src/carto_flow/flow_cartogram/grid.py`
- [Cartogram result](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/cartogram.py): `src/carto_flow/flow_cartogram/cartogram.py`
- [Flow visualization](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/flow_cartogram/visualization.py): `src/carto_flow/flow_cartogram/visualization.py`

### Symbol cartograms

- [Symbol API](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/api.py): `src/carto_flow/symbol_cartogram/api.py`
- [Layout preparation](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/data_prep.py): `src/carto_flow/symbol_cartogram/layouts/data_prep.py`
- [Layout strategies](https://github.com/bright-fakl/carto-flow/tree/main/src/carto_flow/symbol_cartogram/layouts): `src/carto_flow/symbol_cartogram/layouts`
- [Mosaic layout](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py): `src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py`
- [Layout result](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/layouts/layout_result.py): `src/carto_flow/symbol_cartogram/layouts/layout_result.py`
- [Symbols and tiles](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/symbols.py): `src/carto_flow/symbol_cartogram/symbols.py`
- [Symbol visualization](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/symbol_cartogram/visualization.py): `src/carto_flow/symbol_cartogram/visualization.py`

### Proportional cartograms

- [Split and shrink](https://github.com/bright-fakl/carto-flow/tree/main/src/carto_flow/proportional_cartogram): `src/carto_flow/proportional_cartogram`

### Voronoi cartograms

- [Voronoi API](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/voronoi_cartogram/api.py): `src/carto_flow/voronoi_cartogram/api.py`
- [Relaxation fields](https://github.com/bright-fakl/carto-flow/tree/main/src/carto_flow/voronoi_cartogram/fields): `src/carto_flow/voronoi_cartogram/fields`
- [Voronoi result](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/voronoi_cartogram/result.py): `src/carto_flow/voronoi_cartogram/result.py`

### Geographic utilities

- [Adjacency tools](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/geo_utils/adjacency.py): `src/carto_flow/geo_utils/adjacency.py`
- [Contiguity repair](https://github.com/bright-fakl/carto-flow/blob/main/src/carto_flow/geo_utils/contiguity.py): `src/carto_flow/geo_utils/contiguity.py`

### Other components

- **Library user**

## Connections

- Library user → Flow API: requests morph (evidence: `README.md`)
- Diffusion engine → Density field: uses field (evidence: `src/carto_flow/flow_cartogram/algorithm.py`)
- Diffusion engine → Velocity field: uses field (evidence: `src/carto_flow/flow_cartogram/algorithm.py`)
- Diffusion engine → Spatial grid: uses grid (evidence: `src/carto_flow/flow_cartogram/algorithm.py`)
- Cartogram result → Flow visualization: delegates plotting (evidence: `src/carto_flow/flow_cartogram/cartogram.py`)
- Library user → Symbol API: requests layout (evidence: `README.md`)
- Symbol API → Layout preparation: prepares data
- Layout strategies → Layout preparation: uses preparation (evidence: `src/carto_flow/symbol_cartogram/layouts/base.py`)
- Mosaic layout → Layout preparation: uses preparation (evidence: `src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py`)
- Mosaic layout → Contiguity repair: repairs contiguity (evidence: `src/carto_flow/symbol_cartogram/layouts/mosaic/__init__.py`)
- Layout result → Symbols and tiles: uses symbols (evidence: `src/carto_flow/symbol_cartogram/layouts/layout_result.py`)
- Layout result → Symbol visualization: supports visualization
- Library user → Split and shrink: requests split or shrink (evidence: `README.md`)
- Library user → Voronoi API: requests cartogram
- Voronoi API → Relaxation fields: uses fields
- Voronoi result → Adjacency tools: checks adjacency (evidence: `src/carto_flow/voronoi_cartogram/result.py`)
- Voronoi result → Relaxation fields: uses field output
- Contiguity repair → Adjacency tools: uses adjacency (evidence: `src/carto_flow/geo_utils/contiguity.py`)
