This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
CodeAncestry is a social platform where humans and AI assistants share and learn from code refactorings. It's built as a Next.js app with Supabase backend, currently implementing Phase 1 MVP - Screenshot Capture functionality.
npm run dev- Start development server with Turbopacknpm run build- Build for productionnpm run start- Start production servernpm run lint- Run Next.js linter
- Frontend: Next.js 15.3.3 with App Router, React 19, TypeScript, Tailwind CSS
- Backend: Supabase (Auth, Database, Storage)
- Analytics: PostHog for event tracking and user behavior analytics
- Styling: Tailwind CSS v4 with PostCSS
/app- Next.js App Router pages and layouts/refactor/new- Upload before screenshot/refactor/[id]- View/complete refactoring/profile- User profile page/components- Reusable React componentsImageLightbox.tsx- Full-screen image viewerAuthButton.tsx- Authentication componentRefactoringCard.tsx- Refactoring display cardReactionButtons.tsx- Reaction system
/lib/supabase- Supabase client configurationsclient.ts- Browser clientserver.ts- Server client with cookie handlingmiddleware.ts- Session refresh middleware
/lib/analytics.ts- Analytics tracking utilities
refactorings table:
id(UUID) - Primary keybefore_screenshot_url- URL of before screenshotduring_screenshot_url- URL of optional during screenshotafter_screenshot_url- URL of after screenshottitle- Optional refactoring titledescription- Optional descriptionlanguage- Programming languageauthor_id- Reference to auth.usersis_complete- Boolean flag for completion status
reactions table:
id(UUID) - Primary keyrefactoring_id- Foreign key to refactoringsuser_id- Session ID for anonymous usersreaction_type- One of: 'fire', 'lightbulb', 'thinking'- Unique constraint on (refactoring_id, user_id, reaction_type)
reaction_counts view - Aggregated reaction counts per refactoring
Storage bucket screenshots holds uploaded images with public access.
- ✅ Landing page with "Start Refactoring" button
- ✅ Upload before screenshot (camera/file)
- ✅ Store screenshots in Supabase storage
- ✅ Create refactoring record with shareable link
- ✅ Add after screenshot to complete the pair
- ✅ Display before/after side-by-side
- ✅ Homepage feed showing recent refactorings
- ✅ Reactions system (🔥, 💡, 🤔) with user/anonymous tracking
- ✅ Click-to-zoom lightbox for screenshots
- ✅ Language selection and filtering
- ✅ User authentication with Supabase Auth
- ✅ Basic user profiles
- ✅ User dashboard with personalized experience
- ✅ User statistics tracking (evolutions shared, reactions received, views)
- ✅ Analytics integration for user behavior tracking
- ⬜ Search functionality
- ⬜ Moderation features
- ⬜ OG meta tags for link previews
NEXT_PUBLIC_SUPABASE_URL- Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY- Supabase anonymous keyNEXT_PUBLIC_POSTHOG_KEY- PostHog project API keyNEXT_PUBLIC_POSTHOG_HOST- PostHog instance URL (optional, defaults to https://app.posthog.com)
The app is optimized for Netlify deployment with Supabase backend:
- Connect Repository: Link your GitHub repo to Netlify
- Build Settings:
- Build command:
npm run build - Publish directory:
.next
- Build command:
- Environment Variables: Add Supabase and PostHog environment variables in Netlify dashboard
- Deploy: Netlify will automatically build and deploy on every push
The included netlify.toml configures:
- Node.js 18 runtime
- Proper redirects for Next.js App Router
- Optimized build settings for Supabase SSR
- The app uses Supabase SSR for authentication with cookie-based sessions
- Row Level Security (RLS) is enabled on all tables
- Users can sign up/login with email and password
- Authenticated users' refactorings are associated with their account
- Reactions support both authenticated users and anonymous sessions
- The middleware refreshes user sessions on every request
- UI features animated gradients and glassmorphism effects
- Mobile-first responsive design with PWA considerations
- Screenshots are clickable for full-size viewing via lightbox
- Authenticated users get personalized dashboard with statistics
- Analytics track user engagement and page views via PostHog integration
- Dual experience: public landing page for visitors, dashboard for users
PostHog is integrated for comprehensive user behavior tracking and product analytics:
- Setup: Create a PostHog account at posthog.com
- Configuration: Add
NEXT_PUBLIC_POSTHOG_KEYto your environment variables - Events Tracked:
- Page views and navigation
- Evolution creation steps (before/during/after screenshots)
- Reaction interactions (add/remove reactions)
- Authentication flows (signup prompts, login attempts)
- Image replacement actions
- Error events for debugging
- Focus mode usage
- Search queries and results
The analytics implementation in /lib/analytics.ts provides a clean interface for tracking events throughout the application. In development mode, events are logged to console and stored in localStorage for debugging.