How couscousz/bettergpt works
Main Components
a. Browser Extension Architecture:
• Background Script (from entrypoints/background.ts)
• Content Script (from entrypoints/content/)
• UI Components Layer
• Event Communication Layer
b. External Integration:
• ChatGPT Web Interface
• Browser Extension API
Core Extension Components
• ┌─ Browser Extension ─────────────────────────┐
• ┌─ Background Script ─┐ ┌─ Content ─┐ │
• Script │ │
• ┘ └───────────┘ │
• ▲ ▲ │
• ▼ ▼ │
• ┌─ Event Communication Layer ─┐ │
• ┘ │
• ┘
UI Component Hierarchy
• ┌─ UI Components ──────────────────┐
• ┌─ App.tsx ──────────────────┐ │
• Header │ │
• Sidebar │ │
• Messages │ │
• Tools │ │
• Footer │ │
• Theme │ │
• ┘ │
• ┘
Key Elements to Emphasize
• Blue: Core extension components
• Green: UI components
• Orange: External interfaces (ChatGPT)
• Purple: Communication channels
• Specific interactions:
• Content script ↔ ChatGPT web interface
• Event communication between components
• UI component hierarchy
• Message flow for the chat list feature
Technical Details
• Framework: React (evident from .tsx files)
• Styling: Tailwind CSS (from configuration files)
• Build System: WXT
• Type System: TypeScript
Important Architectural Patterns to Highlight
• Component-based architecture (React components)
• Event-driven communication (EventEmitterContext)
• Context-based state management
• Type-safe interfaces (Api.ts, Messages.ts)