# henry0hai/browser-n8n-local architecture

> Architecture diagram of the GitHub repository henry0hai/browser-n8n-local, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/henry0hai/browser-n8n-local
- Repository: https://github.com/henry0hai/browser-n8n-local

## Overview

##### Main Components
- API Server (FastAPI): Represent the core server (see app.py) that handles HTTP requests and exposes all the documented endpoints (/api/v1/*). Indicate that it listens on port 8000 by default.
- Task Management Module: Although not explicitly separated into multiple files, conceptualize the component responsible for task lifecycle management (start, stop, pause, resume, and status tracking).
- Browser Use Python Library Interface: This is the internal bridge that communicates with the Browser Use API locally to mimic the cloud functionality.
- Docker and Deployment: Include Dockerfile and docker-compose as supporting components that encapsulate the whole service and its deployment environment.
- Testing: Incorporate the test_api.py component representing the test harness for the API endpoints.
- Auxiliary Components: Coverage for configuration (represented by files such as .env-example, requirements.txt) indicating dependency management and environment setup.

##### Relationships and Interactions
- Client (n8n or any consumer) sends HTTP requests → API Server processes the requests, performs validations, and calls into the Task Management Module.
- The Task Management Module leverages the Browser Use Python library to execute browser automation tasks.
- When interacting with LLM providers, the API Server (or Task Manager) reaches out to external APIs using credentials/settings configured via the .env file.
- Testing components simulate client requests to ensure all endpoints function as expected.
- Deployment is containerized via Docker where docker-compose might set up service dependencies if there are any (for instance, dynamic API credentials or even mock services).

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate concerns between API request handling, business logic in task management, and external service integrations.
- Configuration via Environment Variables: Highlight the use of .env files for deployment flexibility.
- Containerization: Notice the containerized nature of the application (Dockerfile and docker-compose.yml) which is key for environment consistency.

##### Technologies, Frameworks, and Libraries
- FastAPI for the web server.
- Python 3.10+ as the language/runtime.
- Docker & docker-compose for containerization.
- Browser Use Python library as the main automation engine.
- External LLM APIs (OpenAI, Anthropic, etc.) integrated based on API keys and configuration.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Client (n8n)"]:::client

    subgraph "API Layer"
        B["FastAPI Server (port 8000)"]:::api
        C["Task Management Module"]:::business
        D["Browser Automation Bridge"]:::business
    end

    subgraph "External Integrations"
        E["External LLM Providers Integration"]:::external
        F["Configuration (.env)"]:::config
    end

    subgraph "Deployment"
        G["Dockerfile"]:::deployment
        H["docker-compose.yml"]:::deployment
    end

    subgraph "Testing"
        I["Test Suite (test_api.py)"]:::testing
    end

    subgraph "Auxiliary"
        J["Dependencies (requirements.txt)"]:::aux
        K["Env Example (.env-example)"]:::aux
    end

    A -->|"HTTPRequest"| B
    B -->|"Manages"| C
    C -->|"Invokes"| D
    B -->|"Integrates"| E
    E -->|"ConfiguredBy"| F
    I -->|"Tests"| B
    G --- H
    G ---|"Deploys"| B
    G ---|"Deploys"| E
    J ---|"Provides"| K
    K ---|"Supports"| E

    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef api fill:#bbf,stroke:#333,stroke-width:2px;
    classDef business fill:#fd8,stroke:#333,stroke-width:2px;
    classDef external fill:#cfc,stroke:#333,stroke-width:2px;
    classDef config fill:#fc9,stroke:#333,stroke-width:2px;
    classDef deployment fill:#ccf,stroke:#333,stroke-width:2px;
    classDef testing fill:#fcc,stroke:#333,stroke-width:2px;
    classDef aux fill:#cff,stroke:#333,stroke-width:2px;

    click B "https://github.com/henry0hai/browser-n8n-local/blob/master/app.py"
    click C "https://github.com/henry0hai/browser-n8n-local/blob/master/app.py"
    click D "https://github.com/henry0hai/browser-n8n-local/blob/master/app.py"
    click E "https://github.com/henry0hai/browser-n8n-local/blob/master/.env-example"
    click G "https://github.com/henry0hai/browser-n8n-local/tree/master/Dockerfile"
    click H "https://github.com/henry0hai/browser-n8n-local/blob/master/docker-compose.yml"
    click I "https://github.com/henry0hai/browser-n8n-local/blob/master/test_api.py"
    click J "https://github.com/henry0hai/browser-n8n-local/blob/master/requirements.txt"
    click K "https://github.com/henry0hai/browser-n8n-local/blob/master/.env-example"
```
