# johnw7789/go-iclient architecture

> Architecture diagram of the GitHub repository johnw7789/go-iclient, 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/johnw7789/go-iclient
- Repository: https://github.com/johnw7789/go-iclient

## Overview

##### Project Type & Purpose
- This is not a full-blown full-stack application but rather a Go client library designed to interface with the iCloud web API.
- Its purpose is to encapsulate the authentication workflow (including OTP and SRP mechanisms) and provide module-based functionalities such as generating HME emails and interacting with the mail inbox.

##### Main Components
a. Core Client Module:
- “icloud” package as the central client which ties together different functionalities.
- Inside this component, show sub-modules such as authentication (auth.go, login.go), HME operations (hme.go, static.go), and mail interactions (mail.go). The “client.go” plays a central control role.
b. SRP Module:
- “srp” directory representing the Secure Remote Password protocol.
- Main parts: client, parameters, and utility functions. This module provides a crucial security layer, and its interactions with authentication should be clearly depicted.
c. Testing:
- A separate “tests” component, though not part of the runtime architecture. It verifies the HME and Mail functionalities.

##### Relationships & Interactions
- Optionally, indicate external interactions with the iCloud web API (e.g., actual HTTP requests, OTP channels) as another component or boundary.

##### Architectural Patterns & Design Principles
- The design employs a modular separation whereby each feature (HME, Mail) is encapsulated in separate source files.
- The use of SRP demonstrates attention to secure authentication and follows the separation of concerns principle.
- Although the project is a client library, visually separate the “interaction with external services” (iCloud API endpoints) from the internal logic.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "iCloud Client Library"
        A["iCloud Client"]:::client
        subgraph "Authentication Module"
            B1["auth.go"]:::auth
            B2["login.go"]:::auth
        end
        subgraph "HME Module"
            C1["hme.go"]:::hme
            C2["static.go"]:::hme
        end
        subgraph "Mail Module"
            D1["mail.go"]:::mail
        end
    end

    subgraph "SRP Module"
        E["SRP Security Module"]:::srp
    end

    F["External iCloud Web API"]:::external

    subgraph "Testing Suite"
        G1["tests/hme.go"]:::test
        G2["tests/mail.go"]:::test
    end

    A -->|"init_auth"| B1
    A -->|"init_auth"| B2
    B1 -->|"SRP_check"| E
    B2 -->|"SRP_check"| E
    A -->|"trigger_HME"| C1
    A -->|"trigger_Mail"| D1
    C1 -->|"HME_feedback"| A
    D1 -->|"Mail_response"| A
    A -.->|"HTTP_calls"| F
    G1 -.->|"test_HME"| C1
    G2 -.->|"test_Mail"| D1

    click A "https://github.com/johnw7789/go-iclient/blob/main/icloud/client.go"
    click B1 "https://github.com/johnw7789/go-iclient/blob/main/icloud/auth.go"
    click B2 "https://github.com/johnw7789/go-iclient/blob/main/icloud/login.go"
    click C1 "https://github.com/johnw7789/go-iclient/blob/main/icloud/hme.go"
    click C2 "https://github.com/johnw7789/go-iclient/blob/main/icloud/static.go"
    click D1 "https://github.com/johnw7789/go-iclient/blob/main/icloud/mail.go"
    click E "https://github.com/johnw7789/go-iclient/tree/main/srp/"
    click G1 "https://github.com/johnw7789/go-iclient/blob/main/tests/hme.go"
    click G2 "https://github.com/johnw7789/go-iclient/blob/main/tests/mail.go"

    classDef client fill:#B3E5FC,stroke:#01579B,stroke-width:2px;
    classDef auth fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef hme fill:#FFE082,stroke:#FF8F00,stroke-width:2px;
    classDef mail fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef srp fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef external fill:#F5F5F5,stroke:#9E9E9E,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef test fill:#DCEDC8,stroke:#558B2F,stroke-width:2px;
```
