Development¶
Welcome to the Printernizer development documentation! This section provides everything you need to contribute to the project.
Quick Links¶
- Contributing Guide - How to contribute to Printernizer
- Development Workflow - Git workflow and development process
- Code Sync - Understanding the code synchronization system
- Testing Guide - How to write and run tests
- Debugging - Debugging tips and tools
Getting Started with Development¶
Prerequisites¶
- Python 3.8+
- Git
- Node.js (for frontend development)
- Docker (optional, for testing deployments)
Setup Development Environment¶
# 1. Clone the repository
git clone https://github.com/schmacka/printernizer.git
cd printernizer
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\\Scripts\\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Install pre-commit hooks
pip install pre-commit
pre-commit install
# 5. Run the application
python src/main.py
Development Workflow¶
Printernizer uses a two-branch model:
development- Integration and testing branch- All feature branches merge here first
- Used for Docker testing deployments
-
Pre-release versions (e.g.,
2.7.0-dev) -
master- Production-ready branch - Only stable, tested code
- Used for releases and Home Assistant add-on
- Release versions only (e.g.,
2.7.0)
Workflow:
See Development Workflow for complete details.
Code Synchronization¶
Single Source of Truth: Edit code only in /src/ and /frontend/ directories.
Home Assistant Add-on: Maintained in separate printernizer-ha repository. Code automatically syncs via GitHub Actions when you push to master or development branch.
See Code Sync for details.
Project Structure¶
printernizer/
├── src/ # Backend source code (EDIT HERE)
│ ├── api/ # FastAPI routers
│ ├── models/ # Data models
│ ├── services/ # Business logic
│ ├── printers/ # Printer integrations
│ └── main.py # Application entry point
├── frontend/ # Frontend source code (EDIT HERE)
│ ├── index.html
│ ├── app.js
│ └── styles.css
├── tests/ # Test suite
├── docs/ # Documentation (MkDocs)
├── printernizer/ # Home Assistant add-on (AUTO-SYNCED)
│ ├── src/ # Synced from /src/
│ └── frontend/ # Synced from /frontend/
├── docker/ # Docker configuration
└── scripts/ # Utility scripts
Contributing Guidelines¶
Branching Strategy¶
- Create feature branch from
development - Make changes and commit
- Submit PR to
development - After testing, merge to
masterfor release
Commit Messages¶
Follow conventional commits:
feat: Add new feature
fix: Fix bug
docs: Update documentation
chore: Maintenance tasks
refactor: Code refactoring
test: Add tests
Code Style¶
- Python: Black formatter, PEP 8
- JavaScript: ES6+, consistent formatting
- Line length: 100 characters
- Type hints: Required for Python code
Testing¶
All contributions must include tests:
# Run all tests
pytest
# Run with coverage
pytest --cov=src tests/
# Run specific test
pytest tests/test_printer_service.py
See Testing Guide for details.
Documentation¶
Update documentation when adding features:
- Add docstrings to Python code
- Update relevant .md files in
docs/ - Update CHANGELOG.md
- Update API documentation if needed
Release Process¶
See RELEASE.md for the complete release process.
Development Tools¶
Interactive API Documentation¶
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Database Browser¶
Use any SQLite browser to inspect the database:
Logging¶
Structured logging with different levels:
import structlog
logger = structlog.get_logger(__name__)
logger.info("message", key="value")
logger.error("error", exc_info=True)
Common Development Tasks¶
Adding a New API Endpoint¶
- Create/update router in
src/api/routers/ - Add business logic to service in
src/services/ - Update data models if needed in
src/models/ - Add tests in
tests/ - Update API documentation
Adding Printer Support¶
- Create new printer class in
src/printers/ - Extend
BasePrinterinterface - Implement required methods
- Add configuration schema
- Update documentation
- Add tests
Debugging¶
See Debugging Guide for:
- Setting up debuggers
- Common issues
- Logging best practices
- Performance profiling
Getting Help¶
- Questions: GitHub Discussions
- Bugs: GitHub Issues
- Chat: Check README for community links