This dashboard application is built with React, TypeScript, Redux Toolkit, and Vite. It follows modern best practices for scalability, performance, and maintainability.
- React 18.3+ - UI library with latest features
- TypeScript - Type safety and better developer experience
- Redux Toolkit - State management with RTK Query for data fetching
- Vite - Fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- Radix UI - Accessible component primitives
- Recharts - Charting library
src/
├── store/ # Redux store configuration
│ ├── index.ts # Store setup and configuration
│ ├── hooks.ts # Typed Redux hooks
│ ├── slices/ # Redux slices
│ │ └── uiSlice.ts # UI state management
│ └── api/ # RTK Query APIs
│ └── dashboardApi.ts # Dashboard data API
├── components/ # React components
│ ├── Layout.tsx # Main layout component
│ ├── pages/ # Page components
│ └── ui/ # Reusable UI components
├── styles/ # Stylesheets
│ ├── globals.css # Global styles
│ └── utilities.css # CSS utility classes
└── lib/ # Utility functions
The application uses Redux Toolkit for centralized state management:
- UI State (
uiSlice): Manages sidebar collapse, current page, theme, and mobile menu state - API State (
dashboardApi): Handles data fetching and caching via RTK Query
- Predictable state updates
- Time-travel debugging with Redux DevTools
- Automatic caching and refetching with RTK Query
- Type-safe with TypeScript
- React.memo: Prevents unnecessary re-renders of components
- useMemo: Memoizes expensive calculations
- useCallback: Memoizes callback functions
- Code Splitting: Automatic code splitting via Vite
- CSS Transitions: Replaces JavaScript animations where possible
- CSS Variables: Dynamic theming without JS manipulation
- Container Queries: Modern CSS for responsive design
- Transform Utilities: Hardware-accelerated transforms
- Tree Shaking: Removes unused code
- Code Splitting: Separate chunks for vendor libraries
- Minification: ESBuild for fast minification
- Source Maps: Disabled in production for smaller bundles
The application uses RTK Query for data fetching:
- Automatic Caching: Reduces unnecessary API calls
- Polling: Configurable polling intervals for real-time updates
- Optimistic Updates: Instant UI updates before server confirmation
- Error Handling: Built-in error states and retry logic
// Base URL from environment variable
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
// Polling interval for real-time updates
pollingInterval: 30000 // 30 seconds- Container Components: Handle data fetching and state management
- Presentational Components: Focus on UI rendering
- Small, reusable components
- Props composition for flexibility
- Compound components for complex UI
- Strict type checking enabled
- Type-safe Redux hooks
- Interface definitions for all data structures
- Feature-based folder structure
- Co-located related files
- Clear separation of concerns
- JSDoc comments for all components and functions
- Inline comments for complex logic
- Architecture documentation (this file)
VITE_API_URL=http://localhost:3001/api- Development:
npm run dev- Starts Vite dev server - Build:
npm run build- Creates production build - Deploy:
npm run deploy- Deploys to GitHub Pages
- Add unit tests with Vitest
- Add E2E tests with Playwright
- Implement WebSocket for real-time updates
- Add service worker for offline support
- Implement virtual scrolling for large lists
- Add error boundaries for better error handling