# Phase 0: Data Flow Diagrams **Date:** 2026-07-27 **Status:** Complete **Deliverable:** Comprehensive data flow analysis --- ## Executive Summary The Makepad map codebase has **5 major data flows** with several critical issues including circular data dependencies, unclear data ownership, and inefficient data transformations. **Key Findings:** - 5 major data flows identified - 3 circular data dependencies (critical issue) - Unclear data ownership in several flows - Inefficient data transformations (unnecessary copies) - Missing data validation in several flows --- ## 1. Data Flow Overview ### 1.1 Major Data Flows | ID | Data Flow | Direction | Modules Involved | Status | |----|-----------|-----------|------------------|--------| | DF1 | Tile Loading | Network → Cache → Renderer | scheduler, cache, renderer | **Circular** | | DF2 | User Interaction | User → Viewport → Renderer | view, viewport, renderer | OK | | DF3 | Style Application | Style JSON → Compiled Style → Renderer | style_json, style, renderer | OK | | DF4 | Label Placement | Tile Data → Label State → Renderer | tile_decode, label_state, renderer | **Circular** | | DF5 | Cache Eviction | Cache → Tile Data → Disk | cache, tile_disk | OK | ### 1.2 Data Flow Statistics ``` Total data flows: 5 Circular data flows: 2 (40%) Average modules per flow: 3.2 Maximum modules per flow: 4 (DF4) ``` --- ## 2. Data Flow #1: Tile Loading ### 2.1 Flow Diagram ``` ┌─────────────────────────────────────────────────────────────────────────────┐ │ DATA FLOW #1: TILE LOADING │ └─────────────────────────────────────────────────────────────────────────────┘ ┌─────────────┐ │ Network │ │ (Overpass │ │ API) │ └──────┬──────┘ │ │ HTTP Response (JSON/MVT) │ Size: 10KB - 1MB per tile │ Frequency: 1-100 requests/sec ▼ ┌─────────────────┐ │ TileScheduler │ │ │ │ Data: │ │ - TileKey │ │ - Request ID │ │ - Generation │ └────────┬────────┘ │ │ TileAction::LoadFromNetwork │ Contains: HTTP request ▼ ┌─────────────────┐ │ NigigMapView │ │ │ │ Data: │ │ - HTTP request │ │ - Request ID │ └────────┬────────┘ │ │ Makepad HTTP API │ Async request ▼ ┌─────────────────┐ │ HTTP Client │ │ (Makepad) │ │ │ │ Data: │ │ - URL │ │ - Headers │ │ - Body │ └────────┬────────┘ │ │ HTTP Response │ Status: 200/404/500 │ Body: JSON/MVT (10KB - 1MB) ▼ ┌─────────────────┐ │ NigigMapView │ │ │ │ Data: │ │ - Response │ │ - Status code │ │ - Body │ └────────┬────────┘ │ │ TileWorkerMessage::NetworkTileParsed │ Contains: TileBuffers ▼ ┌─────────────────┐ │ TileDecoder │ │ (Worker Pool) │ │ │ │ Data: │ │ - TileKey │ │ - Body (JSON) │ │ - Style │ └────────┬────────┘ │ │ Parse JSON/MVT │ Extract geometry │ Apply styles ▼ ┌─────────────────┐ │ TileBuffers │ │ │ │ Data: │ │ - fill_vertices│ │ Vec │ │ Size: 10KB │ │ - fill_indices │ │ Vec │ │ Size: 5KB │ │ - stroke_verts │ │ Vec │ │ Size: 20KB │ │ - stroke_inds │ │ Vec │ │ Size: 10KB │ │ - labels │ │ Vec