How danielrmzn1/network-gamer-test works
Purpose and execution modes
FRAGRATE is a gamer-focused network measurement system that converts latency, jitter, UDP loss, throughput, and latency-under-load into overall ranks and per-game PLAYABLE/RISKY/NO-GO verdicts. It has two execution modes:
• Local: browser UI plus a Node measurement server running on the user’s network.
• Hosted: Cloudflare Worker serving the UI; browser-only measurements with optional TURN/WebRTC loss testing.
Entry points: client/src/main.tsx, server/src/index.ts, and worker/index.ts.
Shared domain model and scoring
shared/ is the cross-runtime contract and single source of truth for game definitions, geographic regions, thresholds, grading, baseline values, and wire protocol. Both client and Node server consume these modules, avoiding duplicated scoring or message definitions.
• shared/catalog.ts
• shared/grading.ts
• shared/protocol.ts
Game-specific verdicts derive from collected measurements and genre thresholds; selecting another game or region recomputes from retained measurements rather than requiring another run.
Client application and presentation
The client is a Vite/React TypeScript SPA. Routing separates home/report views from game-oriented routes, while App composes the main dashboard. Desktop and mobile presentations are distinct component layers over the same measurement state.
• client/src/main.tsx
• client/src/routes.tsx
• client/src/App.tsx
• client/src/pages/GamePage.tsx
• client/src/components/mobile/MobileDashboard.tsx
SEO metadata/content and localized UI are client-side concerns, while preferences and startup state preserve user choices such as game or region.
• client/src/seo/Seo.tsx
• client/src/state/store.ts
• client/src/state/prefs.ts
Browser measurement orchestration
The browser engine owns test sequencing, aggregation, and report-ready metrics. It measures download/upload and bufferbloat from the browser, coordinates server-assisted regional and UDP probes, and feeds updates into application state/UI.
• client/src/engine/orchestrator.ts
• client/src/engine/throughput.ts
• client/src/engine/loss.ts
• client/src/engine/stats.ts
Transport boundaries are explicit: browser-to-server realtime commands/results use WebSocket support, while hosted-mode capabilities are detected and constrained by browser networking limitations.
• client/src/engine/ws.ts
• client/src/engine/mode.ts
• client/src/engine/regionPing.ts
Local measurement plane
The Node server is deliberately thin: it serves the production client and executes network probes from the machine where it runs. This makes TCP-connect region latency and STUN UDP loss measurements originate from the user’s actual connection rather than a remote application host.
• server/src/index.ts
• server/src/pinger.ts
• server/src/stun.ts
• server/src/ws/session.ts
It also provides measurement endpoints for local throughput fallback/static serving. The WebSocket session layer is the primary control boundary between browser orchestration and privileged Node TCP/UDP operations.
• server/src/speedtest.ts
• server/src/static.ts
Hosted Cloudflare boundary
The Worker deployment serves built static assets and exposes a narrowly scoped credential-minting endpoint for Cloudflare Realtime TURN. Long-term TURN credentials remain Worker secrets; the client receives only short-lived ICE server credentials.
• worker/index.ts
• wrangler.jsonc
• client/src/engine/loss.ts
Hosted mode cannot perform arbitrary raw TCP/UDP region probing from a browser. It therefore degrades to browser-capable throughput/bufferbloat and, when configured, WebRTC/TURN packet-loss measurement.
Runtime and deployment shape
The repository is a pnpm monorepo with Node 20+ local runtime, React/Vite client build, TypeScript Node server, and Cloudflare Workers deployment. Production local deployment builds the client and has Node serve it on one origin; development uses Vite with server proxying. Cloudflare Workers Static Assets serve client/dist in hosted deployment.
• package.json
• pnpm-workspace.yaml
• client/vite.config.ts
• server/package.json
Main entry points: session.ts WebSocket session · orchestrator.ts Measurement orchestrator · mode.ts Mode and transports · index.ts Local Node server
Components 18
Browser Client
React SPA and browser-side measurement runtime.
- Client entry
client/src/main.tsx - Routes and dashboard · Routes select report and game views around the main dashboard.
client/src/routes.tsx - Game views · Desktop and mobile layers present shared measurement state.
client/src/pages/GamePage.tsx - Mobile dashboard
client/src/components/mobile/MobileDashboard.tsx - Measurement state and prefs · Retains measurements and user game or region choices.
client/src/state/store.ts - Measurement orchestrator · Sequences tests and produces report-ready metrics.
client/src/engine/orchestrator.ts - Browser tests · Runs browser throughput, bufferbloat, aggregation, and hosted loss tests.
client/src/engine/throughput.ts - Mode and transports · Selects local WebSocket probing or hosted-capable measurements.
client/src/engine/mode.ts
Shared Contract
Cross-runtime scoring and protocol source of truth.
- Catalog and grading · Games, regions, thresholds, baselines, ranks, and verdicts.
shared/grading.ts - Wire protocol · Browser and Node realtime message contract.
shared/protocol.ts
Local Measurement Plane
Node runtime on the user's network.
- Local Node server · Serves the built client and hosts privileged local probes.
server/src/index.ts - WebSocket session · Control boundary for browser commands and probe results.
server/src/ws/session.ts - TCP region pinger · Measures regional TCP-connect latency from the user's connection.
server/src/pinger.ts - STUN UDP loss probe · Measures UDP loss from the user's connection.
server/src/stun.ts - Local speed and static assets · Provides throughput fallback and production SPA serving.
server/src/speedtest.ts
Hosted Deployment
Cloudflare-hosted browser-only mode.
- Cloudflare Worker · Serves static assets and mints narrowly scoped TURN credentials.
worker/index.ts - Worker static assets · Serves the built client distribution.
wrangler.jsonc - WebRTC/TURN loss test · Uses short-lived ICE credentials when configured.
client/src/engine/loss.ts
Connections 22
- Client entry → Routes and dashboard: mounts
- Routes and dashboard → Game views: renders
- Game views → Mobile dashboard: mobile presentation
- Game views → Measurement state and prefs: reads updates
- Measurement orchestrator → Measurement state and prefs: publishes metrics
- Measurement orchestrator → Browser tests: runs
- Measurement orchestrator → Mode and transports: selects capabilities
- Measurement state and prefs → Catalog and grading: regrades retained results
- Measurement orchestrator → Catalog and grading: uses thresholds
- Mode and transports → Wire protocol: uses messages
- Mode and transports → WebSocket session: local WebSocket
- Local Node server → WebSocket session: hosts
- WebSocket session → TCP region pinger: commands
- WebSocket session → STUN UDP loss probe: commands
- WebSocket session → Wire protocol: implements
- Local Node server → Local speed and static assets: serves
- Mode and transports → Local speed and static assets: local fallback
- Cloudflare Worker → Worker static assets: serves
- Cloudflare Worker → WebRTC/TURN loss test: mints ICE credentials
- Browser tests → WebRTC/TURN loss test: hosted loss path
- Cloudflare Worker → Client entry: hosts SPA
- Local Node server → Client entry: hosts SPA locally