Real-time Edge Traffic Intelligence Dashboard
A production-ready AI-powered network monitoring platform that simulates, visualizes, and analyzes traffic across global edge locations using Cloudflare's edge computing infrastructure.
EdgeScope is a full-stack application demonstrating advanced edge computing concepts through real-time traffic simulation and AI-powered anomaly detection. Built entirely on Cloudflare's platform, it showcases the power of Workers, Workers AI, and KV storage for building sophisticated observability tools.
Modern distributed systems require real-time visibility into edge network performance. EdgeScope solves this by:
- Simulating realistic traffic patterns across 24 global edge locations
- Detecting anomalies using statistical analysis
- Providing AI-powered root cause analysis via Llama 3
- Enabling session replay for historical analysis
By leveraging Cloudflare's edge network, EdgeScope demonstrates:
- Low Latency: AI analysis runs at the edge, close to users
- Scalability: Serverless Workers handle traffic spikes automatically
- Cost Efficiency: Pay only for actual compute time
- Global Reach: Deploy once, run everywhere
- AI-Powered Anomaly Detection - Llama 3 (Workers AI) analyzes network anomalies and provides root cause analysis
- Real-time Traffic Simulation - Generates realistic traffic patterns between 24 global edge nodes with geographic-based latency
- Interactive Network Visualization - Canvas-based world map showing live traffic flows with color-coded status indicators
- Intelligent Metrics Dashboard - Real-time monitoring of requests, latency, success rates, errors, and anomalies
- Session Management - Cloudflare KV stores simulation sessions for replay and analysis with 30-day retention
- Professional UI/UX - Modern SaaS interface with light/dark modes, collapsible panels, and responsive design
- Chat Interface - AI assistant for querying simulations and understanding anomalies
┌─────────────────┐
│ Browser/UI │
│ (Next.js 16) │
└────────┬────────┘
│
├─── Traffic Simulation (Client-side)
│ • Geographic calculations
│ • Anomaly injection
│ • Real-time visualization
│
├─── API Requests
│
┌────────▼────────┐
│ Cloudflare │
│ Workers │
│ (Hono Framework)│
└────────┬────────┘
│
├─────┬─────────────┬──────────┐
│ │ │ │
┌────▼───┐ │ ┌────▼────┐ ┌──▼──┐
│Workers │ │ │Cloudflare│ │ KV │
│ AI │ │ │ Pages │ │Store│
│(Llama3)│ │ │ │ │ │
└────────┘ │ └─────────┘ └─────┘
│
└─── CORS & Routing
- Next.js 16 with App Router and Turbopack
- React 19 with TypeScript
- Tailwind CSS for styling with OKLCH color system
- Zustand for global state management
- Lucide React for icons
- Canvas API for network visualization
- Cloudflare Workers (serverless edge compute)
- Hono framework for API routing
- TypeScript throughout
- Workers AI (@cf/meta/llama-3-8b-instruct)
- Cloudflare KV for persistent storage
- Geographic distance-based latency calculation
- Statistical anomaly detection algorithms
- AI-powered root cause analysis
- Session replay capabilities
- Real-time streaming updates
- Node.js v18 or later
- npm or pnpm
- Wrangler CLI:
npm install -g wrangler - A Cloudflare account (free tier works)
git clone https://github.com/ryanlyn29/cf_ai_edgescope.git
cd cf_ai_edgescopecd backend
npm install
# Authenticate with Cloudflare
wrangler login
# Create a KV namespace for chat history
wrangler kv:namespace create "CHAT_HISTORY"
# Copy the namespace ID from the output and update wrangler.toml
# Replace YOUR_KV_NAMESPACE_ID with the actual ID
# Run locally
wrangler devThe worker will be available at http://localhost:8787
Note: Workers AI requires a Cloudflare account. Local development will connect to the production AI service.
cd ../frontend
npm install
# Create .env file
echo "NEXT_PUBLIC_API_URL=http://localhost:8787" > .env
# Run development server
npm run devThe frontend will be available at http://localhost:5173
- Open
http://localhost:5173 - Click "Start Simulation" in the header
- Watch traffic flow across the network map
- Observe anomaly detection in real-time
- Click "Analyze with AI" on detected anomalies
- Use the chat interface to query simulations
cd backend
# Deploy to Cloudflare Workers
wrangler deployYour worker will be deployed to https://cf-ai-edgescope.<your-subdomain>.workers.dev
cd frontend
# Update .env with production Worker URL
# NEXT_PUBLIC_API_URL=https://cf-ai-edgescope.<your-subdomain>.workers.dev
# Build for production
npm run build
# Deploy to Cloudflare Pages
# Option 1: Connect GitHub repo via Cloudflare Dashboard
# Option 2: Use Wrangler
npx wrangler pages deploy .nextCreate .env in the frontend/ directory:
NEXT_PUBLIC_API_URL=http://localhost:8787
Key settings in wrangler.toml:
[ai]
binding = "AI"
[[kv_namespaces]]
binding = "CHAT_HISTORY"
id = "YOUR_KV_NAMESPACE_ID"Chat with AI about logs and errors.
Request:
{
"message": "Error: ECONNREFUSED...",
"sessionId": "session_1234567890_abc123"
}Response:
{
"success": true,
"sessionId": "session_1234567890_abc123",
"analysis": {
"summary": "Connection refused to database",
"reasoning": "...",
"potential_fix": "..."
},
"messageCount": 4
}Analyze network anomalies with AI.
Request:
{
"anomaly": {
"type": "latency",
"severity": "high",
"description": "High latency detected: 842ms average",
"affectedNodes": ["sfo", "nrt", "sin"],
"timestamp": 1234567890
},
"traffic": [...]
}Response:
{
"success": true,
"analysis": {
"summary": "...",
"rootCause": "...",
"impactAssessment": "...",
"recommendedActions": [...],
"severity": "high"
}
}Retrieve chat history for a session.
- User clicks "Start Simulation" in header
- Frontend generates realistic requests between edge nodes every 500ms
- Latency calculated based on geographic distance between nodes
- System randomly injects anomalies (latency spikes, error bursts) with 10% probability
- Canvas map updates in real-time showing traffic flows with color coding
- Dashboard displays live metrics (requests, latency, errors, success rate)
- System detects anomaly patterns (high latency, error rate spikes, timeouts)
- User clicks "Analyze with AI" on detected anomaly
- POST request sent to
/api/analyzewith anomaly data and recent traffic context - Workers AI (Llama 3) analyzes the pattern and generates structured insights
- AI returns root cause, impact assessment, and recommended actions
- Results displayed in collapsible panels within the anomaly card
- Local Storage: Recent simulations saved in browser (up to 10 sessions)
- KV Storage: Chat history and analysis results stored in Cloudflare KV with 30-day TTL
- Replay: Load previous sessions from the Sessions page
- Workers AI Limits: Free tier has rate limits. For production use, upgrade to paid plan.
- KV Storage: Free tier includes 100k reads/day and 1k writes/day
- Session Expiry: Sessions automatically deleted after 30 days
- CORS: Configured for local development; update for production
This project follows a minimalist, developer-first aesthetic:
- No gradients or shadows - Clean, flat design
- High contrast - Excellent readability in both light and dark modes
- Border-focused - Clear visual hierarchy
- Monospace for code - JetBrains Mono for technical content
- Collapsible panels - Progressive disclosure of complexity
- OKLCH colors - Modern color space for consistent theming
cf_ai_edgescope/
├── backend/ # Cloudflare Worker
│ ├── src/
│ │ ├── index.ts # API routes
│ │ ├── ai.ts # Workers AI integration
│ │ └── memory.ts # KV storage layer
│ ├── package.json
│ └── wrangler.toml # Cloudflare configuration
│
├── frontend/ # Next.js Application
│ ├── app/ # App Router pages
│ ├── components/
│ │ ├── ui/ # Base components
│ │ ├── layout/ # Layout components
│ │ ├── dashboard/ # Dashboard components
│ │ └── chat/ # Chat interface
│ ├── store/ # Zustand state management
│ ├── services/ # API client
│ ├── types/ # TypeScript interfaces
│ ├── data/ # Edge node locations
│ ├── utils/ # Simulation engine
│ └── package.json
│
└── README.md
This project was built with assistance from AI tools. See PROMPTS.md for documentation of AI prompts and system design.
Built for the Cloudflare Engineering Internship application. This project demonstrates:
- Deep understanding of Cloudflare's edge computing platform
- Production-ready code architecture and TypeScript best practices
- Developer-focused UX design and modern web standards
- Effective use of Workers AI, KV storage, and serverless patterns
- Real-world application of edge computing for observability tools