⌘/
Live
← Back to Docs

Architecture

Technical

System design, services, and data flow

Tech Stack

Framework

Next.js 15 (App Router)

React 19

Language

TypeScript 5.9

Styling

Tailwind CSS 4

shadcn/ui

Radix UI

AI

Vercel AI SDK v5

OpenAI GPT-4o

Data Fetching

TanStack React Query

State

Jotai

Charts

Recharts

Maps

Leaflet

React-Leaflet

Database

PostgreSQL

Prisma ORM

Blockchain

@solana/web3.js

Wallet Adapter

Project Structure

src/
├── app/                      # Next.js App Router pages
│   ├── page.tsx              # Homepage dashboard
│   ├── pnodes/               # pNode explorer & detail pages
│   ├── network/              # Network analytics (5 tabs)
│   ├── analytics/            # Historical analytics
│   ├── insights/             # AI insights
│   ├── alerts/               # Alert management
│   ├── compare/              # pNode comparison
│   ├── watchlist/            # User watchlist
│   ├── settings/             # App settings
│   ├── help/                 # Help & documentation
│   ├── docs/                 # In-app documentation
│   └── api/                  # API routes
│       ├── chat/             # AI chat endpoint
│       ├── prpc/             # pRPC proxy
│       ├── pnodes/           # pNode endpoints
│       ├── alerts/           # Alert endpoints
│       └── analytics/        # Analytics endpoints
├── components/
│   ├── app-sidebar.tsx       # Left sidebar navigation
│   ├── app-header.tsx        # Top header with controls
│   ├── mobile-nav.tsx        # Mobile bottom navigation
│   ├── ai-chat.tsx           # AI chat component
│   ├── rewards-tracking.tsx  # Rewards & epoch tracking
│   ├── network-topology.tsx  # Network visualization
│   ├── pnodes/               # pNode-specific components
│   ├── alerts/               # Alert components
│   └── ui/                   # shadcn/ui components
├── services/
│   ├── pnode.service.ts      # pNode data fetching
│   ├── analytics.service.ts  # Analytics & predictions
│   ├── alert.service.ts      # Alert management
│   ├── geoip.service.ts      # GeoIP lookup
│   └── websocket.service.ts  # Real-time updates
├── lib/
│   ├── prisma.ts             # Prisma client
│   └── utils.ts              # Utility functions
└── types/                    # TypeScript definitions

Service Layer

The application uses a service layer pattern to encapsulate business logic and external API calls.

PNodeService

pnode.service.ts

Core service for fetching pNode data from Xandeum network

getPNodes()getPNodeDetails(id)getNetworkStats()getEpochInfo()

AnalyticsService

analytics.service.ts

Historical data, predictions, and quantitative analysis

getHistory()getPredictions()getAnomalies()getLeaderboard()

AlertService

alert.service.ts

Alert creation, management, and notification delivery

createAlert()getAlerts()updateRule()dismissAlert()

WebSocketService

websocket.service.ts

Real-time updates via WebSocket with polling fallback

connect()subscribe()disconnect()onMessage()

GeoIPService

geoip.service.ts

Geographic location lookup for pNode IP addresses

lookupGeoIP(ip)getLocationForIP(ip)batchLookup()

Data Flow

1
User ActionClick, navigate, or request data
2
React QueryCheck cache, decide to fetch
3
API RouteNext.js serverless function
4
Service LayerPNodeService, AnalyticsService, etc.
5
External APIpnRPC (6000), Xandeum RPC (8899)
6
TransformNormalize data, add GeoIP
7
ResponseReturn JSON to client
8
UI UpdateReact renders new state

Database Schema

PostgreSQL with Prisma ORM for analytics persistence and alert management.

NetworkSnapshot

Historical network state at each index run

timestamptotalPNodesonlinePNodestotalStorageavgPerformance

PNodeSnapshot

Per-pNode historical metrics

pubkeytimestampstatusstorageperformanceuptime

Alert

Generated alerts

typeseveritypnodeIdmessagestatuscreatedAt

AlertRule

User-configured alert rules

typethresholdenablednotifications

Real-time Updates

How the platform maintains live data

Primary: WebSocket

Streaming connection for instant updates when available

Fallback: Polling

Configurable interval (15s, 30s, 1min, 5min) via settings

React Query handles caching with a 30-second stale time to reduce redundant network requests.

Key Design Decisions

API Route Proxy

All pRPC calls go through /api/prpc to avoid browser CORS restrictions

Service Abstraction

Business logic isolated in service classes for testability and reuse

Incremental Static Regeneration

Static pages with ISR for optimal performance

Dynamic Imports

Heavy components (maps, charts, globe) loaded on demand

Jotai State

Atomic state management for settings, watchlist, and UI preferences

React Query Caching

30s stale time balances freshness with performance