Skip to content
pranaycvPublic

About

Phoenix - AI-Powered C++ Documentation Suite

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

13 Commits

Folders and files

Repository files navigation

๐Ÿš€ Phoenix - AI-Powered C++ Documentation Suite

Phoenix Logo

GitHub release License: MIT Python 3.8+ Code style: black

โœจ Introduction

Phoenix is a comprehensive AI-powered toolkit for automated C++ code documentation, analysis, and maintenance.
It combines the power of tree-sitter parsing, Ollama AI models, and a modern GUI interface to revolutionize how developers document and maintain their C++ codebases.

๐Ÿ”ฅ Why Phoenix?

Phoenix tackles the toughest challenges developers face when working with legacy C++ code base:

  1. Understand legacy code faster โ€“ make even decades-old codebases easier to read and maintain.
  2. Keep your code secure โ€“ all documentation is generated locally on your system, never leaving your machine.
  3. Onboard new developers instantly โ€“ newcomers can quickly grasp project structure and flow.
  4. From zero to full documentation โ€“ transform undocumented projects into fully documented codebases.
  5. Seamless Doxygen integration โ€“ generate complete Doxygen documentation directly from AI-powered docs.
  6. Continuous Documentation Updates โ€“ once full documentation is generated, Phoenix also keeps your docs up to date by tracking Git changes since the last documentation date.
  7. Catch hidden issues โ€“ AI powered function-by-function analysis of entire code based, detects potential glitches and bugs, producing a structured JSON report.

๐Ÿ“‹ Basic Requirement

  • The C++ codebase must be a Git repository.
  • Computer with GPU having 24GB memory and 7k CUDA cores for faster processing.

๐ŸŒŸ Key Features

๐Ÿค– AI-Powered Documentation Generation

  • Doxygen-style Comments: Automatically generates comprehensive function documentation
  • Inline Code Comments: Smart contextual comments for complex logic blocks
  • Multi-line Statement Handling: Correctly handles complex C++ constructs

๐Ÿ” Git Integration & Change Tracking

  • Smart Change Detection: Identifies modified, added, and deleted functions
  • Historical Analysis: Compare functions across commits and time ranges
  • Automated Processing: Process only changed functions for efficiency

๐Ÿ–ฅ๏ธ Modern GUI Interface

  • Intuitive Design: Clean, modern interface built with Streamlit
  • Real-time Progress: Live logging and status updates with advanced logging mechanism
  • Customizable Settings: Flexible configuration options

๐Ÿ“Š Static Code Quality Analysis

  • Critical Glitch Detection: Identifies memory leaks, null pointer dereferences
  • Performance Analysis: Spots potential bottlenecks and issues
  • Security Assessment: Detects buffer overflows and injection vulnerabilities

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.8 or higher
  • Git (for repository analysis)
  • Ollama server (local or remote)

Quick Install

# Clone the repository
git clone https://github.com/pranaycv/phoenix.git
cd phoenix

# Install dependencies
pip install -r requirements.txt

# For development setup
pip install -e .

Ollama Setup

# Install and start Ollama
curl -fsSL https://ollama.ai/install.sh | sh
ollama pull gpt-oss:20b  # or your preferred model
ollama serve

๐Ÿš€ Quick Start

1. GUI Mode (Recommended)

streamlit run phoenix.py

Default Login Credentials:

  • Username: phoenix
  • Password: phoenix

Configuration Options:

  • Directory Path: Your C++ project directory
  • Last Document Date: Process changes since this date
  • Ollama Host: AI model server URL
  • Branch: Git branch to analyze (optional)

2. Command Line Usage

Extract Single Function:

python extract_function_code_2.py
# Edit the file_path and line_number variables

Analyze Git Changes:

python get_git_changes.py --start-date 2024-01-01 --branch main

Batch Process Files:

python generate_docs_ollama.py
# Configure source_directory in the script

๐Ÿ“ Project Structure

phoenix/
โ”œโ”€โ”€ ๐ŸŽฏ phoenix.py                   # Main Streamlit GUI application
โ”œโ”€โ”€ ๐Ÿ” extract_function_code_2.py   # Function extraction utility
โ”œโ”€โ”€ ๐Ÿ“ generate_docs_ollama.py      # Batch documentation generator
โ”œโ”€โ”€ ๐Ÿ”„ get_git_changes.py          # Git change analyzer
โ”œโ”€โ”€ ๐Ÿ“‹ requirements.txt            # Dependencies
โ”œโ”€โ”€ ๐Ÿ—๏ธ setup.py                   # Package setup
โ”œโ”€โ”€ ๐Ÿ“š docs/                       # Documentation
โ”œโ”€โ”€ ๐Ÿงช examples/                   # Usage examples
โ””โ”€โ”€ โš™๏ธ config/                    # Configuration files

๐ŸŽฎ Usage Examples

Example 1: Document Recent Changes

# Set your project path
repo_path = "D:/YourProject"

# Process changes from last week
last_date = "2024-01-15"

# Run with GUI
streamlit run phoenix.py

Example 2: Extract Specific Function

from extract_function_code_2 import FunctionExtractor

extractor = FunctionExtractor("src/main.cpp", 42)
extractor.ExtractAndSave()

Example 3: Analyze Git Changes

from get_git_changes import ChangeProcessor, GitRepoHandler, CppParser, FunctionExtractor

parser = CppParser()
extractor = FunctionExtractor(parser)
git_handler = GitRepoHandler("./")
processor = ChangeProcessor(git_handler, extractor, ('.cpp', '.hpp'))
processor.ProcessChanges('HEAD~10')

โš™๏ธ Configuration

Environment Variables

export OLLAMA_HOST="http://localhost:11434"
export PHOENIX_MODEL="gpt-oss:20b"
export PHOENIX_TEMP_DIR="/tmp/phoenix"

Config File (config/phoenix.json)

{
  "ollama": {
    "host": "http://127.0.0.1:11434",
    "model": "gpt-oss:20b",
    "temperature": 0.0
  },
  "git": {
    "extensions": [".cpp", ".hpp", ".cc", ".h"],
    "ignore_patterns": ["**/build/**", "**/test/**"]
  },
  "documentation": {
    "include_doxygen": true,
    "inline_comments": true,
    "code_review": true
  }
}

๐Ÿ—๏ธ Architecture

Core Components

๐Ÿง  AI Engine (CustomOllamaGenerator)

  • Direct HTTP API integration with Ollama
  • Robust error handling and retry logic
  • Optimized prompts for C++ documentation

๐ŸŒณ Parsing Engine (CppParser)

  • Tree-sitter based C++ parsing
  • Accurate function extraction
  • Multi-file support with encoding detection

๐Ÿ“ File Management (FileProcessor)

  • Smart encoding detection
  • Batch processing capabilities
  • Status tracking and resumable operations

๐Ÿ”„ Version Control (GitRepoHandler)

  • Git integration for change detection
  • Support for branches and commit ranges
  • Staged and unstaged change handling

Data Flow

C++ Source Files โ†’ Tree-sitter Parser โ†’ Function Extraction 
                                             โ†“
Git Change Analysis โ†’ AI Documentation โ†’ Code Integration
                                             โ†“
Quality Review โ†’ Updated Source Files โ†’ Status Tracking

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Fork and clone the repository
git clone https://github.com/pranaycv/phoenix.git
cd phoenix

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Install development dependencies
pip install -r requirements.txt
pip install -e .

# Run tests
pytest tests/

Code Standards

  • Black for code formatting
  • flake8 for linting
  • mypy for type checking
  • pytest for testing

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Tree-sitter team for the excellent parsing library
  • Ollama team for making AI models accessible
  • Streamlit for the modern GUI framework
  • Open Source Community for continuous inspiration

๐Ÿ“ž Support

๐Ÿ—บ๏ธ Roadmap

  • VS Code Extension integration
  • Multiple AI Model support (OpenAI, Claude, etc.)
  • Java/Python language support
  • Team Collaboration features
  • CI/CD Pipeline integration
  • Cloud-based processing options

Made with โค๏ธ by developers, for developers

โญ Star this repo | ๐Ÿ› Report Bug | ๐Ÿ’ก Request Feature

About

Phoenix - AI-Powered C++ Documentation Suite

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages