The React dashboard provides a modern, user-friendly interface for the Cryptocurrency Wallet & Trading Engine Simulator. Built with React 18, TypeScript, and Material-UI, it offers real-time updates, intuitive trading interfaces, and comprehensive wallet management.
- React 18 with TypeScript
- Vite for fast development and optimized builds
- Material-UI (MUI) v5 for modern UI components
- React Query for efficient data fetching and caching
- Axios for HTTP requests
- React Router for navigation
- Socket.io-client (ready for WebSocket integration)
frontend/
├── src/
│ ├── api/
│ │ └── client.ts # API client with TypeScript types
│ ├── components/
│ │ ├── OrderBook.tsx # Order book visualization
│ │ ├── RecentTrades.tsx # Recent trades table
│ │ └── Navigation.tsx # Bottom navigation bar
│ ├── pages/
│ │ ├── Dashboard.tsx # Main dashboard
│ │ ├── Wallet.tsx # Wallet management
│ │ ├── Trading.tsx # Order placement
│ │ └── Orders.tsx # Order history
│ ├── hooks/
│ │ └── useWebSocket.ts # WebSocket hook (ready for integration)
│ ├── App.tsx # Main app component
│ └── main.tsx # Entry point
├── public/ # Static assets
├── package.json # Dependencies
├── vite.config.ts # Vite configuration
└── tsconfig.json # TypeScript config
- Overview Cards: Total balance, open orders count, active symbol
- Live Order Book: Real-time bid/ask visualization
- Recent Trades: Latest trade executions
- Auto-refresh: Updates every 2-5 seconds
- Balance Display: View all wallet balances (USDT, BTC, ETH)
- Deposit Modal: Add funds to any currency
- Real-time Updates: Balance refreshes automatically
- Value Conversion: Shows USDT equivalent for crypto balances
- Order Types: LIMIT and MARKET orders
- Order Side: BUY or SELL toggle
- Symbol Selection: BTC/USDT or ETH/USDT
- Price Input: Custom price for LIMIT orders
- Quantity Input: Amount to trade
- Order Book Sidebar: Live order book for reference
- Total Cost Display: Shows total cost for LIMIT orders
- Market Price Helper: Displays current market price
- Order List: All user orders in a table
- Status Chips: Color-coded status (OPEN, PARTIAL, FILLED, CANCELLED)
- Order Details: Price, quantity, filled quantity, timestamp
- Cancel Action: Cancel open/partial orders
- Auto-refresh: Updates every 5 seconds
- API URL:
http://localhost:8080/api/v1 - Proxy: Configured in
vite.config.tsfor development - CORS: Handled by backend CORS configuration
POST /users- Create userGET /users/{id}- Get user details
GET /wallets/balances?userId={id}- Get all balancesGET /wallets/balance?userId={id}¤cy={currency}- Get specific balancePOST /wallets/deposit?userId={id}¤cy={currency}- Deposit funds
POST /orders?userId={id}- Place orderGET /orders?userId={id}- Get user ordersGET /orders/{id}?userId={id}- Get order detailsPOST /orders/{id}/cancel?userId={id}- Cancel order
GET /market/orderbook/{symbol}- Get order bookGET /market/trades/{symbol}?limit={limit}- Get recent trades
- Uses React Query polling for real-time updates
- Polling intervals:
- Order book: 2 seconds
- Recent trades: 3 seconds
- Wallet balances: 5 seconds
- User orders: 5 seconds
The useWebSocket hook is implemented and ready for WebSocket integration:
// In useWebSocket.ts
export const useWebSocket = () => {
// Currently simulates connection
// Ready to connect to WebSocket server
}To enable WebSocket:
- Add WebSocket endpoint to backend
- Update
useWebSocket.tsto connect to WebSocket server - Replace polling with WebSocket subscriptions
- Caching: Automatic caching of API responses
- Refetching: Configurable refetch intervals
- Optimistic Updates: Mutations update cache immediately
- Error Handling: Built-in error states
- Form inputs (price, quantity, etc.)
- UI state (modals, navigation)
- User ID (stored in localStorage)
- Dark Theme: Custom dark theme with crypto-trading aesthetic
- Primary Color: Cyan (
#00d4ff) - Background: Dark blue (
#0a0e27,#151932) - Typography: Inter font family
- Material-UI components with custom styling
- Responsive grid layouts
- Custom scrollbars
- Hover effects and transitions
- Node.js 18+
- npm or yarn
cd frontend
npm installnpm run dev- Runs on http://localhost:3000
- Hot module replacement enabled
- API proxy configured
npm run build- Output:
dist/directory - Optimized for production
- TypeScript compilation
- Asset optimization
npm run preview- ✅ User creation flow
- ✅ Wallet deposit functionality
- ✅ Order placement (LIMIT and MARKET)
- ✅ Order cancellation
- ✅ Order book display
- ✅ Recent trades display
- ✅ Balance updates
- ✅ Navigation between pages
- ✅ Responsive design
npm run build- ✅ TypeScript compilation successful
- ✅ No build errors
- ✅ Assets optimized
- ✅ Production bundle created
docker build -t crypto-wallet-frontend ./frontend
docker run -p 3000:3000 crypto-wallet-frontendBuild the project and deploy the dist/ directory to:
- Netlify
- Vercel
- AWS S3 + CloudFront
- GitHub Pages
Create .env file:
VITE_API_URL=http://localhost:8080/api/v1- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Production Build: ~550 KB (gzipped: ~171 KB)
- CSS: ~1 KB (gzipped: ~0.5 KB)
- Optimizations: Code splitting, tree shaking, minification
- React Query caching reduces API calls
- Lazy loading for routes (ready for implementation)
- Image optimization
- Code splitting (ready for implementation)
- Uses polling instead of WebSocket (WebSocket hook ready)
- No authentication (demo mode)
- No error boundaries (can be added)
- No loading skeletons (can be added)
- WebSocket integration for real-time updates
- Authentication and authorization
- Error boundaries for better error handling
- Loading skeletons for better UX
- Order history charts and analytics
- Multi-language support
- PWA support
- Ensure backend CORS is configured
- Check API URL in
vite.config.ts
- Verify backend is running:
curl http://localhost:8080/actuator/health - Check network tab in browser DevTools
- Clear
node_modulesand reinstall:rm -rf node_modules && npm install - Check TypeScript version compatibility
- Change port in
vite.config.ts:server: { port: 3001 }