Skip to content

Grkmyldz148/GNN-App-Builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advanced GNN Code Analyzer & AI App Builder

Welcome to the Advanced GNN Code Analyzer & AI App Builder, an intelligent platform designed to revolutionize how developers interact with, understand, and generate code. This project leverages a powerful Graph Neural Network (GNN) to perform deep contextual analysis of codebases, empowering a suite of AI agents to perform complex tasks like refactoring, documentation, and even full application scaffolding from a simple prompt.

🎯 Project Overview

Why was this project created?

In the age of AI-driven development, Large Language Models (LLMs) are incredibly powerful but often lack a deep, structural understanding of the code they are asked to work on. They can read code as text, but they don't inherently grasp the intricate web of dependencies, the architectural patterns, or the data flow that defines a software project. This limitation can lead to superficial analysis, buggy code generation, and hallucinations.

This project was built to solve that problem. It acts as a Cognitive Coding Engine, creating a rich, multi-layered understanding of a codebase that an AI can use to reason about code with unparalleled accuracy and context-awareness.

What does it do?

The system analyzes a given codebase and transforms it into a comprehensive knowledge graph. This graph, enriched with semantic and structural embeddings, becomes the long-term memory for a team of specialized AI agents. These agents can then perform a variety of tasks with a deep understanding of the project's nuances.

✨ Features

  • Deep Code Analysis: Goes beyond traditional static analysis by using a Graph Neural Network (GNN) to understand relationships, call stacks, and architectural patterns.
  • Intelligent AI Agents: A multi-agent system routes user requests to the best-suited specialist (e.g., DocumentationAgent, AppBuilderAgent, GeneralAgent).
  • AI-Powered App Scaffolding: Generate entire applications, including controllers, services, models, and tests, from a single natural language prompt.
  • Context-Aware Code Generation: New code is generated based on patterns, styles, and conventions learned from the existing codebase, ensuring consistency.
  • Graph-Aware Search: Find relevant code snippets not just by keyword, but by understanding their role and connections within the project.
  • Automated Documentation: Generate comprehensive project documentation, including a deep dive into the GNN analysis.
  • Interactive Web UI & CLI: Interact with the agents through either a user-friendly web interface or a powerful command-line tool.

🧠 The GNN Engine: A Deep Dive

The core of this project is its unique Graph Neural Network engine, which provides the deep contextual understanding that sets it apart.

Purpose

The GNN's primary purpose is to model the codebase as a complex network of relationships. Instead of seeing code as a flat collection of files, the GNN sees it as it truly is: an interconnected system. This allows the AI to understand:

  • Data Flow: How data moves between functions and classes.
  • Control Flow: The execution paths within the application.
  • Dependencies: Which components rely on others.
  • Architectural Patterns: Identifying patterns like RESTful APIs, MVC, or microservices.

How It Works

  1. Parsing: The CodeParser reads the source files and uses an Abstract Syntax Tree (AST) to identify all functions, classes, imports, and function calls.
  2. Graph Construction: The GraphBuilder takes the parsed data and constructs a multi-relational graph. Nodes represent files, classes, and functions. Edges represent relationships like contains, calls, and inherits.
  3. Semantic Embedding: Each node is passed through a semantic embedding model (@xenova/transformers) to create a vector representing its "meaning" or intent.
  4. GNN Processing: The entire graph, now enriched with semantic embeddings, is passed to a Python-based GNN model (src/gnn/gnn_embedder.py). The GNN processes the graph's structure and the nodes' semantic information simultaneously.
  5. Insight Generation: The GNN outputs a new, powerful "structural embedding" for each node, along with a rich set of analyses, including code quality scores, detected design patterns, potential vulnerabilities, and performance hotspots.
  6. AI Context: This complete, multi-layered context (semantic + structural + GNN analysis) is then provided to the AI agents, giving them a deep and nuanced understanding of the codebase to fulfill user requests accurately.

🏗️ Project Structure

/
├── cli/                     # Command-line interface entry point
├── logs/                    # Log files for debugging agent prompts and errors
├── model_cache/             # Cache for downloaded machine learning models
├── src/
│   ├── agent/               # Core AI agent logic and routing
│   │   └── specialized/     # Specialized agents for specific tasks
│   ├── ai-studio/           # Wrapper for the Google AI Studio (Gemini) API
│   ├── app-builder/         # Components for scaffolding new applications
│   ├── embeddings/          # Code for generating different types of embeddings
│   ├── engine/              # Core analysis engine (parser, graph builder)
│   ├── features/            # High-level analysis features (metrics, dependencies)
│   ├── gnn/                 # Python-based GNN model, layers, and data processing
│   ├── intelligence/        # Higher-level AI reasoning components (search, generation)
│   └── utils/               # Utility functions like logging
├── tests/                   # Unit and integration tests (to be developed)
└── web/
    ├── public/              # Frontend assets for the web UI (HTML, CSS, JS)
    └── server.js            # Express server for the web interface

🚀 Getting Started

Follow these steps to get the project running on your local machine.

Prerequisites

  • Node.js: v18.x or later
  • Python: v3.9 or later (with a virtual environment recommended)
  • Git: For cloning the repository and history analysis.

Installation

  1. Clone the Repository

    git clone https://github.com/your-username/advanced-gnn-code-analyzer.git
    cd advanced-gnn-code-analyzer
  2. Install Node.js Dependencies

    npm install
  3. Set up Python Environment It's highly recommended to use a virtual environment.

    python3 -m venv gnn-env
    source gnn-env/bin/activate  # On Windows, use `gnn-env\Scripts\activate`
    pip install -r src/gnn/requirements.txt
  4. Configure Environment Variables Create a .env file in the project root by copying the example file.

    cp .env.example .env

    Now, open the .env file and add your Google AI Studio API key:

    AI_STUDIO_API_KEY="your_api_key_here"
    

Running the Application

You can interact with the analyzer in two ways:

1. Command-Line Interface (CLI)

To analyze the current project and ask the AI to perform a task:

node cli/gnn-analyzer.js ask . "Refactor the main loop in src/index.js to be more efficient."

To generate a new application based on a prompt:

node cli/gnn-analyzer.js build . "Build a simple Express.js API for a blog with endpoints for posts and comments."

2. Web Interface

For a more interactive experience, run the web server:

npm run web

Then, open your browser and navigate to http://localhost:3000.

🔮 Future Development

This project is a foundational platform with immense potential for growth. Future development could include:

  • Support for More Languages: Extending the parser and GNN to support languages like Python, Java, C++, and Go.
  • Real-time Analysis: Integrating with the file system to provide real-time analysis and suggestions as developers code.
  • Advanced Test Generation: Moving beyond boilerplate to generate meaningful unit and integration tests based on code behavior.
  • Automated CI/CD Integration: Creating a GitHub Action that performs a GNN-based quality and security audit on every pull request.
  • Enhanced Behavioral Analysis: Capturing runtime traces to create more accurate behavioral embeddings for performance optimization.

🤝 Contributing

Contributions are welcome! If you have ideas for new features, improvements, or bug fixes, please open an issue or submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors