How anushka2503769/wallet-ui works
1. Overall shape
This repo is split into two major subsystems:
- a React/Vite frontend prototype for the TradeFlow Wallet UI
- a Rust blockchain simulator/backend under rust-blockchain/
The frontend is currently the primary user-facing app; the Rust side appears to be a separate executable/service that will eventually back the UI.
2. Frontend shell
The entry point is a single-page application built with React + Vite (src/main.jsx, src/App.jsx, src/routes.jsx).
Routing is page-based, not server-rendered: the app navigates across dashboard, wallet, explorer, trading, staking, validators, and harness screens.
3. Page-level domains
The src/pages/ folder defines the product’s major functional areas:
- Dashboard / Portfolio / Transactions / SendReceive for wallet operations
- Blockchain / Explorer / Validators / Staking for chain visibility and participation
- Markets / FuturesTrading / OptionsTrading / PerpetualsTrading / OpenPositions / TradeHistory for trading-oriented views
- Harness for automated testing or simulation monitoring
- Settings for user/app preferences
These pages are mostly presentation and orchestration layers over shared components and service calls.
4. Shared UI component system
Reusable UI lives in src/components/ and is organized by domain:
- common/ for shell elements like header, sidebar, loading state, stat cards
- wallet/ for wallet cards and transaction form
- blockchain/ for block cards, block lists, network status
- tables/ and charts/ for tabular and analytical views
This indicates a design where pages assemble data-driven widgets rather than containing heavy logic themselves.
5. State and cross-cutting concerns
App-wide state is managed with React context in src/context/:
- ThemeContext handles dark/light mode
- WalletContext manages wallet-related state across pages
There is also a useBlockchain hook in src/hooks/, which centralizes blockchain-data access for components and pages that need chain state.
6. Frontend data layer and abstraction boundary
The src/services/ folder is the key boundary between UI and data sources:
- services/api/ contains HTTP client and wallet API wrappers
- services/blockchain/ contains a blockchain provider abstraction plus a mock provider
- services/harness/ contains simulation/test harness logic
This structure suggests the UI is designed to swap between mocked local data and real backend integrations without changing page components.
7. Mock-first development mode
The presence of src/data/*.json and src/utils/mockDelay.js shows the frontend currently runs heavily on mock datasets for:
- blocks
- transactions
- portfolio
- validators
- harness logs
This is an important architectural boundary: the UI can function independently of the Rust backend while still modeling the eventual real data flows.
8. Rust blockchain subsystem
The rust-blockchain/ directory is a separate Rust project (Cargo.toml, src/main.rs) with:
- cli.rs for command-line interaction
- consensus.rs for consensus logic
- ledger/ for persistent chain state
- blockchain_gui.py as an auxiliary GUI/utility entry point
The Rust project appears to implement blockchain behavior and persistence, not the React UI itself.
9. Ledger and persistence model
The ledger/ directory contains files like CURRENT, IDENTITY, LOCK, and LOG, which strongly suggests a file-backed local ledger/store rather than a remote database.
That means chain state is likely persisted on disk inside the Rust subsystem, and the frontend would consume chain state through services or an API layer rather than directly.
10. Likely end-to-end data flow
The intended flow is:
- user interacts with a React page
- page calls a shared service or hook
- service reads mock JSON locally or calls an HTTP/API integration
- blockchain-specific requests eventually map to the Rust backend or simulation layer
For harness and validator views, data is probably sourced from simulation logs or mock streams rather than live chain polling today.
11. Tooling and runtime boundaries
The frontend runs in a Node/Vite browser runtime and is styled through global/theme CSS files.
The Rust subsystem runs as an independent native binary.
This separation is useful for architecture diagrams: treat them as two deployable units with a loose integration boundary, not as one monolith.
12. What to emphasize in an architecture diagram
The main boxes should be:
- React SPA shell
- Route-based feature pages
- Shared UI components
- Contexts/hooks
- Service layer with API + blockchain provider abstraction
- Mock data / harness simulation sources
- Rust blockchain engine with CLI, consensus, and file-backed ledger
The primary relationship is frontend orchestration over blockchain/testing data, with the Rust backend serving as the future authoritative chain engine.
Main entry points: routes.jsx Routes · main.rs Rust app · httpClient.js Services · Header.jsx Common UI
Components 21
React SPA
Browser-based wallet and trading UI built with React and Vite.
- App shell · Bootstraps the single-page app and global layout.
src/main.jsx - Routes · Maps URLs to product pages.
src/routes.jsx - Dashboard · Overview page for portfolio and activity.
src/pages/Dashboard/Dashboard.jsx - Wallet pages · Portfolio, transactions, and send/receive flows.
src/pages/Portfolio/Portfolio.jsx - Chain pages · Blockchain, explorer, validators, and staking screens.
src/pages/Blockchain/Blockchain.jsx - Trading pages · Markets and derivatives trading screens.
src/pages/Markets/Markets.jsx - Ops pages · Harness, open positions, trade history, and settings.
src/pages/Harness/Harness.jsx - Common UI · Shell and reusable layout elements.
src/components/common/Header.jsx - Wallet UI · Wallet cards and transaction entry widgets.
src/components/wallet/WalletCard.jsx - Chain UI · Block lists, cards, and network status widgets.
src/components/blockchain/BlockList.jsx - Analytics UI · Tabular and chart-based portfolio and history views.
src/components/charts/PortfolioChart.jsx - Contexts · App-wide theme and wallet state.
src/context/ThemeContext.jsx - Chain hook · Shared access point for blockchain state.
src/hooks/useBlockchain.js - Services · API, blockchain provider, and harness integration layer.
src/services/api/httpClient.js - Mock data · Static JSON fixtures used by the UI.
src/data/mockBlocks.json - Harness sim · Simulation and test harness logic for non-live runs.
src/services/harness/simulationService.js
Rust Engine
Native blockchain simulator and ledger subsystem.
- Rust app · Entry point for the blockchain simulator/backend.
rust-blockchain/src/main.rs - CLI · Command-line interaction and control.
rust-blockchain/src/cli.rs - Consensus · Consensus and validation logic.
rust-blockchain/src/consensus.rs - Ledger store · Persistent chain state stored on disk.
rust-blockchain/ledger/CURRENT - Aux GUI · Supplementary GUI or helper entry point.
rust-blockchain/blockchain_gui.py
Connections 22
- App shell → Routes: uses · Shell renders routed screens.
- Routes → Dashboard: opens · Route dispatch to dashboard.
- Routes → Wallet pages: opens · Route dispatch to wallet views.
- Routes → Chain pages: opens · Route dispatch to chain views.
- Routes → Trading pages: opens · Route dispatch to trading views.
- Routes → Ops pages: opens · Route dispatch to support views.
- Dashboard → Common UI: assembles · Uses shared layout and page chrome.
- Wallet pages → Wallet UI: uses · Wallet screens compose wallet widgets.
- Chain pages → Chain UI: uses · Chain screens compose blockchain widgets.
- Trading pages → Analytics UI: uses · Trading screens lean on tables and charts.
- Ops pages → Common UI: uses · Support views reuse shell components.
- Common UI → Contexts: reads · Shell consumes global theme and wallet state.
- Wallet UI → Contexts: reads · Wallet widgets depend on wallet context.
- Chain UI → Chain hook: reads · Blockchain widgets use shared chain access.
- Chain hook → Services: calls · Hook delegates to service abstractions.
- Services → Mock data: loads · Default data source for local UI flows.
- Services → Harness sim: orchestrates · Harness service coordinates simulation flows.
- Services → Rust app: integrates with · Backend boundary for real chain execution.
- Rust app → CLI: exposes · Native binary includes CLI entry points.
- Rust app → Consensus: runs · Main process drives consensus logic.
- Rust app → Ledger store: persists to · Chain state is stored in file-backed ledger.
- Rust app → Aux GUI: supports · Auxiliary GUI/helper entry point.