|
| 1 | +# Time Series Explorer |
| 2 | + |
| 3 | +Static web UI for exploring a HuggingFace time-series dataset. Reads from a |
| 4 | +local JSONL file during development and from the HuggingFace Datasets Server |
| 5 | +API in production. Deploys to GitHub Pages. |
| 6 | + |
| 7 | +This is the **scaffolding phase** — the UI is intentionally a bare placeholder |
| 8 | +that just confirms the data pipeline works end to end. Real exploration UI |
| 9 | +lands in the design phase. |
| 10 | + |
| 11 | +## Stack |
| 12 | + |
| 13 | +- **Vite + React** — fast dev loop, builds to static files for GitHub Pages. |
| 14 | +- **Plotly.js** (via `react-plotly.js` factory + `plotly.js-dist-min`) — zoom, |
| 15 | + pan, and rangeslider come built in. |
| 16 | +- Plain JavaScript (no TypeScript) — easy to add later if it earns its keep. |
| 17 | + |
| 18 | +## Project layout |
| 19 | + |
| 20 | +``` |
| 21 | +. |
| 22 | +├── index.html # Vite entry |
| 23 | +├── vite.config.js # base path is configurable for GH Pages |
| 24 | +├── package.json |
| 25 | +├── public/ |
| 26 | +│ └── data/ |
| 27 | +│ └── sample.jsonl # tiny synthetic dataset for the dev loop |
| 28 | +├── src/ |
| 29 | +│ ├── main.jsx # React mount |
| 30 | +│ ├── App.jsx # placeholder UI (loads data, plots row 0) |
| 31 | +│ ├── index.css |
| 32 | +│ ├── config.js # reads VITE_* env vars, picks data source |
| 33 | +│ ├── components/ |
| 34 | +│ │ └── Plot.jsx # Plotly wrapper (factory + dist-min) |
| 35 | +│ └── data/ |
| 36 | +│ ├── DataSource.js # abstract interface |
| 37 | +│ ├── LocalDataSource.js # fetches JSONL from public/ |
| 38 | +│ ├── HFDataSource.js # hits datasets-server.huggingface.co |
| 39 | +│ └── index.js # factory: returns the right one for the env |
| 40 | +├── scripts/ |
| 41 | +│ └── export_to_json.py # HF dataset → JSONL for local dev |
| 42 | +└── .github/workflows/ |
| 43 | + └── deploy.yml # build + deploy to GitHub Pages |
| 44 | +``` |
| 45 | + |
| 46 | +## Quick start |
| 47 | + |
| 48 | +```bash |
| 49 | +npm install |
| 50 | +npm run dev |
| 51 | +``` |
| 52 | + |
| 53 | +Opens at http://localhost:5173 reading `public/data/sample.jsonl` (5 short |
| 54 | +synthetic series). You should see metadata up top and a Plotly preview of the |
| 55 | +first row. |
| 56 | + |
| 57 | +## Switching data sources |
| 58 | + |
| 59 | +Two modes, controlled by `VITE_DATA_SOURCE`: |
| 60 | + |
| 61 | +| Mode | Reads from | When | |
| 62 | +| ------- | ------------------------------------------- | ----------- | |
| 63 | +| `local` | `public/<VITE_LOCAL_DATA_PATH>` (JSONL) | dev default | |
| 64 | +| `hf` | HuggingFace Datasets Server API (no auth, public datasets) | prod default | |
| 65 | + |
| 66 | +### Use your real dataset locally |
| 67 | + |
| 68 | +Convert the on-disk HF dataset to JSONL once: |
| 69 | + |
| 70 | +```bash |
| 71 | +pip install datasets |
| 72 | +python scripts/export_to_json.py \ |
| 73 | + --dataset /path/to/your/saved/dataset \ |
| 74 | + --output public/data/dataset.jsonl |
| 75 | +``` |
| 76 | + |
| 77 | +Then in `.env.local`: |
| 78 | + |
| 79 | +``` |
| 80 | +VITE_LOCAL_DATA_PATH=data/dataset.jsonl |
| 81 | +``` |
| 82 | + |
| 83 | +For fast iteration while developing, pass `--limit 200` to export a subset. |
| 84 | + |
| 85 | +### Point at the HuggingFace Hub instead |
| 86 | + |
| 87 | +Once your dataset is uploaded: |
| 88 | + |
| 89 | +``` |
| 90 | +VITE_DATA_SOURCE=hf |
| 91 | +VITE_HF_DATASET=your-username/your-dataset |
| 92 | +VITE_HF_CONFIG=default |
| 93 | +VITE_HF_SPLIT=train |
| 94 | +``` |
| 95 | + |
| 96 | +The `HFDataSource` paginates the `/rows` endpoint (which caps at 100 rows per |
| 97 | +request). |
| 98 | + |
| 99 | +## Deploying to GitHub Pages |
| 100 | + |
| 101 | +1. Push this repo to GitHub. |
| 102 | +2. **Settings → Pages**: set source to **GitHub Actions**. |
| 103 | +3. **Settings → Secrets and variables → Actions → Variables**: add |
| 104 | + `HF_DATASET` (and optionally `HF_CONFIG`, `HF_SPLIT`). |
| 105 | +4. Push to `main`. The workflow builds with `BASE_PATH=/<repo-name>/` and |
| 106 | + deploys. |
| 107 | + |
| 108 | +The site URL will be `https://<your-username>.github.io/<repo-name>/`. |
| 109 | + |
| 110 | +> Static-site limitation: any HF token shipped with the build is public, so |
| 111 | +> the dataset must remain **public** on HuggingFace for this deployment model. |
| 112 | +
|
| 113 | +## What's intentionally not here yet |
| 114 | + |
| 115 | +- Schema-aware exploration (filtering, multi-series overlay, search) — design |
| 116 | + phase. |
| 117 | +- Styling beyond a minimal reset — design phase. |
| 118 | +- Tests — once the data layer firms up. |
| 119 | +- TypeScript — straightforward to add when the surface is bigger. |
| 120 | + |
| 121 | +## Next step |
| 122 | + |
| 123 | +Share a sample row (or the dataset schema) and we'll lock in the data shape |
| 124 | +the rest of the UI will be built around. |
0 commit comments