This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a monorepo with three main packages:
/packages/app/- Next.js frontend application (main application)/packages/api/- Koa.js API server with PostgreSQL backend/packages/grafana/- Grafana monitoring and analytics
npm run dev- Start development server with Turbopacknpm run build- Build the application with Turbopacknpm run start- Start production servernpm run lint- Run ESLint
npm run dev- Development server with hot reloadnpm run build- TypeScript compilationnpm run start- Production servernpm run test- Jest test suitenpm run lint- ESLint checkingnpm run migration:generate- Generate database migrationsnpm run migration:push- Apply database migrationsnpm run db:setup- Start Docker containers and initialize database
docker build -t chain-derby-grafana .- Build Grafana Docker imagedocker run -p 3000:3000 chain-derby-grafana- Run Grafana container
- Framework: Next.js 15 with React 19 and TypeScript
- Build Tool: Turbopack for faster development and builds
- Imports: Use absolute imports with path aliases (e.g.,
@/components,@/hooks) - Component structure:
- Use React functional components with TypeScript types
- Client components should use "use client" directive
- Props should be typed with Readonly for immutability
- Naming:
- PascalCase for components and their files
- camelCase for variables, functions, and hooks
- Styling: Tailwind CSS v4 with class-variance-authority for variants
- Type safety: Enable strict TypeScript mode, prefer explicit types
- Error handling: Use try/catch blocks with appropriate error messaging
- UI Components: Use Radix UI primitives combined with custom styling
- State management: React hooks with context providers when needed
Chain Derby is a blockchain transaction speed racing application that compares transaction latency across multiple EVM-compatible and Solana networks. Users can:
- Generate embedded wallets (EVM and Solana)
- Fund wallets on multiple blockchain networks
- Execute parallel transactions across all selected chains
- Measure and compare real-time transaction confirmation times
- View race results with detailed performance metrics
- EVM Chains: RISE Testnet, Monad Testnet, MegaETH Testnet, Sonic Mainnet, Base Sepolia
- Non-EVM: Solana Testnet
- Each chain has specific optimizations (custom RPC methods, gas settings, fallback endpoints)
WagmiProvider (blockchain integration)
├── QueryClientProvider (data fetching)
├── ThemeProvider (dark/light mode)
├── ChainRaceProvider (core race logic)
├── PageProvider (page state)
└── ModalProvider (modal management)
useChainRace: Central hook managing race state, balances, transaction processinguseEmbeddedWallet: EVM wallet generation and management (viem/wagmi)useSolanaEmbeddedWallet: Solana wallet generation and managementuseModal: Global modal state management
- EVM: Uses viem/wagmi v2 for blockchain interactions
- Solana: Uses @solana/web3.js with custom wallet management
- Chain Configuration: Centralized in
/chain/config.tsand/chain/networks.ts - Multi-Chain Support: Parallel transaction processing with chain-specific optimizations
ChainRace: Main racing visualization and controllerEmbeddedWallet: Wallet display and management for both EVM and SolanaFundingPhase: UI for funding wallets across chains with balance validationRaceController: Race start/stop controls with pre-transaction validationLeaderboardPanel: Real-time race results and rankingsScoreboard: Detailed performance metrics and transaction data
- Framework: Koa.js with TypeScript
- Database: PostgreSQL with Drizzle ORM
- Schema: Three main tables (race_sessions, chain_results, transaction_details)
- Validation: Zod for schema validation
- Testing: Jest test suite
- Generate embedded wallets on first load (both EVM and Solana)
- User funds wallets across selected chains with balance validation
- Race starts by pre-signing and sending parallel transactions
- Real-time tracking of transaction confirmations with latency measurement
- Results displayed with rankings, timing data, and transaction hashes
- Optional data persistence via API backend
ChainRaceStatus: Race phases (idle, funding, ready, racing, finished)ChainBalance: Balance information per chain (chainId, balance, hasBalance, error)RaceResult: Core race tracking with performance metrics, styling, hashes, latenciesTransactionCount: Number of transactions per chain (fixed at 10)ChainConfig: Extends viem's Chain with UI properties (color, emoji, logo)ModalContextType&ModalProps: Application-wide modal managementPageContextType: Page-level state and view preferences
- Pre-signed transactions for faster execution
- Parallel transaction processing across all chains
- Strategic RPC endpoint fallbacks for reliability
- Minimal re-renders with stable state management
- Chain-specific optimizations (custom RPC methods, gas settings)