Skip to content

Repository files navigation

🛡️ CodeGuardian

Automated Repository Analysis, SAST Security Auditing & Test Generation Platform

Stars Forks License Next.js TypeScript



📌 Overview

CodeGuardian is a software engineering analysis platform that automates codebase security audits, static SAST scanning, unit test synthesis, design pattern inspection, and architecture dependency mapping for GitHub repositories.

Simply provide a public or private GitHub repository URL. CodeGuardian fetches the source tree via the GitHub REST API, executes pattern-matching and AST parsing rules, and generates actionable findings with 1-click remediation diffs and downloadable executive audit reports.


✨ Key Features

  • 🔍 Live GitHub Codebase Fetching: Connects directly to GitHub REST API to recursively inspect repository trees and source files.
  • 🛡️ Static SAST Security Audit: Scans for OWASP Top 10 vulnerabilities, hardcoded secret tokens, unhandled eval() invocations, and XSS rendering risks.
  • 🧪 Unit Test Generation: Inspects exported function signatures and synthesizes Vitest / Jest compatible test stubs.
  • 📐 Code Quality & SOLID Review: Detects code smells, oversized files, nested loop complexity, and missing error handlers.
  • 🕸️ Architecture Dependency Mapping: Parses import/require graphs to visualize module interaction topology.
  • 📄 Executive Report Exporter: Downloads full audit packages in Markdown, HTML, PDF, JSON, and CSV formats.
  • 🤖 Optional OpenAI GPT-4o Integration: Uses GPT-4o when an API key is provided, or seamlessly falls back to fast local static analysis.

🏗️ System Architecture

CodeGuardian uses a multi-stage audit pipeline to process repositories concurrently:

flowchart TD
    A[GitHub Repository URL] --> B[GitHub REST API Client]
    B --> C[Source Tree & File Parser]
    C --> D[Multi-Stage Analysis Pipeline]

    subgraph Pipeline [Analysis Pipeline Engine]
        D --> E[Security & SAST Module]
        D --> F[Code Review & Quality Module]
        D --> G[Testing & Synthesis Module]
        D --> H[Architecture Topology Module]
        D --> I[Documentation Module]
    end

    E --> J[Unified Finding & Issue Store]
    F --> J
    G --> J
    H --> J
    I --> J

    J --> K[Executive Dashboard & Workbench]
    J --> L[Report Exporter - Markdown/HTML/PDF/JSON/CSV]
Loading

🛠️ Tech Stack


⚡ Quick Start

1. Clone & Install

git clone https://github.com/prajwal-mhase/CodeGuardian.git
cd CodeGuardian
npm install

2. Configure Environment Variables

Copy .env.example to .env.local:

cp .env.example .env.local

Edit .env.local:

# Optional: Increase GitHub API rate limit from 60 to 5,000 req/hr & scan private repos
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_github_token

# Optional: Enable GPT-4o deep analysis (falls back to local AST parsing if empty)
OPENAI_API_KEY=sk-proj-your_openai_key

# Optional: PostgreSQL Database (defaults to in-memory store if omitted)
DATABASE_URL="postgresql://user:password@localhost:5432/codeguardian?sslmode=require"

3. Launch Development Server

npm run dev

Open http://localhost:3000 in your browser.


🚀 Deployment

Deploy on Vercel

The fastest way to deploy CodeGuardian is with Vercel:

  1. Push your repository to GitHub.
  2. Import the repository into Vercel.
  3. Set your environment variables in Vercel settings.
  4. Click Deploy.

Deploy with Vercel

Deploy with Docker

docker-compose up --build -d

🧪 Running Tests

npm run test

📖 API Routes

Endpoint Method Description
/api/scan POST Triggers a scan pipeline for a target GitHub URL
/api/repositories GET, POST Lists or connects analyzed repositories
/api/reports/export GET Exports audit reports (?format=MARKDOWN|HTML|PDF|JSON|CSV)
/api/health GET Health check endpoint

📄 License

Distributed under the MIT License. See LICENSE for details.


Built with Next.js & TypeScript by Prajwal Mhase

About

AI-powered GitHub repository security analyzer that performs SAST scanning, vulnerability detection, code quality analysis, architecture mapping, test generation, and automated audit report generation using Next.js and TypeScript.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages