|
| 1 | +## Project context |
| 2 | +- Squarify: browser-based photo padding tool that normalizes aspect ratios |
| 3 | +- Fully client-side React + TypeScript app — no backend, no auth, no routing |
| 4 | +- Images never leave the user's device |
| 5 | + |
| 6 | +## Tech Stack |
| 7 | +- React 19 + TypeScript |
| 8 | +- Vite 8 with `@tailwindcss/vite` (Tailwind CSS v4) |
| 9 | +- `lucide-react` for icons |
| 10 | +- `jszip` for batch ZIP download |
| 11 | +- Vitest + React Testing Library for unit/integration tests |
| 12 | +- Playwright for E2E UI tests |
| 13 | + |
| 14 | +## Project Structure |
| 15 | +``` |
| 16 | +src/ |
| 17 | + App.tsx – Main app component (upload → process → download flow) |
| 18 | + main.tsx – React entry point |
| 19 | + types.ts – Shared TypeScript types (UploadedPhoto, PaddingSettings) |
| 20 | + index.css – Tailwind CSS entry |
| 21 | + components/ |
| 22 | + PhotoUpload.tsx – Drag-and-drop / file picker upload zone |
| 23 | + PhotoGrid.tsx – Grid display of uploaded/processed photos |
| 24 | + PaddingSettingsPanel.tsx – Settings UI (color/image fill, process button) |
| 25 | + hooks/ |
| 26 | + useLocalStorage.ts – Generic localStorage-backed state hook |
| 27 | + lib/ |
| 28 | + imageUtils.ts – Pure image processing logic (aspect ratio, canvas padding) |
| 29 | +e2e/ – Playwright E2E test specs |
| 30 | +``` |
| 31 | + |
| 32 | +## Development Principles |
| 33 | +- Test-Driven Development: Red-Green-Refactor cycle |
| 34 | +- Incremental Changes: Small, testable modifications |
| 35 | +- Systematic Debugging: Use test failures as guides |
| 36 | +- Validation Before Commit: All tests pass, no lint errors |
| 37 | + |
| 38 | +## Testing Scope |
| 39 | +- **Unit tests (Vitest)**: Pure logic in `lib/imageUtils.ts`, hooks, utility functions |
| 40 | +- **E2E tests (Playwright)**: Critical user journeys — upload, process, download |
| 41 | +- Keep unit tests fast and DOM-independent where possible |
| 42 | +- E2E tests use chromium only for CI speed |
| 43 | + |
| 44 | +## Testing Commands |
| 45 | +```bash |
| 46 | +npm test # Run Vitest unit tests |
| 47 | +npm run test:ui # Run Playwright E2E tests |
| 48 | +npm run test:ui:install # Install Playwright browsers |
| 49 | +``` |
| 50 | + |
| 51 | +## Git Workflow |
| 52 | +- Use conventional commits: `feat:`, `fix:`, `chore:`, `docs:`, `test:`, etc. |
| 53 | +- Feature branches: `feature/<descriptive-name>` |
| 54 | +- Always stage all changes before committing: `git add .` |
| 55 | +- Push to the correct branch: `git push origin <branch-name>` |
| 56 | + |
| 57 | +## CI/CD |
| 58 | +- GitHub Actions CI: lint, typecheck, unit tests, Playwright UI tests |
| 59 | +- GitHub Pages deployment on push to `main` |
| 60 | +- Vite `base` is configured for GitHub Pages |
| 61 | + |
| 62 | +## Key Patterns |
| 63 | +- All image processing happens on `<canvas>` elements in the browser |
| 64 | +- Photos are stored as data URLs in React state (not persisted to disk/server) |
| 65 | +- Settings are persisted via `localStorage` using the `useLocalStorage` hook |
| 66 | +- The `findMaxAspectRatio` function determines the target aspect ratio from uploaded photos |
| 67 | +- `padImageToAspectRatio` creates a new canvas at the target ratio and centers the original image |
0 commit comments