PostgreSQL Database
ClassQuiz uses PostgreSQL as its primary database for storing users, quizzes, sessions, and all application data.PostgreSQL connection URL in the format:
postgresql://username:password@host:port/databaseDocker default: postgresql://postgres:classquiz@db:5432/classquizStandalone example: postgresql://postgres:mysecretpassword@localhost:5432/classquizPostgreSQL Setup
- Docker Compose
- Standalone
PostgreSQL is included in the Docker Compose setup:The connection URL is pre-configured:
docker-compose.yml
Redis Cache
Redis is used for caching, session management, OAuth state storage, and background job queues.Redis connection URL in the format:
redis://host:port/db?decode_responses=TrueDocker default: redis://redis:6379/0?decode_responses=TrueStandalone example: redis://localhost:6379/0?decode_responses=TrueThe
decode_responses=True parameter is required for proper string handlingDefault cache expiration time in seconds.Default: 86400 seconds (24 hours)
Redis Setup
- Docker Compose
- Standalone
Redis is included in the Docker Compose setup:Connection is pre-configured:
docker-compose.yml
Meilisearch
Meilisearch provides fast, typo-tolerant search functionality for quizzes.URL of your Meilisearch instance.Docker default:
http://meilisearch:7700Standalone default: http://127.0.0.1:7700Name of the Meilisearch index used for storing quiz search data.
Meilisearch Setup
- Docker Compose
- Standalone
Meilisearch is included in the Docker Compose setup:Configuration:
docker-compose.yml
Meilisearch indexes are automatically created and configured by ClassQuiz on first use.
Captcha Services
Protect registration and login forms from bots using hCaptcha or Google reCAPTCHA.hCaptcha secret key for server-side verification.Get your key from: hCaptcha Dashboard
Google reCAPTCHA secret key for server-side verification.Get your key from: reCAPTCHA Admin Console
Both captcha services are optional. If neither is configured, captcha verification will be skipped.
hCaptcha Setup
Create hCaptcha account
Sign up at hCaptcha.com
Add your site
- Go to Sites
- Add a new site with your domain
- Copy the Secret Key
reCAPTCHA Setup
Register your site
Go to reCAPTCHA Admin
Configure reCAPTCHA
- Choose reCAPTCHA v2 (“I’m not a robot” checkbox)
- Add your domain
- Accept terms and submit
- Copy the Secret Key
Optional Services
Pixabay API
Integrate Pixabay image search into the quiz editor.API key for Pixabay integration.Get your key from: Pixabay API Documentation
Create Pixabay account
Sign up at Pixabay.com
Get API key
Navigate to API Documentation and find your API key
Mapbox (Not Currently Used)
Mapbox configuration is present in the codebase but not actively used in the current version.Complete External Services Configuration
Health Checks
Verify that external services are running correctly:- PostgreSQL
- Redis
- Meilisearch
- Docker Services
Troubleshooting
Database connection refused
Database connection refused
Check that:
- PostgreSQL is running:
systemctl status postgresql - Port 5432 is not blocked by firewall
- Connection URL is correct (host, port, username, password)
- Database exists:
psql -U postgres -l
Redis connection failed
Redis connection failed
Verify:
- Redis is running:
redis-cli ping - Redis is listening on correct port:
netstat -tlnp | grep 6379 - No authentication is required (or correct password is provided)
decode_responses=Trueparameter is present in the URL
Meilisearch not indexing
Meilisearch not indexing
Common issues:
- Meilisearch service not running
- Incorrect MEILISEARCH_URL
- Network connectivity issues
- Disk space full (check Meilisearch data directory)
Captcha verification failing
Captcha verification failing
Verify:
- You’re using the Secret Key (not Site Key) in HCAPTCHA_KEY/RECAPTCHA_KEY
- Your domain is registered in the captcha service dashboard
- Client-side captcha is correctly implemented with the Site Key
- No network issues preventing server-side verification
Performance Tuning
PostgreSQL
Redis
Meilisearch
For large datasets, consider:- Increasing memory allocation
- Using dedicated Meilisearch server
- Configuring custom ranking rules
- Setting up replica for high availability
Security Best Practices
- Use strong passwords for PostgreSQL and Redis
- Enable SSL/TLS for database connections in production
- Regularly backup PostgreSQL data
- Implement Redis authentication with
requirepass - Use Meilisearch master keys in production
- Rotate API keys periodically
- Monitor service logs for suspicious activity
Monitoring
Consider implementing monitoring for:- Database query performance (pg_stat_statements)
- Redis memory usage and hit rates
- Meilisearch index size and search latency
- Connection pool utilization
- Error rates and response times
Next Steps
Environment Variables
Complete environment variable reference
Storage Configuration
Configure file storage backends