Tech Stack
CV Builder is built with modern web technologies:- Next.js 16.1.6: React framework with App Router
- React 19.2.3: UI library with React Compiler enabled
- TypeScript 5: Type-safe development with strict mode
- Tailwind CSS 4: Utility-first styling framework
- Firebase 12.8.0: Authentication and Firestore database
- React Hook Form 7.71.1: Performant form management
- Zod 4.3.6: Schema validation
- Framer Motion 12.29.2: Animations and transitions
Project Structure
App Directory (Next.js App Router)
- Uses Next.js App Router for file-based routing
- Server and Client Components separated appropriately
- API routes for server-side operations (PDF generation)
- Layouts for shared UI across routes
Components Directory
- forms/: Form section components using React Hook Form
- home/: Landing page sections
- preview/: Resume preview and PDF generation
- templates/: Template implementations
- ui/: Reusable UI components built with CVA (Class Variance Authority)
Hooks Directory
- Encapsulate complex state logic
- Handle data fetching and caching
- Manage side effects (auto-save, sync)
- Provide reusable business logic
Lib Directory
- cvRepository.ts: Database operations (Firestore)
- cvDraftStorage.ts: Local storage management
- cvThreeWayMerge.ts: Three-way merge for draft conflicts
- cvService.ts: Business logic orchestration
Key Architectural Decisions
1. Privacy-First Design
Guest Mode with localStorage:- Full functionality without authentication
- Data persists locally in browser
- No server dependency for basic usage
- Users opt-in to cloud storage
- Seamless transition from guest to authenticated
2. Dual Storage Strategy
- Auto-saves to localStorage every few seconds
- Cloud-synced users also save drafts to Firestore
- Conflict resolution when local and cloud diverge
- Explicit “Save Version” creates immutable snapshots
- Versions include metadata (name, description, tags)
- Restore any previous version
3. Form Management
React Hook Form + Zod:- Type-safe form validation
- Performant re-renders
- Built-in error handling
- Easy integration with auto-save
4. Template System
Template Structure:- Web Preview: React components with Tailwind CSS
- PDF Export: @react-pdf/renderer with similar styling
- Users can switch templates without data loss
- Same data structure works across all templates
- CSS variables for theme customization
5. State Management
Context for Global State:AuthContext: User authentication state- Minimal use of context to avoid re-render issues
- Form state managed by React Hook Form
- UI state (modals, tabs) with useState
- Custom hooks for data fetching
- No external state management library
6. Type Safety
Centralized Types:- Zod schemas derive types
- TypeScript strict mode enabled
- Comprehensive type coverage
Component Patterns
1. Compound Components
2. Render Props for Flexibility
3. Custom Hooks for Logic
4. Composition over Inheritance
Data Flow
Resume Editing Flow
Version Management Flow
Performance Optimizations
1. Code Splitting
- Dynamic imports for heavy components
- Route-based splitting via Next.js App Router
- Template components loaded on-demand
2. React Compiler
Next.js 16 with React Compiler enabled:- Automatic memoization
- Optimized re-renders
- Better performance without manual optimization
3. Debounced Auto-Save
4. Image Optimization
- Next.js Image component for optimized loading
- Client-side image cropping
- Compressed uploads to Firebase Storage
Testing Strategy
While not extensively covered in the current codebase, here’s the recommended approach:Unit Tests
- Test utility functions (lib/utils.ts)
- Test validation schemas (Zod schemas)
- Test custom hooks (hooks/)
Integration Tests
- Test form submission flows
- Test draft auto-save behavior
- Test version management
E2E Tests
- Test complete user journeys
- Test guest mode flows
- Test authentication flows
Security Considerations
1. Firestore Security Rules
2. Client-Side Validation
All forms validated with Zod schemas before submission.3. Environment Variables
Sensitive keys stored in.env.local, never committed.
Next Steps
Now that you understand the architecture:- Review the Code Style Guide
- Explore the codebase starting with
app/page.tsx - Look at
components/cv-builder.tsxfor the main editor - Check out
lib/cvService.tsfor business logic
Questions about the architecture? Open an issue on GitHub!