Add localhost-only stats endpoint with visit analytics

This commit is contained in:
2026-03-26 13:29:55 +01:00
parent a6d7879c26
commit c5e9896e65
3 changed files with 310 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
# marathon.todo
A frontend-only React + TypeScript app for planning what to loot (or do) in raid in Bungie's Marathon.
A React + TypeScript app with a local Node + SQLite backend for planning what to loot (or do) in raids in Bungie's Marathon.
## Features
- Search for Marathon items by name.
@@ -12,6 +12,7 @@ A frontend-only React + TypeScript app for planning what to loot (or do) in raid
- Mark entries completed.
- Delete entries.
- Persist to-do entries in browser `localStorage`.
- Track anonymous visit statistics in backend SQLite (country, last hour, and 5-day trends).
## Data Source
- Frontend fetches a local proxy endpoint: `/api/catalog`
@@ -20,6 +21,13 @@ A frontend-only React + TypeScript app for planning what to loot (or do) in raid
- Faction upgrades: `https://marathondb.gg/js/data/faction-upgrades.js`
- Proxy stores processed catalog in SQLite (`backend/data/catalog.db`) and refreshes every 24h.
## Stats Endpoint
- `GET /stats` (backend) returns JSON with:
- Visits grouped by country
- Last hour totals (`visits`, `uniqueVisitors`)
- Last 5 calendar days (`visits`, `uniqueVisitors` per day)
- `/stats` is localhost-only at backend level (non-local requests receive `403`).
## Project Structure
- `frontend/`: Vite + React app (`frontend/src`, `frontend/index.html`)
- `backend/`: local proxy API (`backend/server.js`) and SQLite data (`backend/data/`)