07 / 07 — Selected work
Live on this siteportfolio-analytics
First-party analytics for this site: a light client beacon, a FastAPI collector and a SPA dashboard, with no third-party trackers.
Updated 26 Nov 2026TypeScriptMIT
PurposeSee how the portfolio is actually read without handing visitor data to a third-party service.
What I builtA client beacon built on fetch keepalive and sendBeacon, with a sessionStorage retry queue, accurate active time that ignores background tabs and Core Web Vitals collection, posts events to a FastAPI collector; SQLAlchemy 2.0 stores them in PostgreSQL (Neon) and in SQLite locally. A React 19 + TypeScript + Tailwind CSS SPA dashboard in the portfolio design system reads the aggregates.
Engineering
- Sliding 30-minute sessions and accurate active time
- Section funnel and weighted project interest
- 24×7 activity matrix (MSK) and period comparison
- Log of AI-assistant questions and Cmd+K commands
- Core Web Vitals monitoring (LCP, INP, CLS, TTFB)
- Privacy: subnet mask and salted HMAC instead of raw IPs
- Async geo/ASN/datacenter enrichment in the background
- CSV/JSON export and a filter for the owner's own visits (?me=1)
Technology
PythonFastAPIPostgreSQLSQLAlchemySQLiteReactTypeScriptTailwind CSSDocker
Architecture
- One service serves both the /collect endpoint and the static SPA dashboard (React 19 + Vite), storing events in PostgreSQL (Neon) or a local SQLite file.
- Raw IP addresses and third-party cookies are never used: only a subnet mask and a salted HMAC-SHA256 are stored, while geography and provider are enriched by an async background task without delaying the 204 response.
- Ingestion is protected by Origin and site_key checks, a batch size limit and rate limiting; the dashboard sits behind an HttpOnly HMAC cookie.
Decisions
- A first-party collector instead of third-party analytics scripts: no extra weight, no cookie banners and exact knowledge of the portfolio's own events (3D stack, case studies, AI chat, Cmd+K).
- A sessionStorage event queue with delayed retries survives a cold start of the free Render instance without losing the first seconds of a visit.