How I Built FlayshList
A production-grade portfolio with full-stack AI capabilities. Built with modern React patterns, type-safe APIs, and infrastructure that scales.
What This App Demonstrates
AI Image Generation Toolkit
Flagship FeatureA production-grade AI image generation system demonstrating full-stack capabilities: API design, state management, rate limiting, and multi-service integration.
FLUX Schnell (fast), FLUX Pro (quality), SD3 (creative control)
1:1, 16:9, 9:16, 4:3, 3:4 with auto dimension calculation
Vercel KV storage with 60-image auto-cleanup
Two-tier sliding window (5/hr, 20/day) with dev bypass
Click any image to regenerate with identical settings
Discriminated unions for error handling
Tech Stack
Frontend
AI & Infrastructure
Testing & Quality
Production
Architecture
Zero-JS by default, selective hydration
Consistent spacing, typography, color scales
Validation, rate limiting, external API calls
AI models, persistent storage, CDN delivery
Type safety, E2E tests, automated checks
Key Engineering Decisions
Discriminated Union Responses
TypeScript enforces handling success/error cases at compile time
type Response = { success: true; data } | { success: false; error }Model Capability Flags
Adding new AI models only requires config changes, not code changes
supportsNegativePrompt, supportsGuidanceScale, maxGuidanceScaleServer/Client Boundary
Server fetches initial data for fast first paint, client handles state
page.tsx (server) → client.tsx (state management)Two-Tier Rate Limiting
Burst protection (hourly) + quota management (daily) for cost control
5 requests/hour, 20 requests/day, localhost bypassProject Structure
├── src/ │ ├── app/ # Next.js App Router │ │ ├── page.tsx # Homepage with hero │ │ ├── ai-toolkit/ # AI Image Generation │ │ │ ├── page.tsx # Server (data fetch) │ │ │ └── client.tsx # Client (state) │ │ ├── api/ai/image/ # Generation endpoint │ │ ├── performance/ # Platform analysis │ │ ├── music/, reels/, about/, chat/, tools/ │ │ └── layout.tsx, error.tsx, globals.css │ │ │ ├── components/ │ │ ├── ai-toolkit/ # 1000+ lines │ │ │ ├── PromptDock.tsx # Main interface (352 lines) │ │ │ ├── MasonryGrid.tsx # Gallery + lazy load │ │ │ ├── AssetModal.tsx # Full-screen viewer │ │ │ └── ModelSelector, AspectRatioSelector... │ │ ├── ui/ # Design system │ │ ├── layout/ # Header, Footer │ │ └── performance/ # Dashboard components │ │ │ ├── lib/ │ │ ├── ai-models.ts # Model configs (109 lines) │ │ ├── gallery.ts # KV operations (131 lines) │ │ ├── ratelimit.ts # Rate limiting (77 lines) │ │ └── design-system/ │ │ │ └── types/ai.ts # Discriminated unions │ ├── docs/AI_TOOLKIT.md # Technical documentation ├── e2e/smoke.spec.ts # Playwright tests └── .github/workflows/ci.yml # 3 parallel CI jobs
Engineering Signals
Performance
- Server Components by default
- WebP images, responsive sizes
- 1-year immutable cache headers
- Lazy loading in masonry grid
Quality
- TypeScript strict mode
- Discriminated union types
- E2E critical path tests
- Automated CI on every push
Production
- Two-tier rate limiting
- Security headers configured
- Auto-cleanup (60 image limit)
- Graceful error handling
CI/CD Pipeline
3 parallel jobs: lint+typecheck, e2e, build. Artifacts uploaded for test reports.