A Flask-based web application for managing recipes with ingredients, images, and unit conversions.
- Recipe management with ingredients and directions
- Image upload and storage
- Unit conversions for recipe ingredients
- Ingredient density tracking for weight calculations
- Python 3.10+
- Node.js 20+ (for SCSS compilation)
- pnpm package manager
- Docker & Docker Compose (optional, for containerized deployment)
The application uses environment variables for configuration:
DATABASE_URL: Database connection string (defaults to SQLite for local dev)SECRET_KEY: Flask secret key for session management and security
Security Best Practices:
- Never commit
.envfiles to version control (already in.gitignore) - Generate strong SECRET_KEY values:
python -c "import secrets; print(secrets.token_hex(32))" - For production, use secure secret management:
- AWS Secrets Manager
- HashiCorp Vault
- Kubernetes Secrets
- GitHub Actions Secrets (for CI/CD)
- Rotate secrets regularly
See .env.example for a template with detailed instructions.
git clone https://github.com/EReaso/cookbook.git
cd cookbookpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtFor development (includes testing and linting tools):
pip install -r requirements-dev.txtpnpm installflask db upgradepnpm run buildDocker Compose provides a complete environment with PostgreSQL database:
- Set up environment variables:
cp .env.example .env
# Generate a secure SECRET_KEY and update .env
python -c "import secrets; print(secrets.token_hex(32))"- Start the application:
docker-compose up --buildThe application will be available at http://localhost:5000
- Run database migrations (in a new terminal):
docker-compose exec web flask db upgrade- Stop the application:
docker-compose downTo remove volumes (including database data):
docker-compose down -vFor local development without Docker:
python wsgi.pyThe application will be available at http://localhost:5000
Use gunicorn:
gunicorn wsgi:wsgi_apppytestpytest --cov=app --cov-report=htmlView coverage report by opening htmlcov/index.html in your browser.
pytest tests/test_models.pyThis project follows Black's opinionated code style:
- 4-space indentation
- Line length: 120 characters
- Double quotes for strings (with
skip-string-normalizationdisabled by default)
Linting and Formatting:
- Black: Automatic code formatting
- isort: Import sorting (configured to work with Black)
- flake8: Style and quality linting
Automated Formatting: The CI/CD pipeline automatically formats code with Black and isort on pull requests. If formatting changes are needed, they will be automatically committed to your PR branch by the GitHub Actions bot.
Format code with black:
black app testsSort imports with isort:
isort app testsLint code with flake8:
flake8 app testsInstall pre-commit hooks:
pre-commit installRun hooks manually:
pre-commit run --all-filescookbook/
├── app/
│ ├── __init__.py # Flask application factory
│ ├── config.py # Configuration
│ ├── extensions.py # Flask extensions
│ ├── storage.py # File storage handler
│ ├── recipes/ # Recipe blueprint
│ ├── images/ # Image blueprint
│ ├── models/ # Database models
│ ├── schemas/ # Data schemas
│ ├── static/ # Static files (CSS, JS)
│ └── templates/ # HTML templates
├── migrations/ # Database migrations
├── tests/ # Test suite
│ ├── conftest.py # Test fixtures
│ ├── test_models.py # Model tests
│ ├── test_routes.py # Route tests
│ ├── test_images.py # Image route tests
│ └── test_storage.py # Storage tests
├── .github/
│ └── workflows/ # CI/CD workflows
├── requirements.txt # Production dependencies
├── requirements-dev.txt # Development dependencies
└── wsgi.py # WSGI entry point
Create a new migration:
flask db migrate -m "Description of changes"Apply migrations:
flask db upgradeRollback migration:
flask db downgradeThis project uses GitHub Actions for continuous integration:
- Tests: Runs on Python 3.10, 3.11, and 3.12
- Linting: Checks code quality with flake8, black, and isort
- Coverage: Uploads coverage reports to Codecov
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the GPL 3.0 License.