> ## Documentation Index
> Fetch the complete documentation index at: https://www.minitap.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture Overview

> Understand the mobile-use SDK architecture

The mobile-use SDK follows a layered architecture designed to provide both simplicity for common use cases and flexibility for advanced scenarios.

<Note>
  The core concepts apply to both **Platform** and **Local** approaches. The platform simplifies configuration by managing profiles and tasks centrally, while local development gives you full control over all components.
</Note>

## Architecture Diagram

```mermaid theme={null}
graph LR
    subgraph "mobile-use SDK"
        subgraph "Builders"
            TaskBuilder["Task Request Builder"]
            AgentConfig["Agent Config Builder"]
        end

        subgraph "Agent Components"
            Agent["Agent Class"]
            Profiles["Agent Profiles"]
            Tasks["Tasks"]
        end

        subgraph "Services"
            Servers["Servers"]
            DeviceController[["Device Controller"]]
        end

        subgraph "LangGraph Integration"
            LangGraph["mobile-use"]
            LLM["LLM APIs"]
        end

        subgraph "Device Realm"
            Device{{"Device Connection"}}
            AndroidDevice[["Android Device"]]
            iOSDevice[["iOS Device"]]
        end

        Agent --> |uses| Profiles
        Agent --> |initializes| Servers
        Agent --> |creates & runs| Tasks
        Agent --> |manages| Device

        Servers --> DeviceController

        Tasks --> LangGraph
        LangGraph --> |uses| LLM
        LangGraph --> |controls| Device
        DeviceController --> |controls| Device

        TaskBuilder --> |configures| Tasks
        PlatformTaskRequest --> |configures| Tasks
        AgentConfig --> |configures| Agent
    end
    
    Device --> |connects to| AndroidDevice
    Device --> |connects to| iOSDevice
```

## Key Components

<CardGroup cols={2}>
  <Card title="Agent" icon="robot" href="/docs/mobile-use-sdk/core-concepts/agent">
    The central orchestrator for mobile automation
  </Card>

  <Card title="Tasks" icon="list-check" href="/docs/mobile-use-sdk/core-concepts/tasks">
    Goal-based automation workflows with structured output
  </Card>

  <Card title="Profiles" icon="user-gear" href="/docs/mobile-use-sdk/core-concepts/profiles">
    Customize agent behavior and LLM configuration
  </Card>

  <Card title="Builders" icon="wrench" href="/docs/mobile-use-sdk/core-concepts/builders">
    Fluent APIs for configuring agents and tasks
  </Card>
</CardGroup>

## Component Overview

### Agent Layer

The `Agent` class is the primary entry point that coordinates:

* Device connections (Android/iOS)
* Server lifecycle management
* Task creation and execution
* Resource cleanup

### Task Layer

Tasks represent automation workflows defined by:

* **Natural language goals** - What you want to accomplish
* **Structured output** - Type-safe results using Pydantic
* **Tracing** - Recording execution for debugging

### LangGraph Integration

The SDK leverages [LangGraph](https://github.com/langchain-ai/langgraph) for:

* **Agent reasoning** - Transparent decision-making process
* **Step-by-step execution** - Breaking complex tasks into manageable steps
* **Dynamic adaptation** - Responding to what's on screen

### Device Interaction

Two key components handle device control:

<Accordion title="Device Controller">
  Performs physical actions on the device using native platform tools:

  * **Android**: Uses ADB (Android Debug Bridge) with UIAutomator2 for reliable UI automation
  * **iOS**: Uses IDB (iOS Development Bridge) for simulator and device control

  Capabilities include:

  * Tap, swipe, scroll gestures
  * App launching and navigation
  * Key press events
  * Text input
</Accordion>

## Execution Flow

<Steps>
  <Step title="Initialize">
    Agent connects to device and starts required servers
  </Step>

  <Step title="Plan">
    LLM analyzes the goal and creates a plan
  </Step>

  <Step title="Observe">
    Device Controller captures current UI state (screenshots and UI hierarchy)
  </Step>

  <Step title="Decide">
    LLM determines next action based on screen
  </Step>

  <Step title="Act">
    Device Controller executes the action
  </Step>

  <Step title="Repeat">
    Loop through steps 3-5 until goal is achieved
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="Agent" icon="robot" href="/docs/mobile-use-sdk/core-concepts/agent">
    Learn about the Agent class
  </Card>

  <Card title="Tasks" icon="list-check" href="/docs/mobile-use-sdk/core-concepts/tasks">
    Understand task creation and execution
  </Card>
</CardGroup>
