Skip to content

ASP-31/Ghostwriter-reviewer

 
 

Repository files navigation

Ghostwriter: AI-Powered Automated Code Review & Architecture Profiler

Overview

Ghostwriter is an intelligent code review platform that automatically analyzes GitHub Pull Requests and provides high-quality review feedback using AI agents, static analysis, and architectural profiling.

The system integrates directly with GitHub through webhooks and performs asynchronous code reviews without blocking developer workflows. By combining Abstract Syntax Tree (AST) analysis, AI-powered reasoning, and repository-wide architecture evaluation, Ghostwriter helps development teams maintain cleaner, more scalable, and more secure codebases.


Problem Statement

Manual code reviews are often:

  • Time-consuming
  • Inconsistent across reviewers
  • Unable to scale with growing repositories
  • Focused on syntax rather than architecture

Ghostwriter addresses these challenges by automatically reviewing pull requests and generating contextual feedback, allowing developers to focus on higher-level engineering decisions.


Key Features

Automated Pull Request Reviews

  • GitHub webhook integration
  • Automatic review generation on PR creation/update
  • Line-by-line review comments

AI-Powered Analysis

  • Local LLM-based code understanding
  • Context-aware suggestions
  • Refactoring recommendations
  • Best practice enforcement

AST-Based Structural Analysis

  • Class and function extraction
  • Dependency analysis
  • Call graph generation
  • Structural context understanding

Architecture Profiling

Detects:

  • God Classes
  • Long Methods
  • Duplicate Code
  • Tight Coupling
  • Circular Dependencies
  • Excessive Nesting
  • Dead Code
  • Design Smells

Asynchronous Processing

  • Queue-based task execution
  • Scalable worker architecture
  • Fault-tolerant job handling

Analytics Dashboard

  • Repository health metrics
  • Code quality trends
  • Historical review reports
  • Architecture score tracking

System Architecture

                ┌────────────────────┐
                │     GitHub PR      │
                └─────────┬──────────┘
                          │
                          ▼
                ┌────────────────────┐
                │ Webhook Receiver   │
                │ (FastAPI / Go)     │
                └─────────┬──────────┘
                          │
                          ▼
                ┌────────────────────┐
                │ Message Queue      │
                │ Redis / RabbitMQ   │
                └─────────┬──────────┘
                          │
                          ▼
                ┌────────────────────┐
                │ Worker Services    │
                └─────────┬──────────┘
                          │
                          ▼
                ┌────────────────────┐
                │ AST Parser         │
                │ AI Agent Workflow  │
                └─────────┬──────────┘
                          │
                          ▼
                ┌────────────────────┐
                │ Review Generator   │
                └─────────┬──────────┘
                          │
                          ▼
                ┌────────────────────┐
                │ GitHub PR Comments │
                └────────────────────┘

Technology Stack

Backend

Component Technology
API Server FastAPI / Go
Database PostgreSQL
Authentication GitHub OAuth
ORM SQLAlchemy

Queue & Infrastructure

Component Technology
Message Queue Redis / RabbitMQ
Task Workers Celery
Caching Redis

AI & Code Analysis

Component Technology
LLM Llama 3
Local Inference Ollama
Agent Framework LangGraph / CrewAI
Parsing Engine Tree-sitter
Analysis Language Python

Frontend

Component Technology
Framework React.js
Styling Tailwind CSS
Charts Recharts
API Communication Axios

DevOps

Component Technology
Containerization Docker
Orchestration Docker Compose
CI/CD GitHub Actions

Project Workflow

Step 1: Pull Request Creation

A developer opens or updates a Pull Request in GitHub.

Step 2: Webhook Trigger

GitHub sends a webhook event to Ghostwriter.

Step 3: Job Ingestion

The backend validates the request and creates a review job.

Step 4: Queue Processing

The review task is pushed to Redis or RabbitMQ.

Step 5: Code Analysis

Workers:

  • Fetch repository changes
  • Parse code into AST
  • Extract structural information
  • Generate contextual code chunks

Step 6: AI Review

AI agents perform:

  • Code quality analysis
  • Security checks
  • Architecture review
  • Performance evaluation

Step 7: Feedback Generation

Review comments and summary reports are created.

Step 8: GitHub Integration

Generated feedback is posted directly to the Pull Request.


Team Responsibilities

Member 1: Backend & API Development

Responsibilities

  • Webhook Receiver
  • API Development
  • Authentication
  • Job Creation
  • Database Design
  • GitHub Integration

Technologies

  • FastAPI / Go
  • PostgreSQL

Member 2: Async Infrastructure & Queueing

Responsibilities

  • Background Task Management
  • Queue Architecture
  • Worker Management
  • Retry Handling
  • Failure Recovery

Technologies

  • Redis
  • RabbitMQ
  • Celery

Member 3: AI Agents & Code Parsing

Responsibilities

  • AST Parsing
  • Smart Code Chunking
  • Context Extraction
  • AI Agent Workflow Design
  • Architecture Analysis
  • Review Generation

Technologies

  • LangGraph
  • CrewAI
  • Ollama
  • Llama 3
  • Tree-sitter

Member 4: DevOps & Frontend Dashboard

Responsibilities

  • Dockerization
  • Deployment Setup
  • Monitoring
  • Analytics Dashboard
  • UI/UX Development

Technologies

  • Docker
  • React.js
  • Tailwind CSS

Example Review

Input Code

def calculate(users):
    result = []
    for user in users:
        if user.active:
            if user.has_permission:
                if user.age > 18:
                    result.append(user)
    return result

Generated Feedback

Issue: High nesting complexity detected.

Recommendation:

  • Use guard clauses.
  • Reduce cyclomatic complexity.
  • Improve readability.

Suggested Refactor:

def calculate(users):
    return [
        user for user in users
        if user.active
        and user.has_permission
        and user.age > 18
    ]

Dashboard Features

  • Repository Health Score
  • Code Quality Trends
  • Most Common Issues
  • Pull Request Statistics
  • Architecture Risk Indicators
  • Review History

Future Enhancements

Phase 2

  • Multi-language support
  • Security vulnerability detection
  • Test coverage analysis
  • Technical debt scoring

Phase 3

  • Repository-wide architecture graph
  • AI-generated pull request summaries
  • Automated refactoring suggestions
  • Slack and Discord integrations

Phase 4

  • Enterprise deployment support
  • Multi-repository analytics
  • Team performance insights
  • Custom review policies

Installation

git clone https://github.com/your-org/ghostwriter.git

cd ghostwriter

docker-compose up --build

Testing

Running Tests Locally

To run the tests in your local environment, install the dependencies in a virtual environment and execute pytest:

# Create a virtual environment
py -m venv venv

# Activate and install dependencies
.\venv\Scripts\pip install -r requirements.txt

# Execute the test suite
.\venv\Scripts\python -m pytest

Running Tests in Docker

If you have Docker running, you can execute the tests inside the container environment:

# Build the test image
docker build -t ghostwriter-test .

# Run pytest inside the container
docker run --rm ghostwriter-test pytest

Contributors

  • Member 1 – Backend & API
  • Member 2 – Queueing & Infrastructure
  • Member 3 – AI Agents & Code Parsing
  • Member 4 – DevOps & Frontend Dashboard

License

MIT License


Vision

Ghostwriter aims to become an intelligent engineering assistant capable of understanding software architecture, reviewing code at scale, and helping teams ship higher-quality software faster.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 90.4%
  • HTML 5.1%
  • CSS 2.7%
  • JavaScript 1.5%
  • Dockerfile 0.3%