Skip to main content
Back to Projects

LighterPulse

All Systems Operational

Analytics and exploration platform for the Lighter.xyz ecosystem, covering dashboards, a block explorer, exchange statistics, multi-venue funding comparison, and protocol announcements. Redis-backed caching and a split between live and cached data paths keep the UI responsive.

Tech stack

Next.jsTypeScriptTailwind CSSUpstash RedisDune AnalyticsWebSocketsNext.js API Routes

Overview

LighterPulse is a single product surface for traders and researchers who use Lighter.xyz. It combines account-level dashboards (including dynamic routes keyed by address), a block and transaction explorer with hash- and height-based navigation, an exchange statistics view built around a fixed set of KPI cards, a funding comparison workflow across Lighter and major perpetual venues, and an announcements area for protocol and product updates. The implementation prioritizes predictable latency: metrics that can tolerate staleness are served through a cached layer, while prices, positions, and explorer results stay on shorter-lived or on-demand fetches. The UI uses progressive disclosure and lazy loading so heavy panels do not block first paint on constrained networks.

Technical deep dive

Application architecture

The app is structured on the Next.js App Router with feature-oriented route segments: marketing landing, dashboard with `[address]` dynamics, explorer with nested `tx/[txnhash]`, plus standalone sections for exchange statistics, funding comparison, announcements, and support. Shared layout and error boundaries (`error.tsx`, `global-error.tsx`, `not-found.tsx`) keep failures localized and recoverable.

Server components are used where data can be resolved on the server without shipping unnecessary client JavaScript. Client components own interactivity: search inputs, manual refresh controls, charts, and WebSocket-driven updates. API routes under `app/api` encapsulate server-only secrets (for example Dune and Upstash credentials) and return JSON consumed by the client or by server components via internal fetch patterns where appropriate.

Data layer, caching, and external APIs

Lighter.xyz public APIs supply account balances, positions, market metadata, and explorer-shaped data. Dune Analytics augments protocol- and chain-level metrics where SQL-defined datasets are the right source of truth. Funding comparison aggregates REST endpoints from Lighter, Binance, Bybit, and Hyperliquid; each integration is typed independently so schema drift on one venue does not break the others.

Upstash Redis backs a metrics endpoint (for example `/api/metrics`) with a roughly one-hour TTL for expensive aggregates: TVL, user counts, retention-style figures, and similar KPIs that power the exchange statistics cards. Trading-adjacent views that require fresher data bypass that cache or use shorter TTLs. Manual refresh actions revalidate selected queries and surface last-updated timestamps so users can reason about freshness.

Real-time channels and client performance

WebSockets (configured via public `wss` URL where the protocol exposes streaming data) support live updates on views that benefit from push-style refreshes without polling loops. Where sockets are not used, the client batches parallel `fetch` calls and avoids waterfall requests on dashboard and explorer entry.

Tailwind CSS 4 and a small set of third-party UI primitives (Radix, Lucide, plus motion-heavy presentation components) keep styling consistent. Images and non-critical panels load lazily; route-level code splitting is largely inherited from the App Router's per-segment bundles.

Types, validation, and operational concerns

Domain types live in dedicated modules (funding, explorer, exchange statistics, transactions, routes) so API mappers and UI props stay aligned. Input validation utilities guard address, hash, and numeric search parameters before hitting upstream APIs, reducing avoidable 4xx noise and improving error messaging.

SEO primitives (`sitemap.ts`, `robots.ts`) and metadata on layouts support discoverability for a public deployment. Environment variables are documented for local and hosted setups: API base URLs, WebSocket URL, Dune key, Upstash REST URL and token, and optional analytics IDs.

Challenges

  • Defining a single caching policy that works across KPI aggregates (hour-safe), pair statistics (minutes-level), and user-specific dashboard data (near real-time) without contradictory UI states
  • Normalizing funding rate and market structures across four exchanges with different field names, precisions, and update cadences
  • Chaining Lighter, Dune, and venue APIs in explorer and dashboard flows while keeping time-to-interactive acceptable on 3G-class connections
  • Handling explorer edge cases: invalid hashes, delayed confirmation messaging, and empty result sets without breaking search UX
  • Sharing data-fetch helpers between server and client code paths without duplicating business logic or leaking secrets to the bundle

Learnings

  • Hour-scoped Redis caching for aggregate metrics reduced redundant upstream calls by a large margin and brought several views into a consistent sub-2 second perceived load when the cache was warm
  • Labeling surfaces explicitly as live versus cached, plus manual refresh and timestamps, reduced support questions about stale numbers more than micro-optimizing TTLs alone
  • Investing in per-domain TypeScript models early paid off when exchange APIs shipped minor breaking changes; refactors stayed localized to mapper functions
  • Lazy loading below-the-fold panels and deferring non-critical third-party work improved Lighthouse scores without changing product scope
  • Centralizing secrets in Route Handlers and validating all user-derived IDs before proxying to Lighter or Dune simplified security review and error handling

Related Projects

Lighter Liquidations

Lighter Liquidations

Backend service for Lighter.xyz that ingests perpetuals liquidation events over WebSockets, deduplicates noisy replay batches, aggregates notional USD into per-minute buckets in Upstash Redis, and serves a rolling 24 hour liquidation total over HTTP.

All Systems Operational
View Details
WalletX

WalletX

Full-stack FinTech-style wallet demo: P2P transfers, balances, history, and dashboard analytics. MongoDB multi-document transactions enforce ACID semantics so debits and credits stay consistent under concurrency (simulated funds, not real money).

All Systems Operational
View Details
View All Projects