# vapor/async-kit architecture

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

- Interactive diagram: https://gitdiagram.com/vapor/async-kit
- Repository: https://github.com/vapor/async-kit

## Overview

##### Project type and purpose
- This is a Swift “library” package (AsyncKit) providing utilities atop Apple’s Swift NIO concurrency primitives (EventLoop, EventLoopFuture).
- It is an open-source tool/module—not a standalone application—focused on extending and simplifying future composition and connection pooling.

##### File structure
- Top-level:
- Package.swift (defines this as a Swift package)
- Sources/AsyncKit/… (the library’s source modules)
- Tests/AsyncKitTests/… (unit tests for each utility)
- Within Sources/AsyncKit: three main folders:
- ConnectionPool (pooling abstractions over EventLoop/EventLoopGroup)
- EventLoop (extensions adding concurrency support on NIO’s EventLoop and EventLoopGroup)
- EventLoopFuture (operators and combinators for EventLoopFuture)
- Exports.swift re-exports key APIs as the public interface.

##### README
- Confirms this is a legacy package of utilities around EventLoopFuture and pre-Concurrency Swift NIO APIs.
- No higher-level application architecture; the “system” is the library plus its relationships with Swift NIO and the user’s application.

##### Elements
- “User Application”
- “AsyncKit: EventLoop Extensions”
- “AsyncKit: EventLoopFuture Utilities”
- “AsyncKit: ConnectionPool”
- “Swift NIO Core”
- From User Application → AsyncKit modules
- From each AsyncKit module → Swift NIO Core
- From EventLoopFuture Utilities → ConnectionPool (because pools return futures)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Consumer
    UserApp["User Application"]:::consumer

    %% AsyncKit Library Boundary
    subgraph "AsyncKit Package" 
        direction TB
        Exports["Exports.swift"]:::library
        subgraph "EventLoop Extensions"
            direction TB
            ALE["AsyncKit: EventLoop Extensions"]:::library
        end
        subgraph "EventLoopFuture Utilities"
            direction TB
            ALF["AsyncKit: EventLoopFuture Utilities"]:::library
        end
        subgraph "ConnectionPool"
            direction TB
            ACP["AsyncKit: ConnectionPool"]:::library
        end
    end

    %% External Dependency
    SNIO["Swift NIO Core"]:::external

    %% Unit Tests
    Tests["Unit Tests (AsyncKitTests)"]:::tests

    %% Relationships
    UserApp -->|"imports"| Exports
    UserApp -->|uses| ALE
    UserApp -->|uses| ALF
    UserApp -->|uses| ACP

    Exports -->|re-exports API| ALE
    Exports -->|re-exports API| ALF
    Exports -->|re-exports API| ACP

    ALE -->|"extends EventLoop/Group"| SNIO
    ALF -->|"combinators on Future"| SNIO
    ACP -->|"uses EventLoopGroup & Futures"| SNIO

    ALF -->|"returns futures to"| ACP

    Tests -.-> ALE
    Tests -.-> ALF
    Tests -.-> ACP

    %% Click Events
    click Exports "https://github.com/vapor/async-kit/blob/main/Sources/AsyncKit/Exports.swift"
    click ALE "https://github.com/vapor/async-kit/tree/main/Sources/AsyncKit/EventLoop"
    click ALF "https://github.com/vapor/async-kit/tree/main/Sources/AsyncKit/EventLoopFuture"
    click ACP "https://github.com/vapor/async-kit/tree/main/Sources/AsyncKit/ConnectionPool"
    click UserApp "https://github.com/vapor/async-kit/blob/main/Package.swift"
    click Tests "https://github.com/vapor/async-kit/tree/main/Tests/AsyncKitTests"

    %% Styles
    classDef consumer fill:#FFDFA6,stroke:#CC8E35,stroke-width:2px
    classDef library fill:#A6D1FF,stroke:#2E6FB7,stroke-width:2px
    classDef external fill:#C8F7C5,stroke:#3E8E3E,stroke-width:2px
    classDef tests fill:#F7C5F1,stroke:#A73E8E,stroke-width:2px
```
