This guide covers all the APIs and services you need to set up for DreamForge to work properly.
Create a .env.local file in your project root:
# MongoDB Atlas
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/dreamforge?retryWrites=true&w=majority
# Moondream AI (Official API)
FAL_KEY=your_fal_ai_key_here
MOONDREAM_KEY=your_moondream_api_key_here
# Anthropic Claude
ANTHROPIC_API_KEY=sk-ant-api03-your_anthropic_key_here
# Stripe (for payments)
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
# NextAuth.js (for authentication)
NEXTAUTH_SECRET=your_nextauth_secret_here
NEXTAUTH_URL=http://localhost:3000
# GitHub OAuth (optional)
GITHUB_ID=your_github_oauth_app_id
GITHUB_SECRET=your_github_oauth_app_secret
# Google OAuth (optional)
GOOGLE_CLIENT_ID=your_google_oauth_client_id
GOOGLE_CLIENT_SECRET=your_google_oauth_client_secret
# Admin Secret (for admin endpoints)
ADMIN_SECRET=your_admin_secret_here
# Redis (optional, for caching and queues)
REDIS_URL=redis://localhost:6379- Go to MongoDB Atlas
- Create a free cluster
- Create a database user with read/write permissions
- Get your connection string
- Add it to
MONGODB_URI
- Go to Moondream Cloud Dashboard
- Sign up for an account
- Get your API key from the dashboard
- Add it to
MOONDREAM_KEY
- Go to Anthropic Console
- Create an account and get your API key
- Add it to
ANTHROPIC_API_KEY
- Go to Stripe Dashboard
- Create an account
- Get your test keys from the Developers section
- Add them to
STRIPE_SECRET_KEYandSTRIPE_PUBLISHABLE_KEY - Set up webhooks for payment events
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set callback URL to
http://localhost:3000/api/auth/callback/github - Add credentials to environment variables
- Go to Google Cloud Console
- Create a new project
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add callback URL:
http://localhost:3000/api/auth/callback/google
POST /api/analyze- Image analysis with Moondream/ClaudePOST /api/feedback- User feedback collectionGET /api/status- System status check
GET /api/admin/reward-config- Get current reward weightsPUT /api/admin/reward-config- Update reward weightsPOST /api/admin/reward-update- Recompute reward scores
GET /api/auth/signin- Sign in pageGET /api/auth/signout- Sign outPOST /api/auth/callback/*- OAuth callbacks
POST /api/stripe/checkout- Create Stripe checkout sessionPOST /api/stripe/webhook- Handle Stripe webhooks
curl -X POST http://localhost:3000/api/analyze \
-H "Content-Type: application/json" \
-d '{
"image": "data:image/jpeg;base64,/9j/4AAQ...",
"prompt": "What do you see in this image?"
}'curl -X POST http://localhost:3000/api/feedback \
-H "Content-Type: application/json" \
-d '{
"analysisId": "507f1f77bcf86cd799439011",
"feedback": "positive",
"rewardScore": 5,
"comment": "Great analysis!"
}'# Get current reward config
curl -X GET http://localhost:3000/api/admin/reward-config \
-H "x-admin-secret: your_admin_secret"
# Update reward weights
curl -X PUT http://localhost:3000/api/admin/reward-config \
-H "x-admin-secret: your_admin_secret" \
-H "Content-Type: application/json" \
-d '{
"accuracy": 2.0,
"helpfulness": 1.0,
"latency": -0.01
}'- Use
.env.localfor local development - MongoDB Atlas free tier is sufficient
- Stripe test keys for payment testing
- Mock responses when APIs are not configured
- Use Vercel environment variables
- MongoDB Atlas paid tier for better performance
- Stripe live keys for real payments
- All APIs must be properly configured
-
MongoDB Connection Failed
- Check your connection string
- Ensure IP whitelist includes your IP
- Verify database user permissions
-
Moondream API Unauthorized
- Verify your FAL.AI API key
- Check if you have sufficient credits
- The app will fall back to mock responses
-
Stripe Webhook Errors
- Verify webhook secret
- Check webhook endpoint URL
- Ensure proper event handling
-
NextAuth Configuration
- Verify OAuth app settings
- Check callback URLs
- Ensure environment variables are set
Add DEBUG=true to your environment variables to see detailed logs.
- Never commit API keys to version control
- Use environment variables for all secrets
- Validate all inputs in API routes
- Rate limit public endpoints
- Monitor usage to prevent abuse
- Enable caching for frequently accessed data
- Use CDN for static assets
- Optimize images before processing
- Implement connection pooling for MongoDB
- Monitor API response times
- All environment variables set in Vercel
- MongoDB Atlas configured
- Stripe webhooks configured
- OAuth apps configured for production URLs
- Admin secret set
- API keys configured
- Domain configured in OAuth apps
- SSL certificates valid
- Monitoring and alerts set up
- MongoDB Atlas: Free (512MB)
- FAL.AI: Free tier available
- Stripe: No charges for test mode
- Vercel: Free tier available
- MongoDB Atlas: $9/month (2GB)
- FAL.AI: Pay per request (~$0.01-0.05 per image)
- Anthropic Claude: Pay per token (~$0.01-0.03 per request)
- Stripe: 2.9% + 30¢ per transaction
- Vercel: $20/month (Pro plan)
Total estimated cost: $50-200/month depending on usage.