Applied AI / Developer Tooling
AI-Powered Code Review System
A FastAPI platform with repository and pull-request routes, analysis services, persistence, security tooling, background workers, tests, and deployment configuration for AI-assisted review workflows.
Repository evidence: app routes/models/services, tests, Docker/Kubernetes/Terraform, Prometheus/Grafana, and GitHub Actions. README scale and benchmark claims are excluded unless independently verified.
Engineering snapshot
What the repository demonstrates
- Versioned API router with review/repository/health modules
- SQLAlchemy models and Alembic migrations
- AI, RAG, code-analysis, security-scan, and complexity services
- Pytest modules across auth, API, AI, integration, performance, and security
- Container, Kubernetes, Terraform, monitoring, and CI configuration
01
The problem
Pull-request review combines external repository data, code context, static checks, model reasoning, persistence, and user feedback. The system needs clear boundaries so model output can be stored, reviewed, secured, and tested rather than returned as an unstructured prompt response.
02
Engineering requirements
Functional
- Authenticate users and organizations.
- Fetch and analyze repositories and pull requests.
- Persist review and feedback records.
- Expose review, repository, analytics, webhook, security, plugin, and metrics routes.
- Run background work and return health/readiness information.
Non-functional
- Async API and worker-oriented processing.
- Relational persistence and migrations.
- Security controls including JWT/RBAC/API-key paths and audit models.
- Metrics and deployment configuration.
- Testable analysis and API modules.
03
System architecture
The repository contains a FastAPI application, versioned routers, SQLAlchemy/Alembic persistence, AI/RAG and analysis services, Redis/Celery-related infrastructure, frontend code, and operational configuration. The README describes more capabilities than can safely be treated as measured production behavior.
04
Request and data flow
- 01A client authenticates and submits a repository or pull-request review request.
- 02The API validates the request and routes it to review/repository services.
- 03Repository data and changed files are passed into analysis and AI/RAG services.
- 04Review results and feedback are persisted through SQLAlchemy models/migrations.
- 05Long-running work can be handled through worker-oriented infrastructure.
- 06Metrics, health endpoints, logs, and dashboards provide operational hooks.
05
Key engineering decisions
FastAPI for the API boundary
Why: The repository uses async-capable route modules and generated API documentation.
Trade-off: Async route code does not automatically make every downstream provider or database operation non-blocking.
PostgreSQL with SQLAlchemy/Alembic
Why: Reviews, organizations, feedback, keys, and audit records have relational lifecycle and migrations.
Trade-off: Schema evolution and transaction boundaries require operational discipline.
Separate analysis services
Why: GitHub access, AI calls, RAG, complexity, and security scanning have different responsibilities.
Trade-off: More service boundaries mean more failure and test combinations.
Operational configuration in repo
Why: Docker, Kubernetes, Terraform, Prometheus, Grafana, and CI make deployment concerns inspectable.
Trade-off: Configuration presence is not proof that the full topology is deployed or healthy.
06
Deep technical challenge
Problem
The hardest problem is controlling the boundary between repository context and model-generated review so findings remain attributable and actionable.
Why the naive approach fails
A naive implementation would send a PR diff directly to a model and display the response. It would lack durable review history, context retrieval, structured findings, and deterministic checks.
Implemented solution
The repository separates GitHub/repository services, AI/RAG services, code/security/complexity analyzers, persistence models, and API routers. The tests and deployment files provide a broader engineering surface, while exact model quality must be measured with evaluation fixtures.
Edge cases
Provider timeout, GitHub rate limiting, malformed model output, oversized diffs, partial repository fetches, duplicate webhook delivery, and failed background tasks remain important scenarios.
07
Database and API design
SQLAlchemy models surfaced in app/db/models.py include User, Repository, PullRequest, Review, Feedback, ApiKey, AuditLog, Organization, OrganizationMember, and ReviewFeedback. Alembic is present for schema migration. Redis/Celery infrastructure is also present in configuration.
| Method | Endpoint | Purpose | Auth |
|---|---|---|---|
| POST | /api/v1/review/analyze | Start pull-request analysis. | Auth/API key path in application |
| GET | /api/v1/review/{review_id} | Read a review result. | Protected route |
| GET | /api/v1/health | Health/readiness/liveness checks. | Public/operational |
| POST | /api/v1/webhooks/* | Receive repository events. | Webhook verification path |
| GET | /metrics | Expose Prometheus-oriented metrics. | Operational |
08
Security
Implemented
- JWT/password/API-key-related security modules.
- RBAC and organization models.
- Audit log model.
- Security scanner, dependency scanner, SBOM, CodeQL, and pre-commit configuration surfaced.
Potential improvements
- Verify every route has consistent authorization tests.
- Treat provider and GitHub tokens as runtime secrets only.
- Add adversarial tests for prompt injection and malicious repository content.
- Document webhook signature and replay protection.
09
Failure handling
Evidence
- Health/readiness/liveness route modules.
- Test modules for auth, integration, AI, and security.
- Worker/deployment configuration for background processing.
- Metrics and logging configuration.
Remaining scenarios
- README failure-recovery numbers are not verified runtime evidence.
- Model fallback, circuit-breaker, and queue semantics should be confirmed in executable code before claiming them.
- Duplicate webhook/idempotency behavior needs explicit documentation.
10
Performance, scalability, and observability
Performance and scalability
- Async route and worker-oriented components are present.
- Redis, Celery, database indexes/configuration, and Prometheus files provide scalability hooks.
- No formal benchmark was included in the repository evidence reviewed for this case study.
- README throughput, uptime, and coverage figures are intentionally not repeated as verified metrics.
Observability
- Prometheus metrics and Grafana provisioning.
- Health/readiness/liveness endpoints.
- Structured logging and audit model paths.
- Future: connect alert policies to tested SLOs and trace review IDs across workers/providers.
11
Testing and code quality
- Pytest modules cover auth, review API, AI service, complexity, integration, performance, language detection, helpers, and security scanner areas.
- CI workflow and security checks are present.
- Measured coverage should be reported only from an executed current test run.
12
DevOps and deployment
- Docker and Docker Compose files.
- Kubernetes manifests and HPA/configuration.
- Nginx, Prometheus, Grafana, Terraform, and GitHub Actions/CodeQL configuration.
- These files establish deployment intent and configuration, not proof of a live production deployment.
13
Engineering trade-offs
Model reasoning versus deterministic analyzers: richer context versus reproducibility and cost.
PostgreSQL versus document storage: relational review history and organization relationships versus schema rigidity.
Background workers versus synchronous review: responsiveness versus queue/retry complexity.
Configuration-rich deployment versus simpler local setup: operational flexibility versus maintenance surface.
14
What I would improve next
Short term
- Run the current suite and publish measured coverage only.
- Add fixtures for malformed model output and duplicate webhooks.
- Document route authentication and idempotency.
Medium term
- Build retrieval and review-quality evaluation datasets.
- Add provider timeout/circuit-breaker tests.
- Trace a review from webhook/request through worker and persistence.
Production scale
- Tune queue backpressure and provider cost controls.
- Partition or archive review history based on measured growth.
- Harden sandboxing and tenant isolation for untrusted repository content.
15
Key learnings
- AI developer tooling needs deterministic analyzers alongside model reasoning.
- Structured persistence makes model output reviewable and auditable.
- Operational files are valuable only when they are exercised by CI and deployment tests.
- Unverified README numbers should not become portfolio claims.
16
Interview questions
- How would you control hallucinated review findings?
- Why combine static analysis and RAG?
- How should duplicate webhooks be handled?
- What belongs in PostgreSQL versus Redis?
- How would you test provider failure?
- How would you secure untrusted repository content?
- How would you evaluate review quality?
- How would you scale worker queues without losing auditability?
Why this project matters
Recruiter-facing summary
This is the strongest AI/backend case study because it connects API design, persistence, security, asynchronous processing, model workflows, testing, and deployment configuration. The right presentation emphasizes the breadth of the implementation while separating repository evidence from aspirational README metrics.