How shreyaprasad1209/pr-review-tone-assistant works
Project Type and Purpose
a. This is a hybrid full-stack application consisting of:
• A Chrome browser extension (frontend) that hooks into GitHub’s PR UI.
• A standalone Express.js server (backend) that proxies requests to the OpenRouter AI service.
b. Purpose: Capture user input in real-time during PR reviews, send it to an AI service for tone rewriting, and display constructive suggestions inline.
File Structure
Top-level layout:
• .github – Issue templates
• backend/
– server.js (Express server entry point)
– .env (holds OPENROUTER_API_KEY)
– package.json, node_modules
• frontend/
– manifest.json (Chrome extension metadata)
– content.js (content script injected into GitHub pages)
– styles.css (UI styling)
• README.md – high-level overview, setup, usage
Architectural hints:
• Clear separation of “frontend” (browser extension UI + content script) vs. “backend” (API server).
• No database—stateless proxy.
• External dependency: OpenRouter AI API.
Extract Key Insights from the README
• Frontend: content script monitors typing, triggers suggestion fetch after a pause.
• Backend: exposes an endpoint (e.g. POST /rewrite) that calls OpenRouter with the user text and API key.
Main Components
1) Browser (Chrome)
• GitHub PR page UI
• Chrome Extension (background/popup not used here—only content script)
2) Content Script (frontend/content.js + styles.css + manifest.json)
• Throttles/debounces input (3-second pause)
• Sends HTTP request to backend
• Receives rewritten text and injects suggestion UI
3) Backend Server (backend/server.js on Node.js + Express)
• Single endpoint to receive text
• Reads OPENROUTER_API_KEY from .env
• Forwards request to OpenRouter API
• Returns AI-rewritten comments
4) External AI Service (OpenRouter API)
• Hosts the language model
• Processes text and returns suggestions
Architectural Patterns and Principles
• Single Responsibility: frontend only handles UI/interactions; backend only handles AI requests.
• Event-driven: the extension reacts to typing events and idle pauses.
• Proxy pattern: backend acts as a proxy to hide API key from the client.
• Stateless server: no persistence layer, simplifies scaling.
Technologies and Frameworks
• Frontend: JavaScript, Chrome Extension Manifest V3, content scripts, CSS
• Backend: Node.js, Express.js, dotenv
• External: OpenRouter AI REST API