Skip to content

About

A Zero Distraction video viewing engine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔒 The "Zero-Distraction" Engine (ZeeDeeEngine)

A high-performance full-stack prototype designed to sanitize user video interaction interfaces, enforce strict visual attention policies using low-level browser APIs, and ingest telemetry data under aggressive burst traffic using a custom memory-bounded token bucket architecture.

🏗️ Architectural Overview

This system is decoupled into two hyper-specialized layers containerized with Docker Compose:

  1. Frontend (Next.js / TypeScript): A zero-distraction layout utilizing a dual-layer tracking hook powered by the browser's native Page Visibility API and Intersection Observer API. It batches UX telemetry exceptions dynamically over a sliding 5-second window.
  2. Backend (Node.js / Express): A lightweight state machine that implements a raw, mathematical Token Bucket Rate Limiter directly inside the application run loop memory to protect telemetry ingestion routes against DDoS or faulty client loop vectors.

🛠️ Architectural Trade-Offs & Decisions

1. In-Memory Token Bucket vs. Distributed Redis Cache

  • Decision: Implemented an in-memory Map tracking token bucket states inside application memory.
  • Trade-Off: While an in-memory map introduces a statelessness problem if scaled across multi-region serverless infrastructure (like Vercel functions), it provides sub-millisecond execution speeds with zero network round-trip overhead. For the production environment on Render, we deploy the backend as a single persistent Web Service process, preserving the memory layer reliably while keeping compute overhead to an absolute minimum.

2. Time-Delta Refill Mechanism vs. Background setInterval Clocks

  • Decision: Buckets calculate token accumulation lazily using timestamps during the request lifecycle (Date.now() - this.lastRefill).
  • Trade-Off: Running a continuous background thread or interval loop to refill client buckets would create an active CPU burden that scales linearly ($O(N)$) with the number of connected users. The lazy time-delta calculation shifts the computation entirely to $O(1)$ at the exact millisecond a request is received, ensuring maximum server scalability.

3. navigator.sendBeacon vs. Standard Client fetch Buffering

  • Decision: Prioritized sendBeacon for the 5-second queue flushes, falling back to traditional asynchronous fetch pipelines only when unsupported.
  • Trade-Off: Standard HTTP POST requests are often canceled by modern browsers if a user suddenly closes the tab or navigates away. navigator.sendBeacon transmits the payload asynchronously over a background transport layer, ensuring that critical engagement data is successfully delivered even during ungraceful app exits, without impacting page unload performance.

4. Static Site Generation (SSG) Deployment for Frontend

  • Decision: Configured Next.js with output: 'export' to build as a purely static asset distribution for deployment.
  • Trade-Off: By omitting Server-Side Rendering (SSR), we remove the need for a live Node server pool for the UI. The frontend compiles down to atomic HTML, CSS, and JS, allowing it to be hosted on global edge networks permanently for free. It is fully decoupled from the backend and completely immune to free-tier "cold start" sleep delays.

🚀 Local Installation & Execution

Ensure you have Docker and Docker Compose installed on your machine.

  1. Clone the repository and navigate to the project directory:
    cd ZeeDeeEngine

About

A Zero Distraction video viewing engine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages