# saketsarin/composer-web architecture

> Architecture diagram of the GitHub repository saketsarin/composer-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saketsarin/composer-web
- Repository: https://github.com/saketsarin/composer-web

## Overview

##### Project Type and Purpose
- This project is an extension for the Cursor environment that connects to a Chrome browser with remote debugging enabled.
- Its primary function is to monitor browser activity (console logs, network requests, full-page screenshots) and send that information to Composer for debugging, documentation, and sharing purposes.

##### File Structure Analysis and Key Modules
- The file structure follows a modular approach under the main “src” folder:
- src/browser: Contains the monitor.ts file which handles connecting to and monitoring the browser. This module is responsible for establishing remote debugging connections, capturing screenshots, and gathering logs.
- src/composer: Holds integration.ts – this module deals with sending the captured content to Composer, handling the communication between the extension and the Cursor backend.
- src/config: The arrangement of configuration management with index.ts provides settings and parameters for the extension.
- src/types: Provides shared TypeScript interfaces and type definitions to ensure type safety across modules.
- src/utils: Contains utility functions (e.g., clipboard functionality) that support cross-platform operations.
- src/extension.ts: Serves as the main entry point, which ties together the other modules and launches the extension.
- Additional files such as package.json, tsconfig.json, and build-related scripts (esbuild.js) indicate a development environment set up for both production builds and live reloading during development.

a. Main Components:
- Extension Entry Point (src/extension.ts): Your starting block that initializes the extension.
- Browser Monitor Module (src/browser/monitor.ts): Connects to Chrome’s debugging interface, listens for events (console logs, network requests), and captures full-page screenshots.
- Composer Integration Module (src/composer/integration.ts): Receives data from the Browser Monitor and sends it to Composer.
- Configuration Manager (src/config/index.ts): Centralizes extension settings and configurable parameters.
- Utility Functions (src/utils/clipboard.ts): Provides helper functionalities (e.g., clipboard operations) that are used across the system.
- Types/Interfaces (src/types/index.ts): Define contracts for communication and data structures.
- External Dependencies: Google Chrome (with remote debugging enabled), Cursor framework, Node.js runtime, and npm/PNPM as the package manager.

b. Relationships and Interactions:
- The extension entry point (“Extension.ts”) triggers initialization and event setup.
- Upon activation (keyboard shortcut or status bar click), the Browser Monitor module establishes a connection to the target Chrome tab via remote debugging.
- As logs, network requests, and screenshots are captured, this information flows from the Browser Monitor to the Composer Integration module.
- The Composer Integration module processes and formats the data before sending it into Composer.
- The Configuration Manager is referenced by both the Browser Monitor and Composer modules, ensuring that settings (e.g., debugging port, shortcuts, thresholds) are centralized.
- Utility modules (like Clipboard) may be called for additional tasks (e.g., data copy/paste features) as required.

c. Architectural Patterns and Technologies:
- Modularity and separation of concerns are key principles here. Each module (browser monitoring, composer integration, config management) has a clearly defined responsibility.
- The design leverages asynchronous and event-based communication to handle parallel processing of browser logs, network hits, and screenshot capturing.
- Use of TypeScript for type safety and modular code organization.
- The use of external tools (Chrome with remote-debugging enabled, Cursor, etc.) should be part of the interactions.

- For a full-stack-like extension, clearly separate the “frontend” (browser-facing operations) from the “backend” (data processing and communication to Composer).
- To show the integration pathway:
Extension Entry Point → [Browser Monitor Module] ⇄ Chrome (Remote Debugging API)
↓
[Composer Integration Module] → Composer (data ingestion)
↑
[Configuration Manager] (accessed by both modules)
[Utility Functions] used as supporting tools.

##### Final Advice
- Be detailed – include every piece from “src/browser” for monitoring to “src/composer” for integration.
- That all important architectural elements (initialization, data capture, data flow, configuration, and external communications) are well represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Internal Modules
    A["Extension Entry Point"]:::internal
    B["Browser Monitor Module"]:::internal
    C["Composer Integration Module"]:::internal
    D["Configuration Manager"]:::internal
    E["Utility Functions"]:::internal
    F["Types/Interfaces"]:::internal

    %% External Systems
    G["Google Chrome (Remote Debugging)"]:::external
    H["Composer Service"]:::external

    %% Layout: Top - Initialization, Middle - Modules, Bottom - External Systems
    A -->|"initiates"| B
    B -->|"capturesLogs&Screenshots"| G
    B -->|"sendsData"| C
    C -->|"forwardsData"| H

    %% Shared Dependencies (dashed arrows)
    B ---|"readsConfig"| D
    C ---|"readsConfig"| D
    B ---|"usesTypes"| F
    C ---|"usesTypes"| F

    %% Utility functions used by Browser Monitor
    B -->|"usesUtilities"| E

    %% Click Events
    click A "https://github.com/saketsarin/composer-web/blob/main/src/extension.ts"
    click B "https://github.com/saketsarin/composer-web/blob/main/src/browser/monitor.ts"
    click C "https://github.com/saketsarin/composer-web/blob/main/src/composer/integration.ts"
    click D "https://github.com/saketsarin/composer-web/blob/main/src/config/index.ts"
    click E "https://github.com/saketsarin/composer-web/blob/main/src/utils/clipboard.ts"
    click F "https://github.com/saketsarin/composer-web/blob/main/src/types/index.ts"

    %% Styles
    classDef internal fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#A9DFBF,stroke:#229954,stroke-width:2px;
```
