File Structure
Organize components, utilities, and styles.
File Structure
Project Structure
src/
βββ app/ # Next.js App Router pages
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
β βββ docs/ # Documentation pages
β βββ dashboard/ # Application pages
βββ components/
β βββ ui/ # Reusable UI components
β βββ features/ # Feature-specific components
β βββ layout/ # Layout components
βββ content/ # Markdown content files
β βββ docs/ # Documentation content
βββ design-system/ # Theme and design tokens
βββ hooks/ # Custom React hooks
βββ lib/
β βββ utils/ # Utility functions
β βββ i18n/ # Internationalization
β βββ docs/ # Documentation utilities
βββ styles/ # Global styles and SCSS variables
βββ types/ # TypeScript type definitions
Component Structure
Each UI component follows this structure:
src/components/ui/Button/
βββ Button.tsx # Component implementation
βββ Button.module.scss # Styles
βββ Button.types.ts # Type definitions (optional)
βββ Button.test.tsx # Unit tests
βββ index.ts # Barrel export
Naming Conventions
| Type | Convention | Example |
|---|---|---|
| Components | PascalCase | Button.tsx |
| Hooks | camelCase with use prefix | useMediaQuery.ts |
| Utilities | camelCase | formatDate.ts |
| SCSS Modules | ComponentName.module.scss | Button.module.scss |
| Tests | ComponentName.test.tsx | Button.test.tsx |
Import Aliases
Use path aliases for cleaner imports:
// β
Use aliases
import { Button } from '@/components/ui';
import { useMediaQuery } from '@/hooks';
import { cn } from '@/lib/utils';
// β Avoid relative paths
import { Button } from '../../../components/ui';
Barrel Exports
Each component folder has an index.ts for clean imports:
// src/components/ui/Button/index.ts
export { Button } from './Button';
export type { ButtonProps } from './Button.types';