Development Workflow
Guidelines for efficient development in the Zyeta backend project
This guide outlines the recommended development workflow for the Zyeta backend project. Following these practices will help maintain code quality and ensure smooth collaboration.
Development Environment
Before starting development, ensure you have:
- Completed the installation process
- Set up your environment variables
- Installed pre-commit hooks with
pre-commit install
Git Workflow
We follow a branch-based workflow to manage code changes:
Branching Strategy
- Main Branch: Always contains stable, production-ready code
- Dev Branch: All new features and bug fixes are merged in the
dev
branch then escalated further. - Feature Branches: For new features (
feat/feature-name
) - Bugfix Branches: For bug fixes (
fix/issue-id
) - Release Branches: For preparing releases (
release/v1.2.3
)
Branch Naming Convention
feat/short-description
- For new featuresfix/issue-id
- For bug fixesrefactor/component-name
- For code refactoringdocs/what-changed
- For documentation updates
Code Change Process
1. Create a New Branch
2. Make Changes
Write your code following the project’s coding standards (enforced by Ruff and Mypy).
3. Run Tests Locally
4. Commit Changes
The pre-commit hooks will run Ruff for linting and Mypy for type checking. Fix any issues before proceeding.
5. Push Changes
6. Create a Pull Request
Create a pull request on GitHub with:
- Clear title describing the change
- Detailed description of what was changed and why
- References to any related issues
- Ensure the PR is directed to the
dev
branch for review.
7. Code Review
All pull requests require at least one review before merging into dev
. Reviewers should check:
- Code correctness
- Test coverage
- Adherence to project standards
- Documentation
8. Merge
Once approved, the PR can be merged into the dev
branch. After sufficient testing and validation, changes can be merged into master
and then into the release
branch.
Code Quality Standards
Style Guide
We use Ruff for linting with the following key rules:
- 2-space indentation
- 150 character line length
- Python 3.10+ features allowed
Type Annotations
All code should use type annotations and pass Mypy checks:
Documentation
All modules, classes, and functions should have docstrings following Google’s style guide:
Adding New Components
Adding a New Service
- Create a new directory in
src/services/[service_name]/
- Add the required files:
service.py
- Main service implementationschema.py
- Pydantic models
Example service structure:
Adding a New Model
- Create a new file in
src/models/
named[model_name]_model.py
- Define your SQLAlchemy model
- Update
src/models/__init__.py
to export your model
Example model:
- Create a migration:
Database Migrations
Creating Migrations
Debugging
Logging
Use the logger provided by the Acquire class:
FastAPI Debug Mode
For local development, use FastAPI’s debug mode:
This enables auto-reload on code changes.
Deployment Pipeline
Our code follows this deployment pipeline:
Development
Local development and testing
Continuous Integration
Automated tests and checks run on GitHub Actions
Staging Deployment
Automatic deployment to the staging environment after merging into the dev
branch.
Production Deployment
Manual approval and deployment to production
Troubleshooting
Best Practices
- Write tests first: Follow test-driven development when possible
- Keep services focused: Each service should have a single responsibility
- Use async properly: Ensure all I/O operations are async
- Handle exceptions: Always catch and handle exceptions appropriately
- Validate inputs: Use Pydantic models for data validation
- Document your code: Write clear docstrings and comments
- Review your own code: Do a self-review before requesting reviews
By following this development workflow, you’ll contribute high-quality code to the Zyeta backend project while maintaining a smooth collaborative process.