How bilgetutak/d3-cesm-tiling works
Project type and purpose
• This is a thin‑server/full‑client map‑tiling web application.
• Flask (Python) provides a lightweight HTTP server and serves static assets.
• The client (browser) loads HTML/CSS/JS and uses d3.js (and custom JS code) to fetch NetCDF data and render map tiles entirely in the browser.
File structure
• Top level
– app.py: Flask entrypoint
– README.md, LICENSE, .gitignore
• Templates
– templates/index.html: Single HTML page scaffold
• Static
– static/css/site.css (+ fonts)
– static/js/grid.js, outlines.js (d3‑based map logic)
– static/data/*.nc (NetCDF datasets)
README insights
• Client‐heavy rendering: “render map tiles from a NetCDF file completely on the client side.”
• Dependencies (Flask, datashader.utils, xarray, pandas) are needed to run the server, but the actual tiling logic lives in grid.js / outlines.js.
• A Figma schematic exists for a high‑level overview.
Main components
A. Backend (Flask server)
• Component: Flask app (app.py)
• Responsibilities: Serve index.html, CSS/JS assets, and .nc files from static/data
• Technology: Python, Flask, optionally xarray/pandas/datashader for any preprocessing (if used)
B. Frontend (Browser)
• Component: Single‐Page Interface (index.html + site.css)
• Component: d3.js + custom scripts (grid.js, outlines.js)
• Responsibilities:
• Fetch NetCDF files via HTTP GET from /static/data/*.nc
• Parse NetCDF in‐browser (via netcdfjs or similar)
• Generate and layer map tiles using d3.js
C. Data store (Static files)
• Component: NetCDF datasets in static/data
D. External/Optional
• If any server‐side tiling or preprocessing is used, include data‐preprocessor module (xarray, pandas, datashader.utils)
Relationships and interactions
1. Browser → Flask server:
• GET / → index.html
• GET /static/css/site.css, /static/js/*.js → deliver assets
• GET /static/data/*.nc → fetch raw NetCDF files
2. Frontend (grid.js / outlines.js) → in‑browser NetCDF parser → d3.js rendering pipeline
3. (Optional) Flask → xarray/pandas/datashader → preprocessed tiles → static/data
Architectural patterns & design principles
• Client‐heavy MVC:
• V & C in browser (d3.js views + controller logic)
• M is the NetCDF data store
• Separation of concerns:
• Flask only hosts files
• Client does all computational work
• Static asset serving: minimal backend logic
[ ] Components clearly labeled (Flask server, Browser, Data store)
[ ] Notes or annotations on technologies (Flask, d3.js, netcdfjs/xarray)
[ ] Optional extension point: server‐side preprocessing with datashader.utils