System Design

PULSE architecture and system design overview

System Design

PULSE is built on a serverless, cloud-native architecture designed for scalability and cost-efficiency.

Architecture Overview

┌─────────────────────────────────────────────────────────────┐
│                        Client Layer                         │
│  (Web, Mobile, Backend, JavaScript Tracker)                 │
└────────────────────────┬────────────────────────────────────┘

                    HTTP/HTTPS

┌────────────────────────▼────────────────────────────────────┐
│              Cloudflare Edge Network                         │
│  (Rate Limiting, CORS, TLS Termination)                     │
└────────────────────────┬────────────────────────────────────┘

┌────────────────────────▼────────────────────────────────────┐
│         Cloudflare Workers (Main Application)               │
│  ┌──────────────────────────────────────────────────────┐   │
│  │ Request Router                                       │   │
│  │  - /collect → Event Ingestion                        │   │
│  │  - /api/v1/stats → Query Handler                     │   │
│  │  - /api/v1/cohorts → Cohort Management              │   │
│  │  - /api/v1/alerts → Alert Rules                     │   │
│  │  - /api/v1/webhooks → Webhook Management            │   │
│  │  - /api/v1/imports → Bulk Imports                   │   │
│  │  - /api/v1/exports → Scheduled Exports              │   │
│  └──────────────────────────────────────────────────────┘   │
└────────────────────────┬────────────────────────────────────┘
         │               │               │               │
    ┌────▼─────┐    ┌────▼─────┐   ┌────▼─────┐   ┌────▼─────┐
    │  D1 DB   │    │ KV Cache │   │Durable   │   │Datadog   │
    │(SQLite)  │    │          │   │Objects   │   │(optional)│
    └──────────┘    └──────────┘   └──────────┘   └──────────┘

Component Architecture

1. Event Ingestion Layer

Receives events from clients and validates them:

2. Data Layer (D1 Database)

SQLite database for persistent storage:

-- Core tables
events              -- Raw events
users               -- User attributes
sessions            -- Session tracking
cohort_members      -- Cohort membership
retention_snapshots -- Pre-computed retention

-- Feature tables
alert_rules         -- Alert rule definitions
alert_history       -- Alert trigger history
webhook_endpoints   -- Webhook configurations
import_jobs         -- Bulk import tracking
export_jobs         -- Scheduled export tracking

3. Query Engine

Aggregates and filters event data:

4. Caching Layer (KV)

Cloudflare KV for distributed caching:

5. Message Queue (Durable Objects)

Reliable message delivery for:

6. Scheduled Jobs

Cron-triggered maintenance tasks:

Data Flow

Event Ingestion Flow

Event from Client

Validation

Rate Limit Check

Authentication

D1 Insert (transactional)

KV Cache Invalidation

Webhook Dispatch (async)

Response 202 Accepted

Query Flow

Query Request

Authentication

Parameter Validation

KV Cache Check (hit → return)

D1 Query

Result Aggregation

KV Cache Write (TTL)

Response

WebSocket Streaming Flow

Client WebSocket Connect

Durable Object Session Manager

Listen for Event Broadcasts

On New Event: Serialize → Send to Connected Clients

Aggregation Broadcast (every 10s)

Client Receives Real-Time Updates

Scaling Strategy

Horizontal Scaling

Vertical Scaling

Load Testing Results

PULSE handles:

Deployment Model

PULSE runs on Cloudflare infrastructure:

Security Model

Authentication

Data Protection

Compliance

Performance Characteristics

OperationLatencyNotes
Event Ingestion<50msNetwork latency + DB write
Cache Hit Query<10msKV direct lookup
Cache Miss Query<100msD1 query + KV update
WebSocket Broadcast<100msPer-connection serialization
Retention Snapshot<5s10k-100k events aggregation

Monitoring & Observability

Next Steps

Last updated: April 3, 2026