How rawgraphs/rawgraphs-app works
Project Type and Purpose
• RAWGraphs is a client-only, single-page web application (SPA) for creating SVG-based data visualizations on top of D3.js.
• There is no backend or server-side data storage: all data parsing, processing, and rendering happen in the browser.
Key Architectural Layers
a. Static Asset Layer (“public” folder)
– index.html, manifest.json, robots.txt
– Sample datasets served as TSV/CSV files under public/sample-datasets
b. Application Shell (Browser)
– React SPA bootstrapped in src/index.js
– Service Worker (src/serviceWorker.js) for asset caching & offline support
– Web Worker (src/worker/worker.js) for heavy or asynchronous layout computations
c. UI Component Layer (src/components)
– ChartSelector: choose visualization type
– DataLoader: supports UploadFile, URL fetch, SPARQL, Paste, LoadProject
– DataMapping: map raw rows to chart dimensions
– ChartPreview / ChartPreviewWithOptions: render D3 output into SVG
– Exporter / CopyToClipboardButton: export SVG or raw config
– Utility components: Modal, JsonViewer, DataTable/DataGrid, InlineColorPicker, etc.
d. Core Logic & Hooks (src/charts.js, src/hooks)
– charts.js: registry of built-in chart layouts
– useDataLoader, useDataLoaderUtils: parsing and validation
– useCustomCharts: loading user-defined layouts dynamically
– useWindowSize, useDebounce, etc. for UI responsiveness
e. Styling & Fonts (src/styles)
– SCSS modules for component styles, global index.scss
– Embedded IBM-Plex and Inter Web font assets
Visualizing Component Relationships & Data Flow
• At startup, index.html loads the JS bundle → React initializes App.js → Service Worker registers → Main UI renders → Web Worker spun up (optionally) for layout tasks.
• User triggers DataLoader → raw data passed to parsing hooks → structured dataset delivered to DataMapping → mapping result + user options sent to ChartOptions → ChartPreviewWithOptions requests layout from charts.js (or Web Worker) → returns SVG elements → displayed in UI.
• On “export,” Exporter serializes SVG or JSON and uses CopyToClipboardButton or triggers file download.
Architectural Patterns & Principles
• Component-driven UI (React) with isolated, reusable modules.
• Hooks for cross-cutting logic (data parsing, custom chart loading, sizing).
• SPA with clear separation of concerns: static assets vs. UI vs. processing engine vs. export utilities.
• Client-only data privacy: zero backend, no network calls except optional URL/SPARQL fetch.
• Extensibility: dynamic loading of user-provided chart layouts via import_export scripts.