This repository tracks LeetCode solve counts for a small set of accounts and turns them into a time-series dashboard. The important idea is that the site does not compute progress live in the browser. Instead, a GitHub Action periodically runs a Rust updater, writes the newest readings into ProgressViewer/public/readings.json, commits that file back to the repository, and Netlify serves the site from that updated artifact.
The original use case was comparing progress with Munis, but the structure now supports tracking several friends at once.
The repo has two moving parts:
UpdateManager/is the data collection side.ProgressViewer/is the static UI that reads the generated JSON and renders charts.
The browser never talks directly to LeetCode. It only fetches /readings.json, which is the file produced by the updater.
.github/workflows/update.ymlruns on a schedule, on manual dispatch, and on pushes tomain.- The workflow checks out the repository, sets up stable Rust, and reuses cached Cargo dependencies and build artifacts.
- It tests, compiles, and runs the Rust command in
UpdateManager/from the repository root. - The updater fetches each tracked user from the LeetCode API proxy, extracts
totalSolved, compares it with the latest stored reading, and appends a new entry only when the count increases. - The updater loads and saves
ProgressViewer/public/readings.json. - The workflow commits the updated JSON back to
main. - Netlify rebuilds the site from the updated repository contents and serves the refreshed chart.
flowchart TD
A[Update system] --> B[GitHub Actions trigger]
A --> C[UpdateManager]
A --> D[Frontend data handoff]
A --> E[Deployment]
B --> B1[Schedule / manual dispatch / push to main]
B1 --> B2[Checkout repository]
B2 --> B3[Set up stable Rust]
B3 --> B4[Run Cargo tests]
B4 --> B5[Build and run updater]
C --> C1[Fetch LeetCode API proxy]
C1 --> C2[Read totalSolved for each user]
C2 --> C3{Solved count increased?}
C3 -- Yes --> C4[Append new reading]
C3 -- No --> C5[Keep existing history]
D --> D1[Write ProgressViewer/public/readings.json]
D1 --> D2[Commit and push updated JSON]
E --> E1[Netlify rebuilds the frontend]
E1 --> E2[Deploy refreshed tracker]
The repository currently deploys through Netlify, not GitHub Pages. If the hosting target changes later, the last two nodes in the diagram are the only ones that need to change.
UpdateManager/src/main.rs is the entry point. The crate is split into API, model, persistence, configuration, and update-orchestration modules. It loops over the configured usernames, fetches their data, retries transient failures with a bounded retry count, and waits between requests so the API is not hit too aggressively.
The Rust updater uses reqwest for HTTP and serde_json for JSON parsing, with atomic persistence and timestamps handled by focused modules. It requires a successful response containing totalSolved and returns a non-zero exit code after retry attempts are exhausted.
The readings file preserves existing key order and unknown keys. Missing files are initialized, while malformed or unreadable existing files are rejected without overwriting them. Successful writes replace the file atomically.
ProgressViewer/src/App.tsx is the main React component. It fetches /readings.json, converts the stored [solvedCount, timestamp] pairs into chart points, and renders the line chart with controls for:
- time-range filtering,
- custom duration windows,
- drag selection on the chart,
- and optional delta lines between two users.
ProgressViewer/src/main.tsx only boots React, and ProgressViewer/src/index.css is just the styling entry point.
The UI is intentionally static. It becomes current only when the workflow updates readings.json and that file is redeployed.
The project is not primarily designed as a local-first app, but you can still work on it locally:
- Install dependencies in
ProgressViewer/and run the Vite dev server for the UI. - Build and run the Rust updater from the repository root if you want to refresh
readings.jsonmanually.
Typical commands:
cd ProgressViewer
npm install
npm run devcargo run --manifest-path UpdateManager/Cargo.tomlRun the updater tests with:
cargo test --manifest-path UpdateManager/Cargo.tomlThe deployed site is available at https://leetcode-tracker.anga.codes.
The deployment model is deliberately simple: the repository stores the historical readings, the workflow updates that history, and Netlify serves the built static app from the latest commit.
ProgressViewer/public/readings.json: generated history consumed by the UI.ProgressViewer/src/App.tsx: charting and interaction logic.UpdateManager/src/main.rs: updater entry point.UpdateManager/src/api.rs: API client and recursive response parsing.UpdateManager/src/model.rs: ordered readings data model.UpdateManager/src/readings.rs: JSON loading, serialization, and atomic persistence.UpdateManager/src/updater.rs: retries and update orchestration.UpdateManager/Cargo.toml: Rust package definition and dependencies..github/workflows/update.yml: scheduled update job.