Skip to content

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeImpact Logo

CodeImpact

Intelligent Code Dependency & Blast Radius Impact Analyzer
"If I change this function, what else could break?"

Python FastAPI React 19 TypeScript Vite Tests License


πŸ“ Description

Short Description (GitHub About):
An intelligent AST-powered Code Knowledge Graph & Blast Radius Analyzer that maps cascading dependencies, flags breaking API/database mutations, detects untested danger zones, and simulates 'what-if' signature changes before deployment.

CodeImpact is a next-generation static analysis and architecture observability engine. Modern distributed and modular codebases suffer from hidden dependency chains where altering a single function signature can silently break downstream services, external HTTP controllers, database repositories, or untested business logic.

CodeImpact solves this by ingesting multi-language codebases (C#, TypeScript, JavaScript, Python), parsing Abstract Syntax Trees (ASTs), building a directed Code Knowledge Graph (CKG), and calculating an actionable 0–100 blast radius risk score with live Monaco-powered simulation before code is merged.


🏷️ Repository Tags & Topics

dependency-analyzer, blast-radius, code-knowledge-graph, static-analysis, ast-parser, impact-analysis, software-architecture, developer-tools, refactoring, code-quality, pull-request-card, monaco-editor, xyflow, react-flow, fastapi, python3-12, react19, typescript, csharp, tree-sitter, codeimpact
Category Tags & Keywords
Core Domain dependency-analyzer β€’ blast-radius β€’ code-knowledge-graph β€’ static-analysis β€’ ast-parser β€’ impact-analysis
Languages & Runtimes python3-12 β€’ fastapi β€’ react19 β€’ typescript β€’ csharp β€’ javascript β€’ node-ast β€’ vite β€’ tailwindcss
Graph & Visualization networkx β€’ xyflow β€’ react-flow β€’ force-directed-graph β€’ data-visualization
Dev Tooling & DX monaco-editor β€’ developer-tools β€’ refactoring β€’ code-quality β€’ code-review β€’ pull-request-card

πŸ“– Overview

CodeImpact is an AST-powered developer analysis platform that parses source code, constructs a Code Knowledge Graph (CKG), and calculates the complete blast radius of modifying any function, method, or contract before deployment or code review.

It automatically identifies:

  • πŸ” Upstream Caller Cascade: Direct and transitive callers affected by a code modification.
  • 🌐 External HTTP Endpoint Taint: Public controllers and API routes exposed to breaking changes.
  • πŸ’Ύ Database Operations in Call Path: State mutations, queries, and ORM repository operations.
  • πŸ§ͺ Untested Danger Zones: Critical execution paths that have zero unit test coverage.
  • 🚨 Breaking Signature Change Prediction: Exact parameter count mismatches and type discrepancies across call sites.
  • πŸ› οΈ "What-If" Simulation Sandbox: Interactive Monaco Editor to experiment with signature changes and diagnose breaking callers live.

🌟 Key Features

πŸ” Multi-Language AST Engine

  • C# (.cs): Classes, methods, namespaces, parameters, return types, ASP.NET Core controller routing ([HttpGet], [HttpPost]), database attributes, and unit tests.
  • TypeScript & JavaScript (.ts, .tsx, .js, .jsx): High-performance Node.js TypeScript Compiler AST parser + crash-resilient Tree-sitter fallback. Extracts arrow functions (const fn = () => ...), function expressions, class property methods, return type annotations, and nested call sites.
  • Python (.py): Classes, functions, parameters, PyTest/unittest test discovery, and call hierarchy resolution.

⚑ Blast Radius & Risk Scorer (0–100)

Every symbol is scored across four weighted dimensions: $$\text{Blast Score} = \min(100, \text{Fan-Out (35pts)} + \text{Controllers (30pts)} + \text{Database (20pts)} + \text{Untested Penalty (15pts)})$$

  • πŸ”΄ CRITICAL ($\ge 75$): Extensive API endpoint exposure or deep database mutations.
  • 🟠 HIGH ($50 - 74$): Multiple controllers or intermediate services affected.
  • 🟑 MEDIUM ($25 - 49$): Contained service caller chain.
  • 🟒 LOW ($< 25$): Isolated footprint with high test coverage.

πŸ“Š Interactive Ripple Energy Graph (@xyflow/react)

  • Force-directed topological view organized into 4 layered tiers: Controllers/Tests $\rightarrow$ Callers $\rightarrow$ Target $\rightarrow$ Repositories.
  • Animated energy packet ripple pulses propagating along the blast radius path.
  • Minimap, zoom controls, and custom node telemetry cards.

πŸ› οΈ "What-If" Code Sandbox (Monaco Editor)

  • Side-by-side Monaco editor displaying the target symbol's source code.
  • Interactive virtual signature modifier: add/remove parameters, specify types, default values, and experimental return types.
  • Live compiler breaking-change diagnostics identifying exact breaking call sites with line numbers and recommended fixes.

πŸ“¦ Direct Project Upload & Local Scanning

  • Drag-and-Drop .zip Upload: Safely extracts and analyzes project archives with path traversal guards.
  • Local Directory Scanning: Enter any machine path (e.g. D:\projects\my-service) for instant AST parsing.
  • Project Deduplication: Auto-detects dominant language and prevents duplicate dropdown entries.

πŸ“‹ 1-Click GitHub PR Blast Radius Card

  • Generates formatted GitHub-flavored markdown summaries with risk badges, impact metric tables, and affected endpoint lists.
  • 1-click clipboard copy and full JSON audit report download for CI/CD pipeline integration.

πŸ—οΈ Architecture

flowchart TB
    subgraph Input["Codebase Ingestion"]
        A1["C# (.cs)"]
        A2["TypeScript/JavaScript (.ts, .js)"]
        A3["Python (.py)"]
        ZIP["Project ZIP / Local Directory"]
    end

    subgraph Engine["CodeImpact Core Engine"]
        P1["AST Parser Engine<br/>(Node TS Compiler + Tree-sitter)"]
        CKG["Code Knowledge Graph<br/>(NetworkX Directed Graph)"]
        BRA["Blast Radius Analyzer<br/>(Upstream/Downstream Traversal)"]
        SIM["Change Simulator<br/>('What-If' Parameter & Return Checks)"]
    end

    subgraph API["FastAPI High-Performance Server (:8000)"]
        EP1["/api/scan & /api/upload-project"]
        EP2["/api/impact & /api/simulate"]
        EP3["/api/graph-data & /api/export-report"]
    end

    subgraph UI["React 19 Interactive Dashboard (:5173)"]
        HUD["Impact HUD & Risk Meter"]
        RF["Ripple Energy Graph (@xyflow)"]
        SBOX["Monaco 'What-If' Sandbox"]
        MODAL["GitHub PR Card Exporter"]
    end

    Input --> P1
    ZIP --> P1
    P1 --> CKG
    CKG --> BRA
    CKG --> SIM
    BRA --> API
    SIM --> API
    API --> UI
Loading

πŸš€ How to Run the Project

Prerequisites

Ensure you have the following installed:

  • Python 3.10+ (Tested on Python 3.12)
  • Node.js 18+ (Tested on Node.js 20+)
  • Git

Step 1: Clone Repository

git clone https://github.com/Humaam-04-06/CodeImpact.git
cd CodeImpact

Step 2: Backend Setup & Launch

On Windows (PowerShell):

# 1. Create Python virtual environment
python -m venv backend\venv

# 2. Activate virtual environment
backend\venv\Scripts\activate

# 3. Install backend dependencies
pip install -r backend\requirements.txt

# 4. Start the FastAPI backend server
python -m uvicorn backend.main:app --port 8000 --reload

On macOS / Linux:

# 1. Create Python virtual environment
python3 -m venv backend/venv

# 2. Activate virtual environment
source backend/venv/bin/activate

# 3. Install backend dependencies
pip install -r backend/requirements.txt

# 4. Start the FastAPI backend server
python3 -m uvicorn backend.main:app --port 8000 --reload

🌐 Backend API Documentation: Open http://127.0.0.1:8000/docs in your browser for interactive Swagger API documentation.


Step 3: Frontend Setup & Launch

Open a new terminal window:

# 1. Navigate to frontend directory
cd frontend

# 2. Install frontend dependencies
npm install

# 3. Start Vite development server
npm run dev

⚑ Frontend Application: Open http://localhost:5173 in your browser to launch the CodeImpact Dashboard!


πŸ§ͺ Automated Testing & Verification

CodeImpact includes a comprehensive automated test suite covering all AST parsers, knowledge graph construction, blast radius formulas, "what-if" simulations, and API endpoints.

Run Backend Tests (23 Passing Tests):

# From the project root
backend\venv\Scripts\pytest backend/tests/ -v
============================= test session starts =============================
platform win32 -- Python 3.12.10, pytest-9.1.1
collected 23 items

backend/tests/test_api_endpoints.py::test_health PASSED                  [  4%]
backend/tests/test_api_endpoints.py::test_samples PASSED                 [  8%]
backend/tests/test_api_endpoints.py::test_scan_and_symbols PASSED        [ 13%]
backend/tests/test_api_endpoints.py::test_impact_analysis PASSED         [ 17%]
backend/tests/test_api_endpoints.py::test_simulate_change PASSED         [ 21%]
backend/tests/test_api_endpoints.py::test_graph_data PASSED              [ 26%]
backend/tests/test_api_endpoints.py::test_export_report PASSED           [ 30%]
backend/tests/test_api_endpoints.py::test_ts_saas_scan PASSED            [ 34%]
backend/tests/test_api_endpoints.py::test_upload_project_zip PASSED      [ 39%]
backend/tests/test_api_endpoints.py::test_upload_invalid_file PASSED     [ 43%]
backend/tests/test_api_endpoints.py::test_upload_deduplication_and_multiple_projects PASSED [ 47%]
backend/tests/test_api_endpoints.py::test_js_ts_arrow_functions_and_return_types PASSED [ 52%]
backend/tests/test_impact.py::test_csharp_parser_accuracy PASSED         [ 56%]
backend/tests/test_impact.py::test_typescript_parser_accuracy PASSED     [ 60%]
backend/tests/test_impact.py::test_python_parser_accuracy PASSED         [ 65%]
backend/tests/test_impact.py::test_graph_construction_and_cross_file_resolution PASSED [ 69%]
backend/tests/test_impact.py::test_graph_cycles_resilience PASSED        [ 73%]
backend/tests/test_impact.py::test_disconnected_components PASSED        [ 78%]
backend/tests/test_impact.py::test_user_service_get_user_exact_metrics PASSED [ 82%]
backend/tests/test_impact.py::test_change_simulation_add_required_parameter PASSED [ 86%]
backend/tests/test_impact.py::test_change_simulation_optional_parameter_no_breaking PASSED [ 91%]
backend/tests/test_impact.py::test_change_simulation_return_type_mismatch PASSED [ 95%]
backend/tests/test_impact.py::test_markdown_report_formatting PASSED     [100%]

======================= 23 passed, 2 warnings in 1.52s ========================

Run Frontend Production Build:

cd frontend
npm run build
  • TypeScript compilation (tsc -b): 0 errors.
  • Production bundle: Built in <400ms.

πŸ“‚ Preloaded Sample Projects

CodeImpact includes 3 realistic enterprise sample codebases out of the box:

Project Language Architecture & Files
C# E-Commerce Microservice C# (.cs) UserService, OrderService, PaymentService, AuthController, OrderController, UserRepository, UserServiceTests
TypeScript Cloud Billing SaaS TypeScript (.ts) SubscriptionService, BillingController, PaymentGateway, unit tests
Python AI Sentiment Service Python (.py) ModelService, ApiController, DbLogger, test_model

🎯 Benchmark Verification Scenario:

Select UserService.GetUser(string userId) in the dropdown:

  • 7 Dependent Callers: UpdateUserProfile, ChangePassword, ProcessPayment, PlaceOrder, AuthController.Login, OrderController.Create, UserController.GetProfile
  • 3 Public Controllers: AuthController, OrderController, UserController
  • 2 Database Operations: FindByIdAsync, UpdateLastLoginAsync
  • 1 Unit Test: UserServiceTests.TestGetUser
  • Untested Danger Zones Flagged: ProcessPayment, PlaceOrder, ChangePassword
  • Blast Score: 55 / 100 $\rightarrow$ HIGH RISK

πŸ“ Repository Structure

Dependency_Impact_Analyzer/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ engine/
β”‚   β”‚   β”œβ”€β”€ change_simulator.py      # "What-If" contract change simulator
β”‚   β”‚   β”œβ”€β”€ graph_builder.py         # NetworkX Code Knowledge Graph constructor
β”‚   β”‚   β”œβ”€β”€ impact_analyzer.py       # Blast radius, danger zones & scoring engine
β”‚   β”‚   β”œβ”€β”€ js_ts_ast_parser.js      # High-performance Node.js AST parser for JS/TS
β”‚   β”‚   β”œβ”€β”€ models.py                # Pydantic schemas (SymbolNode, BlastReport, etc.)
β”‚   β”‚   └── parser_engine.py         # Multi-language AST engine (C#, JS/TS, Python)
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   β”œβ”€β”€ test_api_endpoints.py    # FastAPI endpoint & upload integration tests
β”‚   β”‚   └── test_impact.py           # AST parser precision & graph algorithm tests
β”‚   β”œβ”€β”€ main.py                      # FastAPI application & REST endpoints
β”‚   └── requirements.txt             # Backend Python dependencies
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ favicon.svg              # Custom browser tab icon
β”‚   β”‚   β”œβ”€β”€ logo.png                 # Brand logo image (high-res)
β”‚   β”‚   └── logo.svg                 # Scalable vector brand logo
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ CodeSandbox.tsx      # Monaco editor & "What-If" simulator UI
β”‚   β”‚   β”‚   β”œβ”€β”€ CustomEdges.tsx      # Animated SVG ripple energy edges
β”‚   β”‚   β”‚   β”œβ”€β”€ CustomNodes.tsx      # Custom React Flow symbol nodes
β”‚   β”‚   β”‚   β”œβ”€β”€ GraphView.tsx        # React Flow graph canvas & minimap
β”‚   β”‚   β”‚   β”œβ”€β”€ ImpactHUD.tsx        # Blast radius score gauge & metric cards
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.tsx           # Workspace selector & project upload trigger
β”‚   β”‚   β”‚   β”œβ”€β”€ PRReportModal.tsx    # GitHub PR Blast Radius card exporter
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx          # Symbol tree navigator & filter pills
β”‚   β”‚   β”‚   └── UploadProjectModal.tsx # ZIP dropzone & local path scanner
β”‚   β”‚   β”œβ”€β”€ services/api.ts          # Strongly-typed backend API client
β”‚   β”‚   β”œβ”€β”€ types/impact.ts          # TypeScript interfaces matching backend models
β”‚   β”‚   β”œβ”€β”€ utils/icons.ts           # FontAwesome icon catalog
β”‚   β”‚   β”œβ”€β”€ App.tsx                  # Main application orchestrator
β”‚   β”‚   β”œβ”€β”€ index.css                # Tailwind CSS v4 styling & dark theme
β”‚   β”‚   └── main.tsx                 # React DOM entry point
β”‚   β”œβ”€β”€ package.json                 # Frontend dependencies & scripts
β”‚   └── vite.config.ts               # Vite configuration with proxy to port 8000
β”œβ”€β”€ sample_projects/                 # Enterprise sample codebases (C#, TS, Python)
β”œβ”€β”€ pytest.ini                       # Pytest configuration
└── README.md                        # Documentation & setup guide

πŸ› οΈ Technology Stack

Layer Technologies
Backend Python 3.12, FastAPI, Uvicorn, Pydantic v2, NetworkX (Graph Theory), Tree-sitter, Pytest
Frontend React 19, TypeScript 6, Vite 8, Tailwind CSS v4, Monaco Editor (@monaco-editor/react), React Flow (@xyflow/react)
Icons & Design FontAwesome (@fortawesome/react-fontawesome), JetBrains Mono, Inter
Parsing Node.js TypeScript Compiler AST (typescript) + Tree-sitter (C#, Python)

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

About

Intelligent Code Knowledge Graph & Blast Radius Analyzer. Predicts cascading breaking changes, API route taints, and untested danger zones across C#, TypeScript, and Python codebases before you deploy.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages