# a9t9/rpa architecture

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

- Interactive diagram: https://gitdiagram.com/a9t9/rpa
- Repository: https://github.com/a9t9/rpa

## Overview

##### Main System Components

a) Browser Extension Layer
- Three separate browser contexts (Chrome/Edge, Firefox)
- Extension's main components:
- Background Script (src/ext/bg.js)
- Content Scripts (src/ext/content_script)
- Popup UI (src/ext/popup)
- Side Panel (src/containers/sidepanel)

b) Core Services Layer
- AI Services (src/services/ai)
- Vision Services (src/services/vision)
- Storage Services (src/services/storage)
- Player Services (src/services/player)
- OCR Services (src/services/ocr)
- Desktop Integration (src/services/desktop)
- File System Services (src/services/filesystem)

c) User Interface Components
- Dashboard (src/containers/dashboard)
- Vision Editor (src/vision_editor)
- CSV Editor (src/csv_editor)
- Settings Modal (src/components/settings_modal)

##### Interaction Flows

a) Data Flow
- Storage interactions between browser storage and filesystem
- Command execution flow from UI → Player → Content Scripts
- Vision/OCR processing pipeline
- AI service integration paths

b) Control Flow
- RPA execution pipeline
- Event handling and message passing between components
- Browser extension communication channels

##### Key Architectural Patterns to Highlight

a) Service Architecture
- Separation of services in src/services
- Modular structure of each service

b) State Management
- Redux store (src/redux)
- Action/reducer flow (src/actions, src/reducers)

c) Extension Architecture
- Demonstrate the separation between background, content scripts, and UI
- IPC (Inter-Process Communication) patterns (src/common/ipc)

##### Integration Points

External integrations:
- Native host communication
- AI services connection
- File system access
- Desktop automation capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef browser fill:#FFE5CC,stroke:#FF9933
    classDef core fill:#CCE5FF,stroke:#3399FF
    classDef ui fill:#D9F2D9,stroke:#47A447
    classDef integration fill:#FFD9D9,stroke:#D9534F
    classDef state fill:#E5CCE5,stroke:#9933FF

    %% Legend
    subgraph Legend
        L1[Browser Components]:::browser
        L2[Core Services]:::core
        L3[UI Components]:::ui
        L4[External Integration]:::integration
        L5[State Management]:::state
    end

    %% Browser Extension Layer
    subgraph BrowserLayer[Browser Extension Components]
        Chrome[Chrome/Edge Extension]
        Firefox[Firefox Extension]
        
        subgraph ExtComponents[Extension Components]
            Background["Background Script"]:::browser
            ContentScripts["Content Scripts"]:::browser
            PopupUI["Popup UI"]:::browser
            SidePanel["Side Panel"]:::browser
        end
    end

    %% Core Services Layer
    subgraph CoreServices[Core Services]
        AI["AI Services"]:::core
        Vision["Vision Services"]:::core
        Storage["Storage Services"]:::core
        Player["Player Services"]:::core
        OCR["OCR Services"]:::core
        Desktop["Desktop Integration"]:::core
        FileSystem["File System Services"]:::core
    end

    %% UI Components
    subgraph UILayer[User Interface Components]
        Dashboard["Dashboard"]:::ui
        VisionEditor["Vision Editor"]:::ui
        CSVEditor["CSV Editor"]:::ui
        Settings["Settings Modal"]:::ui
    end

    %% State Management
    subgraph StateManagement[State Management]
        ReduxStore["Redux Store"]:::state
        Actions["Actions"]:::state
        Reducers["Reducers"]:::state
        IPC["IPC Communication"]:::state
    end

    %% Relationships
    Chrome --> ExtComponents
    Firefox --> ExtComponents
    Background --> CoreServices
    ContentScripts --> Player
    PopupUI --> ReduxStore
    SidePanel --> ReduxStore
    Player --> ContentScripts
    Vision --> OCR
    Storage --> FileSystem
    AI --> Vision
    Dashboard --> ReduxStore
    VisionEditor --> Vision
    Actions --> ReduxStore
    Reducers --> ReduxStore
    IPC --> Background
    Desktop --> FileSystem

    %% Click Events
    click Background "https://github.com/A9T9/RPA/blob/master/src/ext/bg.js"
    click ContentScripts "https://github.com/A9T9/RPA/tree/master/src/ext/content_script/"
    click PopupUI "https://github.com/A9T9/RPA/tree/master/src/ext/popup/"
    click SidePanel "https://github.com/A9T9/RPA/tree/master/src/containers/sidepanel/"
    click AI "https://github.com/A9T9/RPA/tree/master/src/services/ai/"
    click Vision "https://github.com/A9T9/RPA/tree/master/src/services/vision/"
    click Storage "https://github.com/A9T9/RPA/tree/master/src/services/storage/"
    click Player "https://github.com/A9T9/RPA/tree/master/src/services/player/"
    click OCR "https://github.com/A9T9/RPA/tree/master/src/services/ocr/"
    click Desktop "https://github.com/A9T9/RPA/tree/master/src/services/desktop/"
    click FileSystem "https://github.com/A9T9/RPA/tree/master/src/services/filesystem/"
    click Dashboard "https://github.com/A9T9/RPA/tree/master/src/containers/dashboard/"
    click VisionEditor "https://github.com/A9T9/RPA/tree/master/src/vision_editor/"
    click CSVEditor "https://github.com/A9T9/RPA/blob/master/src/csv_editor.js"
    click Settings "https://github.com/A9T9/RPA/tree/master/src/components/settings_modal/"
    click ReduxStore "https://github.com/A9T9/RPA/tree/master/src/redux/"
    click Actions "https://github.com/A9T9/RPA/tree/master/src/actions/"
    click Reducers "https://github.com/A9T9/RPA/tree/master/src/reducers/"
    click IPC "https://github.com/A9T9/RPA/tree/master/src/common/ipc/"
```
