How samarthg187/1050-light-website-ml-implementation works
1. This repository is a static, browser-first web app backed by JSON files in the GitHub repo itself. There is no traditional database or application server; the primary data store is the readings/ folder plus the top-level sessions.json index.
2. The site has three main user-facing pages: index.html for the map overview, SessionDetail.html for per-session exploration, and SubmitReading.html for ingesting new CSV sessions. Aboutuspage.html is documentation/reference content rather than a data-driven view.
3. The homepage is the light-weight entry point. It fetches only sessions.json, not the full reading payloads, so it can place one map pin per session and color those pins by avgClear. This keeps the overview decoupled from the larger session files.
4. SessionDetail.html is the deep-dive view. It loads one file from readings/session_XXX.json based on the session query parameter, then renders session stats, a time-sequenced reading bar, and a modal spectral breakdown chart for a selected reading. This page is the main consumer of the full time-series payload.
5. The data model is split into two layers: a compact index in sessions.json and full session histories in readings/*.json. The index stores summary metadata such as date/time range, average and peak Clear channel values, row count, and GPS coordinates; the reading files store the per-interval sensor samples.
6. The underlying source data comes from an ESP32-based field sensor that samples every 2 seconds from an AS7341 spectral sensor, with timestamps from a DS1302 RTC and data written to SD card as CSV. The CSV structure contains 10 spectral channels plus NIR, Clear, and optionally Lux_Est; the web app’s upload path accepts both 12-column and 13-column variants.
7. SubmitReading.html is the ingestion boundary between raw field data and repo-backed storage. It parses a dropped CSV entirely in the browser, shows a preview and session summary, and then commits the generated session JSON into readings/ while also updating sessions.json.
8. New session commits are pushed directly to GitHub using the GitHub Contents API, authenticated by a local config.js file that is intentionally gitignored. This means the repo itself is the persistence layer, and the browser is the client that writes to it when a user uploads data locally.
9. AI analysis is a separate server-side boundary. The browser sends a session summary to api/analyse.js, a Vercel serverless function, which then calls Anthropic Claude and returns a plain-English interpretation of the light pollution characteristics. The Anthropic API key stays on the server side in Vercel environment variables.
10. Deployment is split between static hosting and serverless execution on Vercel. The HTML/JS pages and JSON assets are served as static content, while api/analyse.js is deployed as a Vercel function. No custom build pipeline or framework runtime is involved.
11. The main external dependencies that shape the architecture are Leaflet/OpenStreetMap for the map UI, Anthropic for the AI commentary, and GitHub as the writable content store. Google Fonts are present for presentation, but they do not affect the data flow.
12. The key architectural flow is: sensor CSV → browser upload/parser → generated session JSON + summary index update in GitHub → homepage map reads sessions.json → detail page reads full session JSON → optional AI analysis via Vercel function. This repo is therefore a data-publishing dashboard with GitHub-backed persistence and a thin serverless AI augmentation layer.
Main entry points: SessionDetail.html Session detail · vercel.json Vercel deploy · analyse.js AI analysis · index.html Map overview
Components 16
Browser app
Static pages that read, render, and write repository-backed data in the browser.
- Map overview · Lightweight entry point that reads the session index and places one pin per session.
index.html - Session detail · Deep-dive view for a single session with stats, timeline, and spectrum modal.
SessionDetail.html - Upload session · Browser ingestion flow for parsing CSV, previewing data, and committing new sessions.
SubmitReading.html - About page · Documentation and reference content outside the main data-driven flow.
Aboutuspage.html - Local config · Gitignored browser-local configuration holding GitHub API credentials.
.gitignore
Repo data
GitHub-hosted JSON assets that act as the persistence layer.
- Session index · Compact metadata for each session including time range, coordinates, row count, and clear-channel summaries.
sessions.json - Session history · Full per-session readings with spectral samples used by the detail view.
readings/session_001.json - Reading archive · Repository folder containing the full session payloads backing the deep-dive view.
readings/session_002.json - GitHub contents · Repo-backed persistence layer updated directly by browser uploads via the GitHub Contents API.
Serverless AI
Vercel function that augments session data with generated commentary.
- AI analysis · Vercel endpoint that turns session summaries into plain-English light-pollution commentary.
api/analyse.js
Other components
- Sensor CSV · Raw CSV produced by the ESP32 and AS7341 sampling setup before browser ingestion.
- ESP32 sensor · Microcontroller-based data source sampling the spectral sensor every two seconds.
- AS7341 sensor · Primary light sensor providing the channel data captured in each reading.
- DS1302 RTC · Timestamp source embedded in the field logging hardware.
- Claude API · External model service used to generate the textual analysis.
- Vercel deploy · Static hosting for pages and assets plus serverless execution for the analysis endpoint.
vercel.json
Connections 21
- ESP32 sensor → AS7341 sensor: samples · Field device reads spectral channels from the sensor.
- ESP32 sensor → DS1302 RTC: timestamps · Field device uses RTC time for each sample.
- AS7341 sensor → Sensor CSV: exports · Sensor readings are written into CSV sessions.
- DS1302 RTC → Sensor CSV: annotates · Timestamp stream is embedded in the exported CSV.
- Sensor CSV → Upload session: upload · User drops a raw CSV into the browser ingestion page.
- Upload session → GitHub contents: writes · Parsed session JSON and index updates are committed to the repository.
- Local config → Upload session: auth · Local browser config provides GitHub API credentials.
- GitHub contents → Session index: persists · Session metadata is stored as the lightweight index.
- GitHub contents → Reading archive: persists · Full session histories are stored under the readings folder.
- Session index → Map overview: loads · Homepage reads only the compact index for map pins.
- Session index → Session detail: summaries · Detail page uses index metadata for session context.
- Reading archive → Session detail: loads · Detail page fetches one full session JSON by query parameter.
- Map overview → Session detail: links · Map pins open the selected session's deep-dive view.
- Session detail → AI analysis: analyzes · Browser sends a session summary to request AI commentary.
- AI analysis → Claude API: calls · Serverless function invokes Claude using server-side credentials.
- AI analysis → Session detail: returns · Generated interpretation is displayed back in the session view.
- Vercel deploy → AI analysis: hosts · Vercel executes the serverless analysis endpoint.
- Vercel deploy → Map overview: serves · Static hosting delivers the browser application and JSON assets.
- Vercel deploy → Upload session: serves · Static hosting delivers the upload page.
- Vercel deploy → Session detail: serves · Static hosting delivers the detail page.
- About page → Map overview: nav · Reference page sits alongside the main app navigation.