Skip to content

Gautam-aman/PromptPilot-AI

Repository files navigation

✈️ PromptPilot AI

An AI-powered prompt optimization companion that elevates your interactions with ChatGPT, Claude, and Gemini in real-time. By injecting an optimization layer directly into your favorite AI interfaces, PromptPilot AI refines, scores, and structures your prompts for maximum performance using advanced prompt engineering patterns.


🏗️ Architecture Overview

PromptPilot AI is designed with a decoupled, high-performance architecture:

graph TD
    subgraph Browser [Client-Side Browser Extension]
        UI[ChatGPT / Claude / Gemini UI] -->|Injects Button| CS[Content Script]
        CS -->|Message| BG[Service Worker / Background Script]
    end

    subgraph Server [Backend Stack - Docker Compose]
        BG -->|POST /api/prompts/optimize| SB[Spring Boot API Gateway]
        SB -->|Caching| RD[(Redis)]
        SB -->|Persistence| DB[(PostgreSQL)]
        SB -->|Optimizes via Spring AI| OpenAI[OpenAI API]
        
        SB -->|Exposes Metrics| Prom[Prometheus]
        Prom -->|Visualizes| Graf[Grafana]
    end
Loading
  1. Chrome Extension (Manifest V3): Detects the active text area on chatgpt.com, claude.ai, and gemini.google.com, and injects a premium Optimize button. It routes request payloads through a background script to bypass Content Security Policies (CSP).
  2. Spring Boot Backend: Powered by Java 21, Spring Boot, and Spring AI to interface with OpenAI.
  3. Redis Caching: Caches optimized prompts to minimize OpenAI API usage and latency.
  4. PostgreSQL Database: Persists prompt-optimization history.
  5. Observability Stack: Spring Boot Actuator exposes health status and Prometheus metrics, which are scraped by Prometheus and visualized via Grafana.

✨ Features

  • Direct UI Injection: Integrates cleanly into ChatGPT, Claude, and Gemini input boxes.
  • Deep Prompt Analysis:
    • Evaluates user intent and injects clear context and target roles.
    • Adds formatting instructions and explicit constraints.
    • Returns a refined version of the prompt, a quality score, and a list of missing information fields.
  • Response Caching: Prevents redundant upstream API calls using Redis.
  • Audit History: Automatically saves prompt refinement history (original prompt, optimized prompt, and score) to PostgreSQL.
  • Production Observability: Built-in Grafana and Prometheus configurations to monitor API latency, JVM metrics, and application performance.

🛠️ Tech Stack

  • Backend: Java 21, Spring Boot 3.x, Spring AI, Hibernate/JPA, Lombok
  • Datastore & Cache: PostgreSQL 16, Redis 7
  • Browser Extension: HTML5, CSS3, JavaScript (Chrome Extension Manifest V3)
  • Monitoring: Prometheus, Grafana, Spring Boot Actuator
  • Deployment: Docker, Docker Compose

🚀 Getting Started

Prerequisites


Setup Instructions

1. Configure Environment Variables

Create a .env file in the project root:

OPENAI_API_KEY=your-actual-openai-api-key

2. Run the Stack with Docker Compose

From the root directory, start all services (Database, Redis, Spring Boot Backend, Prometheus, and Grafana) in detached mode:

docker compose up -d

Verify that all services are running:

docker compose ps

Services will be exposed on:

  • Spring Boot Backend: http://localhost:8080
  • Prometheus: http://localhost:9090
  • Grafana Dashboard: http://localhost:3000

3. Install the Chrome Extension

  1. Open Chrome and navigate to chrome://extensions/.
  2. Enable Developer mode (toggle in the top-right corner).
  3. Click Load unpacked in the top-left corner.
  4. Select the extension/ folder from this project directory.
  5. PromptPilot AI is now active!

📖 Usage

  1. Open ChatGPT or Claude or Gemini.
  2. You will see a premium ✨ Optimize button next to or inside the prompt text area.
  3. Type a draft prompt (e.g., "write an email to my boss asking for a raise").
  4. Click Optimize.
  5. The button will change to Optimizing..., send the prompt to your local Spring Boot backend, and insert the fully engineered prompt directly back into your text editor.

📂 Project Structure

PromptPilot/
├── Backend/                 # Spring Boot application
│   ├── Dockerfile           # Multi-stage JVM runtime build
│   ├── src/                 # Spring Boot controllers, services, and configs
│   └── pom.xml              # Maven dependencies (including Spring AI)
├── extension/               # Chrome Extension source
│   ├── manifest.json        # Extension configuration
│   ├── background.js        # Background worker for API routing (CORS bypass)
│   ├── content/             # DOM adapters for ChatGPT, Claude, and Gemini
│   └── styles/              # Extension UI styling
├── prometheus/              # Prometheus scraping configuration
├── grafana/                 # Grafana datasource provisioning
├── docker-compose.yml       # Production-ready compose orchestration
└── .env                     # Local environment file (API keys)

📊 Monitoring & Metrics

The backend exposes system metrics under /actuator/prometheus.

  • Prometheus scrapes these metrics every 5 seconds.
  • Grafana is pre-configured with a Prometheus datasource. You can access it at http://localhost:3000 (Default login: admin / admin).

About

Chromium extension & Spring Boot microservice stack that optimizes LLM prompts on the fly. Features Spring AI integration, Redis caching, PostgreSQL persistence, and Prometheus/Grafana monitoring.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors