Root Directory Structure
Directory Breakdown
assets/
assets/
Contains all static resources used throughout the application.Purpose: Centralized location for all static resources, making asset management easier.
auth/
auth/
Authentication feature module with complete authentication flow.Key Files:
pages/LoginPage.tsx: Main login interfacelayout/AuthLayout.tsx: Layout wrapper for authentication pagesroutes/AuthRoutes.tsx: Route definitions for authentication flow
core/
core/
Core application components that are used across the entire application.MenuSidebar.tsx: Central configuration file that defines all available pages, their routes, permissions, and sidebar menu items.
pages/
pages/
Feature-based page modules. Each feature has its own directory with components, logic, and tests.Organization Pattern:
- Each feature has a main page component (e.g.,
ProductPage.tsx) - Feature-specific components go in a
components/subdirectory - Tests are co-located with the components they test
router/
router/
services/
services/
API service layer for backend communication.Purpose: Centralized API logic separate from components, making it easier to maintain and test.
store/
store/
State management using both Redux Toolkit and Zustand.See State Management for detailed documentation.
theme/
theme/
Application theme and styling configuration.Purpose: Centralized theme management for consistent styling across the application.
utils/
utils/
Utility functions and reusable components.Purpose: Shared utilities and components that don’t belong to a specific feature.
Feature Module Pattern
The application follows a consistent pattern for organizing features:Benefits of this Pattern
- Modularity: Each feature is self-contained and independent
- Scalability: Easy to add new features without affecting existing ones
- Maintainability: Related code is co-located, making it easier to understand and modify
- Testability: Tests are close to the code they test
Entry Point
The application bootstraps inMain.tsx:
src/Main.tsx
Best Practices
Feature-First Organization
Group files by feature rather than by type. Keep related components, hooks, and utilities together.
Consistent Naming
Use PascalCase for components (e.g.,
ProductPage.tsx) and camelCase for utilities (e.g., formatDate.ts).Co-locate Tests
Keep test files next to the components they test for better discoverability.
Barrel Exports
Use
index.ts files to create clean public APIs for each module.Next Steps
State Management
Learn about Redux and Zustand state management patterns
Routing
Understand the routing system and protected routes