How ipenywis/roastui works
Main System Components
a) Client Layer:
• Next.js Frontend (src/app directory)
• Preview System (src/app/(preview))
• Authentication UI (src/app/(main)/(auth))
• Component Library (src/components)
b) API Layer:
• Authentication API (src/app/api/auth)
• Roast API (src/app/api/roast)
• Subscription API (src/app/api/subscribe)
• Webhook Handlers (src/app/api/webhooks)
c) Core Services:
• AI Service Integration (src/lib/ai.ts)
• Image Processing Service (src/services/imageService.ts)
• Payment Service (src/services/paymentService.ts)
• User Service (src/services/userService.ts)
d) Infrastructure:
• SQLite Database with LiteFS
• Cloudflare R2 Storage
• OpenRouter AI Integration
• esbuild WASM Compiler
Component Relationships
a) Frontend Flow:
User Interface → API Layer → Core Services → External Services
b) Data Flow:
Client → API Routes → Services → Database/Storage
c) AI Processing Flow:
Design Upload → Image Processing → AI Analysis → Preview Generation
Special Architectural Elements
Unique aspects:
a) Preview System:
• Browser-based Code Compilation (src/lib/bundler)
• Real-time Preview Rendering (src/components/previewRenderer)
• Streaming AI Responses (src/app/api/roast-streaming)
b) State Management:
• Design Preview Store (src/lib/stores/designPreviewStore.ts)
• Preview View Store (src/lib/stores/previewViewStore.ts)
Key Integration Points
Crucial connections:
• Authentication flow with NextAuth
• OpenRouter AI model integration
• Cloudflare R2 storage integration
• esbuild WASM compilation system
• Payment processing with Stripe
Deployment Architecture
A section showing:
• Fly.io VPS deployment
• Multi-region distribution
• LiteFS database replication
• Static asset delivery