How jonathanbertholet/promptmanager works
Project and Its Purpose
• Project Type: Chrome extension.
• Purpose: Manage and organize prompts for various AI chatbots (e.g., ChatGPT, Claude, Gemini, etc.) with capabilities like saving, editing, searching, and importing/exporting prompts.
• Key Functionality: Providing a lightweight, client-side prompt manager that works across different AI platforms by injecting saved prompts into the appropriate chat input fields.
File Structure
• Top-Level Files:
• Manifest File: manifest.json – defines extension metadata, permissions, and script bindings.
• HTML Files: popup.html (main UI for prompt management), settings.html (configuration options), info.html (possibly additional extension info).
• JavaScript Files:
• popup.js – drives the popup UI interactions.
• settings.js – manages settings interactions.
• prompts.js – handles creation, editing, and deletion of prompts.
• content.js – acts as a content script that interacts with supported AI chat pages.
• inputBoxHandler.js – responsible for detecting and injecting prompts into input fields.
• importExport.js – handles JSON import/export functionalities.
• utils.js – contains helper functions used across various modules.
• Also, content.js likely coordinates specifically with the injected code into the target chat sites.
• Additional Files: Documentation files (.gitignore, Contributing.md, changelog.html, README.md) provide context but are external to runtime architecture.
System Architecture
• Main Components:
• User Interface (UI) Components:
• Popup UI: popup.html and popup.js that show the prompt selection and management interface.
• Settings UI: settings.html and settings.js for configuration and personalized options.
• Info/Help: info.html serving static information.
• Business Logic:
• Prompt Management: prompts.js handles CRUD operations on prompts.
• Import/Export Functionality: importExport.js allows JSON data operations.
• Utilities: utils.js consolidates common helper functionalities.
• Content Injection and Interaction:
• Content Script: content.js injects the extension’s functionality into supported AI platforms.
• Input Field Handler: inputBoxHandler.js manages the interaction with the chat input fields and places selected prompts into these inputs.
• Configuration Layer:
• Manifest File (manifest.json): declares permissions, scripts, and extension metadata ensuring that appropriate scripts (content and UI) are run in the right contexts.
Relationships and Data Flow
• The user launches the extension leading to the Popup UI (via popup.html and popup.js).
• Through this UI, the user can select, search, or edit prompts (handled by prompts.js, possibly calling utility functions from utils.js).
• When a prompt is selected, a data flow occurs from the popup UI to the content script (content.js) and then to the inputBoxHandler.js to insert the prompt into the AI chat’s input area.
• Import/Export actions are initiated from the popup and processed by importExport.js, using JSON as the data format.
• Settings changes made in settings.html are processed via settings.js and may update internal configurations stored locally.
• All data (i.e., prompt storage) is handled locally (using the browser’s local storage), ensuring privacy and offline availability.
Architectural Patterns and Design Principles
• Separation of Concerns: Distinguishing UI (HTML/JS for popup/settings) from business logic (prompt management and utility functions) and from content interactions (content.js and inputBoxHandler.js).
• Modular Architecture: Each JavaScript file is dedicated to one area of functionality—making the system easier to manage, maintain, and scale.
• Event-Driven Interactions: Utilizing user events (clicks, keyboard navigation) to trigger prompt actions and inter-script communications.
• Client-Side Storage: Local storage is used in lieu of a server, aligning with privacy guidelines.
• Use clear labels to denote each component.
• From User Interactions (clicks, keystrokes) in Popup and Settings UIs => to the prompt manager and then to content/injection modules.
• Another for business logic,
• And another for integration (content/interaction layers).