Prerequisites
Python 3.8+
Mirage is built with Flask and requires Python 3.8 or higher
SQLite
Lightweight database that comes bundled with Python
No additional database setup required! Mirage uses SQLite which is initialized automatically on first run.
Local Development Setup
Install dependencies
Install required Python packages using pip:Key dependencies:
Flask- Web frameworkFlask-CORS- Cross-origin resource sharingWerkzeug- Password hashing utilities
Initialize the database
The database initializes automatically on first run. Review the schema in Database Tables:
app/db.py:app/db.py
users- User accounts and authenticationrooms- Chat room definitionsroom_members- Room membership trackingposts- User posts and contentpost_votes- Upvote/downvote trackingreplies- Post repliesfollowing- User follow relationshipsuser_profile- User statisticsinbox_messages- Direct messages
Start the development server
Run the Flask application:The server starts on
http://0.0.0.0:5000 in debug mode.server.py
Debug mode enables auto-reload on code changes and detailed error pages.
Production Deployment
Option 1: Gunicorn (Recommended)
Option 2: Docker
Option 3: Platform-as-a-Service
- Render
- Heroku
- Railway
- Create a new Web Service on Render
- Connect your GitHub repository
- Configure build settings:
- Build Command:
pip install -r requirements.txt - Start Command:
gunicorn --bind 0.0.0.0:$PORT wsgi:app
- Build Command:
- Add environment variables if needed
- Deploy!
Render’s free tier includes auto-sleep after inactivity. Consider paid tiers for production use.
Environment Variables
For production deployments, use environment variables for sensitive configuration:.env
app/config.py:
Security Considerations
Disable Debug Mode
Disable Debug Mode
In Or use environment variables:
server.py, set debug=False for production:Use HTTPS
Use HTTPS
Always use HTTPS in production. Configure your reverse proxy (nginx/Apache) or use a platform that provides SSL automatically (Render, Heroku, Railway).
Secure CORS Settings
Secure CORS Settings
In production, restrict CORS to specific origins in
app/__init__.py:Database Backups
Database Backups
Regularly backup your
db.sqlite file:Monitoring & Maintenance
Database Maintenance
Room messages auto-cleanup is handled in the code, but you may want to archive old posts:Health Checks
Monitor your deployment with the ping endpoint:- UptimeRobot
- Pingdom
- StatusCake
Logs
Access application logs:Troubleshooting
Database locked errors
Database locked errors
SQLite can have concurrency issues under high load. Consider:
- Using a connection pool
- Migrating to PostgreSQL for production
- Increasing
timeoutin database connections
File upload failures
File upload failures
Verify:
UPLOAD_URLis configured correctly inapp/config.py- Your upload service is accessible
- File size is under 24MB limit
- Request timeout is sufficient (increase with
--timeoutin Gunicorn)
CORS errors
CORS errors
Check CORS configuration in
app/__init__.py:- Ensure your frontend origin is allowed
- Verify
Authorizationheader is inallow_headers - Check browser console for specific CORS errors
Next Steps
API Reference
Explore all available endpoints and integrate with your frontend
Quickstart
Learn how to use Mirage from a user perspective
Contributing
Contribute to the Mirage project on GitHub
GitHub
View source code and star the repository