# aws/nova-act architecture

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

- Interactive diagram: https://gitdiagram.com/aws/nova-act
- Repository: https://github.com/aws/nova-act

## Overview

##### Overall Project Type and Purpose
- This as a Python SDK for browser automation and “actuation” of web browsing tasks.
- It is intended both as a developer tool (via scripting and interactive modes) and as an experimental agent framework where high-level natural language commands are broken down into discrete actions.
- The SDK integrates with Playwright for browser control and uses a modular internal design to manage commands, logging, and session management.

##### Main Components
- Client/Usage Interface: This is where developers write scripts (or interact via a Python shell) by importing NovaAct. It includes the sample scripts provided under the samples directory.
- SDK Core Library (src/nova_act):
- The top-level module (nova_act.py) that exposes the NovaAct class.
- The “impl” submodule contains key implementations for handling browser events, interactions with Playwright, and internal logic (e.g. backend, protocol handling, message encryption).
- “types” and “util” submodules provide contracts, error handling (schemas and Pydantic models) plus utility functions for logging, JSON validation, and terminal management.
- Artifacts (src/nova_act/artifacts): Contains browser extension resources (JavaScript, manifest file, static assets) that are deployed with the SDK to support browser instrumentation. This is especially used for the Chrome MV3 variant.
- Configuration & Build: pyproject.toml and requirements.txt manage dependencies and build configurations.
- Authentication & Logging: The SDK supports API key authentication (see the README instructions) and logs detailed act traces to help in debugging and performance monitoring.
- Parallel/Concurrent Control: Implementation details in the samples and “impl” indicate support for running multiple sessions concurrently (via thread pools) and handling independent browser contexts.

##### Relationships and Data Flow
- Client Code (user scripts or interactive sessions) calls NovaAct’s API (mainly the act() method).
- The NovaAct class routes these commands to internal “impl” modules. For example:
- The “backend.py” may coordinate complex workflow control.
- “protocol.py” and “window_messages.py” handle communications between the Python layer and the Playwright-driven browser.
- The logging and trace system should be indicated, showing that after each act(), a log file (HTML trace) is generated in a user-specified logs directory.
- API key authentication is a preliminary setup step that feeds into session initialization (configured via environment variable or directly in NovaAct’s constructor).

##### Important Architectural Patterns and Technologies
- Modular design: Separation into “impl”, “types”, and “util” directories suggests a clear separation of concerns.
- Command pattern: The act() method encapsulates a high-level command which then gets broken down into multiple lower-level browser actions.
- Parallel processing: Samples hint at running multiple NovaAct sessions concurrently―a microservice-like approach for parallel browser sessions.
- Use of external libraries: Playwright for browser automation and pydantic for defining and validating JSON schemas.
- Authentication and Environment configuration: via environment variables and configuration files.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Interface
    subgraph "Client Interface"
        A["User Script / Interactive Session"]
        B["Samples (Client Interface)"]
    end

    %% SDK Core
    subgraph "SDK Core"
        C["NovaAct Core API"]
        subgraph "Internal Implementations"
            D["Backend Workflow Control"]
            E["Protocol Handling"]
            F["Window Messages"]
            G["Playwright Integration"]
        end
        subgraph "Support Modules"
            H["Type Definitions & Error Handling"]
            I["Utility: Logging"]
            J["Utility: JSON Schema"]
            K["Utility: Terminal Manager"]
        end
    end

    %% Artifacts
    L["Chrome Extension Artifacts"]

    %% Data Flow Connections
    A -->|"calls"| C
    B -->|"provides usage examples"| C
    C -->|"routes command"| D
    C -->|"routes command"| E
    C -->|"routes command"| F
    C -->|"initiates browser actions"| G
    G -->|"controls browser via Playwright"| L
    C -->|"logs activity"| I

    %% Additional internal communication (optional)
    D -->|"communicates with"| E
    D -->|"communicates with"| F

    %% Click Events
    click B "https://github.com/aws/nova-act/tree/main/src/nova_act/samples"
    click C "https://github.com/aws/nova-act/blob/main/src/nova_act/nova_act.py"
    click D "https://github.com/aws/nova-act/blob/main/src/nova_act/impl/backend.py"
    click E "https://github.com/aws/nova-act/blob/main/src/nova_act/impl/protocol.py"
    click F "https://github.com/aws/nova-act/blob/main/src/nova_act/impl/window_messages.py"
    click G "https://github.com/aws/nova-act/blob/main/src/nova_act/impl/playwright.py"
    click L "https://github.com/aws/nova-act/tree/main/src/nova_act/artifacts/chrome-mv3-prod"
    click H "https://github.com/aws/nova-act/tree/main/src/nova_act/types"
    click I "https://github.com/aws/nova-act/blob/main/src/nova_act/util/logging.py"
    click J "https://github.com/aws/nova-act/blob/main/src/nova_act/util/jsonschema.py"
    click K "https://github.com/aws/nova-act/blob/main/src/nova_act/util/terminal_manager.py"

    %% Styles
    class A,B client
    class C,D,E,F,G,H core
    class I,J,K utility
    class L artifact

    classDef client fill:#FADADD,stroke:#B22222,stroke-width:2px
    classDef core fill:#E0FFE0,stroke:#228B22,stroke-width:2px
    classDef utility fill:#FFFACD,stroke:#DAA520,stroke-width:2px
    classDef artifact fill:#E0FFFF,stroke:#20B2AA,stroke-width:2px
```
