# medimnos/junoswift architecture

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

- Interactive diagram: https://gitdiagram.com/medimnos/junoswift
- Repository: https://github.com/medimnos/junoswift

## Overview

##### Main Components
- Library Core – Represented by the core entry point (JunoSwift.h and JunoSwift/Lib/Juno.swift). This is the primary interface for consumers of the library.
– Authentication.swift (authentication concerns)
– Connection.swift (handling network connections)
– Graph.swift (integration with Microsoft Graph)
– Outlook.swift and SharePoint-related code (offering specialized interactions with Office 365 services)
– NetworkClient.swift (abstracting HTTP communications)
– JunoHelper.swift and Log.swift (support services for logging and other utility tasks)
- Models – Under “JunoSwift/Models” (and the nested SharePoint directory), include data structures for SPAttachment, SPFile, SPFolder, SPList, SPListItem, and TokenStorage to model the domain data.
- Protocols – Found in “JunoSwift/Protocols”, these ensure abstraction especially for attachments and will underpin extension points.
- Resource – JunoSwift/Resource/JunoConfig.swift containing configuration or environmental details.
- Auxiliary Components – Unit tests (JunoSwiftTests directory) and Examples (the Xcode example project under the Examples directory) which provide practical instantiation and testing of the API.

##### Relationships and Interactions
- Consumer Application (Example App) → Library API (JunoSwift.h / Juno.swift): The app initializes and calls into the fluent APIs.
- API Core → API Modules: The core delegates specific responsibilities (e.g., authentication, network connection, logging) to their respective modules.
- API Modules ↔ Models: The API modules exchange well-defined data objects (e.g., SharePoint list items) as defined by the Models.
- API Modules → External Services: Modules like Graph.swift, Outlook.swift, and the SharePoint integrations directly interface with external services, sending requests via the NetworkClient.
- Protocols act as abstraction layers ensuring that implementations like “AttachmentActionDelegate” are pluggable and testable.
- Configuration and Logging: Centralized by JunoConfig and Log components to ensure consistent behavior and troubleshooting.

##### Architectural Patterns
- Layered Architecture: Separate layers for configuration, core logic (API orchestration), service integration (external API calls), and domain models.
- Abstraction/Interface Segregation: Use of protocols which decouple implementation from interface (e.g., AttachmentActionDelegate).
- Modular Design: Distinct files and directories for specific functionalities (Authentication, Connection, Graph, etc.) encourage separation of concerns and easier maintenance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Consumer / Auxiliary
    subgraph "Consumer and Auxiliary"
        EA(["Example Application"]):::internal
        UT(["Unit Tests"]):::tests
    end

    %% Library Core
    subgraph "JunoSwift Library Core"
        JSHeader(["JunoSwift.h"]):::internal
        JSSwift(["Juno.swift"]):::internal
    end

    %% API Modules
    subgraph "Fluent API Modules"
        Auth(["Authentication"]):::internal
        Conn(["Connection"]):::internal
        GraphMod(["Graph"]):::internal
        OutlookMod(["Outlook"]):::internal
        NetClient(["NetworkClient"]):::internal
        JunoHelper(["JunoHelper"]):::internal
        LogMod(["Log"]):::internal
        SPInteract(["SharePoint Interactions"]):::internal
    end

    %% Models
    subgraph "Data Models"
        SPAttach(["SPAttachment"]):::internal
        SPFile(["SPFile"]):::internal
        SPFolder(["SPFolder"]):::internal
        SPList(["SPList"]):::internal
        SPListItem(["SPListItem"]):::internal
        TokenStore(["TokenStorage"]):::internal
    end

    %% Protocols
    subgraph "Protocols"
        AttDelegate(["AttachmentActionDelegate"]):::protocol
    end

    %% Resource / Configuration
    subgraph "Configuration & Utilities"
        JunoCfg(["JunoConfig"]):::config
    end

    %% External Services
    subgraph "External Services"
        SharePointAPI(["SharePoint API"]):::external
        GraphAPI(["Graph API"]):::external
        Office365(["Office365 REST API"]):::external
    end

    %% Relationships
    EA -->|"initializes"| JSHeader
    EA -->|"initializes"| JSSwift

    %% Library Core delegates to API Modules
    JSHeader -->|"delegates"| Auth
    JSHeader -->|"delegates"| Conn
    JSHeader -->|"delegates"| GraphMod
    JSHeader -->|"delegates"| OutlookMod
    JSHeader -->|"delegates"| NetClient
    JSHeader -->|"uses"| JunoHelper
    JSHeader -->|"logs via"| LogMod
    JSHeader -->|"delegates"| SPInteract

    %% API Modules interactions with Models
    Auth -->|"processes"| SPAttach
    Conn -->|"handles"| SPFile
    GraphMod -->|"transforms"| SPListItem
    OutlookMod -->|"manages"| SPList
    SPInteract -->|"handles"| SPFolder
    NetClient -->|"carries"| TokenStore

    %% API Modules interact with External Services via NetClient
    GraphMod -->|"API_Call"| GraphAPI
    OutlookMod -->|"API_Call"| Office365
    SPInteract -->|"API_Call"| SharePointAPI
    Conn -->|"API_Call"| NetClient

    %% Modules interacting with Protocols and Config
    Auth -->|"implements"| AttDelegate
    Conn -->|"reads config"| JunoCfg

    %% Auxiliary relationships
    EA -->|"demonstrates use of"| JSHeader

    %% Click Events for Library Core
    click JSHeader "https://github.com/medimnos/junoswift/blob/master/JunoSwift/JunoSwift.h"
    click JSSwift "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/Juno.swift"

    %% Click Events for Fluent API Modules
    click Auth "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/Authentication.swift"
    click Conn "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/Connection.swift"
    click GraphMod "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/Graph.swift"
    click OutlookMod "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/Outlook.swift"
    click NetClient "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/NetworkClient.swift"
    click JunoHelper "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/JunoHelper.swift"
    click LogMod "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/Log.swift"
    click SPInteract "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Lib/SharePoint.swift"

    %% Click Events for Models
    click SPAttach "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Models/SharePoint/SPAttachment.swift"
    click SPFile "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Models/SharePoint/SPFile.swift"
    click SPFolder "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Models/SharePoint/SPFolder.swift"
    click SPList "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Models/SharePoint/SPList.swift"
    click SPListItem "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Models/SharePoint/SPListItem.swift"
    click TokenStore "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Models/TokenStorage.swift"

    %% Click Event for Protocols
    click AttDelegate "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Protocols/Attachment/AttachmentActionDelegate.swift"

    %% Click Event for Resource / Configuration
    click JunoCfg "https://github.com/medimnos/junoswift/blob/master/JunoSwift/Resource/JunoConfig.swift"

    %% Click Event for Auxiliary Components
    click EA "https://github.com/medimnos/junoswift/tree/master/Examples"
    click UT "https://github.com/medimnos/junoswift/tree/master/JunoSwiftTests"

    %% Class styles
    classDef internal fill:#C2E7FF,stroke:#036,stroke-width:2px;
    classDef external fill:#FFD8A8,stroke:#A66321,stroke-width:2px;
    classDef config fill:#D3FFD8,stroke:#0A3,stroke-width:2px;
    classDef protocol fill:#FFE0E0,stroke:#C00,stroke-width:2px;
    classDef tests fill:#E0FFD8,stroke:#090,stroke-width:2px;
```
