Quick Start Guide
Get PadawanForge running in 5 minutes with this streamlined setup guide.
Prerequisites
- Bun installed
- Git installed
- Cloudflare account (free tier works)
5-Minute Setup
1. Clone and Install
git clone https://github.com/your-org/PadawanForge.git
cd PadawanForge
bun install
2. Database Setup
# Create database
bun wrangler d1 create padawan-db
# Copy the database_id from output and update wrangler.jsonc
# Look for the line: database_id = "your-id-here"
# Run migrations
bun run db:migrate
3. Environment Configuration
# Create environment file
echo 'API_TOKEN=dev-token-123' > .dev.vars
echo 'APP_NAME=PadawanForge' >> .dev.vars
4. Start Development
bun run dev
Visit http://localhost:4321 - you’re ready to go!
First Steps
Try the Demo
- Go to http://localhost:4321/demo
- Wait for AI to generate 40 History questions (30-60 seconds)
- Complete the 7-minute cognitive training session
- Review your results and achievements
Test Core Features
# Test AI integration
curl http://localhost:4321/api/ai/test-connection
# Test database
curl http://localhost:4321/api/health
# Run comprehensive tests
bun run test:all
Add Authentication (Optional)
Google OAuth Setup
- Visit Google Cloud Console
- Create a new project or select existing
- Enable the Google+ API
- Create OAuth 2.0 credentials
- Add redirect URI:
http://localhost:4321/api/auth/callback/google - Add credentials to
.dev.vars:
echo 'OAUTH_GOOGLE_CLIENT_ID=your-client-id' >> .dev.vars
echo 'OAUTH_GOOGLE_CLIENT_SECRET=your-client-secret' >> .dev.vars
Discord OAuth Setup
- Visit Discord Developer Portal
- Create a new application
- Go to OAuth2 section and add redirect URI:
http://localhost:4321/api/auth/callback/discord - Add credentials to
.dev.vars:
echo 'OAUTH_DISCORD_CLIENT_ID=your-client-id' >> .dev.vars
echo 'OAUTH_DISCORD_CLIENT_SECRET=your-client-secret' >> .dev.vars
Test Authentication
Visit http://localhost:4321/login and try signing in with your configured providers.
Essential Commands
Development
bun run dev # Start development server
bun run build # Build for production
bun run preview # Preview production build
Database
bun run db:migrate # Run migrations locally
bun run db:migrate:remote # Run migrations on remote
Testing
bun run test:all # Run all tests
bun run test:all:prod # Test production environment
Deployment
bun run deploy # Deploy to Cloudflare Workers
bun run check # Dry run deployment check
Explore the Platform
Game Features
- Demo Mode: Anonymous 7-minute cognitive training sessions
- AI Statements: Automatically generated true/false questions
- Streak System: Hot/cold streaks with score multipliers
- Virtual Tutors: AI personalities (Einstein, Curie, Confucius, Sherlock)
- Progress Tracking: XP, levels, and achievement system
Administrative Tools
- Player Management: View and manage registered players
- NPC Configuration: Customize AI tutor personalities
- Analytics Dashboard: Performance metrics and insights
- Role System: Granular permissions (Guest, Padawan, Game Master, etc.)
Technical Features
- Edge Performance: Cloudflare Workers for global low latency
- Real-time Chat: WebSocket-based messaging system
- AI Integration: Cloudflare Workers AI for content generation
- Privacy Controls: Granular data visibility settings
Key URLs
Main Application
- Home: http://localhost:4321
- Demo: http://localhost:4321/demo
- Login: http://localhost:4321/login
- Game: http://localhost:4321/game
Administrative
- Admin Dashboard: http://localhost:4321/admin
- Player Management: http://localhost:4321/admin/players
- NPC Configuration: http://localhost:4321/admin/npcs
Documentation
- API Docs: http://localhost:4321/docs/api
- Admin Guide: http://localhost:4321/docs/admin
- Integration Examples: http://localhost:4321/docs/examples
API Endpoints
- Health Check: http://localhost:4321/api/health
- AI Test: http://localhost:4321/api/ai/test-connection
- Demo Session:
POST http://localhost:4321/api/demo/session
Common Tasks
Create a Demo Session
curl -X POST http://localhost:4321/api/demo/session \
-H "Content-Type: application/json" \
-d '{}'
Generate AI Statements
curl -X POST http://localhost:4321/api/ai/generate-statements \
-H "Content-Type: application/json" \
-d '{"topic": "Science", "difficulty": "basic", "count": 10}'
Check Player Stats
curl http://localhost:4321/api/users/stats
Troubleshooting
Development Server Won’t Start
# Check if port 4321 is in use
lsof -i :4321
# Kill any processes using the port
kill -9 $(lsof -t -i:4321)
# Restart development server
bun run dev
Database Issues
# Verify database exists
bun wrangler d1 list
# Check migrations
bun wrangler d1 execute padawan-db --local --command="SELECT name FROM sqlite_master WHERE type='table';"
# Reset database (if needed)
bun run db:migrate
AI Generation Not Working
# Test AI connection
curl http://localhost:4321/api/ai/test-connection
# Check Cloudflare Workers logs
bun wrangler tail
OAuth Errors
- Verify redirect URIs match exactly in provider settings
- Check client IDs and secrets in
.dev.vars - Ensure provider applications are properly configured
Production Deployment
Quick Production Setup
# Create production database
bun wrangler d1 create padawan-db-prod
# Update wrangler.jsonc with production database ID
# Run remote migrations
bun run db:migrate:remote
# Set production secrets
bun wrangler secret put API_TOKEN
bun wrangler secret put OAUTH_GOOGLE_CLIENT_ID
bun wrangler secret put OAUTH_GOOGLE_CLIENT_SECRET
# Deploy
bun run deploy
# Test production
bun run test:all:prod
Custom Domain Setup
# Add custom domain
bun wrangler custom-domains create your-domain.com
# Update OAuth redirect URIs to use your domain
# Update any hardcoded localhost references
Next Steps
Learn More
- Architecture Overview: Understand the system design
- API Documentation: Integrate with external systems
- Development Guide: Advanced development and testing
Customize Your Instance
- Game Configuration: Customize demo and game settings
- AI Setup: Configure AI models and prompts
- Authentication: Add more OAuth providers
Contribute
- Contributing Guide: Help improve PadawanForge
- Issue Tracker: Report bugs or request features
- Discussions: Join the community
Support
Getting Help
- Documentation: Comprehensive guides in the
/docsdirectory - GitHub Issues: Report bugs and request features
- Community Discussions: Connect with other developers
- Developer Chat: Real-time support in Discord/Slack
Common Resources
You’re now ready to start building with PadawanForge! The platform provides a solid foundation for cognitive training games with modern web technologies and edge computing performance.