Skip to main content

Edge Infrastructure

Global edge computing and offline capabilities.

Overview

The edge infrastructure provides:

FeatureTechnologyPurpose
Global CDNCloudflareLow-latency content delivery
Edge ComputeWorkersRequest processing at the edge
Offline ModeOlympusEdgeRestaurant resilience
AI at EdgeWorkers AILow-latency inference
Data SyncDurable ObjectsState synchronization

Cloudflare Edge Layer

Architecture

┌─────────────────────────────────────────────────────────────────┐
│ Cloudflare Global Network │
│ (300+ Edge Locations) │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Workers │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ Router │ │ Auth │ │ Rate │ │ │
│ │ │ Worker │ │ Worker │ │ Limiter │ │ │
│ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ │ │
│ └───────┼─────────────┼─────────────┼──────────────────────┘ │
│ │ │ │ │
│ ┌───────┼─────────────┼─────────────┼──────────────────────┐ │
│ │ ▼ ▼ ▼ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ KV Store │ │ Durable │ │ Vectorize│ │ │
│ │ │ │ │ Objects │ │ │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ │ │
│ │ Data Layer │ │
│ └───────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘

Workers

Router Worker

Routes requests to appropriate backends:

export default {
async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url);

// Route API requests
if (url.pathname.startsWith('/api/v1/')) {
return env.API_GATEWAY.fetch(request);
}

// Serve static assets from R2
if (url.pathname.startsWith('/static/')) {
return env.ASSETS.fetch(request);
}

// WebSocket connections
if (request.headers.get('Upgrade') === 'websocket') {
return handleWebSocket(request, env);
}

return new Response('Not Found', { status: 404 });
}
};

Auth Worker

Validates tokens at the edge:

async function validateToken(request: Request, env: Env): Promise<TokenPayload | null> {
const token = request.headers.get('Authorization')?.replace('Bearer ', '');

if (!token) return null;

// Check token cache
const cached = await env.TOKEN_CACHE.get(token);
if (cached) return JSON.parse(cached);

// Validate with auth service
const response = await env.AUTH_SERVICE.fetch('/validate', {
method: 'POST',
body: JSON.stringify({ token }),
});

if (!response.ok) return null;

const payload = await response.json();

// Cache for 5 minutes
await env.TOKEN_CACHE.put(token, JSON.stringify(payload), {
expirationTtl: 300,
});

return payload;
}

Rate Limiter

Protects against abuse:

async function rateLimit(request: Request, env: Env): Promise<Response | null> {
const ip = request.headers.get('CF-Connecting-IP');
const key = `rate:${ip}`;

const id = env.RATE_LIMITER.idFromName(key);
const limiter = env.RATE_LIMITER.get(id);

const response = await limiter.fetch(request);

if (response.status === 429) {
return new Response('Too Many Requests', {
status: 429,
headers: {
'Retry-After': response.headers.get('Retry-After') || '60',
},
});
}

return null;
}

OlympusEdge (On-Premise)

Overview

OlympusEdge provides offline-capable restaurant operations:

┌─────────────────────────────────────────────────────────────────┐
│ Restaurant Location │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ OlympusEdge Device │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ Local │ │ Sync │ │ Local │ │ │
│ │ │ API │ │ Engine │ │ Database │ │ │
│ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ │ │
│ │ │ │ │ │ │
│ │ └─────────────┼─────────────┘ │ │
│ │ │ │ │
│ └─────────────────────┼────────────────────────────────────┘ │
│ │ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ POS │ │ KDS │ │ Kiosk │ │
│ │ Terminal │ │ Display │ │ │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└────────────────────────┼────────────────────────────────────────┘


Cloud Sync (when online)

Offline Capabilities

info

OlympusEdge maintains full POS functionality during internet outages. Card payments use offline authorization tokens with settlement queued for when connectivity returns. Cash transactions operate normally. The sync engine automatically reconciles all queued operations on reconnect.

FeatureOffline SupportSync Strategy
Order CreationFullQueue and sync
Payment (card)Limited (offline auth)Settle when online
Payment (cash)FullSync when online
Menu DisplayFull (cached)Periodic refresh
InventoryFull (local tracking)Reconcile on sync
ReportsLimited (local data)Full sync required

Data Synchronization

pub struct SyncEngine {
local_db: SqlitePool,
cloud_client: CloudClient,
sync_queue: VecDeque<SyncOperation>,
}

impl SyncEngine {
pub async fn sync(&mut self) -> Result<SyncResult> {
// 1. Push local changes
while let Some(op) = self.sync_queue.pop_front() {
match self.cloud_client.push(op).await {
Ok(_) => continue,
Err(e) if e.is_conflict() => {
self.resolve_conflict(op).await?;
}
Err(e) => {
self.sync_queue.push_front(op);
return Err(e);
}
}
}

// 2. Pull cloud changes
let changes = self.cloud_client.pull_since(self.last_sync).await?;
for change in changes {
self.apply_change(change).await?;
}

// 3. Update sync timestamp
self.last_sync = Utc::now();

Ok(SyncResult::Success)
}
}

Conflict Resolution

Conflict TypeResolution
Order updateLast-write wins with merge
Inventory countCloud authoritative
Menu changesCloud authoritative
PaymentCloud authoritative

Edge AI (Workers AI)

Use Cases

FeatureModelLatency
Intent ClassificationLlama Scout< 50ms
Menu SearchText Embeddings< 20ms
Image RecognitionVision Models< 100ms

Example: Intent Classification

async function classifyIntent(text: string, env: Env): Promise<Intent> {
const response = await env.AI.run('@cf/meta/llama-2-7b-chat-int8', {
prompt: `Classify the customer intent: "${text}"

Categories: order, question, complaint, modification, cancel

Intent:`,
max_tokens: 10,
});

return parseIntent(response.response);
}

Data at the Edge

KV Store

Fast key-value storage for:

  • Session tokens
  • Feature flags
  • Rate limit counters
  • Cached responses

Durable Objects

Stateful edge compute for:

  • WebSocket connections
  • Rate limiting state
  • Shopping cart state
  • Real-time collaboration

R2 Storage

Object storage for:

  • Static assets
  • Menu images
  • Receipt PDFs
  • Backup data

Deployment

Worker Deployment

# wrangler.toml
name = "olympus-edge"
main = "src/index.ts"
compatibility_date = "2026-01-01"

[env.production]
routes = [
{ pattern = "api.olympuscloud.ai/*", zone_name = "olympuscloud.ai" }
]

[[kv_namespaces]]
binding = "TOKEN_CACHE"
id = "xxx"

[[durable_objects.bindings]]
name = "RATE_LIMITER"
class_name = "RateLimiter"

[[r2_buckets]]
binding = "ASSETS"
bucket_name = "olympus-assets"

OlympusEdge Deployment

# Install on edge device
curl -fsSL https://edge.olympuscloud.ai/install.sh | bash

# Configure
olympus-edge config set --location-id loc-xyz789
olympus-edge config set --api-key $API_KEY

# Start
olympus-edge start

Monitoring

Edge Metrics

MetricDescription
edge.requestsTotal edge requests
edge.latencyEdge processing time
edge.cache.hit_rateCache effectiveness
edge.errorsError rate

OlympusEdge Metrics

MetricDescription
edge.sync.queue_sizePending sync operations
edge.sync.last_successLast successful sync
edge.offline.durationTime since last online
edge.local.ordersOrders pending sync