← 返回
数据分析 中文

Realtime Dashboard

Complete guide to building real-time dashboards with streaming data, WebSocket/SSE, and live updates. Orchestrates dual-stream architecture, React hooks, and data visualization. Use when building trading dashboards, monitoring UIs, or live analytics. Triggers on realtime dashboard, live data, streaming dashboard, trading UI, monitoring.
完整指南:使用流式数据、WebSocket/SSE 实现实时仪表盘。协调双流架构、React Hooks 与数据可视化。适用于交易仪表盘、监控 UI 或实时分析。触发关键词:实时仪表盘、实时数据、流式仪表盘、交易 UI、监控。
wpank
数据分析 clawhub v1.0.0 1 版本 99793.2 Key: 无需
★ 0
Stars
📥 1,448
下载
💾 50
安装
1
版本
#latest

概述

Real-Time Dashboard (Meta-Skill)

Complete guide to building real-time dashboards with streaming data.

Installation

OpenClaw / Moltbot / Clawbot

npx clawhub@latest install realtime-dashboard

When to Use

  • Building trading or financial dashboards
  • Monitoring and analytics UIs
  • Any dashboard needing live data updates
  • Systems with server-to-client push requirements

Architecture Overview

┌─────────────────────────────────────────────────────────────┐
│                    Data Sources                              │
│  APIs, Databases, Message Queues                            │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│                    Backend Services                          │
├─────────────────────────────────────────────────────────────┤
│  Kafka (durable)     │     Redis Pub/Sub (real-time)       │
│  See: dual-stream-architecture                               │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│                    WebSocket/SSE Gateway                     │
│  See: websocket-hub-patterns                                 │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│                    React Application                         │
├─────────────────────────────────────────────────────────────┤
│  Real-time Hooks          │  Data Visualization             │
│  See: realtime-react-hooks│  See: financial-data-visualization
├─────────────────────────────────────────────────────────────┤
│  Animated Displays        │  Connection Handling            │
│  See: animated-financial  │  See: resilient-connections     │
└─────────────────────────────────────────────────────────────┘

Implementation Steps

Step 1: Event Publishing

Set up dual-stream publishing for durability + real-time.

Read: ai/skills/realtime/dual-stream-architecture

func (p *DualPublisher) Publish(ctx context.Context, event Event) error {
    // 1. Kafka: Must succeed (durable)
    err := p.kafka.WriteMessages(ctx, kafka.Message{...})
    if err != nil {
        return err
    }

    // 2. Redis: Best-effort (real-time)
    p.publishToRedis(ctx, event)
    return nil
}

Step 2: WebSocket Gateway

Create horizontally-scalable WebSocket connections.

Read: ai/skills/realtime/websocket-hub-patterns

type Hub struct {
    connections   map[*Connection]bool
    subscriptions map[string]map[*Connection]bool
    redisClient   *redis.Client
}

// Lazy Redis subscriptions
func (h *Hub) subscribeToChannel(conn *Connection, channel string) {
    // Only subscribe to Redis on first local subscriber
}

Step 3: React Hooks

Connect React to real-time data.

Read: ai/skills/realtime/realtime-react-hooks

const { data, isConnected } = useSSE({ 
  url: '/api/events',
  onMessage: (data) => updateState(data),
});

// Or with SWR integration
const { data } = useRealtimeData('metrics', fetchMetrics);

Step 4: Resilient Connections

Handle connection failures gracefully.

Read: ai/skills/realtime/resilient-connections

const { isConnected, send } = useWebSocket({
  url: 'wss://api/ws',
  reconnect: true,
  maxRetries: 5,
  onMessage: handleMessage,
});

Step 5: Data Visualization

Build dark-themed financial charts.

Read: ai/skills/design-systems/financial-data-visualization

<PriceChart 
  data={priceHistory} 
  isPositive={change >= 0} 
/>

Step 6: Animated Displays

Add smooth number animations.

Read: ai/skills/design-systems/animated-financial-display

<AnimatedNumber value={price} prefix="$" decimals={2} />
<FlashingValue value={value} formatter={formatCurrency} />

Component Skills Reference

SkillPurpose
----------------
dual-stream-architectureKafka + Redis publishing
websocket-hub-patternsScalable WebSocket server
realtime-react-hooksSSE/WebSocket React hooks
resilient-connectionsRetry, circuit breaker
financial-data-visualizationChart theming
animated-financial-displayNumber animations

Key Patterns

Streaming Over Blocking

Never wait for all data. Show immediately, improve progressively:

Phase 1: Initial data + hints      → Immediate display
Phase 2: Background refinement     → Prices update in place
Phase 3: Historical data           → Charts populate

Additive-Only Updates

Never zero out data when refinement fails. Only update when you have better data.

Connection Status

Always show users their connection state:

<ConnectionStatus isConnected={isConnected} />

NEVER Do

  • Never block on data fetching — Show immediately, refine progressively
  • Never skip connection status indicators — Users need to know they're live
  • Never use polling when SSE/WebSocket available — Real-time means push, not pull
  • Never forget graceful degradation — System should work (degraded) when connection lost
  • Never zero out data on refinement failure — Only update when you have better data
  • Never reconnect without exponential backoff — Prevents thundering herd
  • Never skip Redis Pub/Sub failure handling — Redis is best-effort; log and continue
  • Never send full payloads over Redis — Send IDs only, clients fetch from API
  • Never share WebSocket pubsub across channels — Each channel needs own subscription
  • Never forget ping/pong on WebSocket — Load balancers close "idle" connections

Checklist

  • [ ] Set up dual-stream publishing (Kafka + Redis)
  • [ ] Create WebSocket/SSE gateway
  • [ ] Implement React hooks for real-time data
  • [ ] Add reconnection with exponential backoff
  • [ ] Build dark-themed chart components
  • [ ] Add animated number displays
  • [ ] Show connection status to users
  • [ ] Handle errors gracefully

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 00:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Code Review

wpank
涵盖安全、性能、可维护性、正确性和测试的系统化代码审查模式,包含严重等级、结构化反馈指南、审查流程及需避免的反模式。适用于审查 PR、建立审查标准或提升审查质量。
★ 31 📥 17,090
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 367 📥 140,276
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 198 📥 65,027