On this page8
Part of my work on Andazeh. By Mohammad Javad Dastouri, full-stack and AI engineer.
How Andazeh records a visit, plays it back and keeps its live view accurate when browsers disappear without warning.
- Browser client lines
- ~5,300
- Store lines
- ~8,700
- Route lines
- ~13,200
- Route modules
- 16
- Heartbeat synchroniser lines
- 518
- Server runtime dependencies
- 6
At a glance
- Area
- Analytics, SEO and marketing
- My role
- Sole engineer: design, build, deploy and run
- Built with
- Node.js 22, PostgreSQL, WebSocket, JavaScript
- Area
- Analytics, SEO and marketing
- My role
- Sole engineer: design, build, deploy and run
- Built with
- Node.js 22, PostgreSQL, WebSocket, JavaScript
Capturing a visit
The client takes one DOM snapshot when the page loads, then streams each change after it. Replay is an ordered walk through that list.
Typed events
numeric codes such as mouse move 2, click 3, scroll 4, input 5 and page load 7, each with a timestamp.
Throttling
pointer and wheel streams are limited to one event per 100 ms.
Separate recorders
interaction, input and navigation each have their own.
Behaviour
a 1,501-line analytics module, plus engagement tracking.
Typed events
numeric codes such as mouse move 2, click 3, scroll 4, input 5 and page load 7, each with a timestamp.
Throttling
pointer and wheel streams are limited to one event per 100 ms.
Separate recorders
interaction, input and navigation each have their own.
Behaviour
a 1,501-line analytics module, plus engagement tracking.
Why the client has no dependencies
The script runs on the host site, inside someone else's performance budget and security boundary, so the client is about 5,300 lines of plain JavaScript. The server has 6 runtime dependencies in total.
One store per domain
Ten stores sit over PostgreSQL, about 8,700 lines in all. Each owns one area of data and its own queries, and each has an in-memory version behind the same interface.
Journey
2,582
Lines
Message
1,603
Lines
Session
1,342
Lines
Behaviour
1,330
Lines
- JourneyLines2,582
- MessageLines1,603
- SessionLines1,342
- BehaviourLines1,330
Presence that stays honest
A 518-line heartbeat synchroniser reconciles what the server believes with what clients report.
The server side
Events are broadcast to the dashboard over WebSocket, and an online tracker follows who is active. The routes cover about 13,200 lines in 16 modules, led by replay at 1,793 lines, journey at 1,400 and messaging at 1,198.
Key decisions
A client with no dependencies
- What it cost
- More work
- Why it was worth it
- It adds no third-party package to a page I do not own.
One store per domain
- What it cost
- The same boilerplate appears in several stores
- Why it was worth it
- A change to one store cannot disturb another, and queries are tuned store by store.
A heartbeat synchroniser
- What it cost
- Extra traffic and code
- Why it was worth it
- The online count on the dashboard is better for it.
A client with no dependencies
- What it cost
- More work
- Why it was worth it
- It adds no third-party package to a page I do not own.
One store per domain
- What it cost
- The same boilerplate appears in several stores
- Why it was worth it
- A change to one store cannot disturb another, and queries are tuned store by store.
A heartbeat synchroniser
- What it cost
- Extra traffic and code
- Why it was worth it
- The online count on the dashboard is better for it.
Hiring someone to build the whole product?
Tell me about the role, or go back to the project: a complete analytics platform I designed, built and run.
- Section
- Analytics, SEO and marketing
- Updated
- November 9, 2026
- Reading time
- 2 min read
Hiring for this kind of work?
Tell me about the role and I will reply by email.
Discuss a role with me
