# x80110/migration-visualization architecture

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

- Interactive diagram: https://gitdiagram.com/x80110/migration-visualization
- Repository: https://github.com/x80110/migration-visualization

## Overview

##### Project type and purpose
- This is a static, data-driven web application (“Global Migration Data Explorer”) intended for interactive data visualization.

##### File structure
Top-level:
– HTML pages (index.html, stocks.html, flows_by_sex.html, flows_by_type.html)
– JS “entry” scripts (chord-chart.js, sankey-chart.js, prepare-data.js)
– Data directories:
- data/ (raw CSV + country metadata)
- json/ (prepared JSON files per flow and stock measure)
- static/texts/ (markdown/JS for descriptive copy)
– libs/ (third-party JS: chord.js, parsemd.js)
– styles.css
Patterns & build:
– A Node-based preprocessing step (prepare-data.js) converts CSV → JSON.
– No dynamic server: all assets are served statically (can be hosted on GitHub Pages or any static HTTP server).
– Each HTML page loads:
- DataLoader (XHR/fetch of JSON)
- Chart modules (Sankey or chord)
- parsemd.js to render markdown text

##### README for additional insights
– Confirms use of multiple estimation methods → multiple JSON datasets.
– Highlights open-access, client-side interactivity.
– Mentions D3-style visualizations, though direct dependency is chord.js (a D3 plugin) and sankey-style code.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Build-Time Layer
  subgraph "Build-Time"
    CSV(("Raw CSV Files")):::dataStore
    PREP["prepare-data.js"]:::build
    JSON(("Precomputed JSON Files")):::dataStore
  end
  CSV --> PREP --> JSON

  %% Static Hosting & Asset Store
  subgraph "Static Hosting & Asset Store"
    SVR["Static HTTP Server"]:::server
    idx["index.html"]:::server
    stocks["stocks.html"]:::server
    stocks_sex["stocks_by_sex.html"]:::server
    flows_sex["flows_by_sex.html"]:::server
    flows_type["flows_by_type.html"]:::server
    sankeyJS["sankey-chart.js"]:::server
    chordJS["chord-chart.js"]:::server
    parsemd["libs/parsemd.js"]:::server
    chordLib["libs/chord.js"]:::server
    styleCSS["styles.css"]:::server
    fsm["flow-sex-text.md"]:::server
    ftm["flow-total-text.md"]:::server
    ssm["stock-sex-text.md"]:::server
    stm["stock-total-text.md"]:::server
    methods["methods.js"]:::server
  end

  PREP --> SVR
  SVR --> idx --> Browser
  SVR --> stocks --> Browser
  SVR --> stocks_sex --> Browser
  SVR --> flows_sex --> Browser
  SVR --> flows_type --> Browser
  SVR --> sankeyJS --> Browser
  SVR --> chordJS --> Browser
  SVR --> parsemd --> Browser
  SVR --> chordLib --> Browser
  SVR --> styleCSS --> Browser
  SVR --> JSON --> Browser
  SVR --> fsm --> Browser
  SVR --> ftm --> Browser
  SVR --> ssm --> Browser
  SVR --> stm --> Browser
  SVR --> methods --> Browser

  %% Client-Side Browser Layer
  subgraph "Browser (Client-Side)"
    DL["Data Loader Module"]:::client
    SC["Sankey Module"]:::client
    CC["Chord Module"]:::client
    MDREN["Markdown Renderer"]:::client
    CSSC["CSS Styles"]:::client
  end

  Browser --> DL
  DL -->|fetch JSON| JSON
  DL -->|fetch MD| fsm
  DL -->|fetch MD| ftm
  DL -->|fetch MD| ssm
  DL -->|fetch MD| stm
  DL -->|fetch MD| methods
  SC -->|uses| sankeyJS
  CC -->|uses| chordJS
  MDREN -->|uses| parsemd
  SC -->|"renders SVG"| Browser
  CC -->|"renders SVG"| Browser

  %% Repository Config Files
  subgraph "Repository Config"
    git[".gitignore"]:::server
    readme["README.md"]:::server
    vscode[".vscode"]:::server
    ds[".DS_Store"]:::server
  end

  %% Click Events
  click PREP "https://github.com/x80110/migration-visualization/blob/main/prepare-data.js"
  click CSV "https://github.com/x80110/migration-visualization/blob/main/data/country-metadata-flags.csv"
  click JSON "https://github.com/x80110/migration-visualization/tree/main/json/"
  click idx "https://github.com/x80110/migration-visualization/blob/main/index.html"
  click stocks "https://github.com/x80110/migration-visualization/blob/main/stocks.html"
  click stocks_sex "https://github.com/x80110/migration-visualization/blob/main/stocks_by_sex.html"
  click flows_sex "https://github.com/x80110/migration-visualization/blob/main/flows_by_sex.html"
  click flows_type "https://github.com/x80110/migration-visualization/blob/main/flows_by_type.html"
  click sankeyJS "https://github.com/x80110/migration-visualization/blob/main/sankey-chart.js"
  click chordJS "https://github.com/x80110/migration-visualization/blob/main/chord-chart.js"
  click parsemd "https://github.com/x80110/migration-visualization/blob/main/libs/parsemd.js"
  click chordLib "https://github.com/x80110/migration-visualization/blob/main/libs/chord.js"
  click styleCSS "https://github.com/x80110/migration-visualization/blob/main/styles.css"
  click fsm "https://github.com/x80110/migration-visualization/blob/main/static/texts/flow-sex-text.md"
  click ftm "https://github.com/x80110/migration-visualization/blob/main/static/texts/flow-total-text.md"
  click ssm "https://github.com/x80110/migration-visualization/blob/main/static/texts/stock-sex-text.md"
  click stm "https://github.com/x80110/migration-visualization/blob/main/static/texts/stock-total-text.md"
  click methods "https://github.com/x80110/migration-visualization/blob/main/static/texts/methods.js"
  click git "https://github.com/x80110/migration-visualization/blob/main/.gitignore"
  click readme "https://github.com/x80110/migration-visualization/blob/main/README.md"
  click vscode "https://github.com/x80110/migration-visualization/blob/main/.vscode"
  click ds "https://github.com/x80110/migration-visualization/blob/main/.DS_Store"

  %% Styles
  classDef build fill:#9f6,stroke:#333,stroke-width:2px
  classDef server fill:#6cf,stroke:#333,stroke-width:2px
  classDef client fill:#fc6,stroke:#333,stroke-width:2px
  classDef dataStore fill:#fff,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
```
