Skip to content

01 - Frontend Architecture

Stack

The frontend is a React 19 TypeScript SPA built with Vite 8. Current package constraints are read from frontend/package.json.

ConcernImplementation
Routingreact-router 8
Server stateTanStack Query 5
Client stateZustand 5
StylingTailwind CSS 4 and local shadcn-style components
IconsLucide React
Forms/editorsRadix primitives, CodeMirror 6 through @uiw/react-codemirror
Flow canvasXYFlow 12
ChartsPlotly 3 (plotly.js-dist-min) and Lightweight Charts 5
Live app eventsSocket.IO client 4
LanguageTypeScript 7
TestsVitest 4, Testing Library, axe, Playwright
Formatting/lintBiome 2

Routing uses the react-router package directly. react-router-dom is no longer a dependency, so imports come from react-router.

Supported Node versions are >=20.20.0 || >=22.22.0 || >=24.13.0.

Composition

frontend/src/main.tsx mounts the app. frontend/src/app/providers.tsx composes TanStack Query, theme, tooltips, Socket.IO, market-data state, and browser toasts. frontend/src/App.tsx lazy-loads route modules and applies public/authenticated/full-width layout boundaries.

The Flask backend serves the production bundle through blueprints/react_app.py when frontend/dist exists. Vite's development server runs on port 5173 and proxies backend requests according to frontend/vite.config.ts.

Route Families

FamilyExamples
Public/auth/login, /setup, /reset-password, broker callbacks
Trading state/dashboard, /orderbook, /tradebook, /positions, /holdings
Automation/strategy, /chartink, /python, /flow
Tools/optionchain, /strategybuilder, /ivchart, /oitracker, /gex, /gammadensity, /oirange, /arbitrage, /scalping
Monitoring/pnltracker, /latency, /traffic, /health, /security
Admin/integrations/admin, /apikey, /playground, /telegram, /whatsapp

The exact route list is in frontend/src/App.tsx; navigation visibility is defined separately in frontend/src/config/navigation.ts.

State Boundaries

Store/contextResponsibility
authStore.tsUser and Tradeboard API key for client calls
brokerStore.tsActive broker capability metadata
sessionStore.tsActive app-session count
themeStore.tsTheme, accent, live/analyzer presentation mode
flowWorkflowStore.tsFlow editor graph state
MarketDataContext.tsxShared market-data manager lifecycle

TanStack Query owns fetched server data. Zustand is reserved for cross-page client state; feature-local state remains in components.

Data And Live Updates

Feature clients under frontend/src/api/ call Flask blueprint or REST resources with credentials. AuthSync reads /auth/session-status, restores user/broker/API-key state, synchronizes analyzer mode, and records the active-session count.

Market data uses MarketDataManager and hooks such as useLivePrice, useLiveQuote, useMarketData, and useOptionChainLive. Order lifecycle refreshes are triggered by Socket.IO events through useOrderEventRefresh, avoiding high-frequency account polling where an event is available.

Build And Test Commands

Run from frontend/:

bash
npm ci
npm run lint
npm run test:run
npm run build
npm run e2e -- --project=chromium

npm run build runs TypeScript project builds before Vite. CI uploads frontend/dist, and main-branch automation rebuilds and commits the production bundle.

Key Files

FilePurpose
frontend/src/App.tsxRoute graph and lazy modules
frontend/src/app/providers.tsxGlobal providers
frontend/src/config/navigation.tsSidebar/tool navigation
frontend/src/api/client.tsShared HTTP client behavior
frontend/src/components/auth/AuthSync.tsxFlask session synchronization
frontend/src/lib/MarketDataManager.tsShared WebSocket market-data lifecycle
frontend/vite.config.tsBuild and development proxy