# santony760/sotoscribe architecture

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

- Interactive diagram: https://gitdiagram.com/santony760/sotoscribe
- Repository: https://github.com/santony760/sotoscribe

## Overview

##### Project Type and Purpose
- Project type: Browser extension (Microsoft Edge/Chrome) for capturing and editing user workflows entirely in the browser.
- Purpose:
– Inject scripts into web pages to record clicks, text entry, navigations, and screenshots.
– Provide a popup UI to start/stop recording.
– Open an editor UI in a new tab to review/edit/export the recorded steps (PDF / SharePoint embed).
– All data lives in memory—no external calls or persistent storage.

##### Main Architectural Components
A. manifest.json
– Declares extension metadata, permissions, script registrations (content scripts, background script, popup, editor).
B. Background Script (background.js)
– Event-driven service worker (MV3) or persistent page (MV2) listening for messages/triggers.
– Manages in-memory store of recorded events.
– Orchestrates starting/stopping recording and opening the editor tab.
C. Content Scripts (content.js + screenshot.js)
– Injected into every page (via permissions: activeTab, scripting).
– Listens for DOM events (clicks, form inputs, navigation).
– Captures screenshots using chrome.tabs.captureVisibleTab (screenshot.js).
– Sends event objects (action, screenshot blob, metadata) to background.
D. Popup UI (popup.html + popup.js)
– “Start Recording” / “Stop Recording” buttons.
– Sends messages to background to toggle recording state.
– Displays recording badge.
E. Editor UI (editor.html + editor.js + screenshot.js)
– Opens in a new tab when recording stops.
– Reads the in-memory workflow data via chrome.runtime messaging or injection.
– Renders a step list with screenshots and editable text.
– Provides image-editing (blurring, annotations) via screenshot.js.
– Supports PDF export (e.g., jsPDF or html2canvas) and SharePoint embed code generation.
F. Assets

##### Data Flows and Interactions
2. Popup sends message → Background toggles recording ON → Background injects content scripts (if needed) and notifies them to begin capturing.
3. Content scripts intercept user events → capture metadata + screenshot → send event payloads to Background.
4. Background appends events to its in-memory list.
5. User clicks “Stop Recording” in Popup → message to Background → Background opens editor.html in a new tab, passing the events list.
6. Editor UI fetches events → displays steps, allows edits → on export, runs PDF / SharePoint-embed logic locally → clears memory when done or on tab close.

##### Architectural Patterns and Principles
- MV3 Extension Pattern: Separate background service, content scripts, and UI pages.
- Message-Passing Architecture: All data flows via chrome.runtime.sendMessage / onMessage.
- In-Memory Event Store: Ephemeral storage ensures no data persists beyond session.
- Client-Only Processing: All processing (screenshot, PDF export, image editing) in the browser.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Browser Extension"
        manifest["manifest.json"]:::service
        subgraph "Services & Scripts"
            background["Background Service Worker\n(background.js)"]:::service
            Store[(In-Memory Event Store)]:::store
            subgraph "Content Scripts"
                ContentJS["content.js"]:::content
                ScreenshotCS["screenshot.js"]:::content
            end
        end

        subgraph "UI Components"
            subgraph "Popup UI"
                PopupHTML["popup.html"]:::frontend
                PopupJS["popup.js"]:::frontend
            end
            subgraph "Editor UI"
                EditorHTML["editor.html"]:::frontend
                EditorJS["editor.js"]:::frontend
                ScreenshotEditor["screenshot.js"]:::frontend
            end
        end

        Assets["Assets\n(icons/)"]:::service

        subgraph "Browser APIs" 
            style Browser APIs stroke-dasharray: 5 5
            chromeRuntime["chrome.runtime"]:::api
            chromeTabs["chrome.tabs"]:::api
            chromeScripting["chrome.scripting"]:::api
        end
    end

    %% Data Flows
    PopupJS -->|"START_RECORDING"| background
    background -->|"BEGIN_CAPTURE"| ContentJS
    ContentJS -->|"captureClick()/sendMessage()"| background
    ScreenshotCS -->|"captureVisibleTab() via chrome.tabs"| chromeTabs
    ScreenshotCS -->|"sendMessage()"| background
    background -->|"OPEN_EDITOR (new tab)"| EditorHTML
    EditorJS -->|"REQUEST_EVENTS"| background
    EditorJS -->|"PDF/IMG_EDIT"| chromeRuntime
    EditorJS -->|"PDF/IMG_EDIT"| chromeTabs
    Background -->|"inject scripts"| chromeScripting

    %% Internal Relations
    background --> Store

    %% Click Events
    click manifest "https://github.com/santony760/sotoscribe/blob/main/manifest.json"
    click background "https://github.com/santony760/sotoscribe/blob/main/background.js"
    click ContentJS "https://github.com/santony760/sotoscribe/blob/main/content.js"
    click ScreenshotCS "https://github.com/santony760/sotoscribe/blob/main/screenshot.js"
    click PopupHTML "https://github.com/santony760/sotoscribe/blob/main/popup.html"
    click PopupJS "https://github.com/santony760/sotoscribe/blob/main/popup.js"
    click EditorHTML "https://github.com/santony760/sotoscribe/blob/main/editor.html"
    click EditorJS "https://github.com/santony760/sotoscribe/blob/main/editor.js"
    click ScreenshotEditor "https://github.com/santony760/sotoscribe/blob/main/screenshot.js"
    click Assets "https://github.com/santony760/sotoscribe/tree/main/icons/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef service fill:#d4edda,stroke:#155724,color:#155724
    classDef content fill:#fff3cd,stroke:#856404,color:#856404
    classDef api fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef store fill:#f8d7da,stroke:#721c24,color:#721c24
```
