# majd/ipatool architecture

> Architecture diagram of the GitHub repository majd/ipatool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/majd/ipatool
- Repository: https://github.com/majd/ipatool

## Overview

ipatool is a CLI for authenticating with Apple’s App Store, discovering apps and versions, managing licenses and purchases, and downloading iOS-family or macOS packages. The main workflow uses an authenticated account to find or identify an app, optionally acquire its license, then download its package. The repository also exposes MCP tools for app-store operations. The graph preserves documented command capabilities; several implementation links for unsampled commands and subsystems are documented-level rather than source-verified.

Main entry points: [`pkg/appstore`](https://github.com/majd/ipatool/tree/main/pkg/appstore) (App Store client), [`main.go`](https://github.com/majd/ipatool/blob/main/main.go) (CLI entry), [`pkg/http/client.go`](https://github.com/majd/ipatool/blob/main/pkg/http/client.go) (HTTP client), [`pkg/appstore/appstore_login.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_login.go) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and MCP"]
  node_entry["CLI entry<br/>[main.go]"]
  node_auth_cli["Auth commands<br/>[auth.go]"]
  node_search_cli["Search command<br/>[search.go]"]
  node_download_cli["Download command<br/>[download.go]"]
  node_other_cli["Other commands"]
  node_mcp_tools["MCP tools<br/>[mcp_tools.go]"]
end

subgraph group_account["Account and Catalog"]
  node_appstore_api["App Store client"]
  node_login["Authentication<br/>[appstore_login.go]"]
  node_search["App search<br/>[appstore_search.go]"]
  node_owned["Owned apps"]
  node_versions["Version metadata"]
  node_lookup["App lookup"]
end

subgraph group_acquisition["Licensing and Downloads"]
  node_purchase["License purchase"]
  node_download["Package download"]
end

subgraph group_runtime["SAP Signing Runtime"]
  node_signer["SAP action signer<br/>[signer_local.go]"]
  node_machine["SAP guest machine<br/>[machine.go]"]
  node_machimage["Mach-O images<br/>[image.go]"]
  node_unicorn["Emulation engine<br/>[engine.go]"]
end

subgraph group_foundation["State and Transport"]
  node_http["HTTP client<br/>[client.go]"]
  node_keychain["Credential keychain<br/>[keychain.go]"]
  node_state["CLI dependencies and state<br/>[common.go]"]
end

node_user(("User"))
node_appstore_external(("Apple App Store"))

node_user -->|"runs"| node_entry
node_entry -.->|"dispatches"| node_auth_cli
node_entry -.->|"dispatches"| node_search_cli
node_entry -.->|"dispatches"| node_download_cli
node_entry -.->|"dispatches"| node_other_cli
node_entry -.->|"serves tools"| node_mcp_tools
node_auth_cli -->|"calls"| node_appstore_api
node_search_cli -->|"queries"| node_appstore_api
node_download_cli -->|"requests download"| node_appstore_api
node_other_cli -.->|"provides operations"| node_appstore_api
node_mcp_tools -->|"invokes operations"| node_appstore_api
node_appstore_api -.->|"uses App Store"| node_appstore_external
node_appstore_api -.->|"implements"| node_login
node_appstore_api -.->|"implements"| node_search
node_appstore_api -.->|"implements"| node_owned
node_appstore_api -.->|"provides"| node_versions
node_appstore_api -.->|"provides"| node_lookup
node_appstore_api -.->|"provides"| node_purchase
node_appstore_api -.->|"implements"| node_download
node_login -->|"sends requests"| node_http
node_search -->|"sends requests"| node_http
node_owned -->|"sends requests"| node_http
node_download -.->|"uses transport"| node_http
node_login -.->|"creates signer"| node_signer
node_signer -->|"uses guest"| node_machine
node_machine -->|"opens images"| node_machimage
node_machine -->|"runs guest code"| node_unicorn
node_state -->|"configures"| node_keychain
node_state -->|"constructs client"| node_appstore_api

click node_entry "https://github.com/majd/ipatool/blob/main/main.go"
click node_auth_cli "https://github.com/majd/ipatool/blob/main/cmd/auth.go"
click node_search_cli "https://github.com/majd/ipatool/blob/main/cmd/search.go"
click node_download_cli "https://github.com/majd/ipatool/blob/main/cmd/download.go"
click node_other_cli "https://github.com/majd/ipatool/tree/main/cmd"
click node_mcp_tools "https://github.com/majd/ipatool/blob/main/cmd/mcp_tools.go"
click node_appstore_api "https://github.com/majd/ipatool/tree/main/pkg/appstore"
click node_login "https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_login.go"
click node_search "https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_search.go"
click node_owned "https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_owned_apps.go"
click node_versions "https://github.com/majd/ipatool/tree/main/pkg/appstore"
click node_lookup "https://github.com/majd/ipatool/tree/main/pkg/appstore"
click node_purchase "https://github.com/majd/ipatool/tree/main/pkg/appstore"
click node_download "https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download_product.go"
click node_signer "https://github.com/majd/ipatool/blob/main/internal/sap/signer_local.go"
click node_machine "https://github.com/majd/ipatool/blob/main/internal/sap/machine/machine.go"
click node_machimage "https://github.com/majd/ipatool/blob/main/internal/sap/machimage/image.go"
click node_unicorn "https://github.com/majd/ipatool/blob/main/internal/sap/unicorn/engine.go"
click node_http "https://github.com/majd/ipatool/blob/main/pkg/http/client.go"
click node_keychain "https://github.com/majd/ipatool/blob/main/pkg/keychain/keychain.go"
click node_state "https://github.com/majd/ipatool/blob/main/cmd/common.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_auth_cli,node_search_cli,node_download_cli,node_other_cli,node_mcp_tools,node_user toneBlue
class node_appstore_api,node_login,node_search,node_owned,node_versions,node_lookup toneAmber
class node_purchase,node_download toneMint
class node_signer,node_machine,node_machimage,node_unicorn toneRose
class node_http,node_keychain,node_state,node_appstore_external toneIndigo
```

## Components

### CLI and MCP

- [CLI entry](https://github.com/majd/ipatool/blob/main/main.go): `main.go`
- [Auth commands](https://github.com/majd/ipatool/blob/main/cmd/auth.go): `cmd/auth.go`
- [Search command](https://github.com/majd/ipatool/blob/main/cmd/search.go): `cmd/search.go`
- [Download command](https://github.com/majd/ipatool/blob/main/cmd/download.go): `cmd/download.go`
- [Other commands](https://github.com/majd/ipatool/tree/main/cmd): `cmd`
- [MCP tools](https://github.com/majd/ipatool/blob/main/cmd/mcp_tools.go): `cmd/mcp_tools.go`

### Account and Catalog

- [App Store client](https://github.com/majd/ipatool/tree/main/pkg/appstore): `pkg/appstore`
- [Authentication](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_login.go): `pkg/appstore/appstore_login.go`
- [App search](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_search.go): `pkg/appstore/appstore_search.go`
- [Owned apps](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_owned_apps.go): `pkg/appstore/appstore_owned_apps.go`
- [Version metadata](https://github.com/majd/ipatool/tree/main/pkg/appstore): `pkg/appstore`
- [App lookup](https://github.com/majd/ipatool/tree/main/pkg/appstore): `pkg/appstore`

### Licensing and Downloads

- [License purchase](https://github.com/majd/ipatool/tree/main/pkg/appstore): `pkg/appstore`
- [Package download](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download_product.go): `pkg/appstore/appstore_download_product.go`

### SAP Signing Runtime

- [SAP action signer](https://github.com/majd/ipatool/blob/main/internal/sap/signer_local.go): `internal/sap/signer_local.go`
- [SAP guest machine](https://github.com/majd/ipatool/blob/main/internal/sap/machine/machine.go): `internal/sap/machine/machine.go`
- [Mach-O images](https://github.com/majd/ipatool/blob/main/internal/sap/machimage/image.go): `internal/sap/machimage/image.go`
- [Emulation engine](https://github.com/majd/ipatool/blob/main/internal/sap/unicorn/engine.go): `internal/sap/unicorn/engine.go`

### State and Transport

- [HTTP client](https://github.com/majd/ipatool/blob/main/pkg/http/client.go): `pkg/http/client.go`
- [Credential keychain](https://github.com/majd/ipatool/blob/main/pkg/keychain/keychain.go): `pkg/keychain/keychain.go`
- [CLI dependencies and state](https://github.com/majd/ipatool/blob/main/cmd/common.go): `cmd/common.go`

### Other components

- **User**
- **Apple App Store**

## Connections

- User → CLI entry: runs (evidence: `main.go`)
- CLI entry → Auth commands: dispatches
- CLI entry → Search command: dispatches
- CLI entry → Download command: dispatches
- CLI entry → Other commands: dispatches (evidence: `main.go`)
- CLI entry → MCP tools: serves tools
- Auth commands → App Store client: calls (evidence: `cmd/auth.go`)
- Search command → App Store client: queries (evidence: `cmd/search.go`)
- Download command → App Store client: requests download (evidence: `cmd/download.go`)
- Other commands → App Store client: provides operations (evidence: `cmd/auth.go`)
- MCP tools → App Store client: invokes operations (evidence: `cmd/mcp_tools.go`)
- App Store client → Apple App Store: uses App Store
- App Store client → Authentication: implements
- App Store client → App search: implements
- App Store client → Owned apps: implements
- App Store client → Version metadata: provides
- App Store client → App lookup: provides
- App Store client → License purchase: provides
- App Store client → Package download: implements
- Authentication → HTTP client: sends requests (evidence: `pkg/appstore/appstore_login.go`)
- App search → HTTP client: sends requests (evidence: `pkg/appstore/appstore_search.go`)
- Owned apps → HTTP client: sends requests (evidence: `pkg/appstore/appstore_owned_apps.go`)
- Package download → HTTP client: uses transport (evidence: `pkg/appstore/appstore_download_product.go`)
- Authentication → SAP action signer: creates signer
- SAP action signer → SAP guest machine: uses guest (evidence: `internal/sap/signer_local.go`)
- SAP guest machine → Mach-O images: opens images (evidence: `internal/sap/machine/machine.go`)
- SAP guest machine → Emulation engine: runs guest code (evidence: `internal/sap/machine/machine.go`)
- CLI dependencies and state → Credential keychain: configures (evidence: `cmd/common.go`)
- CLI dependencies and state → App Store client: constructs client (evidence: `cmd/common.go`)
