Status: โ PRODUCTION READY - Full Stack Integration โ Complete โ Tested โ Monitored โ
๐ MILESTONE ACHIEVED: Project fully completed with production monitoring!
GangGPT revolutionizes Grand Theft Auto V multiplayer roleplay by integrating advanced AI systems that create a living, breathing virtual world. Built on RAGE:MP with Azure OpenAI GPT-4o-mini, this project delivers procedurally-generated missions, intelligent NPCs with persistent memory, and dynamic faction warfareโtransforming traditional roleplay into an immersive, AI-driven experience.
- RAGE:MP Server: โ Real GTA V multiplayer integration ready
- Backend Server: โ Running on http://localhost:4828 (Healthy)
- Frontend App: โ Running on http://localhost:4829 (Responsive)
- Database: โ PostgreSQL connected and operational
- API Endpoints: โ All endpoints responding < 50ms average
- Real-time Stats: โ Live data updates with WebSocket
- Monitoring: โ Prometheus metrics with Grafana dashboards
- Security: โ Rate limiting and CORS hardening implemented
- AI Integration: โ Azure OpenAI fully integrated with metrics
- Test Coverage: โ 80%+ for critical components
- โ COMPLETED: Full replacement of simulation code with real RAGE:MP APIs
- โ COMPLETED: Client-side scripts for in-game player interaction
- โ COMPLETED: Server configuration with proper RAGE:MP package structure
- โ COMPLETED: Real event handlers for player actions (join, death, vehicles, chat)
- โ COMPLETED: AI integration for in-game NPCs and mission generation
- โ COMPLETED: Dynamic world events based on actual player activities
- โ COMPLETED: Faction system integration with real territory control
- โ COMPLETED: Economy system driven by actual player transactions
- June 7, 2025: ๐ COMPLETED REAL RAGE:MP INTEGRATION - All simulation code removed
- June 5, 2025: Fixed statistics component and improved test coverage
- June 4, 2025: Enhanced Redis connection handling with proper fallbacks
- June 3, 2025: Implemented E2E testing with Playwright
- Integration Tests: โ All tests passing (Backend + Frontend + E2E)
- Type Safety: โ 100% TypeScript, zero compilation errors
- tRPC Integration: โ Full frontend-backend type safety
- Production Ready: โ Docker + Environment configs complete
- ๐ Quick Start
- โจ Features
- ๐ป Technology Stack
- ๐ง System Requirements
- โ๏ธ Installation Guide
- ๐ Authentication System
- ๐ค AI Integration
- ๐ Dashboard & Statistics
- ๐ Testing
- ๐ Deployment
- ๐ Project Structure
- ๐ง AI Systems Architecture
- ๐ณ Docker Setup
- ๐ Deployment
- ๐ก๏ธ Security Implementation
- ๐ Performance Standards
- ๐งช Testing Strategy
- ๐ข Development Workflow
- ๐ Community & Support
- ๐ Additional Documentation
- ๐ License
- RAGE:MP Server installed and configured
- Node.js 18+ and npm/pnpm
- PostgreSQL database
- Redis cache
- Azure OpenAI API access
# 1. Clone the repository
git clone https://github.com/yourusername/gang-gpt-gta-v.git
cd gang-gpt-gta-v
# 2. Install dependencies
npm install
# 3. Set up environment variables
cp .env.example .env
# Edit .env with your database and Azure OpenAI credentials
# 4. Set up database
npm run db:generate
npm run db:migrate
# 5. Copy RAGE:MP files to your server directory
# Copy client_packages/ to your RAGE:MP server's client_packages/
# Copy packages/ganggpt/ to your RAGE:MP server's packages/
# Copy conf.json to your RAGE:MP server root (merge with existing config)
# 6. Start the backend server
npm run dev
# 7. Start your RAGE:MP server
# The server will automatically connect to GangGPT backend# Clone the repository
git clone https://github.com/yourusername/gang-gpt-gta-v.git
cd gang-gpt-gta-v
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your database and Azure OpenAI credentials
# Set up database
npm run db:generate
npm run db:migrate
# Start development server
npm run dev
# Test all systems
npm run test:serverServer will be running at: http://localhost:4828
- ๐ง AI-Powered NPCs - Dynamic personalities with memory and evolving dialogue
- ๐ฏ Procedural Missions - AI-generated quests tailored to your playstyle
- ๐ค AI Companions - Intelligent companion NPCs that learn and evolve
- โ๏ธ Dynamic Factions - AI-driven faction politics and territory control
- ๐ Persistent World - Your choices shape the city's future
- ๐ฐ Player Economy - AI-verified service marketplace with dynamic pricing
- ๐ญ Adaptive Storytelling - Micro-lore arcs based on player behavior
- ๐๏ธ Territory Control - Strategic areas with resources and influence
- ๐ Real-time Updates - WebSocket-driven event notifications
- ๐ฒ Dynamic Events - Procedurally generated world events
- Runtime: Node.js with TypeScript (strict mode)
- Framework: RAGE:MP (Grand Theft Auto V multiplayer mod)
- AI Integration: Azure OpenAI GPT-4o-mini
- Database: PostgreSQL with Prisma ORM
- Cache: Redis for session and temporary data
- Authentication: JWT with bcrypt hashing
- Real-time: Socket.IO for live updates
- Framework: Next.js 14+ with App Router
- Styling: Tailwind CSS with custom design system
- UI Components: Headless UI and Radix UI
- State Management: Zustand with persistence
- API Layer: tRPC for type-safe APIs
- Authentication: NextAuth.js
- Cloud Provider: Google Cloud Platform
- Containerization: Docker with multi-stage builds
- Orchestration: Kubernetes for production
- CI/CD: GitHub Actions with automated testing
- Monitoring: Prometheus, Grafana, and Google Cloud Monitoring
- Logging: Structured logging with Winston
- Node.js 18+
- PostgreSQL 15+
- Redis 6+
- Azure OpenAI API access
- RAGE:MP server (for GTA V integration)
# Clone the repository
git clone https://github.com/yourusername/gang-gpt-gta-v.git
cd gang-gpt-gta-v
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your Azure OpenAI keys and database credentials
# Generate Prisma client
npm run db:generate
# Run database migrations (requires PostgreSQL running)
npm run db:migrate
# Build the project
npm run build
# Start development server
npm run dev- Install PostgreSQL and create a database:
CREATE DATABASE gang_gpt_db;
CREATE USER gang_gpt_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE gang_gpt_db TO gang_gpt_user;- Update your
.envfile with the database connection string:
DATABASE_URL="postgresql://gang_gpt_user:your_password@localhost:4831/gang_gpt_db"- Run the database migrations:
npm run db:migrate-
Create an Azure OpenAI resource in the Azure portal
-
Deploy a GPT-4o-mini model
-
Update your
.envfile with the endpoint and API key:
AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
AZURE_OPENAI_API_KEY="your-api-key-here"
AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini"gang-gpt-gta-v/
โโโ .github/ # GitHub workflows and templates
โโโ docs/ # Comprehensive documentation
โโโ src/
โ โโโ config/ # Application configuration
โ โโโ modules/
โ โ โโโ ai/ # AI system core and prompts
โ โ โโโ economy/ # Economic simulation system
โ โ โโโ factions/ # Faction management and dynamics
โ โ โโโ players/ # Player management and progression
โ โ โโโ world/ # World state and environment control
โ โโโ infrastructure/
โ โ โโโ database/ # Database connection and migrations
โ โ โโโ cache/ # Redis cache implementation
โ โ โโโ ragemp/ # RAGE:MP game server integration
โ โ โโโ websocket/ # WebSocket real-time communication
โ โ โโโ ai/ # AI service integrations
โ โ โโโ logging/ # Logging infrastructure
โ โโโ shared/
โ โโโ types/ # TypeScript type definitions
โ โโโ utils/ # Shared utility functions
โ โโโ constants/ # Application constants
โ โโโ validators/ # Input validation schemas
โโโ prisma/ # Database schema and migrations
โโโ tests/ # Comprehensive test suite
โโโ scripts/ # Development and deployment scripts
GangGPT features a sophisticated AI architecture designed for creating a dynamic gaming world:
- Memory Persistence: PostgreSQL storage for long-term memory
- Active Memory Caching: Redis for recent interactions (24-hour window)
- Memory Decay: Realistic forgetting algorithms based on significance
- Emotional Context: Tracking NPC feelings and relationship development
- Memory Compression: Efficient long-term storage of significant events
- Contextual Prompts: Missions generated based on game state and player history
- Difficulty Scaling: Adaptive challenge based on player level and skills
- Faction Integration: Missions aligned with current faction dynamics
- Player Choice: Multiple mission paths generated for decision-making
- Narrative Continuity: Tracking completion history for evolving storylines
- Decision Trees: Advanced logic for faction decisions and actions
- Influence Matrices: Territory control modeling with influence spread
- Economic Modeling: Resource allocation and strategic decision-making
- Dynamic Events: Events generated based on faction relationships
- Player Opportunities: AI actions create meaningful gameplay scenarios
- Request Metrics: Track AI request volume, latency and token usage
- Content Filtering: Automatic detection and filtering of inappropriate content
- Optimization: Caching of common AI responses for performance
- Fallback Systems: Graceful degradation when AI services are unavailable
- Dashboard Visualization: Grafana dashboards for AI performance monitoring
GangGPT is fully containerized for easy deployment and scaling:
# Build the Docker image
npm run docker:build
# Run the containerized server
npm run docker:runFor a complete development environment with PostgreSQL and Redis:
# Start all services
docker-compose up -d
# View container logs
docker-compose logs -f
# Shut down the environment
docker-compose downGangGPT is optimized for deployment on GCP:
- Set up a GKE cluster and container registry
- Configure secrets in GCP Secret Manager
- Deploy using the provided Kubernetes manifests:
# Build and push the image
docker build -t gcr.io/your-project/gang-gpt:latest .
docker push gcr.io/your-project/gang-gpt:latest
# Deploy to Kubernetes
kubectl apply -f kubernetes/GitHub Actions workflow provides automated deployment:
- Triggered on pushes to
mainbranch - Runs comprehensive test suite
- Builds and pushes Docker image
- Updates Kubernetes deployment
- Notifies Discord on deployment status
- JWT Token Security: 1-hour expiration with refresh token rotation
- Role-Based Access Control: Granular permission system
- Input Validation: Comprehensive Zod schemas for all endpoints
- Rate Limiting: Protection against abuse on all API endpoints
- Secure Communication: HTTPS for all server endpoints
- Encryption: Sensitive data encrypted at rest using AES-256
- SQL Injection Protection: ORM-based query parameterization
- Cross-Origin Protection: Strict CORS configuration
- Security Logging: Comprehensive audit trail of security events
- API Response Time: < 200ms average for standard requests
- AI Response Time: < 2 seconds for companion interactions
- Mission Generation: < 5 seconds for full mission creation
- Database Queries: < 100ms average response time
- Real-time Updates: < 50ms WebSocket latency
- Concurrent Users: Support for 1,000+ simultaneous players
- Unit Testing: Jest with > 80% code coverage
- Integration Testing: API endpoints with database integration
- AI Testing: Companion response quality verification
- Performance Testing: Load testing for all major systems
- End-to-End Testing: Playwright-based full system testing
GangGPT implements a comprehensive testing strategy across the entire application:
- Framework: Jest with TypeScript support
- Coverage Target: >80% code coverage
- Component Testing: React Testing Library for frontend components
- API Testing: Integration tests for all API endpoints
- Mock Data: Realistic test fixtures for consistent testing
- Framework: Playwright for browser automation
- Scenarios: Complete user journeys and critical paths
- Environments: Tests run against development, staging, and production
- Visual Testing: Screenshot comparison for UI verification
- Performance: Load and stress testing for critical endpoints
# Run all unit and integration tests
npm test
# Run specific test suite
npm test -- components/sections/__tests__/statistics-simple.test.tsx
# Run E2E tests
npx playwright test
# Run specific E2E test
npx playwright test e2e/statistics.e2e.test.tsSee our Testing Strategy Documentation for detailed information on writing tests, best practices, and troubleshooting.
GangGPT features a robust watch mode for development with automatic restart and live reloading across all services:
# Start all services with watch mode (recommended for development)
pnpm run dev:watch
# Or use VS Code tasks (Ctrl+Shift+P โ "Tasks: Run Task")
# Select "GangGPT: Start Watch Mode (All Services)"For focused development on specific services:
# Watch backend only (API + database)
pnpm run dev:watch:backend
# Watch frontend only (Next.js with hot reload)
pnpm run dev:watch:frontend
# Watch RAGE:MP server only
pnpm run dev:watch:ragemp
# Watch all services (same as dev:watch)
pnpm run dev:watch:all- ๐ Live Reloading: Automatic restart on file changes
- ๐ Smart File Watching: Monitors relevant file types (.ts, .js, .json, .jsx, .tsx)
- โก Fast Restart: Optimized restart times with caching
- ๐ฏ Selective Watching: Per-service watchers for targeted development
- ๐ Debug Output: Detailed logging with timestamps and service identification
- โ๏ธ Error Recovery: Automatic restart on crashes with retry logic
- ๐ Health Monitoring: Built-in service health checks
| Service | Watched Path | File Types | Features |
|---|---|---|---|
| Backend | src/**/* |
.ts, .js, .json |
tsx watch + custom watcher |
| Frontend | web/**/* |
All files | Next.js built-in hot reload |
| RAGE:MP | ragemp-server/packages/**/* |
.js |
Custom file watcher |
Watch mode is fully integrated with VS Code tasks for easy access:
- Open Command Palette:
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Type: "Tasks: Run Task"
- Select from available options:
GangGPT: Start Watch Mode (All Services)- Complete development environmentGangGPT: Watch Backend Only- API and database developmentGangGPT: Watch Frontend Only- UI development with hot reloadGangGPT: Watch RAGE:MP Only- Game server development
The watch mode can be customized with command-line parameters:
# Skip initial build (faster startup)
pnpm run dev:watch -- -SkipBuild
# Enable verbose logging
pnpm run dev:watch -- -Verbose
# Skip RAGE:MP server (web-only development)
pnpm run dev:watch -- -NoRageMP
# Combine multiple options
pnpm run dev:watch -- -SkipBuild -Verbose -NoRageMP- Prevents restart spam during rapid file changes
- Per-file tracking to avoid duplicate events
- Configurable delay (default: 1000ms)
- Automatic restart on service crashes
- Retry logic with exponential backoff
- Health monitoring with automatic recovery
- Exclude patterns for node_modules, .git, logs, etc.
- File type filtering to watch only relevant files
- Efficient file system monitoring with minimal resource usage
Watch mode not starting:
# Check prerequisites
node --version # Should be 18+
pnpm --version # Should be 8+
# Verify project structure
ls package.json # Should exist in project rootServices not restarting:
# Check file watcher permissions
# On Windows: Run PowerShell as Administrator
# On Linux/Mac: Check file system permissionsPort conflicts:
# Check if ports are already in use
netstat -an | findstr "4828" # Backend port
netstat -an | findstr "4829" # Frontend port
netstat -an | findstr "22005" # RAGE:MP portFor large projects, you may want to adjust the debounce timing:
# Edit scripts/start-dev-watch.ps1
# Change line: $debounceMs = 1000 # to desired value in milliseconds- Start watch mode:
pnpm run dev:watch - Edit code: Files are automatically watched
- Save changes: Services restart automatically
- Check logs: Monitor console output for status
- Test changes: Visit http://localhost:4829 for frontend
- Stop services:
Ctrl+Cin terminal
- Use watch mode for active development - Saves time with automatic restarts
- Use individual watchers when working on specific services
- Monitor console output for restart notifications and errors
- Use VS Code tasks for integrated development experience
- Combine with debugger for enhanced development workflow
Built with โค๏ธ by the GangGPT development team