# google/promises architecture

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

- Interactive diagram: https://gitdiagram.com/google/promises
- Repository: https://github.com/google/promises

## Overview

##### Project type and purpose
- This is a library/framework (not a running application) for asynchronous programming in Swift and Objective-C, implementing “promises.”
- Its purpose is to provide a common API for creating, chaining, and handling asynchronous tasks, plus extensions (All, Any, Race, Retry, etc.) and test helpers for integration and performance testing.

##### File structure
- Top-level packaging and configuration
- BUILD.bazel, WORKSPACE, Package.swift, PromisesObjC.podspec, PromisesSwift.podspec – build and distribution targets for Bazel, SwiftPM, CocoaPods, Carthage
- .github/workflows/ci.yaml, .travis.yml – CI pipelines
- Sources/
- FBLPromises – Objective-C core implementation (FBLPromise.m, separate category files for each extension)
- FBLPromisesTestHelpers – Objective-C utilities to facilitate testing and interoperability
- Promises – Swift API surface mirroring FBLPromises functionality (Promise.swift and per-feature extensions)
- PromisesTestHelpers – Swift test utilities
- Tests/
- Organized by language and purpose: interoperability tests, performance tests, core feature tests in both Obj-C and Swift
- Examples & docs
- Promises.playground – interactive Swift Playground
- g3doc/ – Markdown documentation (introduction, usage, advanced topics)

##### README for additional insights
- Confirms support for multiple package managers and platforms (iOS, macOS, watchOS, tvOS).
- Lists core features (All, Race, Timeout, etc.) and advanced topics (default queue, retain cycles, testing, Obj-C/Swift interop).

##### Final recommendations
- Be exhaustive: include every source module and packaging target as its own component
- Layering: core → extensions → façade → packaging → CI → consumers/tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Objective-C Core
    subgraph "Objective-C Core"
        FBLCore["FBLPromises (Core Engine)"]:::objc
    end
    click FBLCore "https://github.com/google/promises/tree/master/Sources/FBLPromises"

    %% Objective-C Extensions
    subgraph "ObjC Extensions"
        FBLAll["FBLPromise+All"]:::ext
        FBLAny["FBLPromise+Any"]:::ext
        FBLRace["FBLPromise+Race"]:::ext
        FBLRetry["FBLPromise+Retry"]:::ext
    end
    click FBLAll "https://github.com/google/promises/blob/master/Sources/FBLPromises/FBLPromise+All.m"
    click FBLAny "https://github.com/google/promises/blob/master/Sources/FBLPromises/FBLPromise+Any.m"

    %% Swift Façade
    subgraph "Swift Façade"
        SwiftPromise["Promise.swift"]:::swift
    end
    click SwiftPromise "https://github.com/google/promises/blob/master/Sources/Promises/Promise.swift"

    %% Swift Extensions
    subgraph "Swift Extensions"
        SwiftAll["Promise+All"]:::ext
        SwiftAny["Promise+Any"]:::ext
        SwiftRace["Promise+Race"]:::ext
        SwiftRetry["Promise+Retry"]:::ext
    end
    click SwiftAll "https://github.com/google/promises/blob/master/Sources/Promises/Promise+All.swift"
    click SwiftAny "https://github.com/google/promises/blob/master/Sources/Promises/Promise+Any.swift"

    %% Test Helpers
    subgraph "Test Helpers"
        ObjCTest["FBLPromisesTestHelpers"]:::test
        SwiftTest["PromisesTestHelpers"]:::test
    end
    click ObjCTest "https://github.com/google/promises/tree/master/Sources/FBLPromisesTestHelpers"
    click SwiftTest "https://github.com/google/promises/tree/master/Sources/PromisesTestHelpers"

    %% Packaging
    subgraph "Packaging & Config"
        Bazel["Bazel"]:::pack
        SwiftPM["SwiftPM"]:::pack
        CocoaPods["CocoaPods"]:::pack
    end
    click Bazel "https://github.com/google/promises/blob/master/BUILD.bazel"
    click Bazel "https://github.com/google/promises/tree/master/WORKSPACE"
    click SwiftPM "https://github.com/google/promises/blob/master/Package.swift"
    click CocoaPods "https://github.com/google/promises/blob/master/PromisesObjC.podspec"
    click CocoaPods "https://github.com/google/promises/blob/master/PromisesSwift.podspec"

    %% CI/CD Pipelines
    subgraph "CI/CD Pipelines"
        GHCI["GitHub Actions"]:::ci
        Travis["Travis CI"]:::ci
    end
    click GHCI "https://github.com/google/promises/blob/master/.github/workflows/ci.yaml"
    click Travis "https://github.com/google/promises/blob/master/.travis.yml"

    %% Documentation & Examples
    subgraph "Docs & Examples"
        Playground["Promises.playground"]:::doc
        Docs["g3doc/index.md"]:::doc
    end
    click Playground "https://github.com/google/promises/blob/master/Promises.playground"
    click Docs "https://github.com/google/promises/blob/master/g3doc/index.md"

    %% Consumers
    Apps["App Consumers (iOS/macOS/watchOS/tvOS)"]:::external

    %% Relationships
    SwiftPromise -->|"bridges via modulemap"| FBLCore
    SwiftAll -->|"extends"| SwiftPromise
    SwiftAny -->|"extends"| SwiftPromise
    SwiftRace -->|"extends"| SwiftPromise
    SwiftRetry -->|"extends"| SwiftPromise

    FBLAll -->|"category on"| FBLCore
    FBLAny -->|"category on"| FBLCore
    FBLRace -->|"category on"| FBLCore
    FBLRetry -->|"category on"| FBLCore

    ObjCTest -->|"wraps & tests"| FBLCore
    ObjCTest -->|"wraps & tests"| FBLAll
    SwiftTest -->|"wraps & tests"| SwiftPromise
    SwiftTest -->|"wraps & tests"| SwiftAll

    Bazel -->|"packages"| FBLCore
    Bazel -->|"packages"| SwiftPromise
    SwiftPM -->|"packages"| FBLCore
    SwiftPM -->|"packages"| SwiftPromise
    CocoaPods -->|"packages"| FBLCore
    CocoaPods -->|"packages"| SwiftPromise

    GHCI -->|"runs CI on"| Bazel
    GHCI -->|"runs CI on"| SwiftPM
    GHCI -->|"runs CI on"| CocoaPods
    GHCI -->|"executes tests"| ObjCTest
    GHCI -->|"executes tests"| SwiftTest

    Travis -->|"runs CI on"| Bazel
    Travis -->|"runs CI on"| SwiftPM
    Travis -->|"runs CI on"| CocoaPods
    Travis -->|"executes tests"| ObjCTest
    Travis -->|"executes tests"| SwiftTest

    Apps -->|"use public API"| SwiftPromise

    Playground -->|"demo API"| SwiftPromise
    Docs -->|"document API"| SwiftPromise

    %% Styles
    classDef objc fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef swift fill:#90EE90,stroke:#333,stroke-width:1px
    classDef ext fill:#FFFFE0,stroke:#333,stroke-width:1px
    classDef test fill:#D3D3D3,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef pack fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef ci fill:#E6E6FA,stroke:#333,stroke-width:1px
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef doc fill:#FFFACD,stroke:#333,stroke-width:1px
```
