The frontend uses two complementary state systems:
  1. JWT context — session, user profile, login/logout (React context + useReducer)
  2. Redux Toolkit — shared app flags and cached admin data

Redux store — store/index.ts

Typed hooks are re-exported:

When Redux is used

  • Header — reads/writes zerodha.isZerodhaConnected after Zerodha status checks
  • User list page — dispatches getUsersDetails after fetching users
  • Dashboard useruseSelector(selectZerodhaStatus) before placing orders

JWT context — contexts/JWTContext.tsx

Auth is not in Redux. JWTProvider holds:

Methods exposed via useAuth()

Token storage key: localStorage.serviceToken.

State flow diagram

Design rationale

  • Auth in context — token lifecycle tied to axios interceptors and socket connection in one place
  • Zerodha flag in Redux — multiple components (Header, DashboardUser) need the same connection status without prop drilling
  • Users in Redux + persist — admin table survives refresh without refetch