Time. Space. Software. It's more than a linear path โ it's a prism of endless possibilities where a single change can branch into infinite unseen consequences.
WHAT IF...? is a software engineering impact intelligence platform. Before you merge a pull request or modify a critical file, WHAT IF...? traverses your codebase's Abstract Syntax Tree (AST) and historical Git evolution to compute the deterministic downstream blast radius, estimate risk scores, and surface the most qualified code reviewers.
- ๐ Core Pillars
- ๐๏ธ Architectural Architecture
- โก Quick Start
- ๐ฎ WHAT IF Oracle (CI/CD API)
- ๐ฅ Blast Radius Simulator
- ๐ช Multiverse Graph Visualizer
- ๐ก Complete API Reference
- โ๏ธ Configuration
- ๐งช Testing
- ๐ค Contributing
- ๐ License
- Python Native AST (
ast.parse): Recursively walks Python syntax trees to extract classes, functions, asynchronous definitions, and imports (Import,ImportFrom). - Tree-sitter Integration: Supports JavaScript and TypeScript grammars for cross-file dependency mapping.
- Hierarchical Dotted Import Resolution: Resolves dotted imports (e.g.
fastapi.routing.APIRouterorrequests.sessions.Session) directly to their defining origin source files.
- Direct integration with
GitPythonacross commit trees. - Extracts author telemetry, change frequencies, insertions, deletions, and commit classifications.
- Co-Evolution Coupling: Identifies files that statistically change together across commits, revealing hidden coupling that static AST analysis cannot detect.
- Computes multi-hop propagation using reverse-adjacency Breadth-First Search (BFS) DAG traversal.
- Tri-color classification:
- Structural Inevitability (Cyan): Downstream modules that directly or transitively import the target file.
- Historical Resonance (Purple): Files that frequently co-commit alongside the target.
- The Singularity (White): The collision nexus where code structure and historical developer behavior overlap.
- Answers: "What if I change this file?"
- Computes a quantitative risk score (0โ100) and risk tier (
NONE,LOW,MEDIUM,HIGH,CRITICAL). - Applies change multipliers:
delete(1.4ร),rename(1.25ร),modify(1.0ร),add_dependency(0.85ร). - Analyzes commit history to surface top historical contributors as recommended PR reviewers.
- Outputs copy-pasteable
cURLsnippets and GitHub Actions-ready JSON payloads.
WHAT IF...?/
โโโ ๐ backend/
โ โโโ ๐ fastapi_app/
โ โ โโโ ๐ api/ # REST router endpoints (repositories, oracle, graph, commits)
โ โ โโโ ๐ core/ # Analyzer engine, AST extractors, DB session setup
โ โ โโโ ๐ models/ # SQLAlchemy ORM models (Repository, File, Commit, GraphEdge)
โ โ โโโ ๐ schemas/ # Pydantic validation schemas
โ โ โโโ ๐ services/ # Oracle risk intelligence, Git history, Graph builder, BFS impact
โ โโโ ๐ django_app/ # Django administration suite
โ โโโ ๐ tests/ # Pytest test suite with dynamic repository simulation
โโโ ๐ frontend/ # Cinematic sci-fi command HUD
โ โโโ index.html # Single-page interface with canvas & Oracle decks
โ โโโ app.js # Force simulation, Pan/Zoom, Matrix/Orbital tabs, API client
โ โโโ styles.css # Cyberpunk glassmorphism, responsive HUD styling
โโโ docker-compose.yml # PostgreSQL container stack
โโโ requirements.txt # Backend dependencies
โโโ README.md
- Python โฅ 3.10
- PostgreSQL or Docker
git clone https://github.com/Jeetchavan02/WHATIF.git
cd "WHAT IF"
# Configure environment
cp .env.example .envdocker-compose up -dpython3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtTerminal 1 โ Backend API (Port 8000):
export PYTHONPATH=$PWD
uvicorn backend.fastapi_app.main:app --host 0.0.0.0 --port 8000 --reloadAPI documentation available at http://localhost:8000/docs
Terminal 2 โ Frontend HUD (Port 3000):
python3 -m http.server 3000 --directory frontendOpen http://localhost:3000 in any modern web browser.
The Oracle endpoint is designed for automated pull-request risk assessment and CI/CD pipelines.
curl -X POST http://localhost:8000/api/repositories/1/oracle \
-H "Content-Type: application/json" \
-d '{
"file_path": "fastapi/routing.py",
"change_type": "delete",
"max_depth": 4
}'{
"scenario_id": "WIF-A94F81C2",
"generated_at": "2026-10-20T01:12:21Z",
"repository_id": 10,
"target_file": "fastapi/routing.py",
"change_type": "delete",
"risk_assessment": {
"risk_level": "HIGH",
"impact_score": 100,
"blast_radius_count": 24,
"source_commit_frequency": 15,
"change_multiplier": 1.4
},
"blast_radius": [
{ "path": "fastapi/applications.py", "language": "python", "depth": 1 },
{ "path": "fastapi/openapi/utils.py", "language": "python", "depth": 1 },
{ "path": "tests/test_route_handler_wrapping.py", "language": "python", "depth": 1 }
],
"suggested_reviewers": [
{ "name": "Lead Maintainer", "email": "maintainer@example.org", "touch_count": 18 },
{ "name": "Module Contributor", "email": "contributor@example.org", "touch_count": 4 }
],
"summary": "Changing 'routing.py' via 'delete' affects 24 file(s) with HIGH risk (score 100/100). 2 reviewer(s) suggested based on commit history."
}- Instant Search: Type file substrings into the
๐ Search files...bar to filter candidates. - Interactive Node Selection: Click any file chip or canvas node to select it as the blast origin.
- Simulation Execution: Adjust depth (1โ10) and hit Simulate Reality Collapse.
- Causal Shockwaves: Shockwaves ripple outwards across the graph while the downstream impact lists populate in real-time.
The canvas visualizer operates on an interactive 2D physics and matrix projection engine:
- Orbital Force: Physics simulation featuring gravitational pull, spring tension, and photon particle conduits.
- Concentric Rims: Projects components radially outward by layer depth.
- Matrix Grid: Aligns complex architectural layers in an organized inspection grid.
- Interactive Controls:
- Pan: Click and drag empty space to pan across space.
- Zoom: Scroll wheel or trackpad pinch to zoom relative to cursor position (
+,โ,โฒ Resetbuttons). - Draggable Nodes: Grab any node to detach it and inspect local relationships.
- High-DPI Retina Ready: Scales dynamically using
window.devicePixelRatio.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/repositories |
Ingest and analyze a Git repository URL or local path |
DELETE |
/api/repositories/{id} |
Completely erase a repository timeline and associated graph data |
PATCH |
/api/repositories/{id}/url |
Update repository URL configuration |
POST |
/api/repositories/{id}/whatif |
Run multi-depth BFS blast radius propagation |
POST |
/api/repositories/{id}/oracle |
Query WHAT IF Oracle for CI/CD risk assessment & reviewer ranking |
GET |
/api/repositories/{id}/graph |
Retrieve node and edge graph geometry |
GET |
/api/repositories/{id}/files |
List all discovered source files |
GET |
/api/repositories/{id}/dependencies |
Inspect parsed AST cross-file dependency edges |
GET |
/api/repositories/{id}/commits |
Paginated commit history stream |
Set via environment variables or .env:
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
postgresql://... |
Connection URI for PostgreSQL database |
WHATIF_MAX_COMMITS |
400 |
Maximum historical commits indexed per repository for performance |
PORT |
8000 |
FastAPI server listening port |
Run the Pytest suite to verify AST extraction, reverse BFS dependency propagation, and Oracle endpoints:
export PYTHONPATH=$PWD
pytest -vReal analysis performance measured on a standard MacBook Air (M-series, local execution):
| Target Repository | Components Parsed | AST Dependencies | Indexed Commits | Total Analysis Time | Oracle Query Latency |
|---|---|---|---|---|---|
psf/requests |
128 | 591 | 400 | ~14s | < 35ms |
pallets/flask |
236 | 675 | 400 | ~19s | < 42ms |
tiangolo/fastapi |
3,192 | 5,273 | 400 | ~48s | < 60ms |
Query Latency Note: The Oracle CI/CD API operates strictly on pre-computed graph indices stored in PostgreSQL. Traversal complexity is
$O(F + C)$ where$F$ is files in the blast radius and$C$ is commits touching those files, returning results in under 60 milliseconds.
While the core dependency traversal and AST extraction are deterministic and functional, consider the following current operational boundaries:
- Dynamic & Runtime Imports: Static AST extraction parses explicit
importandfrom ... importstatements. Dynamic imports (e.g.importlib.import_module()) and metaprogramming attribute access are not statically resolvable. - Cross-Language Boundaries: Python AST and Tree-sitter JS/TS parse dependencies within their respective module ecosystems. Foreign Function Interfaces (FFI / Cython) or network RPC boundaries are mapped via Git co-change coupling rather than static AST edges.
- Privacy & Telemetry: When running the Oracle endpoint in public environments, reviewer suggestions are derived directly from Git commit author metadata. Anonymization or user-ID hashing should be enabled if deploying across proprietary codebases with strict PII requirements.
- Historical Ground-Truth Validation: Benchmarking evaluates predicted impact sets against ground-truth commit diffs. Full continuous backtesting against production outage logs is a planned milestone.
- Fork the repository
- Create your branch:
git checkout -b feature/cosmic-enhancement - Commit your changes:
git commit -m 'feat: introduce new feature' - Push to branch:
git push origin feature/cosmic-enhancement - Open a Pull Request
Distributed under the MIT License. See LICENSE for details.