How ramin4251/llm-prompt-enhancer works
Main Components
• Browser Environment: Representing the Chrome browser that loads the extension.
• Manifest & Configuration: The manifest.json file, which serves as the blueprint for the extension.
• Content Script (content.js): Injects the “Enhance Prompt” button into web pages, monitors textarea elements, sends prompt text to the Groq API, and then updates the text.
• Popup Interface: Comprised of popup.html and popup.js, which allow the user to set and save the Groq API key. Include the styles.css that styles the button and UI.
• API Integration: Highlight the external Groq API service responsible for processing and enhancing prompts.
• Local Data Storage: The browser’s local storage used to securely persist the Groq API key.
Mapping Relationships and Data Flows
• Extension’s manifest, which registers both the content script and the popup.
• From the manifest, split into two key paths:
a. Popup Interface:
• Displays UI components (HTML/CSS) for entering the API key.
• Uses popup.js for handling UI interactions and storing/retrieving the API key in local storage.
b. Content Script:
• Injected in every webpage where textareas are found.
• Contains logic to add the “Enhance Prompt” button next to textareas and remotely interacts with the Groq API.
• That both the popup interface and content script rely on shared configuration details from the manifest.
Architectural Patterns & Details to Highlight
• The extension design follows a modular approach with a clear separation between UI/interaction (popup) and core business logic (content script), orchestrated by the manifest.
• Client-side (browser-based) nature of the extension.
• The use of local storage for secure API key persistence is an important component.
• That the extension creates a direct dependency on an external service (Groq API) and how API key management is a critical aspect.