This document provides an overview of the folder structure and organization of our React.js v19 project using Vite.
/my-react-project
|-- README.md # Project documentation
|-- eslint.config.js # ESLint configuration
|-- index.html # Main HTML file
|-- package-lock.json # Dependency lock file
|-- package.json # Project dependencies and scripts
|-- public/ # Static assets
| `-- vite.svg # Vite logo
|-- src/ # Main source code
| |-- App.jsx # Root component
| |-- assets/ # Static assets (e.g., images, icons)
| | `-- react.svg # React logo
| |-- components/ # Reusable UI components
| | |-- common/ # Common UI elements
| | | |-- Button.jsx # Reusable button component
| | | `-- index.js # Exports for common components
| | `-- ui/ # UI components
| | `-- index.js # UI component exports
| |-- configs/ # Configuration files
| | |-- api.js # API configuration
| | `-- env.js # Environment variables
| |-- constants/ # Global constants
| | |-- api.js # API endpoint constants
| | |-- index.js # General constants
| | `-- route.js # Route constants
| |-- hooks/ # Custom React hooks
| | `-- useToTop.js # Hook for scrolling to top
| |-- language/ # Localization files
| | |-- en/ # English translations
| | | `-- en.json # English translation file
| | `-- vi/ # Vietnamese translations
| | `-- vi.json # Vietnamese translation file
| |-- layouts/ # Layout components
| | `-- layout.jsx # Main layout component
| |-- main.jsx # Application entry point
| |-- pages/ # Page components
| | |-- home/ # Home page
| | | `-- index.jsx # Home page component
| | `-- index.js # Exports for pages
| |-- router/ # Routing configuration
| | |-- privateRoute.js # Private route handling
| | `-- publicRoute.js # Public route handling
| |-- services/ # API services
| | `-- product.js # Product-related API calls
| |-- styles/ # Global styles
| | `-- global.css # Global CSS file
| `-- utils/ # Utility functions
| `-- utils.js # Helper functions
`-- vite.config.js # Vite configuration
- The root component of the application.
- Stores static assets such as images and icons.
- Contains reusable UI components.
common/
includes commonly used elements like buttons.ui/
includes UI-related components.
- Stores configuration settings such as API URLs and environment variables.
- Holds global constants like API endpoints and route names.
- Custom React hooks for shared functionalities.
- Contains language-specific translation files for localization.
- Defines layout components for structuring pages.
- Page components for the application, such as the home page.
- Manages application routing and navigation.
- Handles API calls and data fetching.
- Global CSS styles for the application.
- Contains utility functions and helper methods.
This structure ensures our project is well-organized, scalable, and maintainable by separating concerns and following best practices.
🚀 Happy coding!