Privacy UI Pattern Library Assistant
An expert assistant for the Privacy-UI Pattern Library - a Next.js web application providing comprehensive privacy-focused UI patterns for GDPR/CCPA compliance with real-world examples and academic foundations.
What This Skill Does
This skill helps you work effectively with the Privacy-UI Pattern Library codebase. It understands the architecture, database schema, import pipelines, screenshot system, and development workflow for this Next.js 15 application that showcases privacy design patterns.
Project Context
**Current Status**: Stage 1 MVP Complete (2025-01-12)
Live pattern browsing with direct navigationReal-time search across patterns and examplesScreenshot display system (114+ optimized images)Supabase PostgreSQL database with 16 categories and 149+ examplesTech Stack: Next.js 15, TypeScript, React Query, Tailwind CSS, shadcn/ui**Repository Structure**:
Web Application: Next.js app with pattern browsing and searchScreenshot Scraper: Python tool in `privacy_ui_scraper/` with 149+ captured examplesDatabase Schema: PostgreSQL with categories, patterns, examples, templatesImport Scripts: TypeScript scripts for data import from scraperInstructions
1. Understanding the Architecture
When asked about the codebase structure:
**Frontend Architecture**: Next.js 15 App Router with route groups `(public)` for public routes**Pattern Navigation**: Direct links from category cards to pattern detail pages (`/patterns/{category}/{pattern}`)**Three-tab Pattern Pages**: Explanation, Examples (with screenshots), Templates**API Layer**: RESTful endpoints in `src/app/api/` for categories, patterns, search**Data Layer**: React Query for client-side caching, Supabase for PostgreSQL**Screenshot System**: Images in `public/screenshots/` with intelligent URL matching2. Development Workflow Commands
When helping with setup or development tasks:
```bash
Initial Setup
npm install
cp .env.local.example .env.local # Add Supabase credentials
Run migrations in Supabase SQL editor (supabase/migrations/)
Data Import
npm run import:patterns # Import from scraper data
npm run seed:test # Use test data
npm run copy:screenshots # Copy images from scraper
npm run fix:screenshot-urls # Fix URL encoding issues
Development
npm run dev # Start dev server (Turbopack)
npm run build # Production build
npm run type-check # TypeScript validation
npm run lint # ESLint
```
3. Database Schema Understanding
The schema has four core tables with relationships:
`pattern_categories` (16 pre-seeded) → `patterns` (one-to-many)`patterns` → `examples` (one-to-many, links to screenshots)`patterns` → `templates` (one-to-many)Key constraints:
Pattern slugs unique within categoryDirect navigation assumes one main pattern per categoryCategories are admin-managed, not user-created4. Working with Features
**Direct Pattern Navigation** (implemented 2025-01-10):
Category cards link directly to `/patterns/{category}/{pattern}`Category pages redirect to main pattern"Back" button returns to pattern catalogueImplementation: `/api/categories` includes `main_pattern_slug`**Screenshot System** (implemented 2025-01-12):
114+ screenshots in `public/screenshots/`Intelligent URL matching handles character encodingNext.js Image optimization with lazy loadingResponsive grid layout with error handling**Search Functionality**:
Real-time search with 300ms debounceSearches across pattern names, descriptions, examplesClient component with React Query5. Troubleshooting Common Issues
When debugging problems:
**Database Connection Errors**:
Verify Supabase project is activeCheck `.env.local` credentialsEnsure migrations ran successfully**No Data Showing**:
Run `npm run import:patterns`Check browser console for API errorsVerify Row Level Security policies in Supabase**Screenshots Not Loading**:
Run `npm run copy:screenshots` to copy from scraperRun `npm run fix:screenshot-urls` to fix encodingVerify `public/screenshots/` directory existsCheck database URLs match actual file paths**TypeScript Errors**:
Run `npm run type-check`Ensure all dependencies installedLook for missing type definitions6. Performance Optimizations
Explain these built-in optimizations when relevant:
React Query caching (5min for patterns, 10min for categories)Debounced search (300ms)Direct navigation eliminates page loadsNext.js Image optimization for screenshotsTurbopack for fast refresh in development7. Future Stages Context
When discussing roadmap or future features:
**Stage 2 - Community Features**:
User authentication (Supabase Auth)Pattern submission workflowAdmin dashboard for moderationContributor profiles**Stage 3 - Design Resources**:
Figma template integrationDownloadable design assetsImplementation code examplesPattern variations8. Key Files Reference
When navigating the codebase, prioritize these files:
**Frontend**:
`src/app/(public)/patterns/page.tsx` - Category catalogue`src/app/(public)/patterns/[category]/[pattern]/page.tsx` - Pattern detail`src/components/CategoryCard.tsx` - Direct navigation links`src/components/SearchInput.tsx` - Real-time search**API Routes**:
`src/app/api/categories/route.ts` - Category listing with main patterns`src/app/api/patterns/route.ts` - Pattern listing with pagination`src/app/api/search/route.ts` - Search functionality**Data Layer**:
`src/lib/db/schema.ts` - Database types`src/lib/supabase.ts` - Supabase client`supabase/migrations/` - Database migrations**Import Scripts**:
`scripts/import-patterns.ts` - Import from scraper data`scripts/seed-test-data.ts` - Test data seeding`scripts/fix-screenshot-urls.ts` - URL encoding fixes9. Code Patterns to Follow
When writing or modifying code:
Use TypeScript strictly (no `any` types)Client components need `'use client'` directiveEvery data-fetching page should have `loading.tsx` with skeletonsAPI routes return consistent error formatReact Query hooks for all data fetchingshadcn/ui components for UI consistencyTailwind CSS for styling (glassmorphism theme)10. Testing and Quality Checks
Before considering work complete:
Run `npm run type-check` - no TypeScript errorsRun `npm run lint` - no ESLint warningsTest in browser - data loads correctlyCheck console - no React/API errorsVerify responsive design - works on mobileTest screenshots - images load with fallbacksConstraints
This is a Stage 1 MVP - no authentication or user submission features yetCategories are fixed (16 total) and admin-managedDirect navigation assumes one main pattern per categoryScreenshots are static assets, not dynamically uploadedSupabase is used but only for database, not auth (Stage 2)Pattern data originates from `privacy_ui_scraper/` toolExamples
**Example 1: Adding a new pattern**
User: "How do I add a new pattern to the cookie consent category?"
Response: First, ensure you have the scraper data or test data ready. Then:
1. Add pattern data to `privacy_ui_scraper/privacy_ui_screenshots/cookie-consent/`
2. Run `npm run import:patterns` to import the data
3. If adding screenshots, place them in the pattern folder and run `npm run copy:screenshots`
4. Run `npm run fix:screenshot-urls` to ensure URL matching works
5. Verify in browser at `/patterns/cookie-consent/{your-pattern-slug}`
**Example 2: Debugging search not working**
User: "Search isn't returning any results"
Response: Let's troubleshoot:
1. Check browser console for API errors
2. Verify `/api/search` endpoint is accessible
3. Run `npm run type-check` to ensure no TypeScript errors
4. Check that patterns have been imported with `SELECT COUNT(*) FROM patterns` in Supabase
5. Verify React Query isn't showing errors in the Network tab
6. Ensure the 300ms debounce isn't too aggressive for your use case
**Example 3: Understanding the architecture**
User: "How does the direct navigation feature work?"
Response: Direct navigation was implemented in 2025-01-10 to reduce clicks:
Category cards (on `/patterns`) link directly to `/patterns/{category}/{pattern}`The `/api/categories` endpoint includes `main_pattern_slug` for each categoryCategory pages (`/patterns/[category]`) redirect to the main pattern automaticallyThe "Back" button returns to the pattern catalogue, not the category pageThis eliminates the intermediate step of browsing patterns within a category