Live Public Demonstration: https://VinayKumar2320.github.io/CodeImpact/
Instant interactive exploration: view pull request risk scoring across all 4 risk tiers (LOW,MEDIUM,HIGH,CRITICAL), inspect Tree-sitter dependency graphs, examine TreeSHAP feature attributions, and run intelligent CI test selection with zero setup required.
CodeImpact is a developer tools and continuous integration platform that analyzes pull requests before merge. It reconstructs AST syntactical differences, calculates cyclomatic complexity deltas (
Unlike generic LLM-based code reviewers that hallucinate risk judgments without architectural grounding, CodeImpact is built on measurable, deterministic software engineering principles:
- AST-Level Change Localization: Uses Tree-sitter (Python and TypeScript) to map raw line-diff hunks to exact enclosing function, method, and class scopes.
-
Cyclomatic Complexity Deltas (
$\Delta CC$ ): Measures branch and decision logic growth across modified scopes using Radon and AST control flow inspection. - Transitive Dependency Reification: Uses NetworkX to reconstruct call and import graphs, tracking downstream callers, fan-in, fan-out, and betweenness centrality.
- Calibrated Supervised Risk Modeling: Trained on 1,200 real pull requests mined across major open-source repositories using chronological temporal splits (zero look-ahead leakage), outperforming change-size and churn baselines by +69.2% in PR-AUC.
- Budgeted Greedy Marginal Test Selection: Formulates test selection as a budgeted maximum coverage problem, achieving 100% defect recall with a 73.7% reduction in test execution time.
- Local TreeSHAP Explainability: Explains every risk prediction via game-theoretic Shapley attributions, detailing the exact features driving elevated risk or mitigating factors.
- GitHub-Native Workflow: Ingests HMAC-SHA256 verified webhooks with Redis deduplication and automatically publishes rich, collapsible Markdown summaries to GitHub Check Runs.
flowchart TD
subgraph GitHub ["GitHub Infrastructure"]
PR[Pull Request Opened / Synchronize]
Checks[GitHub Check Run UI]
end
subgraph Ingestion ["Ingestion & Verification"]
Receiver["/api/v1/webhooks/github"]
HMAC[HMAC-SHA256 Verification]
Dedupe[Redis SETNX Deduplication]
end
subgraph Queue ["Asynchronous Task Queue"]
RQ[Redis Queue Worker]
end
subgraph StaticEngine ["Static Code Analysis Engine"]
DiffParser[Unified Diff Parser]
TS[Tree-sitter AST Parser Python / TS]
Radon[Radon Cyclomatic Complexity Engine]
DepGraph[NetworkX Dependency Graph Engine]
GitChurn[Git Churn & Volatility Analyzer]
end
subgraph MLEngine ["ML Risk Engine & Explainability"]
FeatAgg[25-Feature Tabular Aggregator]
Model[Calibrated XGBoost Ensemble]
SHAP[TreeSHAP Feature Attributions]
end
subgraph TestEngine ["Intelligent Test Selection Engine"]
TestMap[Multi-Tier Coverage Context Mapper]
Optimizer[Budgeted Marginal Coverage Optimizer]
end
subgraph Persistence ["Persistence & API Layer"]
PG[(PostgreSQL 16 / SQLite Engine)]
FastAPI[FastAPI REST API]
ReactUI[React 18 + Tailwind Dashboard]
end
PR --> Receiver
Receiver --> HMAC
HMAC --> Dedupe
Dedupe --> RQ
RQ --> DiffParser
DiffParser --> TS
TS --> Radon
TS --> DepGraph
DiffParser --> GitChurn
Radon --> FeatAgg
DepGraph --> FeatAgg
GitChurn --> FeatAgg
FeatAgg --> Model
Model --> SHAP
TS --> TestMap
DepGraph --> TestMap
Model --> Optimizer
TestMap --> Optimizer
SHAP --> PG
Optimizer --> PG
PG --> FastAPI
FastAPI --> ReactUI
FastAPI --> Checks
Evaluated against 135 chronological holdout pull requests with 17.0% positive defect prevalence:
| Model Architecture | PR-AUC | ROC-AUC | Brier Score | Expected Calibration Error (ECE) | F1-Score | Defect Recall |
|---|---|---|---|---|---|---|
| Majority Baseline | 0.1333 | 0.5000 | 0.1161 | 0.1333 | 0.0000 | 0.00% |
| Change Size Heuristic | 0.1724 | 0.5772 | 0.1183 | 0.1582 | 0.0000 | 0.00% |
| Logistic Regression | 0.1351 | 0.5047 | 0.2522 | 0.2641 | 0.2319 | 44.44% |
| Random Forest | 0.1473 | 0.5071 | 0.2036 | 0.2180 | 0.0976 | 11.11% |
| XGBoost (CodeImpact) | 0.2256 | 0.5765 | 0.1775 | 0.1330 | 0.2857 | 30.43% |
Cross-Repository Generalization (pallets/flask holdout): Preserved 98.5% of ROC-AUC (0.5681 vs 0.5765) and 77.3% of PR-AUC on an unseen code repository without fine-tuning.
Evaluated on 150 test cases (
| Strategy | Tests Selected | Duration | Time Savings % | Regressions Caught | Defect Recall % |
|---|---|---|---|---|---|
| Full Test Suite | 150 | 113.43s | 0.0% | 4 / 4 | 100.0% |
| Random Selection (Budgeted) | 56 | 29.99s | 73.56% | 0 / 4 | 0.0% |
| Path Heuristic (Budgeted) | 24 | 29.89s | 73.65% | 4 / 4 | 100.0% |
| Dependency-Only (Budgeted) | 12 | 15.97s | 85.92% | 4 / 4 | 100.0% |
| CodeImpact Marginal Optimizer | 76 | 29.86s | 73.67% | 4 / 4 | 100.0% |
The frontend is built with React 18, TypeScript, Tailwind CSS, React Flow, and Recharts:
- Repository Overview: High-level KPI metrics (total PRs analyzed, average risk score, overall test time saved, risk distribution bar charts).
- Pull Request Risk Details: Radial risk gauge with confidence interval, risk tier badges (
LOW,MEDIUM,HIGH,CRITICAL), and TreeSHAP waterfall attribution breakdown. - Interactive Change Impact Graph: Visualizes altered symbols, callers, and callees in a draggable React Flow node canvas with an interactive node inspector showing degree and betweenness centrality.
- Test Intelligence Suite: Filterable table of recommended tests with rank, execution duration, evidence tier, and a one-click copyable
pytestcommand. - ML Analytics & Model Governance: Calibration curves, ROC curves, and cross-repo generalizability comparisons.
- Markdown Report Viewer: Rendered and copyable GitHub Check Run markdown summary.
Populate the database with realistic repositories (tiangolo/fastapi, psf/requests, pallets/flask) and pull requests spanning all 4 risk tiers:
# 1. Setup virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install -r backend/requirements.txt
# 2. Seed realistic repositories, pull requests, AST diffs, and ML predictions
python scripts/bootstrap_demo.py
# 3. Start the FastAPI backend
uvicorn app.main:app --app-dir backend --reload --port 8000
# 4. In a separate terminal, start the React dashboard
cd frontend
npm install
npm run devOpen http://localhost:5173 to explore the populated dashboard!
Launch the complete stack (PostgreSQL 16, Redis 7, FastAPI API, RQ Background Worker, and Nginx Frontend):
# Copy sample configuration
cp .env.example .env
# Build and start all services
docker compose up -d --buildAccess points:
- Web Dashboard: http://localhost:5173 or http://localhost:80
- FastAPI Interactive Docs: http://localhost:8000/docs
- Health Check Probe: http://localhost:8000/api/v1/health
- Prometheus Metrics: http://localhost:8000/api/v1/metrics/prometheus
- Backend: Python 3.12+, FastAPI, SQLAlchemy 2.0 (asyncpg / psycopg2), Alembic, Pydantic v2, Redis, RQ, HTTPX
- Static Analysis: Tree-sitter (
tree-sitter-python,tree-sitter-typescript), Radon, NetworkX, GitPython - Machine Learning: Scikit-learn, XGBoost, SHAP, MLflow, Pandas, NumPy, Joblib
- Frontend: React 18, TypeScript, Vite, Tailwind CSS, TanStack Query, React Flow (
@xyflow/react), Recharts, Lucide Icons - Infrastructure: Docker, Docker Compose, GitHub Actions CI, PostgreSQL 16, Redis 7
All code adheres strictly to static analysis and automated verification standards:
# Run 92 backend tests across unit, integration, and security suites
pytest backend/tests/ -v
# Run Ruff linter and style checks
ruff check backend/ scripts/
ruff format --check backend/ scripts/
# Run MyPy strict static type checking
mypy --config-file backend/pyproject.toml backend/app
# Run Frontend unit tests and production build
npm --prefix frontend test
npm --prefix frontend run buildComprehensive engineering guides are available in the docs/ directory:
- System Architecture Specification
- Dataset Collection & Chronological Splitting
- Feature Engineering & Mathematical Formulations
- Machine Learning Evaluation & Baseline Benchmarks
- Intelligent Test Selection & Optimization
- Security Architecture & Untrusted Code Isolation
- Deployment, Containerization & Operations
- Phase 1 — Project Foundations: Monorepo layout, FastAPI, SQLAlchemy 2.0, Alembic, React + Vite, Docker Compose, CI.
- Phase 2 — GitHub Integration: Webhook HMAC-SHA256 signature verification, Redis deduplication, GitHub API client.
- Phase 3 — Static Code Analysis Engine: Tree-sitter AST parsing, Radon cyclomatic complexity, NetworkX call graphs.
- Phase 4 — Historical Dataset Collection: Chronological splits without look-ahead leakage, 1,200 records across 4 repos.
- Phase 5 — Regression Risk Prediction: 25-feature vector, calibrated XGBoost, TreeSHAP local explainability.
- Phase 6 — Intelligent Test Selection: Coverage mapping, budgeted greedy marginal optimizer, benchmark suite.
- Phase 7 — REST API Endpoints: Analyses, features, dependencies, predictions, recommended tests, Prometheus metrics.
- Phase 8 — React Dashboard: Overview KPI cards, radial risk gauge, interactive React Flow dependency graph, test selection.
- Phase 9 — GitHub Checks Publisher: Collapsible Markdown summaries, check run formatting, CLI pytest generator.
- Phase 10 — Security Hardening: Timing-safe HMAC, path traversal fuzzing, corrupted diff resilience, token isolation.
- Phase 11 — End-to-End Testing: Webhook-to-dashboard workflow tests, failure injection, synchronizing superseded commits.
- Phase 12 — Empirical Benchmarks: 5-model comparison, PR-AUC, ROC-AUC, Brier score, ECE, test selection savings.
- Phase 13 — Containerization & Demo: Multi-stage Dockerfiles, zero-config
bootstrap_demo.pyscript. - Phase 14 — Comprehensive Documentation: In-depth technical specifications across all 7 architectural domains.