Directory Overview
The Zarna frontend follows a structured, modular organization:Directory Guidelines
src/components/
Component organization by purpose:
ui/ - shadcn/ui Components
🚨 DO NOT MANUALLY EDIT - Generated by shadcn CLI
layout/ - Layout Components
Reusable layout components:
features/ - Feature Components
Domain-specific components organized by feature:
src/context/
React Context for global state:
AuthContext- Authentication stateCompanyContext- Current company selection
src/hooks/
Custom React hooks for reusable logic:
src/lib/
Pure utility functions (no React dependencies):
src/services/
API integration and external service calls:
public/
Static assets served as-is:
File Naming Conventions
Components
- PascalCase:
ComponentName.tsx - Examples:
Button.tsx,UserProfile.tsx,DealPipeline.tsx
Hooks
- kebab-case:
use-hook-name.ts - Examples:
use-auth.ts,use-mobile.ts,use-debounce.ts
Utilities
- kebab-case:
util-name.ts - Examples:
format-date.ts,api-client.ts,validation.ts
Context
- PascalCase:
ContextName.tsx - Examples:
AuthContext.tsx,ThemeContext.tsx
Types
- PascalCase:
TypeName.tsor inline in component files - Examples:
types.ts,api-types.ts
Import Organization
Order imports for consistency:Path Aliases
Configured intsconfig.json:
Configuration Files
tsconfig.json
TypeScript configuration with strict mode:
vite.config.ts
Vite build configuration:
tailwind.config.js
Tailwind CSS configuration:
components.json
shadcn/ui configuration:
Best Practices
Component Organization
Keep components focused
Keep components focused
Each component should have a single responsibility. If a component does too much, split it.
Co-locate related files
Co-locate related files
Use feature folders
Use feature folders
Group related components by feature rather than type.
Extract reusable logic
Extract reusable logic
Move common logic to custom hooks or utility functions.
Naming Conventions
- Be descriptive:
UserProfileCard>Card - Be consistent: Always use PascalCase for components
- Prefix hooks: Always start with
use(e.g.,useAuth) - Suffix contexts: End with
Context(e.g.,AuthContext)
