# atsign-foundation/at_client_sdk architecture

> Architecture diagram of the GitHub repository atsign-foundation/at_client_sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atsign-foundation/at_client_sdk
- Repository: https://github.com/atsign-foundation/at_client_sdk

## Overview

##### Main Components

a. Core Components:
- AtClient Core (at_client package)
- Mobile Client (at_client_mobile package)
- Secondary Server Integration
- Local Storage
- Encryption/Decryption Services
- Sync Service
- Authentication Service

b. Key Subsystems:
- Key Management System
- Collection Management
- Notification Service
- File Transfer Service
- Monitor System
- Sync Manager

##### Application Layer
- Mobile Apps Interface (at_client_mobile)
- Generic Apps Interface (at_client)

##### Service Layer
- Authentication Services
- Encryption Services
- Notification Services
- Sync Services
- File Transfer Services

##### Core Layer
- Key Management
- Data Management
- Storage Management
- Secondary Server Communication

##### Infrastructure Layer
- Local Storage
- Remote Secondary Server
- Encryption/Decryption
- Network Communication

##### Key Relationships

- AtClient's interaction with Secondary Server
- Encryption flow for data security
- Sync mechanism between local and remote storage
- Authentication flow
- Mobile-specific security features

##### Implementation Details

- Application Layer                                       |

- at_client     |                                      |  at_client_mobile    |        |

- Service Layer                                        |

- Auth Service |  | Encrypt Service|  | Notify Service |  | Sync Service       |      |

- Core Layer                                          |

- Key Management |  | Data Management|  | Storage Manager|  | Secondary Client    |     |

- Infrastructure Layer                                     |

- Local Storage  |  | Remote Storage |  | Encryption    |  | Network Protocol    |     |

##### Documentation Notes

Annotations for:
- Security protocols used
- Data encryption points
- Authentication methods
- Storage mechanisms
- Platform-specific implementations

This system design should provide a clear understanding of how the at_client_sdk functions across different platforms while maintaining security and data integrity.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef application fill:#a8d1ff,stroke:#333
    classDef service fill:#90EE90,stroke:#333
    classDef core fill:#FFE5B4,stroke:#333
    classDef infrastructure fill:#E6E6FA,stroke:#333
    classDef security fill:#FFB6C1,stroke:#333

    %% Application Layer
    subgraph Application
        AtClient["AtClient Core"]
        AtClientMobile["Mobile Client"]
    end

    %% Service Layer
    subgraph Services
        AuthService["Authentication Service"]
        EncryptService["Encryption Services"]
        NotifyService["Notification Service"]
        SyncService["Sync Service"]
        FileTransfer["File Transfer Service"]
    end

    %% Core Layer
    subgraph Core
        KeyManagement["Key Management"]
        DataManagement["Data Management"]
        CollectionMgmt["Collection Management"]
        Monitor["Monitor System"]
        SyncManager["Sync Manager"]
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        LocalSecondary["Local Secondary"]
        RemoteSecondary["Remote Secondary"]
        LocalStorage[("Local Storage")]
        NetworkProtocol["Network Protocol"]
    end

    %% Relationships
    AtClient --> AuthService
    AtClient --> EncryptService
    AtClient --> SyncService
    AtClient --> NotifyService
    AtClient --> FileTransfer

    AtClientMobile --> AuthService
    AtClientMobile --> KeyManagement
    
    AuthService --> KeyManagement
    EncryptService --> DataManagement
    SyncService --> SyncManager
    NotifyService --> Monitor
    FileTransfer --> LocalStorage

    KeyManagement --> LocalStorage
    DataManagement --> CollectionMgmt
    CollectionMgmt --> LocalStorage
    SyncManager --> LocalSecondary
    SyncManager --> RemoteSecondary

    LocalSecondary --> LocalStorage
    RemoteSecondary --> NetworkProtocol

    %% Click events for component mapping
    click AtClient "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/client/at_client_impl.dart"
    click AtClientMobile "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client_mobile/lib/src/at_client_mobile_base.dart"
    click LocalSecondary "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/client/local_secondary.dart"
    click RemoteSecondary "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/client/remote_secondary.dart"
    click EncryptService "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/encryption_service/encryption.dart"
    click SyncService "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/service/sync_service.dart"
    click AuthService "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client_mobile/lib/src/auth/at_auth_service.dart"
    click CollectionMgmt "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/at_collection/collections.dart"
    click NotifyService "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/service/notification_service.dart"
    click FileTransfer "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/service/file_transfer_service.dart"
    click Monitor "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/manager/monitor.dart"
    click SyncManager "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client/lib/src/manager/sync_manager.dart"
    click KeyManagement "https://github.com/atsign-foundation/at_client_sdk/blob/trunk/packages/at_client_mobile/lib/src/keychain_manager.dart"

    %% Style applications
    class AtClient,AtClientMobile application
    class AuthService,EncryptService,NotifyService,SyncService,FileTransfer service
    class KeyManagement,DataManagement,CollectionMgmt,Monitor,SyncManager core
    class LocalSecondary,RemoteSecondary,LocalStorage,NetworkProtocol infrastructure
```
