Daily counter loop
One unique hit becomes durable, time-bounded state.
realtime systems
A small but serious WebSocket playground: daily state, Redis-backed coordination, and a React surface that stays live.
Open repositoryRealtime model
One unique hit becomes durable, time-bounded state.
One browser origin, proxied APIs, and durable presence.
What this is
HitCounter starts with a basic hit counter and grows into a compact WebSocket system. FastAPI handles the API, Redis owns bounded daily state, and connected browsers receive updates as they happen. The repository makes the edges visible: timezone buckets, uniqueness, TTLs, proxy upgrades, and a chat-ready identity flow.
How it moves
The browser opens a WebSocket and receives the current snapshot.
A hit resolves the configured daily time bucket.
Redis records bounded state with uniqueness and TTL rules.
The API broadcasts the new state to connected clients.
The React surface stays current without a refresh.
Practices in view
A realtime client needs an initial truth as well as future updates, so the connection starts with state before it listens for change.
Redis keys use daily buckets, uniqueness rules, and TTLs so the demo stays deterministic without accumulating unbounded history.
The chat-ready surface introduces a visitor identity flow before pretending the message timeline already exists.
The web layer keeps HTTP and WebSocket traffic on one origin while preserving the upgrade path through the proxy.
Possible next connections
A next step when one in-memory broadcast loop needs replayable events or a more explicit message backbone.
The repository already documents an AWS-shaped path; a cluster adds room for independent web, API, and worker scaling.
Useful for following a hit from browser request to Redis write to WebSocket broadcast.
Why it is here
Not every open-source project has to be Gastrotech. This one demonstrates a useful building block for any future product where presence, live state, and shared context matter.