Problem
Automate the first review pass for Python PRs without flooding authors with warnings from unchanged code. Results should appear inside GitHub and remain available for history.
A GitHub App for Python Pull Request review. It analyses changed lines only, combines Ruff with GigaChat insights, stores the result, and publishes a structured PR comment.
The system sits across several external services and separates event acceptance from heavy diff analysis.
Automate the first review pass for Python PRs without flooding authors with warnings from unchanged code. Results should appear inside GitHub and remain available for history.
FastAPI verifies the webhook and queues a Celery task. The worker fetches the diff, runs Ruff and GigaChat, persists the review, and publishes through the GitHub API.
Each step has a separate responsibility: event trust, diff retrieval, static analysis, AI enrichment, and publication.
FastAPI validates the GitHub HMAC signature and rejects events that cannot be tied to a trusted sender.
The HTTP handler does not perform review synchronously; event data is delegated to Celery through Redis.
The worker fetches changed lines and reads .codereview.yml from the PR branch, applying select, ignore, and exclude rules.
Ruff produces deterministic findings, while GigaChat adds architecture, security, and refactoring recommendations.
The result is stored in PostgreSQL and published as a structured Pull Request comment; a short Telegram notification is optional.
The architecture preserves a useful result even when the external AI dependency partially fails.
The webhook signature is checked at ingress, so an untrusted event never reaches the task queue.
The bot focuses on PR lines instead of repeating the repository's entire accumulated technical debt.
A GigaChat outage reduces review depth but does not stop baseline static analysis.
Teams can change rules alongside code without restarting the service or sharing one global configuration.
The repository documents the path from a local Docker environment to a GHCR image and VPS deployment.
Unit tests use pytest, pytest-asyncio, and mocks to isolate GitHub and AI integrations.
GitHub App installations, repositories, and review results are persisted in PostgreSQL with schema migrations.
The workflow runs tests, builds a container, publishes the image, and deploys it over SSH.
The system reduces integration risk without hiding the limits of AI-assisted review.
When GigaChat is unavailable, Ruff still runs, but architecture and semantic recommendations become more limited.
The cache is simple and fast, but horizontal scaling would require a shared store or coordinated refresh strategy.
The GitHub App key, webhook secret, AI credentials, and SSH access must stay outside the repository and be reviewed regularly.
The key outcome is a resilient combination of deterministic tooling and AI: Ruff provides a baseline signal, while GigaChat adds context when available.
The README documents local setup, GitHub App configuration, .codereview.yml, Docker, migrations, and CI/CD.