Overview
TheCVBuilder component is the core of the CV Builder application. It provides a complete CV editing experience with:
- Split-panel interface (editor on left, preview on right)
- Real-time form validation and preview updates
- Cloud synchronization with conflict resolution
- Version control and history management
- Template switching and customization
- Authentication integration
- Mobile-responsive design with tab-based navigation
Source Files
- Main Component:
components/cv-builder.tsx(1115 lines) - Location:
/workspace/source/components/cv-builder.tsx
Architecture
The component uses a layered architecture:- CVBuilder (exported): Initializes React Hook Form and provides form context
- CVBuilderContent: Main UI implementation with hooks and state management
- Helper Components: PDFDownloadWrapper, LivePreviewWrapper, MobileEdgeToEdgePreview
Component Structure
CVBuilder (Main Export)
The top-level component that sets up form management.Features
Supports
?template=default|rhyhorn|nexus query parameter for initial template selection.Uses React Hook Form’s
FormProvider to manage CV data state across all child components.Provides toast notification system for user feedback on save, sync, and errors.
State Management
The component manages complex state for:Form State
Managed via React Hook Form with theCVData interface:
Save Status
No active save operation
Save operation in progress
Save completed successfully
Save operation failed
UI State
Mobile tab selection (desktop shows both panels)
Currently active form section for scroll-spy and navigation
Desktop sidebar visibility state
Authentication modal visibility
Custom Hooks
The component integrates multiple custom hooks:useCVDraft
useCVVersions
useScrollSpy
useAuth
Provides authentication state and methods:Conflict Resolution
When local and cloud data diverge, the component displays a conflict resolution dialog:Resolution Options
- Keep Local: Overwrites cloud data with local changes
- Keep Server: Discards local changes, uses cloud data
- Merge: Three-way merge when base data is available
- Close: Keeps cloud data active, preserves local draft
Version Control
Supports named version snapshots:Version Operations
Creates a new named version snapshot
Retrieves version data by ID
Restores CV data from a version
Permanently deletes a version
Updates version metadata (name, description, tags)
Layout Structure
Desktop Layout
Two-panel split with resizable sections:Mobile Layout
Tab-based navigation:Section Management
Dynamic section rendering based on order and visibility:Section Visibility
Toggles a section’s visibility (except “personal” which is always visible)
Shows all sections by clearing the hidden sections array
PDF Generation
On-demand PDF generation without preview overhead:Template Switching
Templates can be changed via selector:default, rhyhorn, nexus
Error Handling
Draft Errors
Save Errors
Provides user-friendly messages based on error type:- Permission errors: Session expired, re-authentication required
- Network errors: Connection issues, retry prompt
- Quota errors: Data size limit exceeded
Accessibility Features
- Keyboard navigation support
- Focus management for section navigation
- Screen reader announcements for save status
- Reduced motion support via
useReducedMotion - Touch-friendly controls on mobile
Performance Optimizations
- Memoized Components: Preview and form sections use React.memo
- Normalized Data:
useNormalizedCVDatahook prevents unnecessary re-renders - Lazy PDF Generation: PDFs generated only on download, not on every change
- Scroll Debouncing: ScrollSpy uses pauseObserver to prevent excessive updates
- Conditional Rendering: Mobile/desktop layouts rendered conditionally
Related Components
- Form Components - Individual form sections
- Preview Components - CVPreview and PDFDocument
- Templates - Template system and implementations