Skip to content

AI-powered code summarizer built with React and Node.js using Google's Gemini API. Supports multiple languages, model selection, and provides detailed token usage and response time.

Notifications You must be signed in to change notification settings

aradhyacp/Ai-Code-Summarizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Code Summarizer

A full-stack AI-powered application that takes in code from users, sends it to Google's Gemini API for summarization, and displays a human-readable explanation of the logic. It supports multiple languages and different Gemini models, with response metadata such as token counts and model latency.


Watch it live :

https://ai-code-summarizer.jack1337.serv00.net/

βš™οΈ Tech Stack

Frontend

  • React (Vite)
  • Tailwind CSS
  • Fetch API
  • Dark theme UI

Backend

  • Node.js
  • Express.js
  • Zod (for validation)
  • Google GenAI SDK (Gemini API)
  • dotenv
  • CORS
  • Express Rate Limit (for safety)

πŸš€ Features

  • 🧠 AI-powered code summarization
  • ✍️ Supports multiple programming languages
  • πŸ“ˆ Model selection (Gemini 2.5 Pro / Flash / Flash Lite)
  • πŸ“Š Displays model metadata:
    • Model version
    • Token counts (prompt, candidate, total, thoughts)
    • Response time in seconds
  • πŸŒ“ Dark themed, responsive UI
  • πŸ” Loading animation while waiting for AI
  • βœ… Input validation using Zod
  • ⚠️ Rate-limiting friendly error handling
  • πŸ› Friendly error UI messages on failure

πŸ§ͺ Local Setup

1. Clone the Repository

git clone [email protected]:aradhyacp/Ai-Code-Summarizer.git
cd Ai-Code-Summarizer

πŸ“€ API Reference

POST /ai-summary

  • Request Body:
{
  "language": "javascript",
  "codeSent": "function test() { return 123; }",
  "model": "gemini-2.5-flash-lite"
}
  • Success Response:
{
  "response": "This function returns the number 123.",
  "modelVersion": "gemini-2.5-flash-lite",
  "promptTokenCount": 100,
  "candidatesTokenCount": 50,
  "totalTokenCount": 160,
  "thoughtsTokenCount": 10,
  "modelResponseTime": 1.48
}
  • Validation Error Response:
{
  "error": "Invalid input",
  "issues": [
    { "message": "Language is required" },
    { "message": "Code is required" },
    { "message": "Model is required" }
  ]
}

πŸ›‘οΈ Error Handling

  • Zod validation errors are caught and returned to frontend

  • Invalid inputs or empty fields are blocked

  • Rate-limiting errors show:

Too many requests. Please try again later. Rate limiter is turned on for safety purpose, limit is 10 requests every minute.

  • Errors during fetch are shown as in-code comments like // Error message here

🧠 Tips for Usage

  • Always select both Language and Model before submitting

  • Code must not be empty

  • Wait for the response spinner to finish before editing again

  • Use Gemini Flash-lite for faster (but cheaper) summaries

About

AI-powered code summarizer built with React and Node.js using Google's Gemini API. Supports multiple languages, model selection, and provides detailed token usage and response time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published