Commit 7667ab4
chore: Modularize frontend architecture and remove ORCA code (#33)
## Summary
This PR refactors the contributor network visualization from a 3,400+
line monolithic `index.js` into a modular, maintainable architecture
with 32 focused ES6 modules. The main entry point has been reduced by
**~57%** (from 3,400+ lines to 1,505 lines), with complex logic
extracted into dedicated, testable modules.
This refactoring also includes significant code cleanup, removing
**~500+ lines of ORCA-specific code** that was inherited from the
original visualization but not used in our implementation. This includes
ORCA data loading, ORCA-specific positioning logic, dual ring
visualization, and highlight backgrounds.
<sup>1</sup> *Note: Vite was initially added during development to test
bundling, but we ultimately decided against it to reduce complexity and
use native ES modules instead.*
### Code Cleanup: ORCA-Specific Code Removal
**Removed:**
- ORCA data loading and processing logic
- ORCA-specific positioning (`RADIUS_CONTRIBUTOR_NON_ORCA`,
`ORCA_PRESENT` flag)
- Dual ring visualization (ORCA vs non-ORCA contributors)
- ORCA highlight backgrounds and opacity reduction logic
- ORCA-specific tooltip content
- `orca_received` and `orca_impacted` data properties
- Remaining contributors ring drawing (not used in our visualization)
**Renamed for Clarity:**
- `ORCA_RING_WIDTH` → `CONTRIBUTOR_RING_WIDTH` (generic contributor
ring)
- `createORCAVisual` → `createContributorNetworkVisual`
- `debug-orca` flag → `debug-contributor-network`
### Architecture Changes
#### 1. **Data Preparation Module** (`src/js/data/prepare.js`)
- Extracted `prepareData()` function (~515 lines → 673 lines with
documentation)
- Handles all data transformation, normalization, and node creation
- Returns structured data object instead of mutating global state
- Includes comprehensive input validation and error handling
#### 2. **Layout & Positioning Module** (`src/js/layout/positioning.js`)
- Extracted `positionContributorNodes()` function (~117 lines → 179
lines)
- Calculates contributor ring radius and positions nodes
- Includes configuration constants and validation
- Returns calculated values instead of mutating globals
#### 3. **Render Orchestration Module** (`src/js/render/draw.js`)
- Extracted `draw()` function (~166 lines → 198 lines)
- Orchestrates the complete rendering pipeline
- Uses dependency injection pattern for render functions
- Includes validation and error checking
### Build System Changes
#### Native ES Modules (No Bundler)
- After testing Vite bundling, switched to use native ES modules instead
#### Updated Build Process
- Modified `src/contributor_network/cli.py` to copy `src/js/` directory
to `dist/`
- Updated HTML template to properly load ES modules with `type="module"`
- Added module load event handling to ensure proper initialization order
## File Structure
```
contributor-network/
├── python/ # Python backend
│ ├── contributor_network/ # CLI package
│ ├── tests/ # Python tests
│ └── templates/ # Jinja2 HTML templates
├── js/ # JavaScript frontend
│ ├── chart.js # Main D3.js visualization (was index.js)
│ ├── index.js # Module re-exports
│ ├── __tests__/ # JS tests
│ ├── config/ # Theme and scales
│ ├── data/ # Data preparation
│ ├── render/ # Canvas rendering
│ └── ...
├── assets/ # Static assets
│ ├── css/ # Stylesheets
│ ├── data/ # CSV data files
│ ├── img/ # Images
│ └── lib/ # Vendored D3 libraries
├── index.html # Entry point
├── pyproject.toml # Python config (points to python/)
├── package.json # JS config
├── config.toml, veda.toml # Project configs
└── README.md, LICENSE, etc.
```
## Migration Notes
### For Developers
1. **Import Paths:** All imports now use relative paths from `src/js/`
2. **Module Structure:** New code should follow the established module
structure
### For Build Process
The build command remains the same:
```bash
uv run contributor-network build data dist
```
The build process now:
1. Copies CSV data files (`top_contributors.csv`, `repositories.csv`,
`links.csv`) to the destination folder
2. Copies `index.js` (main entry point) to the destination
3. Copies `src/js/` modules to `{destination}/src/js/` for native ES
module imports
4. Copies CSS, D3 library files, and images to the destination
5. Generates `index.html` from the Jinja2 template with proper ES module
script tags (`type="module"`)
---------
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>1 parent dbb86d3 commit 7667ab4
File tree
498 files changed
+11446
-3815
lines changed- .github/workflows
- assets
- css
- data
- links
- Clay-foundation/model
- Disasters-Learning-Portal/veda-disasters
- EOEPCA
- demo
- resource-discovery
- EOPF-Explorer
- landing-page
- narratives
- titiler-eopf
- GenericMappingTools/pygmt
- MAAP-Project
- maap-documentation
- maap-eoapi
- NASA-IMPACT
- csda-client
- veda-backend
- veda-config
- veda-data-airflow
- veda-deploy
- veda-keycloak
- veda-odd
- veda-ui
- OSMCha
- osmcha-django
- osmcha-frontend
- beatrizbsperes/eopf-101
- developmentseed
- async-tiff
- cql2-rs
- deck.gl-raster
- eo-predictor
- eoAPI
- eoapi-cdk
- eoapi-k8s
- geojson-pydantic
- geotiff-test-data
- lonboard
- morecantile
- moz-proenergia-backend
- obstore
- openeo-studio
- openeo-udp
- osm-seed
- osm-teams
- pixelverse
- rio-stac
- rio-viz
- stac-auth-proxy
- stac-map
- tipg
- titiler-cmr
- titiler
- eopf-toolkit/eopf-101
- geoarrow
- deck.gl-layers
- geoarrow-rs
- geoarrow
- hotosm
- openaerialmap
- tasking-manager
- opengeospatial/geoparquet
- osm-seed/osm-seed
- pydata/xarray
- radiantearth
- stac-api-spec
- stac-spec
- sentinel-hub/titiler-openeo
- source-cooperative/source.coop
- stac-utils
- pgstac
- pystac-client
- pystac
- rustac
- stac-fastapi-pgstac
- stac-fastapi
- virtual-zarr/obspec-utils
- wri
- project-zeno-deploy
- project-zeno-next
- zarr-developers
- VirtualiZarr
- zarr-python
- repositories
- Clay-foundation
- Disasters-Learning-Portal
- EOEPCA
- EOPF-Explorer
- GenericMappingTools
- MAAP-Project
- NASA-IMPACT
- OSMCha
- beatrizbsperes
- developmentseed
- eopf-toolkit
- geoarrow
- hotosm
- opengeospatial
- osm-seed
- pydata
- radiantearth
- sentinel-hub
- source-cooperative
- stac-utils
- virtual-zarr
- wri
- zarr-developers
- img
- lib
- data/links
- developmentseed
- eoAPI
- titiler
- geoarrow/geoarrow-rs
- pydata/xarray
- stac-utils/pgstac
- js
- __tests__
- config
- data
- interaction
- layout
- render
- simulations
- state
- utils
- visualization
- python
- contributor_network
- templates
- tests
- src/contributor_network
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
498 files changed
+11446
-3815
lines changedBinary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
52 | 75 | | |
53 | 76 | | |
54 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | | - | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | | - | |
| 72 | + | |
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
| |||
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
90 | | - | |
| 89 | + | |
91 | 90 | | |
92 | 91 | | |
93 | | - | |
| 92 | + | |
94 | 93 | | |
95 | 94 | | |
96 | | - | |
| 95 | + | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| |||
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
112 | 151 | | |
113 | 152 | | |
114 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
| 365 | + | |
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
373 | 422 | | |
374 | 423 | | |
375 | 424 | | |
| |||
379 | 428 | | |
380 | 429 | | |
381 | 430 | | |
382 | | - | |
| 431 | + | |
383 | 432 | | |
384 | 433 | | |
385 | 434 | | |
| |||
421 | 470 | | |
422 | 471 | | |
423 | 472 | | |
424 | | - | |
425 | 473 | | |
426 | 474 | | |
427 | 475 | | |
428 | 476 | | |
429 | 477 | | |
| 478 | + | |
430 | 479 | | |
431 | 480 | | |
432 | 481 | | |
| |||
0 commit comments