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 intodev
. Reviewers should check:
- Code correctness
- Test coverage
- Adherence to project standards
- Documentation
8. Merge
Once approved, the PR can be merged into thedev
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
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
- 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:Deployment Pipeline
Our code follows this deployment pipeline:1
Development
Local development and testing
2
Continuous Integration
Automated tests and checks run on GitHub Actions
3
Staging Deployment
Automatic deployment to the staging environment after merging into the
dev
branch.4
Production Deployment
Manual approval and deployment to production
Troubleshooting
Pre-commit Hooks Failing
Pre-commit Hooks Failing
If pre-commit hooks are failing:
- Check Ruff errors:
ruff check src/
- Check Mypy errors:
mypy src/
- Fix the issues before committing again
Database Migration Issues
Database Migration Issues
If you encounter migration errors:
- Check for model conflicts or circular imports
- Try recreating the migration with
alembic revision --autogenerate -m "Fixed migration"
- In worst case, you can reset:
alembic downgrade base
thenalembic upgrade head
Dependency Issues
Dependency Issues
If you encounter new dependency issues:
- Update Poetry:
poetry update
- Check for locked versions:
poetry show -o
- Add specific dependency:
poetry add package-name
- Update lock file:
poetry lock --no-update
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