Skip to content

indiser/DeadHunt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’€ DeadHunt

Hunt the Dead Code. Expose the Zombies.

Python Flask License Code Style

An AI-powered forensic scanner that surgically detects dead code, zombie dependencies, and unused imports in Python repositories.

Features β€’ Demo β€’ Installation β€’ Usage β€’ How It Works β€’ Contributing


🎯 Overview

DeadHunt is a sophisticated static analysis tool that combines AST parsing, dependency analysis, and AI-powered reasoning to identify dead code and zombie dependencies in Python projects. Unlike traditional linters, DeadHunt understands framework patterns (Django, Flask, FastAPI) and reduces false positives through intelligent context analysis.

Why DeadHunt?

  • πŸ” Framework-Aware: Recognizes Django models, Flask routes, FastAPI endpoints, and other framework patterns
  • 🧠 AI-Powered Analysis: Uses LLM reasoning to distinguish real dead code from framework-invoked code
  • πŸ“Š Comprehensive Reports: Beautiful, interactive HTML reports with actionable insights
  • πŸš€ Zero Configuration: Just paste a GitHub URL and scan
  • 🎨 Modern UI: Cyberpunk-inspired terminal interface with real-time progress

✨ Features

πŸ”¬ Dead Code Detection

  • Identifies unused functions, classes, variables, and imports
  • AST-based analysis with cross-file reference tracking
  • Framework-specific whitelisting to avoid false positives
  • Confidence scoring for each finding

🧟 Zombie Dependency Hunting

  • Compares declared dependencies vs. actual imports
  • Detects packages installed but never used
  • Identifies bloated requirements.txt files
  • Suggests safe removal candidates

πŸ“ˆ Intelligent Reporting

  • Executive summary with health score
  • Risk-categorized findings (High/Medium/Low)
  • Actionable recommendations for each issue
  • PDF export and markdown copy functionality
  • Interactive table of contents with scroll spy

🎨 Beautiful Interface

  • Cyberpunk-themed terminal UI
  • Real-time scan progress
  • Animated particles and scanline effects
  • Responsive design for mobile and desktop

🎬 Demo

Landing Page

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ’€ DeadHunt                            β”‚
β”‚  Hunt The Dead Code.                    β”‚
β”‚                                         β”‚
β”‚  ❯ https://github.com/user/repo        β”‚
β”‚    [SCAN]                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Analysis Report

  • Health Score: Visual ring chart showing codebase health (0-100)
  • Finding Cards: Color-coded cards with verdict badges
  • Sidebar TOC: Auto-generated navigation with active section highlighting
  • Export Options: PDF download and raw markdown copy

πŸš€ Installation

Prerequisites

  • Python 3.8 or higher
  • Git
  • pip

Quick Start

  1. Clone the repository

    git clone https://github.com/indiser/DeadHunt.git
    cd DeadHunt
  2. Install dependencies

    pip install -r requirements.txt
  3. Set up environment variables

    # Create a .env file with your API keys
    cp .env.example .env

    Add your API keys to .env:

    GEMINI_API_KEY=your_gemini_api_key_here
    OPENROUTER_API_KEY=your_openrouter_key_here  
    GROQ_API_KEY=your_groq_key_here              
    CEREBRAS_API_KEY=your_cerebras_key_here      
  4. Run the application

    python app.py
  5. Open your browser

    Navigate to http://localhost:5000
    

πŸ“– Usage

Web Interface

  1. Open DeadHunt in your browser
  2. Paste a GitHub repository URL (e.g., https://github.com/user/repo)
  3. Click SCAN
  4. Wait for analysis to complete (typically 30-90 seconds)
  5. Review the forensic report with findings and recommendations

Command Line (Advanced)

from enginex import analyze_repo

# Analyze a repository
report = analyze_repo("https://github.com/user/repo")
print(report)

πŸ”§ How It Works

Phase 1: Clone & Parse

Repository β†’ Shallow Clone β†’ AST Parsing β†’ Framework Detection
  • Clones the target repository (depth=1 for speed)
  • Parses all Python files into Abstract Syntax Trees
  • Detects framework architecture (Django/Flask/FastAPI/Generic)

Phase 2: Static Analysis

AST β†’ Vulture Scanner β†’ Cross-File References β†’ Confidence Scoring
  • Uses Vulture for dead code detection
  • Performs cross-file reference analysis
  • Applies framework-specific whitelists
  • Assigns confidence scores (60-100%)

Phase 3: Dependency Analysis

requirements.txt β†’ Import Extraction β†’ Diff Analysis β†’ Zombie Detection
  • Generates actual imports using pipreqs or manual AST scan
  • Compares declared vs. actual dependencies
  • Identifies unused packages

Phase 4: AI Reasoning

Findings β†’ LLM Analysis β†’ Verdict Assignment β†’ Risk Categorization
  • Sends findings to AI model (Gemini/OpenRouter/Groq/Cerebras)
  • Applies framework pattern recognition
  • Distinguishes false positives from real issues
  • Generates actionable recommendations

πŸ—οΈ Architecture

DeadHunt/
β”œβ”€β”€ app.py                 # Flask application & routing
β”œβ”€β”€ enginex.py             # Core analysis engine
β”œβ”€β”€ deadhunt_router.py     # Multi-provider LLM failover 
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ index.html         # Landing page
β”‚   └── report.html        # Analysis report UI
β”œβ”€β”€ .env                   # API keys (not committed)
└── README.md              # This file

Key Components

  • app.py: Flask web server, handles routing and report rendering
  • enginex.py: Core scanning logic, AST parsing, Vulture integration, LLM communication
  • index.html: Cyberpunk-themed landing page with terminal input
  • report.html: Interactive forensic report with markdown rendering

πŸ›‘οΈ Framework Support

DeadHunt intelligently handles framework-specific patterns:

Framework Supported Patterns
Django Models, Meta classes, admin attributes, signals, middleware, AppConfig
Flask Routes, blueprints, decorators, context processors
FastAPI Path operations, dependencies, background tasks
Celery Task decorators, worker-invoked functions
Pytest Fixtures, test functions, conftest.py
SQLAlchemy Model columns, relationships, event listeners

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Install dev dependencies
pip install -r requirements-dev.txt

# Run tests
pytest tests/

# Format code
black .

# Lint
flake8 .

πŸ“Š Roadmap

  • Support for JavaScript/TypeScript repositories
  • GitHub Actions integration
  • CLI tool for CI/CD pipelines
  • VS Code extension
  • Batch scanning for multiple repositories
  • Historical trend analysis
  • Custom rule configuration

πŸ› Known Limitations

  • Python 2 Support: Limited AST parsing for Python 2 codebases
  • Dynamic Imports: Cannot detect runtime imports via importlib or exec()
  • Reflection Patterns: May flag metaprogramming patterns as dead code
  • Private Repositories: Requires public GitHub URLs (or manual cloning)

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments


πŸ“§ Contact

Project Maintainer: Indiser


Built with πŸ’€ by developers, for developers

⬆ Back to Top

About

πŸ’€ AI-powered forensic scanner that detects dead code, zombie dependencies, and unused imports in Python repositories with framework-aware analysis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors