|
| 1 | +# Contributing to FastAPI Task Manager |
| 2 | + |
| 3 | +Thank you for your interest in contributing to FastAPI Task Manager! This guide will help you get started. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Python 3.10+ |
| 10 | +- [uv](https://docs.astral.sh/uv/) (package manager) |
| 11 | +- Redis (for running the full test suite) |
| 12 | +- [pre-commit](https://pre-commit.com/) |
| 13 | + |
| 14 | +### Setup |
| 15 | + |
| 16 | +1. Clone the repository: |
| 17 | + ```bash |
| 18 | + git clone https://github.com/Morry98/fastapi-task-manager.git |
| 19 | + cd fastapi-task-manager |
| 20 | + ``` |
| 21 | +2. Install dependencies: |
| 22 | + ```bash |
| 23 | + uv sync |
| 24 | + ``` |
| 25 | +3. Install pre-commit hooks: |
| 26 | + ```bash |
| 27 | + pre-commit install |
| 28 | + ``` |
| 29 | +4. Create a branch for your changes: |
| 30 | + ```bash |
| 31 | + git checkout -b your-branch-name |
| 32 | + ``` |
| 33 | + |
| 34 | +> **Tip:** This project includes a `CLAUDE.md` file with detailed instructions for [Claude Code](https://claude.ai/code). If you use Claude Code as your development tool, it will automatically pick up project context, commands, and conventions. |
| 35 | +
|
| 36 | +## Development Workflow |
| 37 | + |
| 38 | +### Running Tests |
| 39 | + |
| 40 | +```bash |
| 41 | +uv run pytest |
| 42 | +``` |
| 43 | + |
| 44 | +With coverage: |
| 45 | +```bash |
| 46 | +uv run coverage run -m pytest && uv run coverage report |
| 47 | +``` |
| 48 | + |
| 49 | +### Code Quality |
| 50 | + |
| 51 | +The project uses pre-commit hooks that run automatically on `git commit`. You can also run them manually: |
| 52 | + |
| 53 | +```bash |
| 54 | +pre-commit run --all-files |
| 55 | +``` |
| 56 | + |
| 57 | +This includes: |
| 58 | +- **Ruff** for linting and formatting (line length: 120) |
| 59 | +- **Bandit** for security checks |
| 60 | +- **ty** for type checking |
| 61 | + |
| 62 | +### Pruning Stale Tags |
| 63 | + |
| 64 | +Before pushing tags, run the manual pre-commit hook to remove local tags that have been deleted on the remote: |
| 65 | + |
| 66 | +```bash |
| 67 | +pre-commit run --hook-stage manual prune-stale-tags |
| 68 | +``` |
| 69 | + |
| 70 | +It's good practice to run this periodically to keep your local tags in sync with the remote. |
| 71 | + |
| 72 | +### Code Style |
| 73 | + |
| 74 | +- Line length: 120 characters |
| 75 | +- Add clear and concise comments to explain non-obvious logic |
| 76 | +- All code, comments, and documentation must be in **English** |
| 77 | +- Follow existing patterns in the codebase |
| 78 | + |
| 79 | +### Documentation |
| 80 | + |
| 81 | +Documentation is built with MkDocs Material. To preview locally: |
| 82 | + |
| 83 | +```bash |
| 84 | +uv run mkdocs serve |
| 85 | +``` |
| 86 | + |
| 87 | +## How to Contribute |
| 88 | + |
| 89 | +### Reporting Bugs |
| 90 | + |
| 91 | +Use the [Bug Report](https://github.com/Morry98/fastapi-task-manager/issues/new?template=bug_report.yml) issue template. Include: |
| 92 | +- Steps to reproduce |
| 93 | +- Expected vs actual behavior |
| 94 | +- Python version and OS |
| 95 | +- Relevant logs or error messages |
| 96 | + |
| 97 | +### Suggesting Features |
| 98 | + |
| 99 | +Use the [Feature Request](https://github.com/Morry98/fastapi-task-manager/issues/new?template=feature_request.yml) issue template. Please describe: |
| 100 | +- The problem your feature would solve |
| 101 | +- Your proposed solution |
| 102 | +- Any alternatives you considered |
| 103 | + |
| 104 | +### Submitting Pull Requests |
| 105 | + |
| 106 | +1. **Open an issue first** to discuss the change, unless it's a small fix |
| 107 | +2. Create a branch from `main` |
| 108 | +3. Write your code following the project's code style |
| 109 | +4. Add or update tests as needed |
| 110 | +5. Ensure all checks pass (`pre-commit run --all-files` and `uv run pytest`) |
| 111 | +6. Update documentation if your change affects the public API |
| 112 | +7. Submit your PR against the `main` branch |
| 113 | + |
| 114 | +#### PR Guidelines |
| 115 | + |
| 116 | +- Keep PRs focused — one feature or fix per PR |
| 117 | +- Write a clear title and description |
| 118 | +- Reference related issues (e.g., `Closes #123`) |
| 119 | +- Be responsive to review feedback |
| 120 | + |
| 121 | +## Project Structure |
| 122 | + |
| 123 | +``` |
| 124 | +src/fastapi_task_manager/ |
| 125 | +├── task_manager.py # Entry point, FastAPI lifespan integration |
| 126 | +├── task_group.py # Task grouping and registration |
| 127 | +├── runner.py # Stream mode orchestrator |
| 128 | +├── leader_election.py # Distributed leader election via Redis |
| 129 | +├── coordinator.py # Task scheduling and stream publishing |
| 130 | +├── stream_consumer.py # Redis Streams consumer groups |
| 131 | +├── reconciler.py # Stale/failed task recovery |
| 132 | +├── statistics.py # Execution history tracking |
| 133 | +├── config.py # Pydantic configuration model |
| 134 | +├── redis_keys.py # Redis key pattern definitions |
| 135 | +├── task_router_services.py # Management API service layer |
| 136 | +├── async_utils.py # Shared async utilities |
| 137 | +└── schema/ # Pydantic response models |
| 138 | +``` |
| 139 | + |
| 140 | +## License |
| 141 | + |
| 142 | +By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE). |
0 commit comments