Skip to content

Technical Architecture

Shield Yield Vaults is built with a modern, production-ready full-stack architecture.

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ React SPA │◄────►│ Express API │◄────►│ PostgreSQL │
│ (Frontend) │ │ (Backend) │ │ (Database) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ Xaman/Xumm SDK │ │ XRP Ledger │
│ (Wallet Auth) │ │ (Blockchain) │
└─────────────────┘ └─────────────────┘
  • React 18: Modern React with hooks and concurrent features
  • TypeScript: Type safety across the entire codebase
  • Vite: Lightning-fast dev server and optimized production builds
  • Wouter: Lightweight routing
  • TanStack Query v5: Server state management with caching
  • Tailwind CSS: Utility-first styling
  • shadcn/ui: High-quality component library built on Radix UI
  • Express.js: RESTful API server
  • Node.js: JavaScript runtime
  • TypeScript: Full type safety on backend
  • Drizzle ORM: Type-safe database queries
  • Zod: Runtime schema validation
  • PostgreSQL (Neon): Serverless database
  • xumm-sdk: Xaman wallet integration for XRPL
  • xrpl: XRP Ledger client library
  • @walletconnect/*: Multi-wallet support
/client - Frontend React application
/src/pages - Page components
/src/components - Reusable UI components
/src/lib - Utilities and contexts
/server - Backend Express API
/routes.ts - API endpoints
/storage.ts - Database interface
/db.ts - Database connection
/shared - Shared types and schemas
/schema.ts - Database schema and types

State Management:

  • React Context for wallet state
  • TanStack Query for server state
  • Local state with useState/useReducer

Data Flow:

User Action → API Request → TanStack Query → Backend API
Cache Update
UI Re-render

Request Flow:

HTTP Request → Route Handler → Validation (Zod)
Storage Interface
Database (Drizzle)
HTTP Response

Detailed table structures are defined in the Drizzle schema: shared/schema.ts.

Key Tables:

  • vaults - Vault configurations
  • positions - User positions
  • transactions - Transaction history
  • vault_metrics_daily - Historical analytics
  • dashboard_snapshots - Portfolio history for charts
  • user_notifications - Notification storage with read status
  • Wallet-based authentication (no passwords)
  • Session management with Express sessions
  • PostgreSQL session store
  • All transactions signed in user’s wallet
  • No private key storage on server
  • Transaction hash verification on blockchain
  • Network isolation (mainnet/testnet)
  • Environment variable validation
  • Request body validation with Zod
  • CORS configuration
  • Rate limiting (production)
  • Replit development environment
  • Hot module reloading
  • Development database (PostgreSQL)
  • Demo mode for testing without API keys
  • Replit deployment platform
  • Automatic TLS/HTTPS
  • Production database (separate from dev)
  • Environment variable management
  • Health checks and monitoring
client/src/components/dashboard/
├── PortfolioSummaryCard.tsx # Real-time vault balances
├── PortfolioPerformanceChart.tsx # Historical charts
├── BoostImpactBanner.tsx # SHIELD boost visualization
└── NotificationCenter.tsx # Persistent notifications
Wallet Connect → useUserDashboard Hook → Dashboard Summary API
TanStack Query Cache
UI Components (30s polling)
Event Trigger (Deposit/Withdrawal/Stake/Claim)
Storage Layer (createUserNotification)
PostgreSQL (user_notifications table)
useNotifications Hook (10s polling)
NotificationCenter UI
  • useUserDashboard: Aggregated portfolio data with health-aware polling
  • usePortfolioHistory: Historical snapshots with time range state
  • useNotifications: CRUD operations with unread count tracking
  • Code splitting with React.lazy
  • TanStack Query caching
  • Optimistic updates
  • Debounced search and filters
  • Image optimization
  • Dashboard polling with stale-while-revalidate
  • Database connection pooling
  • Prepared statements (Drizzle)
  • Response caching headers
  • Efficient query patterns
  • Indexed columns for fast lookups
  • Proper foreign key relationships
  • Decimal precision for financial data
  • Timestamps for audit trails
  • Console logging
  • Hot reload notifications
  • Error boundaries
  • LSP diagnostics
  • Application logs
  • Error tracking
  • Performance monitoring
  • Database query logging