# vapor/vapor architecture

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

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

## Overview

Vapor is a Swift HTTP framework for building websites, APIs, and cloud services. An application configures and runs a server; incoming HTTP requests are represented as Request values, passed through middleware and route handlers, and converted into responses. Content coders handle message bodies, while authentication, sessions, validation, views, caching, and outbound HTTP provide supporting capabilities. The README establishes the product scope; sampled source and the SOURCE INDEX support the central application, routing, middleware, content, and client relationships. Some server dispatch and unsampled capability wiring is shown only as unverified.

Main entry points: [`Sources/Vapor/Application.swift`](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Application.swift) (Application), [`Sources/Vapor/Content/ContentConfiguration.swift`](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Content/ContentConfiguration.swift) (Content coding), [`Sources/Vapor/Request/Request.swift`](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Request/Request.swift) (Request), [`Sources/Vapor/HTTP/Client/VaporHTTPClient.swift`](https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Client/VaporHTTPClient.swift) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application Runtime"]
  node_app["Application<br/>[Application.swift]"]
  node_server["HTTP server<br/>[Server.swift]"]
end

subgraph group_http["HTTP Handling"]
  node_http_handler["HTTP server handler"]
  node_request["Request<br/>[Request.swift]"]
  node_middleware["Middleware chain<br/>[Middleware.swift]"]
  node_route["Route<br/>[Route.swift]"]
  node_responder["Responder<br/>[Responder.swift]"]
  node_response["Response<br/>[Response.swift]"]
end

subgraph group_content["Content and Views"]
  node_content["Content coding"]
  node_content_api["Content API<br/>[Content.swift]"]
  node_view["View rendering<br/>[ViewRenderer.swift]"]
end

subgraph group_services["Application Services"]
  node_auth["Authentication"]
  node_sessions["Sessions"]
  node_cache["Cache<br/>[Cache.swift]"]
  node_client["HTTP client"]
  node_client_request["Client request"]
  node_client_response["Client response"]
end

subgraph group_developer["Developer API"]
  node_routes["Route registration"]
  node_validation["Validation<br/>[Validations.swift]"]
end

node_developer(("Application developer"))
node_actor(("HTTP caller"))

node_developer -->|"configures"| node_app
node_app -->|"runs"| node_server
node_actor -.->|"sends HTTP"| node_server
node_server -.->|"dispatches"| node_http_handler
node_http_handler -.->|"creates"| node_request
node_request -->|"enters chain"| node_middleware
node_middleware -->|"chains to"| node_responder
node_developer -->|"registers routes"| node_routes
node_routes -->|"adds"| node_route
node_route -.->|"dispatches"| node_responder
node_responder -.->|"returns"| node_response
node_app -->|"configures"| node_content
node_content_api -->|"uses coders"| node_content
node_request -.->|"decodes body"| node_content
node_response -->|"encodes body"| node_content
node_app -->|"configures"| node_view
node_app -->|"configures"| node_cache
node_app -->|"configures"| node_client
node_app -->|"configures"| node_sessions
node_request -.->|"provides access"| node_auth
node_request -.->|"provides access"| node_sessions
node_developer -.->|"validates input"| node_validation
node_client -->|"sends"| node_client_request
node_client -->|"produces"| node_client_response
node_client_request -->|"encodes content"| node_content
node_client_response -.->|"decodes content"| node_content

click node_app "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Application.swift"
click node_server "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Server/Server.swift"
click node_http_handler "https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Server/HTTPServerHandler.swift"
click node_request "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Request/Request.swift"
click node_middleware "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Middleware/Middleware.swift"
click node_routes "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Routing/RoutesBuilder%2BMethod.swift"
click node_route "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Routing/Route.swift"
click node_responder "https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Responder.swift"
click node_response "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Response/Response.swift"
click node_content "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Content/ContentConfiguration.swift"
click node_content_api "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Content/Content.swift"
click node_view "https://github.com/vapor/vapor/blob/main/Sources/Vapor/View/ViewRenderer.swift"
click node_auth "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Authentication/Authentication.swift"
click node_sessions "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Sessions/SessionsMiddleware.swift"
click node_cache "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Cache/Cache.swift"
click node_validation "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Validation/Validations.swift"
click node_client "https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Client/VaporHTTPClient.swift"
click node_client_request "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Client/ClientRequest.swift"
click node_client_response "https://github.com/vapor/vapor/blob/main/Sources/Vapor/Client/ClientResponse.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_server toneBlue
class node_http_handler,node_request,node_middleware,node_route,node_responder,node_response toneAmber
class node_content,node_content_api,node_view toneMint
class node_auth,node_sessions,node_cache,node_client,node_client_request,node_client_response toneRose
class node_routes,node_validation,node_developer,node_actor toneIndigo
```

## Components

### Application Runtime

- [Application](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Application.swift): `Sources/Vapor/Application.swift`
- [HTTP server](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Server/Server.swift): `Sources/Vapor/Server/Server.swift`

### HTTP Handling

- [HTTP server handler](https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Server/HTTPServerHandler.swift): `Sources/Vapor/HTTP/Server/HTTPServerHandler.swift`
- [Request](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Request/Request.swift): `Sources/Vapor/Request/Request.swift`
- [Middleware chain](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Middleware/Middleware.swift): `Sources/Vapor/Middleware/Middleware.swift`
- [Route](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Routing/Route.swift): `Sources/Vapor/Routing/Route.swift`
- [Responder](https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Responder.swift): `Sources/Vapor/HTTP/Responder.swift`
- [Response](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Response/Response.swift): `Sources/Vapor/Response/Response.swift`

### Content and Views

- [Content coding](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Content/ContentConfiguration.swift): `Sources/Vapor/Content/ContentConfiguration.swift`
- [Content API](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Content/Content.swift): `Sources/Vapor/Content/Content.swift`
- [View rendering](https://github.com/vapor/vapor/blob/main/Sources/Vapor/View/ViewRenderer.swift): `Sources/Vapor/View/ViewRenderer.swift`

### Application Services

- [Authentication](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Authentication/Authentication.swift): `Sources/Vapor/Authentication/Authentication.swift`
- [Sessions](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Sessions/SessionsMiddleware.swift): `Sources/Vapor/Sessions/SessionsMiddleware.swift`
- [Cache](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Cache/Cache.swift): `Sources/Vapor/Cache/Cache.swift`
- [HTTP client](https://github.com/vapor/vapor/blob/main/Sources/Vapor/HTTP/Client/VaporHTTPClient.swift): `Sources/Vapor/HTTP/Client/VaporHTTPClient.swift`
- [Client request](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Client/ClientRequest.swift): `Sources/Vapor/Client/ClientRequest.swift`
- [Client response](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Client/ClientResponse.swift): `Sources/Vapor/Client/ClientResponse.swift`

### Developer API

- [Route registration](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Routing/RoutesBuilder%2BMethod.swift): `Sources/Vapor/Routing/RoutesBuilder+Method.swift`
- [Validation](https://github.com/vapor/vapor/blob/main/Sources/Vapor/Validation/Validations.swift): `Sources/Vapor/Validation/Validations.swift`

### Other components

- **Application developer**
- **HTTP caller**

## Connections

- Application developer → Application: configures (evidence: `Sources/Vapor/Application.swift`)
- Application → HTTP server: runs (evidence: `Sources/Vapor/Application.swift`)
- HTTP caller → HTTP server: sends HTTP
- HTTP server → HTTP server handler: dispatches
- HTTP server handler → Request: creates
- Request → Middleware chain: enters chain (evidence: `Sources/Vapor/Middleware/Middleware.swift`)
- Middleware chain → Responder: chains to (evidence: `Sources/Vapor/Middleware/Middleware.swift`)
- Application developer → Route registration: registers routes (evidence: `Sources/Vapor/Routing/RoutesBuilder+Method.swift`)
- Route registration → Route: adds (evidence: `Sources/Vapor/Routing/RoutesBuilder+Method.swift`)
- Route → Responder: dispatches (evidence: `Sources/Vapor/Routing/Route.swift`)
- Responder → Response: returns (evidence: `Sources/Vapor/HTTP/Responder.swift`)
- Application → Content coding: configures (evidence: `Sources/Vapor/Application.swift`)
- Content API → Content coding: uses coders (evidence: `Sources/Vapor/Content/Content.swift`)
- Request → Content coding: decodes body (evidence: `Sources/Vapor/Request/Request.swift`)
- Response → Content coding: encodes body (evidence: `Sources/Vapor/Response/Response.swift`)
- Application → View rendering: configures (evidence: `Sources/Vapor/Application.swift`)
- Application → Cache: configures (evidence: `Sources/Vapor/Application.swift`)
- Application → HTTP client: configures (evidence: `Sources/Vapor/Application.swift`)
- Application → Sessions: configures (evidence: `Sources/Vapor/Application.swift`)
- Request → Authentication: provides access (evidence: `Sources/Vapor/Request/Request.swift`)
- Request → Sessions: provides access
- Application developer → Validation: validates input
- HTTP client → Client request: sends (evidence: `Sources/Vapor/HTTP/Client/VaporHTTPClient.swift`)
- HTTP client → Client response: produces (evidence: `Sources/Vapor/HTTP/Client/VaporHTTPClient.swift`)
- Client request → Content coding: encodes content (evidence: `Sources/Vapor/Client/ClientRequest.swift`)
- Client response → Content coding: decodes content (evidence: `Sources/Vapor/Client/ClientResponse.swift`)
