A comprehensive Ruby on Rails API backend for the Life Gamifier MMORPG system, transforming daily life into an engaging RPG experience.
under_world is the Rails-based backend API that powers the Life Gamifier MMORPG system. It provides a comprehensive set of APIs for user management, quest tracking, social features, and real-time communication. The frontend OverWorld Unity app connects to this backend to create an immersive AR life gamification experience.
- 🔐 Authentication System - JWT-based auth with Google OAuth2 integration
- 🎯 Quest Management - Dynamic quest creation, tracking, and completion
- 👥 Social Features - Guilds, parties, friendships, and mentorship
- 📊 Wellbeing Tracking - HP, mood, focus, energy monitoring with daily resets
- 🎨 Avatar System - Customizable user avatars with stats and equipment
- 💬 Real-time Chat - WebSocket-based messaging via Action Cable
- 🏆 Skills System - Skill progression, combinations, and mastery tracking
- 🤖 AI Integration - OpenAI-powered character interactions and adventures
- 🌍 Location Services - Google Places integration for real-world landmarks
- 📈 Analytics & Insights - User behavior tracking and gamification metrics
- Framework: Ruby on Rails 8.0.2 (API-only mode)
- Database: PostgreSQL 15+
- Cache/Queue: Redis 7+ with Solid Cache/Queue
- Background Jobs: Sidekiq
- Authentication: Devise + JWT
- Authorization: Pundit
- Real-time: Action Cable (WebSockets)
- AI: OpenAI GPT integration
- Deployment: Docker + Kamal
- Testing: RSpec with Factory Bot
under_world/
├── 📁 app/
│ ├── controllers/api/v1/ # API endpoints
│ ├── models/ # Data models
│ ├── policies/ # Authorization rules
│ ├── serializers/ # JSON API serialization
│ ├── services/ # Business logic services
│ └── jobs/ # Background jobs
├── 📁 config/ # Configuration
├── 📁 db/ # Database migrations & seeds
├── 📁 spec/ # Tests (RSpec)
└── 📁 lib/tasks/ # Custom Rake tasks
- Ruby 3.2+
- PostgreSQL 15+
- Redis 7+
- Node.js 18+ (for some dependencies)
git clone https://github.com/yourusername/under_world.git
cd under_world
bundle installCreate .env file:
# Database
DATABASE_URL=postgresql://localhost/under_world_development
# JWT Authentication
DEVISE_JWT_SECRET_KEY=your_super_secret_jwt_key_here
# Google OAuth2
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# External Services
OPENAI_API_KEY=your_openai_api_key
GOOGLE_PLACES_API_KEY=your_google_places_api_key
# Redis
REDIS_URL=redis://localhost:6379/0
# CORS (for frontend)
CORS_ALLOWED_ORIGINS=http://localhost:3001,exp://192.168.1.117:19000rails db:create
rails db:migrate
rails db:seed# Start Redis
redis-server
# Start Sidekiq (background jobs)
bundle exec sidekiq
# Start Rails server
rails server -p 3000POST /api/v1/auth/sign_in # User login
POST /api/v1/auth/sign_up # User registration
GET /api/v1/users/me # Current user profile
GET /api/v1/quests # List user quests
POST /api/v1/quests # Create new quest
POST /api/v1/quests/:id/complete # Complete quest
GET /api/v1/guilds # List all guilds
POST /api/v1/guilds/:id/join # Join guild
POST /api/v1/guilds/:id/leave # Leave guild
GET /api/v1/skills # List all skills
GET /api/v1/user_skills # User's skills
POST /api/v1/user_skills/fuse # Fuse skills
// WebSocket connection via Action Cable
const cable = ActionCable.createConsumer('ws://localhost:3000/cable');- Authentication with Devise + JWT
- Wellbeing tracking (HP, mood, focus, energy)
- Social connections (guilds, parties, friends)
- Skills progression system
- Synchronous/Asynchronous modes
- Manual/Auto completion types
- XP and coin rewards
- Label categorization
- Member management
- Collaborative quests
- Guild-specific features
- Skill categories and progression
- Experience points and mastery
- Skill fusion mechanics
- User skill selections
class AiCharacterService
def generate_adventure(context)
# Generate AI-powered adventures
end
def chat_response(message)
# AI character interactions
end
end- Real-time weather data integration
- Weather-based quest modifiers
- Environmental effects
- Location-based features
- Landmark integration
- Real-world quest locations
# Run all tests
bundle exec rspec
# Run specific test types
bundle exec rspec spec/models/
bundle exec rspec spec/requests/
# Run with coverage
COVERAGE=true bundle exec rspecFROM ruby:3.2-alpine
WORKDIR /app
COPY Gemfile* ./
RUN bundle install
COPY . .
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]kamal setup # First-time setup
kamal deploy # Deploy updates- JWT authentication with automatic expiration
- Google OAuth2 integration
- Pundit authorization policies
- CORS configuration
- Input validation and sanitization
- Rate limiting
- SQL injection prevention
- Database query optimization
- Redis caching strategy
- Background job processing
- Efficient API serialization
- Connection pooling
pg_isready -d under_world_development
rails db:reset # If neededredis-cli ping
redis-cli flushall # Clear cache if neededbundle exec sidekiq # Start job processor- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Follow Ruby/Rails conventions
- Write comprehensive tests
- Add documentation for new features
- Use meaningful commit messages
This project is licensed under the MIT License.
- OverWorld - Unity AR frontend
- MMORPG Tools - Development utilities and MCP servers
- Issues: GitHub Issues
- API Documentation: Available when server is running
- Frontend Integration: See OverWorld repository
🏰 Ready to power life gamification? Clone, configure, and start building today!
Made with ❤️ for the life gamification community