# presidio-oss/factif-ai architecture

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

- Interactive diagram: https://gitdiagram.com/presidio-oss/factif-ai
- Repository: https://github.com/presidio-oss/factif-ai

## Overview

##### High-Level Components

a) Frontend Layer:
- React-based web application (indicated by the frontend/src structure)
- Key components: Chat, Console, Explorer, Preview, Terminal
- WebSocket connections for real-time communication

b) Backend Layer:
- Node.js/TypeScript server (evident from backend/src)
- RESTful API endpoints
- WebSocket server for streaming
- Controller layer for different functionalities

c) AI Services Layer:
- Multiple LLM Providers (OpenAI, Anthropic, Gemini)
- OmniParser integration for screen parsing
- Vision-language model integration

d) Automation Layer:
- Puppeteer Mode for web automation
- Docker VNC Mode for desktop automation
- Browser Service interfaces

##### Component Relationships

**Frontend ←→ Backend (REST/WebSocket)**
**Backend ←→ AI Services**
**Backend ←→ Automation Layer**
**Automation Layer ←→ Target Applications**

##### Detailed Component Breakdown

a) Frontend Components (Blue Rectangle):
- Chat Interface
- Preview Window
- File Explorer
- Terminal/Console
- WebSocket Client

b) Backend Services (Green Rectangle):
- Action Controller
- Chat Controller
- File System Controller
- Screenshot Controller
- Streaming Controller
- Testcase Controller

c) AI Services (Purple Hexagon):
- OpenAI Provider
- Anthropic Provider
- Gemini Provider
- OmniParser Service

d) Automation Services (Orange Rectangle):
- Puppeteer Service
- Docker VNC Service
- Browser Service Interface
- Action Executor Service

##### Infrastructure Components (Gray Rectangle)
- Docker Containers
- VNC Server
- WebSocket Server
- File System

##### Data Flow Indicators

- Container communications (thick lines)

##### Notes Section

Annotations for:
- Scalability points
- Security boundaries
- External service dependencies
- Configuration requirements

Remember to highlight the two main automation modes (Puppeteer and Docker VNC) as parallel paths in the architecture, showing how they integrate with the core system differently.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef automation fill:#e67e22,stroke:#d35400,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        Chat["Chat Interface"]:::frontend
        Preview["Preview Window"]:::frontend
        Explorer["File Explorer"]:::frontend
        Terminal["Terminal/Console"]:::frontend
        WSClient["WebSocket Client"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        ActionCtrl["Action Controller"]:::backend
        ChatCtrl["Chat Controller"]:::backend
        FSCtrl["File System Controller"]:::backend
        ScreenCtrl["Screenshot Controller"]:::backend
        StreamCtrl["Streaming Controller"]:::backend
        TestCtrl["Testcase Controller"]:::backend
    end

    %% AI Integration Layer
    subgraph AI
        Claude["Claude Integration"]:::ai
        GPT["GPT-4V Integration"]:::ai
        Gemini["Gemini Integration"]:::ai
        OmniParser["OmniParser Service"]:::ai
    end

    %% Automation Layer
    subgraph Automation
        Puppeteer["Puppeteer Service"]:::automation
        DockerVNC["Docker VNC Service"]:::automation
        BrowserInterface["Browser Service Interface"]:::automation
        ActionExecutor["Action Executor"]:::automation
    end

    %% Infrastructure
    subgraph Infrastructure
        Docker[("Docker Containers")]:::infrastructure
        VNC[("VNC Server")]:::infrastructure
        WSServer[("WebSocket Server")]:::infrastructure
        FileSystem[("File System")]:::infrastructure
    end

    %% Connections
    WSClient <--> WSServer
    Chat --> ActionCtrl
    Preview --> ScreenCtrl
    Explorer --> FSCtrl
    Terminal --> StreamCtrl

    ActionCtrl --> ActionExecutor
    ChatCtrl --> Claude & GPT & Gemini
    ScreenCtrl --> OmniParser
    TestCtrl --> ActionExecutor

    ActionExecutor --> Puppeteer & DockerVNC
    Puppeteer & DockerVNC --> BrowserInterface
    DockerVNC --> VNC
    OmniParser --> Docker

    %% Click Events
    click Chat "https://github.com/presidio-oss/factif-ai/blob/main/frontend/src/components/Chat/Chat.tsx"
    click Preview "https://github.com/presidio-oss/factif-ai/blob/main/frontend/src/components/Preview/Preview.tsx"
    click Explorer "https://github.com/presidio-oss/factif-ai/blob/main/frontend/src/components/Explorer/Explorer.tsx"
    click Terminal "https://github.com/presidio-oss/factif-ai/blob/main/frontend/src/components/Terminal/Terminal.tsx"
    click WSClient "https://github.com/presidio-oss/factif-ai/blob/main/frontend/src/services/socketService.ts"
    click ActionCtrl "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/controllers/actionController.ts"
    click ChatCtrl "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/controllers/chatController.ts"
    click FSCtrl "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/controllers/fileSystemController.ts"
    click ScreenCtrl "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/controllers/screenshotController.ts"
    click StreamCtrl "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/controllers/streamingController.ts"
    click TestCtrl "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/controllers/testcaseController.ts"
    click Claude "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/llm/AnthropicProvider.ts"
    click GPT "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/llm/OpenAIProvider.ts"
    click Gemini "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/llm/GeminiProvider.ts"
    click OmniParser "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/OmniParserService.ts"
    click Puppeteer "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/implementations/puppeteer/PuppeteerService.ts"
    click DockerVNC "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/implementations/docker/DockerVNCService.ts"
    click BrowserInterface "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/interfaces/BrowserService.ts"
    click ActionExecutor "https://github.com/presidio-oss/factif-ai/blob/main/backend/src/services/actionExecutorService.ts"
    click Docker "https://github.com/presidio-oss/factif-ai/tree/main/backend/src/docker"
```
