|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +- **Start development server**: `npm run dev` - Starts Vite dev server with hot reloading |
| 8 | +- **Build for production**: `npm run build` - Builds optimized production bundle |
| 9 | +- **Preview production build**: `npm run preview` - Preview production build locally |
| 10 | +- **Type checking & Accessibility**: `npm run check` - Run Svelte type checking and accessibility linting |
| 11 | +- **Linting**: `npm run lint` - Run ESLint and Prettier checks |
| 12 | +- **Formatting**: `npm run format` - Format code with Prettier |
| 13 | +- **E2E tests**: `npm test` - Run Playwright end-to-end tests (24 comprehensive tests) |
| 14 | + |
| 15 | +## Architecture Overview |
| 16 | + |
| 17 | +This is a personal portfolio website built with **SvelteKit** (using **Svelte 5**) and styled with **Tailwind CSS v4**, featuring comprehensive visual regression testing with **Argos**. |
| 18 | + |
| 19 | +### Important Documentation Links |
| 20 | + |
| 21 | +- **Svelte 5**: https://svelte.dev/docs/svelte/overview |
| 22 | +- **Svelte 5 Migration Guide**: https://svelte.dev/docs/svelte/v5-migration-guide |
| 23 | +- **SvelteKit**: https://svelte.dev/docs/kit/ |
| 24 | +- **Tailwind CSS**: https://tailwindcss.com/docs/ |
| 25 | + |
| 26 | +### Project Structure |
| 27 | + |
| 28 | +- **src/routes/**: SvelteKit file-based routing |
| 29 | + - `+layout.svelte`: Main layout with Nav and theme initialization |
| 30 | + - `+page.svelte`: Homepage with hero section and animations |
| 31 | + - `about/+page.svelte`: About page with interests and bio |
| 32 | + - `projects/+page.svelte`: Project showcase with optimized images |
| 33 | + - `photos/+page.svelte`: Photo gallery with modal viewer |
| 34 | + - `contact/+page.svelte`: Contact methods and social links |
| 35 | + |
| 36 | +- **src/lib/**: Shared library code ($lib alias) |
| 37 | + - `components/`: Reusable Svelte 5 components |
| 38 | + - `Nav.svelte`: Navigation with active states and theme toggle |
| 39 | + - `ThemeToggle.svelte`: Dark/light mode toggle |
| 40 | + - `PhotoModal.svelte`: Modal for photo gallery viewing |
| 41 | + - `SEO.svelte`: Reusable SEO component for Open Graph and Twitter Cards |
| 42 | + - `assets/images/`: Optimized images processed by Vite |
| 43 | + - `photos/`: Photo gallery images (AVIF/WebP/JPEG) |
| 44 | + - `projects/`: Project screenshot images (AVIF/WebP/PNG) |
| 45 | + - `stores/`: Svelte stores |
| 46 | + - `theme.ts`: Theme management with localStorage persistence |
| 47 | + - `types.ts`: TypeScript type definitions |
| 48 | + |
| 49 | +- **static/**: Static files served as-is (no processing) |
| 50 | + - `robots.txt`: SEO configuration with sitemap reference |
| 51 | + - `sitemap.xml`: XML sitemap for search engines |
| 52 | + - `favicon.ico`, `social.png`: Site metadata assets |
| 53 | + |
| 54 | +### Modern Tech Stack |
| 55 | + |
| 56 | +- **Svelte 5**: Latest version with new reactivity model ($state, $effect) |
| 57 | +- **SvelteKit**: Full-stack framework with Vite |
| 58 | +- **TypeScript**: Full type safety throughout |
| 59 | +- **Tailwind CSS v4**: Latest version with CSS-first configuration |
| 60 | +- **Vite**: Build tool for fast development and optimized builds |
| 61 | +- **@sveltejs/enhanced-img**: Automatic image optimization (AVIF/WebP generation) |
| 62 | +- **Fathom Analytics**: Privacy-focused analytics with custom event tracking |
| 63 | +- **Playwright**: End-to-end testing framework with visual regression testing |
| 64 | + |
| 65 | +### Theme System |
| 66 | + |
| 67 | +- **CSS Custom Properties**: Theme variables defined in `app.css` |
| 68 | +- **Dark Mode**: Automatic system preference detection with manual toggle |
| 69 | +- **Color Palette**: Orange primary (#f97316) with dark red accents (#dc2626) |
| 70 | +- **Persistence**: Theme preference saved to localStorage |
| 71 | + |
| 72 | +### Build System |
| 73 | + |
| 74 | +- **Vite**: Modern build tool replacing Rollup/Webpack |
| 75 | +- **SvelteKit Adapter**: Vercel adapter for deployment |
| 76 | +- **TypeScript**: Compile-time type checking |
| 77 | +- **ESLint + Prettier**: Code quality and formatting |
| 78 | + |
| 79 | +### Styling Approach |
| 80 | + |
| 81 | +- **Tailwind CSS v4**: Utility-first with new @theme syntax |
| 82 | +- **System Fonts**: Using system UI font stack |
| 83 | +- **CSS Custom Properties**: For theme variables and smooth transitions |
| 84 | +- **Responsive Design**: Mobile-first approach with Tailwind breakpoints |
| 85 | + |
| 86 | +### Image Optimization |
| 87 | + |
| 88 | +- **@sveltejs/enhanced-img**: Automatically generates AVIF, WebP, and original formats |
| 89 | +- **Asset Organization**: Images in `src/lib/assets/images/` for Vite processing |
| 90 | +- **Static Files**: Only truly static files (robots.txt, favicon, etc.) in `static/` |
| 91 | +- **Usage**: Import with `?enhanced` query and use `<enhanced:img>` component |
| 92 | +- **Performance**: Dramatic file size reductions (619kB → 6.61kB AVIF) |
| 93 | + |
| 94 | +### Analytics |
| 95 | + |
| 96 | +- **Fathom Analytics**: Privacy-focused analytics with site ID `NKUUIGYT` |
| 97 | +- **Custom Events**: Counting user interactions instead of "tracking" |
| 98 | + - Nav clicks: `nav_about_click`, `nav_projects_click`, etc. |
| 99 | + - Project interactions: `project_demo_repo_remover`, `project_github_personal_website` |
| 100 | + - Photo views: `photo_view_faraglioni_islets`, etc. |
| 101 | +- **Implementation**: Functions like `countNavClick()`, `countProjectClick()` |
| 102 | + |
| 103 | +### SEO & Performance |
| 104 | + |
| 105 | +- **SEO Component**: Reusable `SEO.svelte` component for consistent meta tags |
| 106 | +- **Open Graph**: Complete social media preview support (Facebook, Twitter, etc.) |
| 107 | +- **Sitemap**: XML sitemap at `/sitemap.xml` for search engine discovery |
| 108 | +- **Robots.txt**: Proper search engine crawler configuration |
| 109 | +- **Performance**: Image optimization with AVIF/WebP formats |
| 110 | + |
| 111 | +### Testing & Quality |
| 112 | + |
| 113 | +- **E2E Testing**: 24 comprehensive Playwright tests with DRY utilities |
| 114 | +- **Visual Regression**: Argos integration for cross-platform visual testing |
| 115 | +- **Test Coverage**: Desktop, mobile, tablet, and dark theme screenshots |
| 116 | +- **Smart Waiting**: Content-aware waits instead of networkidle for faster, more reliable tests |
| 117 | +- **Pre-commit Hooks**: Automatic formatting (Prettier) and linting (ESLint) on every commit |
| 118 | +- **CI/CD**: GitHub Actions with Argos reporter for visual diff reviews |
| 119 | + |
| 120 | +### Development Tools |
| 121 | + |
| 122 | +- **Node Version**: Managed with `.node-version` file (Node 22.12+) |
| 123 | +- **Quality Checks**: `npm run check` catches TypeScript and accessibility issues |
| 124 | +- **Accessibility**: All buttons/links have proper `aria-label` attributes |
| 125 | +- **Hot Reloading**: Fast development with Vite HMR |
| 126 | +- **Git Hooks**: Husky + lint-staged for automatic code quality on commit |
| 127 | +- **Test Utils**: DRY utilities in `e2e/test-utils.ts` for maintainable test code |
| 128 | + |
| 129 | +### Visual Testing with Argos |
| 130 | + |
| 131 | +- **Cross-platform Consistency**: Argos handles Linux CI vs macOS local differences |
| 132 | +- **Comprehensive Coverage**: All pages tested on desktop, mobile, and dark theme |
| 133 | +- **Smart Screenshots**: Content-aware waiting with font and image loading detection |
| 134 | +- **CI Integration**: Automatic screenshot uploads and PR status checks |
| 135 | +- **Review Process**: Visual diffs available in Argos dashboard for easy review |
| 136 | + |
| 137 | +### Deployment |
| 138 | + |
| 139 | +- **Vercel**: Deployed via @sveltejs/adapter-vercel |
| 140 | +- **Static Generation**: Pre-rendered for optimal performance |
0 commit comments