# victorfernandesraton/vagabot architecture

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

- Interactive diagram: https://gitdiagram.com/victorfernandesraton/vagabot
- Repository: https://github.com/victorfernandesraton/vagabot

## Overview

##### Project type and purpose
- This is a Python-based CLI automation tool (“Vagabot”) that uses Selenium to:
a) search LinkedIn posts matching a query
b) extract authors and post data
c) comment on posts the user hasn’t yet interacted with
- It runs as a Dockerized worker container talking to a Selenium Grid and persisting results in a local SQLite file.

##### File structure
- Top-level:
- script.py (CLI entrypoint)
- Dockerfile, docker-compose.yml (container + Selenium Grid)
- pyproject.toml / requirements.txt (Python deps)
- env-example (env var specification)
- Core package “vagabot”:
- workflows/  – orchestration of LinkedIn flows (login, search, comment)
- services/   – RemoteBrowserService wraps Selenium WebDriver remote calls
- adapters/   – HTML → domain entity mapping (post search adapter)
- repository/ – Repository pattern over SQLite (post + author)
- entities.py – Post and Author data models
- Tests mirror these layers under tests/.

##### Read README for additional insights
- CLI commands:
- search-posts
- post-comment
- Requires Docker Compose (worker + Selenium Hub + Node(s)).
- Environment variables for LinkedIn credentials, DB filename, Selenium Grid host/port.

##### Diagramming recommendations
- e.g., blue for CLI/Workflow, green for Service, yellow for Adapter, brown for Repository, orange for Data Store, red for external systems
- “Worker Container” housing CLI, workflows, services, adapters, repositories
- “Selenium Grid Network” housing Hub + Node

##### Essential details to capture
- The flow of credentials and queries from CLI args or environment into workflows
- The back-and-forth between RemoteBrowserService and the Selenium Grid over HTTP
- The transformation step in the adapter layer (raw HTML → Entities)
- Persistence calls from repository layer to SQLite
- How the post-comment workflow retrieves stored posts, sends browser commands, and updates state

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Worker Container Layer
    subgraph "Worker Container"
        direction TB
        CLI["script.py"]:::cli
        subgraph "Workflows" 
            direction TB
            WF_Main["linkedin_workflow.py"]:::workflow
            WF_Auth["linkedin_auth.py"]:::workflow
            WF_GetPosts["linkedin_get_posts.py"]:::workflow
            WF_Comment["linkedin_comment_post.py"]:::workflow
        end
        Service["RemoteBrowserService"]:::service
        Adapter["posts_from_search_adapters.py"]:::adapter
        Entities["entities.py"]:::entity
        subgraph "Repositories"
            direction TB
            Repo_Base["repository.py"]:::repository
            Repo_Post["post_repository.py"]:::repository
            Repo_Author["author_repository.py"]:::repository
        end
        DB["SQLite Database File"]:::datastore
    end

    %% External Services
    subgraph "Selenium Grid Network"
        direction TB
        Hub["Selenium Hub"]:::external
        Node["Selenium Node"]:::external
    end
    LinkedIn["LinkedIn Web UI"]:::external

    %% Data Flow
    CLI -->|"invoke search-posts or post-comment"| WF_Main
    WF_Main -->|"auth sequence"| WF_Auth
    WF_Main -->|"get posts"| WF_GetPosts
    WF_Main -->|"comment posts"| WF_Comment

    WF_GetPosts -->|"calls service"| Service
    WF_Comment -->|"calls service"| Service

    Service -.->|"HTTP WebDriver"| Hub
    Hub -->|"allocates session"| Node
    Node -->|"navigates to and interacts with"| LinkedIn
    Node -->|"returns HTML"| Service

    Service -->|"raw HTML"| WF_GetPosts
    WF_GetPosts -->|"transform"| Adapter
    Adapter -->|"entities"| Entities

    Entities -->|"save posts"| Repo_Post
    Entities -->|"save authors"| Repo_Author
    Repo_Post -->|"persist"| DB
    Repo_Author -->|"persist"| DB

    WF_Comment -->|"fetch new posts"| Repo_Post
    Repo_Post -->|"posts data"| WF_Comment
    WF_Comment -->|"commands"| Service
    WF_Comment -->|"update status"| Repo_Post

    %% Click Events
    click CLI "https://github.com/victorfernandesraton/vagabot/blob/main/script.py"
    click WF_Main "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/workflows/linkedin_workflow.py"
    click WF_Auth "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/workflows/linkedin_auth.py"
    click WF_GetPosts "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/workflows/linkedin_get_posts.py"
    click WF_Comment "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/workflows/linkedin_comment_post.py"
    click Service "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/services/remote_browser_service.py"
    click Adapter "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/adapters/posts_from_search_adapters.py"
    click Entities "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/entities.py"
    click Repo_Base "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/repository/repository.py"
    click Repo_Post "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/repository/post_repository.py"
    click Repo_Author "https://github.com/victorfernandesraton/vagabot/blob/main/vagabot/repository/author_repository.py"

    %% Styles
    classDef cli fill:#D0E6FF,stroke:#1E73BE,stroke-width:1px
    classDef workflow fill:#B3DDF2,stroke:#1E73BE,stroke-width:1px
    classDef service fill:#D6F5D6,stroke:#28A745,stroke-width:1px
    classDef adapter fill:#FFF5B1,stroke:#E1C542,stroke-width:1px
    classDef entity fill:#FFE1D6,stroke:#D35400,stroke-width:1px
    classDef repository fill:#E2CFC3,stroke:#8B4513,stroke-width:1px
    classDef datastore fill:#FFD8A8,stroke:#E67E22,stroke-width:1px
    classDef external fill:#F8D7DA,stroke:#C82333,stroke-width:1px
```
