Skip to content

celtadenya/ai-code-analysis-tool

Repository files navigation

AIVA — AI-Powered Code Analysis & Assistance Tool

Final Year Project | BSc Computer Science (Digital Systems Security) | University of Wollongong

AIVA (AI Visual Assistant) is a web-based developer tool built with Python and Flask that uses trained Machine Learning models to automate common software engineering tasks — including code documentation, refactoring, commit message generation, and security-relevant invalid input testing.


Features

Feature Description
Auto Comment Generation Generates inline code comments for Python and Java using trained ML models
Code Refactoring Automatically refactors and cleans up code structure
Auto Indentation Detects language and corrects indentation for Python and Java
Commit Message Generation Compares two code blocks and generates meaningful commit messages
Release Notes Generator Generates formatted release notes from commit history
Invalid Input Testing Analyses function signatures and generates test cases for valid and invalid inputs — security-relevant input validation testing
Voice Bot Interface Voice-controlled interface for hands-free code assistance
Export to File Export any generated output directly to a local file

Tech Stack

  • Backend: Python, Flask
  • ML Models: Scikit-learn (trained on Python and Java code/comment datasets), Pickle
  • Frontend: HTML, CSS, JavaScript, Jinja2 templating
  • Architecture: MVC (Model-View-Controller)
  • Deployment: Heroku (Procfile included)
  • Languages Supported: Python, Java

Security Relevance

The Invalid Input Testing module is directly relevant to application security — it analyses function signatures to identify expected data types and automatically generates boundary/invalid test cases. This mirrors real-world input validation testing performed during security assessments and penetration testing of applications.


Project Structure

AIVA/
├── main.py                         # Flask app entry point, all routes
├── boundary/                       # Frontend HTML templates (Jinja2)
│   ├── index.html
│   ├── commentsGen.html
│   ├── autoIndentation.html
│   ├── commitMsgGen.html
│   ├── inputTesting.html
│   ├── codeRefactor.html
│   ├── releaseNotesGen.html
│   └── structureGen.html
├── controller/                     # Business logic controllers
│   ├── generateCommentsController.py
│   ├── invalidInputController.py
│   ├── autoIndentController.py
│   ├── generateCommitMessagesController.py
│   ├── generateReleaseNotesController.py
│   ├── codeRefactorController.py
│   ├── structureGenController.py
│   ├── voiceBot.py
│   └── exportFile.py
├── ML/                             # Trained ML models and datasets
│   ├── PythonComments/
│   │   ├── pythonComments_model
│   │   ├── pythonComments_vectorizer
│   │   └── pythonCodeAndComments.csv
│   └── JavaComments/
│       ├── javaComments_model
│       ├── javaComments_vectorizer
│       └── javaCodeAndComments.csv
├── AIVA Test/                      # Test cases for all features
├── static/                         # CSS, JS, assets
├── requirements.txt
├── Procfile
└── runtime.txt

How to Run

Step 1 — Install dependencies

pip install -r requirements.txt

Step 2 — Run Flask

On Mac/Linux:

export FLASK_APP=main.py
export FLASK_ENV=development
flask run

On Windows:

set FLASK_APP=main.py
set FLASK_ENV=development
flask run

Step 3 — Visit http://127.0.0.1:5000


How the ML Comment Generation Works

  1. Code is split line by line
  2. Operators are translated to natural language words (e.g. +=add, ==equal)
  3. Each line is vectorized using a trained TF-IDF vectorizer
  4. A trained classification model predicts the appropriate comment
  5. Comments are prepended to each line and returned as an annotated code block

Separate models are trained for Python and Java, each with their own language-specific operator dictionaries and ignore lists.


Author

Celta Denya Hadinata Wijaya BSc Computer Science (Digital Systems Security) — University of Wollongong MSc Cybersecurity (Ethical Hacking) — Coventry University (in progress) github.com/celtadenya

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors