Transform the messy vanilla HTML/JS master branch into a modern, well-organized React + Vite + shadcn/ui application with proper testing and component architecture.
- Multiple HTML files (index.html, about.html, book.html, manufacturer.html, etc.) with duplicated code
- Inline styles mixed with external CSS
- No component structure - everything is procedural JavaScript
- Complex export functionality spread across multiple files (exporters.js, print.js, etc.)
- No testing framework
- Messy file organization in public/scripts/ with 31+ files
- Font management issues - fonts scattered across multiple locations
✅ Completed:
- Vite + React + TypeScript setup
- shadcn/ui configuration
- Basic Navigation component
- Manufacturer page structure
- Tailwind CSS integration
Goal: Establish solid foundation with testing infrastructure
-
Setup Testing Framework
npm install -D vitest @testing-library/react @testing-library/jest-dom jsdom npm install -D @playwright/test
- Configure Vitest for unit tests
- Configure Playwright for integration tests
- Setup test scripts in package.json
-
Create Core Type Definitions
src/types/taboo.ts- TabooCard, Category, etc.src/types/export.ts- Export formats and optionssrc/types/ui.ts- UI component props
-
Establish File Structure
src/ ├── components/ │ ├── ui/ # shadcn components │ ├── features/ # Feature-specific components │ └── layout/ # Layout components ├── pages/ # Page components ├── hooks/ # Custom React hooks ├── lib/ # Utility functions ├── services/ # API/business logic ├── stores/ # State management └── types/ # TypeScript definitions
Goal: Extract and test core business logic from vanilla JS
-
Data Layer Migration
- Migrate
public/scripts/data/→src/lib/data/ - Convert to TypeScript modules
- Add data validation with Zod
- Unit tests for data structures
- Migrate
-
Category System
- Extract category logic from
public/scripts/lib/categories.js - Create
src/services/categoryService.ts - Add tests for category detection and color mapping
- Extract category logic from
-
SVG Generation
- Migrate
public/scripts/lib/generateSVG.js→ React component - Create
src/components/features/CardGenerator.tsx - Add visual regression tests
- Migrate
Goal: Convert each HTML page to React component with tests
-
Card Generator Page (Priority: High)
- Migrate
public/index.html→src/pages/CardGenerator.tsx - Component breakdown:
CardGenerator- Main page componentCardForm- Input form for custom cardsCardPreview- Live preview componentCardList- Generated cards display
- Tests: Unit tests for each component, integration tests for workflow
- Migrate
-
Book Page (Priority: Medium)
- Migrate
public/book.html→src/pages/Book.tsx - Create book generation components
- Add pagination and filtering
- Migrate
-
About Page (Priority: Low)
- Migrate
public/about.html→src/pages/About.tsx - Static content with shadcn components
- Migrate
-
System Pages (Priority: Low)
- Migrate system.html, system-print.html
- Consolidate into single page with mode toggle
Goal: Rebuild export functionality with modern patterns
-
Export Service
- Create
src/services/exportService.ts - Abstract export logic into clean interfaces
- Support for multiple formats (SVG, PNG, PDF)
- Create
-
Export Components
ExportModal- Unified export interfaceExportProgress- Progress trackingExportHistory- Previous exports
-
Export Testing
- Mock canvas API for unit tests
- Integration tests with Playwright
- File output validation
Goal: Add missing features and improve UX
-
State Management
- Implement Zustand or Jotai for global state
- Persist user preferences
- Add undo/redo functionality
-
Performance Optimization
- Lazy loading for heavy components
- Virtual scrolling for large card lists
- Memoization for expensive operations
-
Accessibility
- ARIA labels and roles
- Keyboard navigation
- Screen reader support
- High contrast mode
-
Internationalization
- Add react-i18next
- Extract all text strings
- Add language switcher
- Coverage Goal: 90%+
- Focus: Business logic, utilities, pure functions
- Example:
test("should detect correct category from keywords", () => { expect(detectCategory("React hooks")).toBe("Frontend"); expect(detectCategory("Docker containers")).toBe("DevOps"); });
- Coverage Goal: All user workflows
- Focus: Page interactions, export flows, navigation
- Example:
test("card generation workflow", async ({ page }) => { await page.goto("/"); await page.fill('[data-testid="word-input"]', "React"); await page.click('[data-testid="generate-btn"]'); await expect(page.locator('[data-testid="card-preview"]')).toBeVisible(); });
- Coverage Goal: All UI components
- Tool: Playwright with screenshots
- Trigger: On PR, before merge
- Backup master branch
- Create feature branches for each phase
- Setup CI/CD pipeline
- Configure code quality tools (ESLint, Prettier)
- Write tests BEFORE refactoring code
- Migrate one feature at a time
- Keep master branch deployable
- Document breaking changes
- Performance audit (Lighthouse)
- Security audit
- User acceptance testing
- Migration guide for users
-
Code Quality
- 90%+ test coverage
- 0 TypeScript errors
- ESLint score: 10/10
-
Performance
- Lighthouse score: 90+
- Bundle size: <500KB (gzipped)
- First Contentful Paint: <1.5s
-
Developer Experience
- Hot reload working
- Clear error messages
- Comprehensive documentation
-
User Experience
- All features working
- Mobile responsive
- Accessible (WCAG 2.1 AA)
| Risk | Impact | Mitigation |
|---|---|---|
| Export functionality breaks | High | Comprehensive testing, gradual migration |
| Performance regression | Medium | Bundle analysis, lazy loading |
| Lost features | High | Feature audit, user feedback |
| Browser compatibility | Medium | Cross-browser testing, polyfills |
- Phase 1: 2-3 days (Foundation)
- Phase 2: 3-4 days (Core Logic)
- Phase 3: 5-7 days (Pages)
- Phase 4: 4-5 days (Export System)
- Phase 5: 3-4 days (Polish)
Total: 17-23 days
- Commit current refactor branch progress
- Create feature branch for Phase 1
- Setup testing infrastructure
- Begin with data layer migration
This plan should be updated as we discover new information during the refactoring process.