Frontend Project Structure
The frontend template follows a modular React architecture designed for scalability and maintainability. This document explains the organization of the project and the purpose of each directory.
Directory Overview
frontend/
├── public/ # Static files
├── src/ # Source code
│ ├── assets/ # Static assets
│ │ └── icons/ # SVG icons
│ ├── common/ # Shared resources
│ │ ├── components/
│ │ ├── contexts/
│ │ ├── hooks/
│ │ ├── layouts/
│ │ └── utils/
│ ├── pages/ # Page components
│ │ ├── account/
│ │ ├── home/
│ │ └── not-found/
│ ├── App.css # Global styles
│ └── App.jsx # Root component
└── README.md # Documentation
Core Directories
src/ Directory
The source directory contains all application code, organized into specific subdirectories based on functionality.
assets/
Contains static files that are not code:
icons/: SVG icon files used throughout the application- Images, fonts, and other media files
common/
Houses shared resources used across multiple pages:
components/: Reusable React componentscontexts/: React context providers and consumershooks/: Custom React hookslayouts/: Page layout components for routingutils/: Helper functions and utilities
pages/
Contains components and logic for each unique page or set of related pages:
account/: User account-related pages (login, signup, profile)home/: Homepage componentsnot-found/: 404 error page
Root Files
App.jsx: Application entry point, contains:- Global context providers
- Routing configuration
- Top-level layout
App.css: Global stylesheet
Protected Files
The following files should not be modified directly:
├── .vscode/ # VSCode settings
├── build/ # Production build output
├── node_modules/ # Project dependencies
├── eslint.config.mjs # Linting configuration
├── jsconfig.json # JS compilation settings
├── package-lock.json # Dependency lock file
└── package.json # Project metadata
These files are essential for project configuration:
.vscode/: Editor-specific settings (e.g., format on save)build/: Generated during production buildsnode_modules/: Managed by npm- Configuration files: Maintain consistent code style and behavior
Adding New Features
When adding new features to the frontend:
- Create a new directory in
pages/for page-specific components - Add shared components to
common/components/ - Create custom hooks in
common/hooks/if needed - Add new contexts in
common/contexts/for state management - Update routing in
App.jsx
Component Organization
Each component should:
- Have its own directory if it has associated files
- Use
.jsxextension if it contains JSX - Include any component-specific styles, tests, or utilities
- Define PropTypes for all props
Example component structure:
ComponentName/