
Level 1: Grouping by File Types
. ├── public/ │ ├── data │ └── img └── src/ ├── assets/ │ ├── maps/ │ ├── svg/ │ └── style/ ├── api/ ├── configs/ ├── components/ │ ├── SignUpForm.tsx │ ├── Employees.tsx │ ├── Button.tsx │ └── PaymentForm.tsx ├── hooks/ │ ├── useAuth.ts │ ├── useEmployees.ts │ └── usePayment.ts ├── lib/ ├── store/ ├── services/ └── utils/ └── constants/
- Project Size: Small to Medium
- Advantages:
- Simple and Understandable: If the project is small, it is easy and logically convenient to separate files by type.
- Disadvantages:
- Complexity in Handling Larger Projects: As your project grows, this approach becomes more complex, as features may become interlinked and harder to manage.
Level 2: Grouping by File Types and Features
. ├── public/ │ ├── data/ │ └── img/ │ ├── avatars/ │ ├── logo/ │ ├── products/ │ ├── countries/ │ └── others/ └── src/ ├── assets/ │ ├── maps/ │ ├── svg/ │ └── style/ │ ├── components/ │ ├── template/ │ ├── docs/ │ └── others/ ├── api/ ├── configs/ ├── views/ │ ├── auth/ │ ├── crm/ │ ├── crypto/ │ └── docs/ ├── pages/ │ ├── welcome/ │ ├── home/ │ └── AccessDenied/ ├── components/ │ ├── docs/ │ ├── layout/ │ ├── route/ │ ├── shared/ │ ├── template/ │ │ ├── auth/ │ │ │ └── SignUpForm.tsx │ │ ├── employees/ │ │ │ └── Employees.tsx │ │ └── payment/ │ │ ├── PaymentForm.tsx │ │ ├── EmployeeList.tsx │ │ └── EmployeeSummary.tsx │ └── ui/ │ ├── Button.tsx │ └── Avatar.tsx ├── hooks/ │ ├── useAuth.ts │ ├── useEmployees.ts │ └── usePayment.ts ├── constants/ ├── lib/ ├── store/ ├── services/ └── utils/
- Project Size: Medium to Large
- Advantages:
- Grouping by Features: Files are grouped by features, which makes code management easier.
- Disadvantages:
- Spread-out Features: Code related to certain features may still be scattered across several folders, which can be challenging as the project grows.
Level 3: Grouping by Features/Modules
. ├── public/ │ ├── data/ │ └── img/ │ ├── avatars/ │ ├── logo/ │ ├── products/ │ ├── countries/ │ └── others/ └── src/ ├── assets/ │ ├── maps/ │ ├── svg/ │ └── style/ │ ├── components/ │ ├── template/ │ ├── docs/ │ └── others/ └── modules/ ├── core/ │ ├── api/ │ ├── configs/ │ ├── views/ │ ├── pages/ │ │ ├── welcome/ │ │ ├── home/ │ │ └── AccessDenied/ │ ├── components/ │ │ ├── docs/ │ │ ├── layout/ │ │ ├── route/ │ │ ├── shared/ │ │ ├── template/ │ │ └── ui/ │ │ ├── Button.tsx │ │ └── Avatar.tsx │ ├── hooks/ │ ├── constants/ │ ├── lib/ │ ├── store/ │ ├── services/ │ └── utils/ ├── payment/ │ ├── components/ │ │ ├── template/ │ │ │ └── PaymentForm.tsx │ │ └── ui/ │ ├── hooks/ │ │ └── useEmployees.ts │ ├── constants/ │ ├── lib/ │ ├── store/ │ ├── services/ │ └── utils/ └── employee/ ├── components/ │ ├── template/ │ │ ├── EmployeeList.tsx │ │ └── EmployeeSummary.tsx │ └── ui/ ├── hooks/ │ └── useEmployees.ts ├── constants/ ├── lib/ ├── store/ ├── services/ └── utils/
- Project Size: Large and complex
- Advantages:
- Module-based architecture: Separating the project by features or modules ensures management without increasing complexity.
- Independence of modules: Modifying or removing one module does not affect others, reducing technical debt.
- Disadvantages:
- Requires experience: You need a good understanding of business logic to make correct grouping decisions.
Give Clear and Understandable Folder Names
General Recommendations
- Small projects: 1-level approach may be sufficient.
- Medium projects: 2-level structure provides easy management.
- Large and complex projects: 3-level approach ensures the independence of modules and keeps the code cleaner.
1. public/
- General purpose: To store static resources visible to the user, such as images and data files.
- Subfolders:
- data/: Folder containing static data files (JSON, CSV, etc.).
- img/: Folder containing images needed for the project.
2. src/
- General purpose: Folder containing all source code (frontend and backend). This is the heart of the project.
- assets/: Folder for storing styling resources, such as fonts, icons, or common CSS files.
- modules/: Folder containing separate modules related to different features of the project. Each module may have its own business logic and UI components.
- payment/: Module containing code and components related to payment systems.
- employee/: Module containing code and components related to employee management or HR systems.
- core/: Folder for the central and common components, configurations, features, and functions of the project.
- api/: Folder for code related to backend API calls or requests.
- configs/: Folder containing necessary configurations for the project (e.g., API URLs, environment settings).
- views/: Folder containing commonly used UI views or pages (e.g., header, footer, layout).
- pages/: Folder containing routing and components for pages within the project.
- components/: Folder containing UI components (e.g., buttons, forms, cards).
- hooks/: Folder containing common React hooks (e.g., state management, lifecycle hooks).
- constants/: Folder containing various constants used in the project, such as URLs, status codes, and rules.
- lib/: Folder for storing general user libraries or helper functions.
- store/: Folder containing stores for Redux or other state management.
- services/: Service layer, i.e., code handling API interactions or executing business logic.
- utils/: Folder containing common helper functions and utilities.
Similar Articles
Main features of Reactjs
In this article, we will learn about the key features of React.js, which will also be useful for interview questions.
August 21, 2024React Native: Why Choose React Native for Mobile Development?
The field of mobile development is rapidly evolving, and developers constantly seek efficient ways to create applications for both iOS and Android platforms simultaneously. React Native has emerged a
December 15, 2024What is React js? What role does React play in software development?
Today, we'll discuss React.js, one of the top JavaScript libraries, including its advantages, what we can do with it, and everything else you need to know in this post.
August 20, 2024What is an SPA (Single Page Application)?
Let's explore what an SPA (Single Page Application) is, which is used in today's modern websites.
August 29, 2024What is a React component? What are its main elements?
In this post, we will learn in detail about components, which are the main building blocks of React.js.
September 7, 2024React.js Public Folder and Its Static Assets
In this article, I discussed the Public folder, which forms an important part of projects. What is the Public Folder? The files in the React.js public folder and their significance, as well as their r
August 27, 2024