01 - Frontend Architecture

Overview

OpenAlgo features a modern React 19 Single Page Application (SPA) built with TypeScript, Vite, and Tailwind CSS 4. The frontend provides a responsive trading interface with real-time market data, visual workflow automation, and comprehensive strategy management.

Technology Stack

Technology
Version
Purpose

React

19.2.3

UI framework

TypeScript

5.9.3

Type safety

Vite

7.2.4

Build tool & dev server

Tailwind CSS

4.1.18

Utility-first styling

React Router

7.12.0

Client-side routing

Zustand

5.0.9

Client state management

TanStack Query

5.90.16

Server state & caching

Axios

1.13.5

HTTP client

Socket.IO Client

4.8.3

Real-time events

@xyflow/react

12.3.6

Flow editor canvas

Plotly.js

react-plotly.js

Interactive analytics charts

Radix UI

Latest

Accessible UI primitives

Architecture Diagram

Directory Structure

State Management

1. Zustand (Client State)

Lightweight state management for UI state that persists across sessions.

Stores:

  • authStore - User session, API key, authentication state

  • themeStore - Dark/light mode, analyzer mode toggle

  • alertStore - Toast notification state and management

  • flowWorkflowStore - Flow editor nodes, edges, selection state

2. TanStack Query (Server State)

Handles all server data fetching with automatic caching and refetching.

API Integration

Three Axios Clients

CSRF Protection

Routing Structure

Route Categories

Category
Example Routes
Layout

Public

/, /login, /setup, /download

None

Broker Auth

/broker, /broker/:broker/totp

None

Protected

/dashboard, /positions, /strategy

Standard Layout

Analytics

/tools, /gex, /ivsmile, /oitracker, /maxpain, /volsurface

Standard Layout

Full-Width

/flow/editor/:id, /playground, /historify

Full-Width Layout

Code Splitting

All pages are lazy-loaded for optimal bundle size:

Real-Time Communication

Socket.IO (Order Events)

Events: order_event, cancel_order_event, modify_order_event, close_position_event

WebSocket (Market Data)

Component Library (shadcn/ui)

Built on Radix UI primitives with Tailwind styling:

Category
Components

Form

Button, Input, Select, Checkbox, Switch, Label

Display

Card, Table, Badge, Avatar, Skeleton

Overlay

Dialog, Sheet, Popover, Tooltip, DropdownMenu

Custom

JsonEditor, PythonEditor, LogViewer, PageLoader

Build & Development

Bundle Optimization

Vite splits the bundle into chunks:

Chunk
Contents

vendor-react

React, ReactDOM

vendor-router

React Router

vendor-radix

Radix UI components

vendor-icons

Lucide React icons

vendor-syntax

Code highlighter (loaded on demand)

Key Files Reference

File
Purpose

src/App.tsx

Route definitions

src/api/client.ts

Axios clients configuration

src/stores/authStore.ts

Authentication state

src/components/layout/Layout.tsx

Main layout with Navbar/Footer

src/components/auth/AuthSync.tsx

Flask session sync

vite.config.ts

Build configuration

Last updated