This document analyzes and describes the technical architecture and data flows of the Cloudflare Worker-based telemetry module for the VibeNVR project.
The project implements a fast and cost-effective edge-based serverless service in order to:
- Collect installation and usage data completely anonymously from active VibeNVR instances around the world.
- Provide a secure and internal API (
/api/stats) to query the data by dynamically interrogating the Cloudflare time-series database (Analytics Engine). - Display a public Dashboard accessible from the browser (route
/dashboardor/) generated in HTML, styled with Tailwind and graphed using Chart.js to consult top KPIs and the hardware distribution of VibeNVR.
The main file src/index.js handles routes via the fetch(request, env, ctx) block typical of Cloudflare Workers.
When a VibeNVR instance starts or forwards a regular ping, it makes a GET request to this endpoint passing basic information in the querystring:
instance_id,version,os,arch,cpu,ram,cameras,groups,events,gpu,notifications.- Privacy First: No user IP addresses or specific paths are ever stored or tracked.
- Edge Geolocation: The country of origin is silently deduced and grouped via internal headers exposed to Workers (
request.cf.country). - Data Persistence: These query params are saved by formatting them onto
env.VIBENVR_USAGE.writeDataPoint(...)of the Analytics Engine (identified with thevibenvr_telemetry_eventsdataset). - Fallback Response: Instantly terminates execution returning a 1x1 transparent PNG image (
transparentPos), convenient as it is invisible, lightweight, and natively compatible with normal HTTP parsers of almost all languages, avoiding blocking CORS errors, complex logic, or unnecessary bodies.
A route designed for backend use to hide precious API-Keys and Cloudflare Secrets from public visitors of the dashboard.
- Makes GraphQL queries to
https://api.cloudflare.com/client/v4/graphql. - Retrieves: active installations (last 7 days via the
datetime_geqtime condition), historical total installations, prevalent Countries, Versions, and CPU architectures. - Requires proper configuration of secret server variables:
env.ACCOUNT_IDandenv.API_TOKEN. - Returns a compressed JSON file that the frontend will inject into Chart.js.
Responds with plain text HTML to render a very lightweight and minimal Single Page Application.
- Uses TailwindCSS from CDN to limit the size of the generated bundle and style the page instantly in Dark Mode (
darkclass on the html element). - Uses Chart.js for dynamic Pie and horizontal/vertical Bar charts.
- Makes a single
fetch()on the client to its own Worker at the/api/statsroute, populating the KPIs and rendering the map instantly without making the initial DOM parser wait.
- Cloudflare Workers (Edge Computing): Global serverless platform in Node.js (V8 Isolate) to minimize cold starts, slashing latency for geographically distributed data storage.
- Cloudflare Analytics Engine: Extremely high-performance column-based data warehouse for time-series that accepts datapoints divided by
blobs,doublesvectors, or indexed viaindexes. It does not apply strict schema constraints and costs a fraction of a cent compared to equivalent relational DBs. - JS ESModules: The package makes direct use of standard ECMAScript module exports and performs setup via
npm/wrangler. - Wrangler: The official Cloudflare CLI defined in the
devDependenciesof thepackage.jsonfile, used for local development (wrangler dev) and staging/production (wrangler deploy).