Documentation

System Overview & Architecture

XTND Vantage • Comprehensive Platform Architecture & Dataflow Specification


1. Architectural Philosophy

XTND Vantage was engineered to solve the observability challenge of modern distributed AI applications and edge-rendered web platforms. Traditional telemetry tools (Datadog, New Relic, PostHog, Langfuse) often present significant drawbacks when applied to latency-critical edge workloads:

  • Synchronous HTTP dispatches block browser rendering or edge worker responses.
  • Heavy JavaScript tracking scripts degrade Core Web Vitals (LCP, INP, CLS).
  • AI token pricing and prompt caching economics are fragmented across multiple vendor dashboards.
  • Network partitions or client disconnects cause telemetry data loss.

XTND Vantage resolves these challenges through four architectural pillars:

graph TD
    A["100% Event-Driven & Local-First"] --> B["All events land in local memory or IndexedDB"]
    C["Urgency-Classified Routing"] --> D["P0 immediate bypass vs P1-P3 idle batching"]
    E["Zero-Modification Edge Interceptors"] --> F["Monitor LaoGPT & EvergreenAI via DNS/Worker wrapper"]
    G["Unified AI Token Economics"] --> H["Real-time cost matrix & prompt cache ROI calculation"]

2. Global Network Topology & Domains

The platform operates across Cloudflare's 330+ edge data centers using dedicated hostnames on xgi.io:

Domain Service / Worker Runtime Role / Function
api.vantage.xgi.io xtnd-vantage-api Cloudflare Worker Central telemetry ingestion exchange. Ingests P0 urgent events and P1–P3 event batches, persisting to Cloudflare KV and Cloudflare Analytics Engine.
api.sonar.vantage.xgi.io xtnd-sonar-api Cloudflare Worker Transparent AI gateway reverse-proxy. Proxies requests to OpenAI, Anthropic, and Gemini; meters tokens, TTFT, and cache hits; dispatches telemetry.
api.radar.vantage.xgi.io xtnd-radar-api Cloudflare Worker High-throughput web telemetry gateway. Collects browser events, user interaction signals, and edge request timings.
argus.xgi.io xtnd-argus-web Cloudflare Worker (static assets) Argus, the live operational dashboard — its own product. Provides live operational event streams, priority breakdowns, quota gauges, and system status.
vantage.xgi.io xtnd-vantage-web Cloudflare Worker (static assets) The Vantage portal: platform overview and this documentation, built from xtnd-vantage-doc. Links to Argus for system access.

3. End-to-End Telemetry Lifecycle

sequenceDiagram
    autonumber
    actor User as Web Visitor / AI Client
    participant Origin as Web App / Edge Worker
    participant LocalBuffer as Local Storage Buffer
    participant Urgency as Urgency Engine
    participant Gateway as Sonar / Radar Gateway
    participant Central as Central Vantage API
    participant Storage as CF KV / Analytics Engine
    participant Argus as Argus Command Center

    User->>Origin: Trigger Action (Page view, AI prompt, click)
    Origin->>LocalBuffer: writeEvent(type, payload) [Synchronous / Non-blocking]
    LocalBuffer-->>Origin: Return event ID instantly (0ms delay)
    
    LocalBuffer->>Urgency: evaluate(type, payload)
    
    alt P0_CRITICAL (Quota Exhausted, Circuit Trip, 5xx Error)
        Urgency-->>Gateway: Immediate Dispatch (fetch with keepalive)
        Gateway->>Central: POST /v1/events/urgent
        Central->>Storage: Store in KV (7-day TTL) & writeDataPoint()
        Central-->>Argus: Real-time broadcast
    else P1_HIGH / P2_NORMAL / P3_DEFERRED
        Urgency-->>LocalBuffer: Enqueue in buffer
        Note over LocalBuffer: Wait for 10s timer or requestIdleCallback
        LocalBuffer->>Gateway: POST /v1/events/web (Batch of N events)
        Gateway->>Central: POST /v1/events/batch
        Central->>Storage: Stream to Cloudflare Analytics Engine
    end

4. Subsystem Interrelationships

classDiagram
    class VantageClient {
        +VantageEventBus bus
        +VantageStorageManager storageManager
        +VantageAIQuotaTracker sonar
        +VantageBrowserDispatcher radar
        +VantageCircuitBreaker sentinel
        +VantageStatusProbe aegis
        +VantageEdgeInterceptor edgeInterceptor
    }

    class VantageEventBus {
        +dispatch(type, payload, options)
        +on(type, handler)
        +once(type, handler)
        +off(type, handler)
    }

    class VantageStorageManager {
        -IStorageAdapter storage
        -IUrgencyEvaluator urgencyEvaluator
        -ISyncTransport transport
        +writeEvent(type, payload, options)
        +flush()
        +startSyncLoop()
    }

    class VantageAIQuotaTracker {
        +updateQuota(state)
        +getQuota(provider)
        +calculateTimeUntilRenewal(provider)
    }

    class VantageCircuitBreaker {
        +recordSuccess()
        +recordError(error)
        +recordAgentStep(step, cost)
        +canExecute()
    }

    class VantageStatusProbe {
        +recordHeartbeat(componentId, name, latency)
        +declareIncident(componentId, details)
        +resolveIncident(componentId, notes)
    }

    class VantageBrowserDispatcher {
        +initPage(meta)
        +trackInteraction(name, data)
        +recordWebVital(metric)
    }

    class VantageEdgeInterceptor {
        +handleRequest(request, originFetch, ctx)
    }

    VantageClient --> VantageEventBus
    VantageClient --> VantageStorageManager
    VantageClient --> VantageAIQuotaTracker
    VantageClient --> VantageCircuitBreaker
    VantageClient --> VantageStatusProbe
    VantageClient --> VantageBrowserDispatcher
    VantageClient --> VantageEdgeInterceptor

    VantageAIQuotaTracker --> VantageStorageManager : writes quota events
    VantageCircuitBreaker --> VantageStorageManager : writes circuit#58;trip (P0)
    VantageStatusProbe --> VantageStorageManager : writes heartbeat / outage (P0)
    VantageBrowserDispatcher --> VantageStorageManager : writes page#58;init / metrics (P2)
    VantageEdgeInterceptor --> VantageStorageManager : writes edge#58;request#58;completed

5. Summary of Key Invariants

  1. Listeners NEVER Make Network Calls: In Vantage, event bus listeners and SDK consumers are strictly prohibited from performing direct network fetches. All mutations write to IStorageAdapter.
  2. The Storage Manager Controls the Wire: The VantageStorageManager is the single authority that decides when, how, and over which transport events leave the client.
  3. P0 Bypasses the Batch Loop: When an event is evaluated as P0_CRITICAL, it triggers an immediate out-of-band network dispatch while asynchronously writing to local storage.
  4. Origin Websites are Sovereign: When using VantageEdgeInterceptor, origin application code in LaoGPT or EvergreenAI is executed unmodified; failure in telemetry logging never aborts the origin response.