|
1 | 1 | # sky-viewer |
2 | 2 |
|
3 | | -Enter a date, location (select on a map), direction, and time of day, and get back a fun animated visualization of the stars — with astronomical accuracy to better than 0.1° over 1900–2100. |
| 3 | +**Live demo:** <https://context-lab.com/sky-viewer/> |
4 | 4 |
|
5 | | -The default view opens on **Moore Hall, Dartmouth College**, facing due north, at midnight on 1969-12-13 EST. |
| 5 | +An interactive, astronomically accurate planetarium in your browser. Pick a date, location (by map, city search, or GPS), direction, and time of day; see the sky as it would appear from that vantage point. Works offline after first load, on any browser, desktop or mobile. |
6 | 6 |
|
7 | | -## What it is |
| 7 | +The default view opens on **Moore Hall, Dartmouth College, Hanover NH**, facing due north, at the current time. |
8 | 8 |
|
9 | | -- **Single-HTML-page web app.** No backend. No API keys. No runtime external calls. |
10 | | -- **Offline-capable** after the first load (service worker precaches everything). |
11 | | -- **Hosted on GitHub Pages**, works in every popular browser on desktop and mobile. |
12 | | -- **Astronomically accurate**: Yale Bright Star Catalogue (≤ mag 6.5), Stellarium Western constellation figures, Meeus-derived Sun / Moon / planet ephemeris, refraction-corrected altitude/azimuth transforms. |
13 | | -- **Rendered in WebGL2** with a full **Canvas2D fallback** for devices without WebGL. |
| 9 | +--- |
14 | 10 |
|
15 | | -## Local development |
| 11 | +## About this project |
| 12 | + |
| 13 | +sky-viewer was built as an in-class demo hackathon project for the **Storytelling with Data** course at Dartmouth, during the *Vibe Coding* lecture. |
| 14 | + |
| 15 | +- Course: <https://context-lab.com/storytelling-with-data/> |
| 16 | +- Vibe coding lecture: <https://context-lab.com/storytelling-with-data/slides/vibe-coding.html> |
| 17 | + |
| 18 | +The entire codebase — spec, plan, tasks, astronomy math, rendering pipeline, UI, tests, CI — was generated through a single Claude Code session using the Spec Kit workflow (`/speckit.constitution` → `/speckit.specify` → `/speckit.plan` → `/speckit.tasks` → `/speckit.implement`) plus many rounds of interactive back-and-forth. The commit history tells the story of the live build. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Features |
| 23 | + |
| 24 | +- **Astronomically accurate.** Yale Bright Star Catalogue (≤ mag 6.5, 8,404 stars) plus Sun, Moon, and all eight planets computed via Meeus-derived ephemeris (VSOP87 / ELP / low-precision Keplerian with empirical corrections). Target accuracy: ≤ 0.1° over 1900–2100. |
| 25 | +- **Any time, any place.** Date, time-of-day, and latitude/longitude are fully user-controllable. Observer time-zones resolve offline via a compact 0.25° IANA boundary lookup. |
| 26 | +- **Click-to-pick location.** Offline map picker with a Natural Earth admin-0 SVG, a GeoNames city autocomplete, and an opt-in `navigator.geolocation` shortcut. |
| 27 | +- **Drag-to-rotate, pinch-to-zoom.** Bearing, pitch (−30° to +90°), and field-of-view (30° to 180°) are all manipulable from the sky canvas or dedicated instrument widgets. |
| 28 | +- **88 IAU constellation line-figures + 87 named bright stars.** Layer toggles for each. |
| 29 | +- **Live View (mobile).** On devices with real sensors, GPS + compass + accelerometer slave the view to where the phone is pointing. |
| 30 | +- **Night Vision Mode.** Red-channel-only overlay to preserve dark-adapted eyes for real stargazing. |
| 31 | +- **Offline after first load.** A small service worker precaches the HTML shell and all five data files so subsequent visits work with no network. |
| 32 | +- **Single-page, no backend.** No API keys. No accounts. No telemetry. No runtime external calls. Host the static output anywhere. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## Run it locally |
16 | 37 |
|
17 | 38 | ```bash |
18 | 39 | npm install |
19 | | -npm run dev # serves at http://localhost:5173 |
| 40 | +npm run dev # http://localhost:5173 |
20 | 41 | ``` |
21 | 42 |
|
22 | | -## Production build |
| 43 | +## Build and preview production |
23 | 44 |
|
24 | 45 | ```bash |
25 | | -npm run build # inlines JS+CSS into dist/index.html, enforces payload budget |
26 | | -npm run preview # serves dist/ at http://localhost:4173 |
| 46 | +npm run build # emits dist/ (single inlined index.html + data/) |
| 47 | +npm run preview # http://localhost:4173 |
27 | 48 | ``` |
28 | 49 |
|
29 | 50 | ## Tests |
30 | 51 |
|
31 | 52 | ```bash |
32 | | -npm test # Vitest — astronomy math, state store, a11y |
33 | | -npm run test:e2e # Playwright — end-to-end in Chromium/Firefox/WebKit |
| 53 | +npm test # Vitest: astronomy math, observation store, a11y |
| 54 | +npm run test:e2e # Playwright: cross-browser E2E with screenshots |
34 | 55 | ``` |
35 | 56 |
|
36 | | -**Astronomical accuracy is verified** by comparing every test fixture against [`astronomy-engine`](https://github.com/cosinekitty/astronomy) (MIT, NASA-derived). Tolerances: 0.1° for stars, 0.2° for planets, 0.5 mag for planet brightness. |
| 57 | +Astronomical accuracy is verified each run against [`astronomy-engine`](https://github.com/cosinekitty/astronomy) (NASA-derived reference, MIT) at five fixture observations. |
37 | 58 |
|
38 | 59 | ## Deploy |
39 | 60 |
|
40 | | -```bash |
41 | | -npm run deploy # pushes dist/ to the gh-pages branch |
42 | | -``` |
| 61 | +A GitHub Actions workflow (`.github/workflows/pages.yml`) auto-deploys to GitHub Pages on every push to `main`. |
| 62 | + |
| 63 | +--- |
43 | 64 |
|
44 | 65 | ## Data sources (all public domain / CC0) |
45 | 66 |
|
46 | | -- **Stars:** Yale Bright Star Catalogue, 5th revised edition |
47 | | -- **Constellations:** Stellarium Western skyculture |
48 | | -- **World map:** Natural Earth 1:110m admin-0 countries |
49 | | -- **Cities:** GeoNames `cities15000` |
50 | | -- **Timezones:** `timezone-boundary-builder` 2024a |
| 67 | +| Source | Used for | |
| 68 | +|-|-| |
| 69 | +| Yale Bright Star Catalogue 5th revised (Harvard) | Star positions + proper motion | |
| 70 | +| Stellarium Western skyculture | Constellation line-figures | |
| 71 | +| Natural Earth 1:110m admin-0 countries | World map SVG | |
| 72 | +| GeoNames `cities15000` | City search | |
| 73 | +| `timezone-boundary-builder` 2024a | Offline tz resolution | |
51 | 74 |
|
52 | | -Raw datasets are pulled by `npm run build:data` and processed into the compact runtime files under `data/`. |
| 75 | +Raw datasets are downloaded and processed to compact runtime files by `npm run build:data`; processed files live under `data/` and ship with the repo. |
| 76 | + |
| 77 | +--- |
53 | 78 |
|
54 | 79 | ## Architecture |
55 | 80 |
|
56 | | -See [`specs/001-sky-viewer-mvp/`](specs/001-sky-viewer-mvp/) for the full specification, plan, research, and tasks. Key principles in [`.specify/memory/constitution.md`](.specify/memory/constitution.md). |
| 81 | +- **`src/astro/`** — pure TypeScript astronomy (time, transforms, Sun/Moon/planets, twilight, star catalogue, constellations) |
| 82 | +- **`src/app/`** — Observation state store with localStorage persistence + a11y live-region summary |
| 83 | +- **`src/render/`** — WebGL2 primary renderer + Canvas2D progressive-enhancement fallback (byte-for-byte-identical projection math) |
| 84 | +- **`src/ui/`** — Date/time, map picker, compass, pitch, FOV, playback, labels, layer toggles, Live View, Night Vision Mode |
| 85 | +- **`specs/001-sky-viewer-mvp/`** — full Spec Kit artifacts (spec, plan, research, data-model, contracts, tasks) |
| 86 | +- **`.specify/memory/constitution.md`** — guiding principles (performance, delight, accuracy, progressive enhancement, spec-driven discipline) |
| 87 | + |
| 88 | +--- |
57 | 89 |
|
58 | | -## Licence |
| 90 | +## License |
59 | 91 |
|
60 | 92 | MIT. See [LICENSE](LICENSE). |
| 93 | + |
| 94 | +Copyright © 2026 Contextual Dynamics Laboratory. |
0 commit comments