Introduction
Exchange Web is a modern, real-time crypto trading frontend built with React, TypeScript, and Vite. The application provides a professional trading interface with live order books, price charts, and instant trade execution.Monorepo Structure
The project uses a Turborepo monorepo structure with Yarn workspaces:Apps Directory
- web: The primary trading interface application built with React + Vite
Packages Directory
- ui: Reusable UI components (buttons, cards, etc.)
- eslint-config: Shared linting rules
- typescript-config: Shared TypeScript compiler settings
Technology Stack
React 18
Modern React with hooks for component logic
TypeScript
Type-safe development with full type coverage
Vite
Fast build tool and dev server
React Router
Client-side routing with react-router-dom v6
Key Dependencies
Application Structure
Component Hierarchy
The application follows a clear component hierarchy:Root Level
App.tsx wraps the entire application with:TradesProviderfor global stateBrowserRouterfor routing- Toast notifications via Sonner
- Vercel Analytics
Page Level
Trade.tsx (apps/web/src/pages/Trade.tsx:32-49) composes the main trading interface:Data Flow Architecture
Data Flow Diagram
Routing
The application uses react-router-dom v6 for client-side routing:- Primary route:
/trade/:market(e.g.,/trade/SOL_USDC) - Fallback: Redirects all unknown routes to SOL_USDC market
- Market parameter extracted with
useParams()hook
Real-Time Updates
The application is designed for real-time trading with:WebSocket Connection
Persistent connection to exchange backend
Live Order Book
Real-time bid/ask updates
Trade Stream
Instant trade notifications
Price Ticker
Live price and stats updates
Performance Considerations
Optimization Strategies
- Singleton Pattern: WsManager uses singleton to maintain single WebSocket connection
- Message Buffering: Messages buffered until connection established
- Selective Updates: Components only re-render when relevant state changes
- Context Optimization: TradesProvider exposes granular setters to minimize re-renders
Next Steps
Components
Explore component structure and composition
State Management
Learn about TradesProvider and context usage
WebSocket
Understand real-time communication