Skip to content

sohail9972/Antigravity_Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›°οΈ Antigravity AI β€” Autonomous Unit Test Case Generator

"Point it at any Python repo. It writes, runs, and fixes unit tests for you β€” automatically."


πŸ“‹ Table of Contents


πŸ”΄ Problem Statement

Writing unit tests is one of the most critical yet time-consuming tasks in software development. Developers often skip it due to time pressure, unfamiliarity, or the complexity of the codebase. This leads to:

  • Low code coverage, hiding bugs until they reach production.
  • Slow development cycles, with manual QA taking up enormous time.
  • Technical debt that compounds as projects scale.

There was no tool that could look at an arbitrary Python codebase and automatically produce a passing, high-coverage unit test suite β€” until now.


βœ… Our Solution

Antigravity AI is a full-stack web application that takes a GitHub repository URL as input and uses Google Gemini 1.5 Flash to autonomously:

  1. Clone the repository.
  2. Identify the most logic-rich Python file.
  3. Generate a complete unit test file.
  4. Execute the tests and capture failures.
  5. Repair broken tests using AI reasoning on the failure logs.
  6. Repeat until all tests pass.
  7. Save the final test suite and code coverage to the user's dashboard.

No manual coding. No test writing. Just a GitHub link.


✨ Key Features

Feature Description
πŸ€– AI Test Generation Gemini 1.5 Flash reads source code and writes contextually accurate unit tests
πŸ” Self-Healing Loop If tests fail, the AI reads the error output and auto-repairs them (up to 5 cycles)
πŸ“Š Coverage Tracking Real-time code coverage % extracted using pytest-cov
πŸ’Ž Premium Live UI Glassmorphism design with real-time log streaming via Server-Sent Events
πŸ” User Authentication Secure multi-user system with JWT sessions and bcrypt-hashed passwords
πŸ—‚οΈ Private Workspaces Each user has an isolated dashboard of all their past test generation runs
πŸ“œ History & Reports Every generated test suite is persistently stored for review and download

βš™οΈ How It Works

GitHub URL Input
       β”‚
       β–Ό
  1. Clone Repository (GitPython)
       β”‚
       β–Ό
  2. Scan & Select Best Python File
       (largest non-test source file)
       β”‚
       β–Ό
  3. Gemini AI Analyzes Source Code
       β†’ Generates Full Unit Test File
       β”‚
       β–Ό
  4. Execute Tests (Pytest + Coverage)
       β”‚
     Pass? ──── YES ──────────────────────────┐
       β”‚                                       β”‚
      NO                                       β”‚
       β”‚                                       β”‚
  5. AI Reads Failure Logs & Repairs Tests     β”‚
       β”‚                                       β”‚
  6. Loop (max 5 iterations)                  β”‚
       β”‚                                       β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
  7. Final Report Generated
      β†’ Coverage % + Test Code Saved to DB
      β†’ Displayed in User Dashboard

πŸ› οΈ Tech Stack

Backend

Technology Role
FastAPI High-performance REST API & Server-Sent Events
Google Gemini 1.5 Flash Core AI for test generation and self-repair
SQLModel + SQLite ORM-based persistent storage for users and tasks
Pytest + pytest-cov Test execution engine & coverage measurement
python-jose + passlib JWT authentication & bcrypt password hashing
GitPython Programmatic GitHub repository cloning
python-dotenv Secure environment variable management

Frontend

Technology Role
React.js (Vite) Modern reactive UI framework
Vanilla CSS Custom glassmorphism design system
Server-Sent Events (SSE) Real-time log streaming from agent to browser
localStorage Persistent JWT session management

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    React Frontend   β”‚ ←─SSE─→ β”‚   FastAPI Backend      β”‚
β”‚                     β”‚         β”‚                        β”‚
β”‚  β€’ Auth (Sign In/Up)β”‚ ←─────→ β”‚  β€’ JWT Auth            β”‚
β”‚  β€’ Repo URL Input   β”‚         β”‚  β€’ SQLite DB           β”‚
β”‚  β€’ Live Terminal    β”‚         β”‚  β€’ Task Queue (async)  β”‚
β”‚  β€’ History View     β”‚         β”‚  β€’ Git Cloning         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                            β”‚
                                            β–Ό
                                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                 β”‚   AI Agent (agent.py)β”‚
                                 β”‚                      β”‚
                                 β”‚  β€’ Gemini API Calls  β”‚
                                 β”‚  β€’ Pytest Execution  β”‚
                                 β”‚  β€’ Repair Loop       β”‚
                                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Installation & Setup

Prerequisites

  • Python 3.10+
  • Node.js & npm
  • Git
  • A free Google Gemini API key β†’ Get one here

Step 1 β€” Clone

git clone https://github.com/sohail9972/Antigravity_Application.git
cd Antigravity_Application

Step 2 β€” Backend Setup

cd backend
pip install -r requirements.txt

Step 3 β€” Frontend Setup

cd ../frontend
npm install

Step 4 β€” Configure Environment

Create backend/.env with:

GOOGLE_API_KEY=your_gemini_api_key_here
JWT_SECRET=any_random_secret_string

Step 5 β€” Launch

# Run from the root project directory
python start_app.py

Open: http://localhost:5173


πŸ“‘ API Reference

Method Endpoint Auth Description
POST /api/auth/register ❌ Register a new user
POST /api/auth/login ❌ Login and receive JWT token
GET /api/auth/me βœ… Get current authenticated user
POST /api/analyze βœ… Trigger test generation for a repo
GET /api/stream/{task_id} ❌ Stream live AI agent logs (SSE)
GET /api/tasks βœ… View all past analysis sessions
GET /api/tasks/{task_id} βœ… Get full details of a specific run
DELETE /api/tasks/{task_id} βœ… Remove a task from history

🧠 Challenges & Learnings

  • Server Reloads Killing Sessions: Uvicorn's --reload mode was restarting the server every time a new repo was cloned (since the files landed inside the backend/ folder). Fixed by moving the workspace directory outside the watched directory.
  • Gemini JSON Mode: Prompted the model with response_mime_type: "application/json" for structured, reliable output. Built a fallback JSON extractor for edge cases.
  • Multi-user Isolation: Linking every analysis task to a specific user ID in the database ensures full workspace isolation between accounts.
  • Real-time Streaming: Used FastAPI's StreamingResponse with text/event-stream to push live log messages to the browser without polling.

πŸš€ Future Enhancements

  • File Browser: Let the user manually select which file in the repo to test, instead of auto-selection.
  • Multi-language Support: Extend beyond Python to support JavaScript, Java, and Go.
  • GitHub OAuth: One-click login via GitHub account for seamless repo access.
  • PR Integration: Automatically open a Pull Request in the target repository with the generated test file.
  • Export Reports: Download the full analysis report as a Markdown or PDF document.
  • Test Quality Scoring: Use a secondary AI pass to assess test quality beyond just pass/fail.

πŸ‘¨β€πŸ’» Team Members

Name Role
Sohail Full-Stack Developer & AI Integration Lead

πŸ™ Acknowledgments

  • Google AI (Gemini 1.5 Flash) for the powerful and affordable AI backbone.
  • FastAPI for making async Python backends a joy to build.
  • Hack2Skill for organizing a hackathon that encourages real-world, impactful AI solutions.

πŸ“„ License

This project is licensed under the MIT License.


πŸ“Œ Project Status

🟒 Active β€” Core features complete. Submitted for Hack2Skill 2026.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors