A modern, full-stack AI-powered image generation platform built with React Router 7, BetterAuth, Trigger.dev, and Prisma.
- 🎨 AI Typography & Art Generation - Create stunning typography designs and artistic compositions with OpenAI's DALL-E 3
- 🔐 Complete Authentication - Secure user accounts with BetterAuth
- ⚡ Real-time Updates - Live task monitoring with Trigger.dev
- 💳 Credit System - User-based credit management for generation limits
- 🌙 Dark Mode - Comprehensive light/dark theme support
- 📱 Responsive Design - Beautiful UI that works on all devices
- 🚀 Server-Side Rendering - Fast, SEO-friendly React Router 7
- 🗃️ Type-Safe Database - Prisma ORM with PostgreSQLA modern, full-stack AI-powered image generation platform built with React Router 7, BetterAuth, Trigger.dev, and Prisma.
- 🎨 AI Image Generation - Create stunning images with OpenAI's DALL-E 3
- 🔐 Complete Authentication - Secure user accounts with BetterAuth
- ⚡ Real-time Updates - Live task monitoring with Trigger.dev
- 💳 Credit System - User-based credit management for generation limits
- 🌙 Dark Mode - Comprehensive light/dark theme support
- 📱 Responsive Design - Beautiful UI that works on all devices
- 🚀 Server-Side Rendering - Fast, SEO-friendly React Router 7
- �️ Type-Safe Database - Prisma ORM with PostgreSQL
- React Router 7 - Modern SSR framework with file-based routing
- React 19 - Latest React with concurrent features
- TypeScript - Type-safe development
- TailwindCSS v4 - Utility-first styling with automatic dark mode
- Lucide React - Beautiful, customizable icons
- Prisma - Type-safe database ORM
- PostgreSQL - Robust relational database
- BetterAuth - Modern authentication with Prisma adapter
- Trigger.dev v3 - Background task processing and monitoring
- OpenAI DALL-E 3 - State-of-the-art typography and art generation
- OpenAI GPT-4o - Enhanced prompt processing and artistic captions
- Node.js 18+
- PostgreSQL database
- OpenAI API key
- Trigger.dev account
-
Clone the repository
git clone https://github.com/sethdavis512/tws-trigger-dev.git cd tws-trigger-dev -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Fill in your environment variables:
DATABASE_URL="postgresql://user:password@localhost:5432/rapidalle" OPENAI_API_KEY="your_openai_api_key" TRIGGER_SECRET_KEY="your_trigger_secret_key"
-
Set up the database
npx prisma migrate dev npx prisma generate
Start the development servers:
# Terminal 1: React Router dev server
npm run dev
# Terminal 2: Trigger.dev dev server
npm run trigger:devYour application will be available at http://localhost:5173.
├── app/
│ ├── lib/ # Auth configuration and utilities
│ ├── models/ # Database operations (Prisma)
│ ├── routes/ # Pages and API endpoints
│ │ ├── authenticated.tsx # Protected route layout
│ │ ├── api/ # API routes
│ │ └── ...
│ ├── components/ # Reusable UI components
│ └── ...
├── trigger/
│ └── generateContent.ts # Background image generation task
├── prisma/
│ ├── schema.prisma # Database schema
│ └── migrations/ # Database migrations
└── ...
The app uses BetterAuth with email/password authentication:
- Session-based auth with 7-day expiry
- Prisma adapter for database integration
- Layout-based protection for authenticated routes
- Custom user fields including credit system
app/lib/auth.server.ts- BetterAuth server configurationapp/lib/auth.client.ts- Client-side auth setupapp/lib/session.server.ts- Auth helper functionsapp/routes/authenticated.tsx- Protected route wrapper
- User creates prompt in the responsive prompt card interface
- Credit validation ensures user has sufficient credits
- Background task triggered via Trigger.dev for async processing
- Real-time updates show generation progress to user
- Image persistence saves results to database with metadata
- Gallery display shows generated images in responsive grid
trigger/generateContent.ts- Main generation taskapp/routes/api/dalle.ts- Generation API endpointapp/components/PromptCard.tsx- Generation interfaceapp/routes/library.tsx- Image gallery
- User - Authentication and credits management
- Prompt - Reusable generation prompts
- Image - Generated images with metadata
- Auth Tables - Account, Session, Verification for BetterAuth
- Cascading deletes for data integrity
- Credit system with atomic operations
- Relationship mapping between users, prompts, and images
Ensure these environment variables are set:
DATABASE_URL=your_production_postgres_url
OPENAI_API_KEY=your_openai_key
TRIGGER_SECRET_KEY=your_trigger_keynpm run build
npm run startdocker build -t rapidalle .
docker run -p 3000:3000 rapidalleCompatible with: AWS ECS, Google Cloud Run, Azure Container Apps, Railway, Fly.io
npm run dev # Start React Router dev server
npm run trigger:dev # Start Trigger.dev dev server
npm run build # Build for production
npm run typecheck # TypeScript validation
npx prisma studio # Visual database browser
npx prisma migrate dev # Apply database migrations- Users start with 10 free credits
- Each image generation costs 1 credit
- Atomic credit deduction prevents race conditions
- Extensible for future payment integration
- Live task status updates via Trigger.dev hooks
- Progress indicators during generation
- Error handling and retry logic
- No polling - efficient WebSocket connections
- System preference detection
- Comprehensive component coverage
- Smooth transitions and proper contrast ratios
- TailwindCSS media strategy implementation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
- React Router - Modern React framework
- BetterAuth - Simple, powerful authentication
- Trigger.dev - Background job processing
- Prisma - Next-generation ORM
- OpenAI - AI-powered image generation
Built with ❤️ using React Router 7, BetterAuth, Trigger.dev, and Prisma.