Configuration
Complete configuration guide for Ticket System
Configuration Overview
Ticket System requires configuration in several areas:
- Discord Bot - Bot tokens, permissions, and OAuth settings
- Payment Providers - Stripe, PayPal, and Patreon integration
- Domain Settings - Custom domains and SSL configuration
- Feature Limits - Subscription tier restrictions
- Security - Encryption keys and authentication
Discord Configuration
Bot Setup
- Go to the Discord Developer Portal
- Create a new application or use an existing one
- Navigate to the "Bot" section
- Create a bot and copy the token
- Configure the following permissions:
- Send Messages
- Manage Threads
- Use Slash Commands
- Attach Files
- Embed Links
- Read Message History
OAuth Configuration
- In your Discord application, go to "OAuth2" → "General"
- Add your redirect URI:
https://yourdomain.com/api/auth/callback/discord - Copy the Client ID and Client Secret
- Configure the scopes:
identify guilds
# Example Discord configuration
discord:
defaultBot:
token: "your-bot-token-here"
clientId: "your-client-id"
enabled: true
oauth:
clientId: "your-oauth-client-id"
clientSecret: "your-oauth-client-secret"
redirectUri: "https://yourdomain.com/api/auth/callback/discord"
Payment Configuration
Stripe Setup
- Create a Stripe account
- Get your API keys from the Dashboard
- Configure webhook endpoint:
https://yourdomain.com/api/webhooks/stripe - Set webhook events:
customer.subscription.created,customer.subscription.updated,customer.subscription.deleted
# Stripe configuration
payments:
stripe:
publicKey: "pk_test_..."
secretKey: "sk_test_..."
webhookSecret: "whsec_..."
enabled: true
PayPal Setup
- Create a PayPal Developer account
- Create an app and get Client ID and Secret
- Configure webhook URL:
https://yourdomain.com/api/webhooks/paypal - Set environment (sandbox/production)
# PayPal configuration
payments:
paypal:
clientId: "your-paypal-client-id"
clientSecret: "your-paypal-client-secret"
webhookId: "your-webhook-id"
environment: "sandbox" # or "production"
enabled: true
Patreon Setup
- Create a Patreon Creator account
- Register your application
- Get Client ID and Secret
- Configure redirect URI:
https://yourdomain.com/api/auth/callback/patreon
# Patreon configuration
payments:
patreon:
clientId: "your-patreon-client-id"
clientSecret: "your-patreon-client-secret"
accessToken: "your-access-token"
refreshToken: "your-refresh-token"
enabled: true
Domain Configuration
Primary Domain
Set your primary domain for the application:
domain:
primary: "https://yourdomain.com"
allowCustomDomains: true
sslEnabled: true
Custom Domains
For enterprise customers, you can enable custom domains:
- Set
allowCustomDomains: true - Configure DNS records for customer domains
- Set up SSL certificates for each domain
- Configure NGINX virtual hosts
Feature Limits
Subscription Tiers
features:
maxFreeGuilds: 1
maxProGuilds: 5
maxEnterpriseGuilds: -1 # Unlimited
transcriptRetentionDays: 365
Usage Limits
- Free Tier: 1 server, 50 tickets/month, 7-day retention
- Pro Tier: 5 servers, 500 tickets/month, 30-day retention
- Enterprise Tier: Unlimited servers, unlimited tickets, 365-day retention
Security Configuration
Encryption Keys
Generate secure encryption keys for your installation:
# Generate master key (32 bytes)
openssl rand -base64 32
# Generate JWT keys (Ed25519)
openssl genpkey -algorithm Ed25519 -out private.pem
openssl pkey -in private.pem -pubout -out public.pem
# Convert to base64 for configuration
base64 -w 0 private.pem
base64 -w 0 public.pem
Environment Variables
# Security configuration
NEXTAUTH_SECRET=your-nextauth-secret-here
NEXTAUTH_URL=https://yourdomain.com
# Encryption keys
MASTER_KEY=your-base64-encoded-master-key
JWT_PRIVATE_KEY=your-base64-encoded-private-key
JWT_PUBLIC_KEY=your-base64-encoded-public-key
Database Configuration
MongoDB Setup
# Local MongoDB
MONGODB_URI=mongodb://localhost:27017/ticket-system
# MongoDB Atlas
MONGODB_URI=mongodb+srv://username:[email protected]/ticket-system
# With authentication
MONGODB_URI=mongodb://username:password@localhost:27017/ticket-system?authSource=admin
Redis Setup
# Local Redis
REDIS_URL=redis://localhost:6379
# Redis Cloud
REDIS_URL=redis://username:password@host:port
# With SSL
REDIS_URL=rediss://username:password@host:port
Monitoring Configuration
Health Checks
# Health check endpoints
GET /api/health # Web application health
GET /health # Bot health
GET /api/admin/status # System status
Logging
# Log levels
LOG_LEVEL=info # error, warn, info, debug
LOG_FORMAT=json # json, simple
LOG_FILE=logs/app.log # File logging
Metrics
Configure metrics collection for monitoring:
- Application Metrics: Response times, error rates
- Business Metrics: Ticket volume, user activity
- System Metrics: CPU, memory, disk usage
Testing Your Configuration
1. Verify Bot Connection
# Test bot connectivity
curl -X GET http://localhost:3001/health
# Check bot status in Discord
# The bot should appear online in your server
2. Test OAuth Flow
- Visit
https://yourdomain.com/api/auth/signin - Click "Sign in with Discord"
- Complete the OAuth flow
- Verify you're redirected back to the dashboard
3. Test Payment Integration
- Create a test subscription
- Verify webhook processing
- Check database records
- Test subscription management
4. Verify Database Connections
# Test MongoDB connection
mongosh --eval "db.runCommand({ping:1})"
# Test Redis connection
redis-cli ping
# Check application logs for connection errors
Troubleshooting
Common Configuration Issues
- Invalid Bot Token: Check token format and permissions
- OAuth Redirect Errors: Verify redirect URI matches exactly
- Payment Webhook Failures: Check webhook URL and signature verification
- Database Connection Errors: Verify connection strings and network access
- SSL Certificate Issues: Check certificate validity and NGINX configuration
Configuration Validation
# Validate configuration
npm run validate:config
# Check environment variables
npm run check:env
# Test all integrations
npm run test:integrations
Next Steps
After completing configuration:
- First Setup - Create your first ticket category
- Bot Setup - Configure Discord bot permissions
- Dashboard Setup - Configure the web interface
- Analytics Setup - Configure monitoring and reporting