How iamakchavan/harv works
Main Components
• Browser Extension Core: Start with the manifest (manifest.json) which outlines the extension’s permissions, background scripts, and UI pages. This acts as the entry point for your architecture.
• Frontend/UI: Represent the static HTML files (index.html, popup.html) and the React application (src/App.tsx), along with its components (the entire src/components/ folder). These elements compose the user interface – including components like FloatingSearch, Header, and ModelSelector.
• Background Process: Indicate the background script (src/background.ts) that runs persistently to handle tasks such as monitoring browser events and managing communication between the extension’s UI and the external services.
• Content Scripts: Include the content script (src/content.tsx) that may interact with web pages to perform tasks like on-page analysis or text selection features.
• Utility and AI Providers: Illustrate the utilities in src/utils (like ai-config.ts, ai.ts, tts.ts, url-analyzer.ts) and specific AI provider modules (src/utils/ai-providers/*). These handle API integrations, model switching, and processing logic.
Relationships and Data Flow
• From the UI layer, show that user interactions (e.g., smart search and text selection) trigger events that flow to the background process or directly call utility functions.
– UI Interaction → Background/Content Script → AI Utility Modules → External AI APIs (Gemini, Perplexity, xAI)
• Bidirectional communication if the background scripts are relaying results back to the UI.
Architectural Patterns and Design Principles
• Separation of Concerns: Demonstrate how the project separates UI components, background processes, and utility logic for clarity and maintainability.
• Modular Design: Emphasize that each AI model provider is encapsulated within its own module, allowing for easier swapping or updating.
• Event-Driven Communication: Represent how user actions (keyboard shortcuts, selections) trigger events handled by the background script and then dispatched to the UI components.
• Use of React for dynamic UI rendering and Tailwind CSS (configured via tailwind.config.js) for styling, ensuring a modern frontend development approach.
Incorporate Technologies, Frameworks, and Libraries
• React / TypeScript: Core technologies driving the frontend (e.g., components in src/components/ and main application logic in src/App.tsx).
• Vite: The project uses Vite as its build tool, evidenced by vite.config.ts and tsconfig files.
• Tailwind CSS: Utilized for styling, as seen in tailwind.config.js and the inclusion of src/index.css.
• Node/NPM: Shown by the package.json and associated configuration files (postcss.config.js, eslint.config.js).
Elements
• Labels: Each component should be clearly labeled (e.g., “Background Script”, “Popup UI”, “Content Script”, “AI Provider: Gemini”).