How krishna-kumargupta/smart-code-reviewer works
Purpose and System Shape
Smart Code Reviewer automates GitHub pull-request analysis and feedback. The repository contains four deployable concerns: a React dashboard, a Node API/GitHub integration layer, a Node webhook ingress/queue service, and a Python FastAPI/Celery review worker. The Python review-agent is the primary analysis pipeline described by the README.
User Application and API Boundary
The browser application boots at frontend/src/main.jsx and routes from frontend/src/App.jsx. It uses Supabase-backed authentication via frontend/src/context/AuthContext.jsx, protects dashboard/admin areas through frontend/src/layouts/ProtectedRoute.jsx and frontend/src/layouts/AdminRoute.jsx, and calls backend/GitHub/review endpoints through frontend/src/services/api.js, frontend/src/services/github.api.js, and frontend/src/services/reviewService.js.
The Node backend entry point is backend/server.js. It exposes profile, admin, review, and GitHub routes (backend/src/routes/review.routes.js, backend/src/routes/profile.js, backend/src/github/routes/githubRoutes.js) with JWT and admin middleware at backend/src/middleware/verifyJWT.js and backend/src/middleware/isAdmin.js.
Identity, Persistence, and Repository Connection
Supabase/PostgreSQL is the shared application persistence and authentication boundary. Backend access is configured in backend/src/config/supabase.js and privileged service access in backend/src/services/supabaseAdmin.js; schema evolution is captured in supabase/schema.sql and supabase/migrations/002_github_accounts.sql.
GitHub OAuth/token and repository lifecycle logic are concentrated under backend/src/github/services/githubOAuthService.js, backend/src/github/services/githubTokenService.js, and backend/src/github/services/githubRepositorySyncService.js. This layer maps authenticated application users to GitHub accounts, access tokens, tracked repositories, and webhook setup.
GitHub Event Ingress and Dispatch
There are two webhook-facing implementations: GitHub integration routes in the backend (backend/src/github/routes/githubWebhookRoutes.js) and a dedicated webhook service rooted at webhook-service/server.js. The dedicated service verifies GitHub signatures in webhook-service/src/utils/githubWebhookVerifier.js, handles events in webhook-service/src/controllers/webhookController.js, and enqueues accepted work through webhook-service/src/services/webhookQueueService.js.
Redis is therefore the asynchronous handoff boundary between short-lived webhook processing and review execution; its connection configuration is webhook-service/src/config/redis.js. GitHub webhook authenticity must be established before queueing.
Review-Agent Runtime and Task Orchestration
The Python service starts at review-agent/app/main.py. It has service authentication middleware in review-agent/app/auth/middleware.py, application configuration in review-agent/app/config.py, and a Celery application in review-agent/app/celery_app.py. review-agent/app/tasks.py defines background review execution, allowing webhook/API requests to return independently of repository analysis.
The worker has its own database models/session boundary at review-agent/app/db/models.py and review-agent/app/db/session.py; integration or ownership relative to Supabase should be treated as a deployment/data-contract decision.
Review Pipeline
A queued PR review fetches repository and diff context through review-agent/app/repo/fetch.py and review-agent/app/repo/diff.py. It then limits/analyzes changed-code context using the impact slicer (review-agent/app/slicing/graph.py, review-agent/app/slicing/budget.py, review-agent/app/slicing/symbols.py).
Parallel or composed analysis domains include structural checks and circular dependency detection (review-agent/app/structure/checker.py, review-agent/app/structure/circular_deps.py) plus dependency vulnerability scanning through OSV (review-agent/app/vuln/osv_runner.py, review-agent/app/vuln/osv_parser.py). Language-specific structural rules live in review-agent/app/structure/rules/.
AI review is orchestrated with LangGraph in review-agent/app/review/langgraph_review.py, using model access in review-agent/app/review/llm_client.py and prompts in review-agent/app/review/prompts.py. Findings are scored and rendered into a unified report by review-agent/app/merge/scorer.py and review-agent/app/merge/report.py.
Outputs and External Services
The worker publishes completed review feedback back to GitHub through review-agent/app/notify/github_comment.py; optional email notification is isolated in review-agent/app/notify/email_client.py. Material external dependencies are GitHub OAuth/API/webhooks, OpenAI-compatible LLM access, OSV Scanner, Redis/Celery, and PostgreSQL/Supabase. Container composition begins at docker-compose.yml, while the review worker’s container contract is review-agent/Dockerfile.
Main entry points: server.js Node API · githubOAuthService.js GitHub account lifecycle · fetch.py Repository and diff fetch · graph.py Impact slicing
Components 22
Dashboard
- React application · Authenticated dashboard for review and repository workflows.
frontend/src/main.jsx - Auth and route guards
frontend/src/context/AuthContext.jsx - API clients
frontend/src/services/api.js
Node API & GitHub
- Node API · Profiles, administration, review, and GitHub endpoints.
backend/server.js - JWT and admin guard
backend/src/middleware/verifyJWT.js - GitHub account lifecycle · Manages OAuth tokens, tracked repositories, and webhook setup.
backend/src/github/services/githubOAuthService.js - Backend webhook routes
backend/src/github/routes/githubWebhookRoutes.js
Webhook Ingress
- Webhook service · Short-lived GitHub event receiver and dispatcher.
webhook-service/server.js - Signature verification
webhook-service/src/utils/githubWebhookVerifier.js - Event queue publisher
webhook-service/src/services/webhookQueueService.js
Review Agent
- FastAPI review service · Authenticated review runtime and task entry point.
review-agent/app/main.py - Celery review tasks · Runs reviews independently of request handling.
review-agent/app/tasks.py - Repository and diff fetch
review-agent/app/repo/fetch.py - Impact slicing · Bounds changed-code context before analysis.
review-agent/app/slicing/graph.py - Structure and vulnerability checks · Combines structural rules, dependency cycles, and OSV scanning.
review-agent/app/structure/checker.py - LangGraph AI review
review-agent/app/review/langgraph_review.py - Scoring and report
review-agent/app/merge/report.py - GitHub feedback publisher
review-agent/app/notify/github_comment.py
Other components
- Supabase / PostgreSQL · Shared application authentication and persistence boundary.
supabase/schema.sql - GitHub · OAuth, repositories, pull requests, and webhook source.
- Redis · Queue handoff and Celery broker.
webhook-service/src/config/redis.js - LLM and OSV Scanner
Connections 27
- React application → Auth and route guards: authenticates
- Auth and route guards → Supabase / PostgreSQL: Supabase auth
- React application → API clients: invokes
- API clients → Node API: API requests
- Node API → JWT and admin guard: protects routes
- Node API → Supabase / PostgreSQL: profiles and app data
- Node API → GitHub account lifecycle: GitHub routes
- GitHub account lifecycle → GitHub: OAuth, tokens, repositories
- GitHub account lifecycle → Supabase / PostgreSQL: account and repository mapping
- GitHub → Backend webhook routes: webhook events
- GitHub → Webhook service: webhook events
- Webhook service → Signature verification: verifies first
- Signature verification → Event queue publisher: accepted event
- Event queue publisher → Redis: enqueue
- Redis → Celery review tasks: dispatch review
- FastAPI review service → Celery review tasks: starts tasks
- Celery review tasks → Repository and diff fetch: fetch PR context
- Repository and diff fetch → GitHub: repository and diff API
- Repository and diff fetch → Impact slicing: changed context
- Impact slicing → Structure and vulnerability checks: bounded code context
- Impact slicing → LangGraph AI review: bounded code context
- Structure and vulnerability checks → LLM and OSV Scanner: OSV vulnerability scan
- LangGraph AI review → LLM and OSV Scanner: model inference
- Structure and vulnerability checks → Scoring and report: findings
- LangGraph AI review → Scoring and report: findings
- Scoring and report → GitHub feedback publisher: completed feedback
- GitHub feedback publisher → GitHub: PR comments