- JWT context — session, user profile, login/logout (React context + useReducer)
- 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.isZerodhaConnectedafter Zerodha status checks - User list page — dispatches
getUsersDetailsafter fetching users - Dashboard user —
useSelector(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