A Flask-based web application for managing LARP (Live Action Role-Playing) game data, including characters, events, and game mechanics.
- Character management and creation
- Event organization and tracking
- Database management for game rules and items
- User authentication and authorization
- Email notifications
- QR code generation
- PDF generation for game materials
- Python 3.10 or higher
- pip
- Git
-
Clone the repository:
git clone https://github.com/FixerSchis/os-app.git cd os-app -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
cp env.example .env # Edit .env with your configuration -
Initialize the database:
flask db upgrade
-
Run the application:
python app.py
The application will be available at the URL and port specified in your environment variables (default: http://localhost:5000)
This application uses environment variables for all configuration. Copy env.example to .env and modify the values as needed:
SECRET_KEY: Secret key for Flask sessions (generate a secure random string)MAIL_USERNAME: Gmail username for sending emailsMAIL_PASSWORD: Gmail app password (not your regular password)
FLASK_RUN_PORT: Port to run the server on (default: 5000)SSL_ENABLED: Enable SSL/HTTPS (default: false)SSL_CERT_FILE: Path to SSL certificate fileSSL_KEY_FILE: Path to SSL private key fileBASE_URL: Base URL for the application (default: http://localhost)MAIL_SERVER: SMTP server (default: smtp.gmail.com)MAIL_PORT: SMTP port (default: 587)MAIL_USE_TLS: Use TLS for email (default: true)MAIL_DEFAULT_SENDER: Default sender email address
For development, you can use these settings in your .env file:
FLASK_DEBUG=1
FLASK_RUN_PORT=5000
SSL_ENABLED=false
BASE_URL=http://localhostFor production, use these settings:
FLASK_DEBUG=0
FLASK_RUN_PORT=443
SSL_ENABLED=true
BASE_URL=https://yourdomain.com-
Install development dependencies:
pip install -r requirements-dev.txt
-
Install pre-commit hooks:
pre-commit install
-
Run tests:
pytest
-
Format code:
black . isort .
-
Lint code:
flake8 .
We welcome contributions! Please see our Contributing Guide for details on how to:
- Set up your development environment
- Follow our coding standards
- Submit pull requests
- Report issues
This project uses several tools to maintain code quality:
- Black: Code formatting
- isort: Import sorting
- flake8: Linting
- pytest: Testing
- bandit: Security analysis
- pre-commit: Git hooks for automated checks
This project uses GitHub Actions for automated testing, code quality checks, and branch protection. The CI/CD pipeline ensures that all code changes meet quality standards before being merged.
Every commit and pull request triggers the following checks:
-
Tests and Linting (
Tests and Lintingjob):- Runs tests across Python 3.10, 3.11, and 3.12
- Executes linting with flake8
- Checks code formatting with Black
- Verifies import sorting with isort
- Runs pytest with coverage (minimum 70% required)
- Uploads coverage reports to Codecov
-
Security Checks (
Security Checksjob):- Runs Bandit security analysis
- Checks for known security vulnerabilities with Safety
- Generates security reports
-
Pre-commit Checks (
Pre-commit Checksjob):- Runs all pre-commit hooks on all files
- Ensures consistent code formatting and quality
The main and develop branches are protected with the following rules:
- Required Status Checks: All CI jobs must pass before merging
- Pull Request Reviews: At least 1 approval required
- Code Owner Reviews: Required for main branch
- Stale Review Dismissal: Outdated reviews are automatically dismissed
- No Force Pushes: Force pushes are disabled
- No Deletions: Branch deletions are disabled
Branch protection is automatically configured when you push to main or develop branches. You can also manually trigger the setup:
- Go to the Actions tab in your GitHub repository
- Select the Setup Branch Protection workflow
- Click Run workflow
- Choose the branch to protect (main or develop)
-
Install pre-commit hooks (recommended):
pip install -r requirements-dev.txt pre-commit install
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes and commit:
git add . git commit -m "Add your feature"
(Pre-commit hooks will run automatically)
-
Push and create a pull request:
git push origin feature/your-feature-name
-
Wait for CI checks to complete on your PR
-
Request review from code owners (for main branch)
-
Merge once all checks pass and reviews are approved
ci.yml: Main CI workflow that runs on all commits and PRssetup-branch-protection.yml: Automatically configures branch protectionrelease.yml: Handles releases and versioning
Common Issues and Solutions:
-
Formatting Issues:
# Fix Black formatting black . # Fix import sorting isort .
-
Linting Issues:
# Check specific issues flake8 . --select=E9,F63,F7,F82 # Check all issues flake8 . --count --exit-zero --max-complexity=10 --max-line-length=100
-
Test Failures:
# Run tests locally pytest # Run with coverage pytest --cov=. --cov-report=term-missing
-
Pre-commit Hook Failures:
# Run pre-commit manually pre-commit run --all-files # Run specific hook pre-commit run black --all-files
-
Coverage Issues:
- Ensure new code has adequate test coverage
- Minimum coverage requirement is 70%
- Add tests for new functionality
.github/workflows/ci.yml: Main CI workflow.github/workflows/setup-branch-protection.yml: Branch protection setup.pre-commit-config.yaml: Pre-commit hooks configurationpyproject.toml: Tool configurations (Black, isort, pytest)pytest.ini: Pytest configuration.bandit: Bandit security configuration
- Caching: Dependencies are cached between runs
- Parallel Jobs: Tests run in parallel across Python versions
- Conditional Execution: Some jobs only run when needed
- Matrix Strategy: Tests multiple Python versions efficiently
Run the test suite:
pytestRun with coverage:
pytest --cov=. --cov-report=htmlos-app/
├── app.py # Main application entry point
├── models/ # Database models
├── routes/ # Flask routes and views
├── templates/ # Jinja2 templates
├── static/ # Static files (CSS, JS, images)
├── tests/ # Test suite
├── migrations/ # Database migrations
├── config/ # Configuration files
└── utils/ # Utility functions
- Set up a production server
- Install dependencies
- Configure environment variables
- Set up a production database
- Run database migrations
- Configure a WSGI server (e.g., Gunicorn)
- Set up a reverse proxy (e.g., Nginx)
The application can be installed as a systemd service for automatic startup and management. This is the recommended approach for production deployments.
- Linux system with systemd
- Python 3.10 or higher
- Application deployed to
/opt/orion-sphere-lrp(or modify the service file accordingly)
Create a dedicated user for running the application:
sudo useradd -r -s /bin/false orion-sphere
sudo groupadd orion-sphere
sudo usermod -a -G orion-sphere orion-sphereDeploy your application to the target directory:
sudo mkdir -p /opt/orion-sphere-lrp
sudo cp -r . /opt/orion-sphere-lrp/
sudo rm -rf /opt/orion-sphere-lrp/.git
sudo chown -R orion-sphere:orion-sphere /opt/orion-sphere-lrp/Copy the service file to the systemd directory:
sudo cp orion-sphere-lrp.service /etc/systemd/system/
sudo chmod 644 /etc/systemd/system/orion-sphere-lrp.serviceCreate a production environment file:
sudo -u orion-sphere nano /opt/orion-sphere-lrp/.envAdd your production environment variables:
FLASK_ENV=production
SECRET_KEY=your-secret-key-here
MAIL_SERVER=your-mail-server
MAIL_USERNAME=your-email-username
MAIL_PASSWORD=your-email-passwordcd /opt/orion-sphere-lrp
sudo -u orion-sphere python3 -m venv venv
sudo -u orion-sphere venv/bin/pip install -r requirements.txtsudo -u orion-sphere venv/bin/flask db upgradesudo systemctl daemon-reload
sudo systemctl enable orion-sphere-lrp
sudo systemctl start orion-sphere-lrpCheck the service status:
sudo systemctl status orion-sphere-lrpView logs:
sudo journalctl -u orion-sphere-lrp -f# Start the service
sudo systemctl start orion-sphere-lrp
# Stop the service
sudo systemctl stop orion-sphere-lrp
# Restart the service
sudo systemctl restart orion-sphere-lrp
# Reload configuration (without stopping)
sudo systemctl reload orion-sphere-lrp
# Check status
sudo systemctl status orion-sphere-lrp
# View logs
sudo journalctl -u orion-sphere-lrp
# Follow logs in real-time
sudo journalctl -u orion-sphere-lrp -f
# Disable auto-start
sudo systemctl disable orion-sphere-lrp- Service fails to start: Check logs with
sudo journalctl -u orion-sphere-lrp -n 50 - Permission issues: Ensure the
orion-sphereuser owns the application directory - Environment variables: Verify
.envfile exists and has correct permissions - Database connection: Test database connectivity manually
- Port conflicts: Ensure port 5000 (or your configured port) is available
You can modify the service file to:
- Change the working directory
- Use a different user/group
- Add additional environment variables
- Configure different restart policies
- Set resource limits
Example modifications:
# Add environment variables
Environment=FLASK_ENV=production
Environment=PORT=8080
# Change working directory
WorkingDirectory=/path/to/your/app
# Use different user
User=www-data
Group=www-dataRequired environment variables:
SECRET_KEY: Flask secret keyDATABASE_PATH: Database directory path (defaults to/var/lib/os-appin production,./dbin development)MAIL_SERVER: SMTP server for emailMAIL_USERNAME: Email usernameMAIL_PASSWORD: Email password
Database Configuration:
- Development: Database is stored in
./db/oslrp.db(relative to project root) - Production: Database is stored in
/var/lib/os-app/oslrp.db(persistent across deployments)
[Add your license information here]
- Create an issue for bugs or feature requests
- Check the documentation in the
/docsfolder - Join our community discussions
- Flask framework and ecosystem
- Contributors and maintainers
- LARP community feedback