# rwf2/rocket architecture

> Architecture diagram of the GitHub repository rwf2/rocket, 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/rwf2/rocket
- Repository: https://github.com/rwf2/rocket

## Overview

Rocket is an asynchronous Rust web framework. In the main workflow, an application declares and mounts routes, starts a server, and an incoming HTTP request is parsed and dispatched to a matching handler; the handler’s result is converted to a response and sent back. The repository also provides request/data handling, catchers, file serving, templates, database pools, WebSockets, TLS, and local clients. The graph combines README-described behavior with source-index references and sampled excerpts; several extension internals were not sampled, so their links are limited to documented or indexed relationships.

Main entry points: [`core/lib/src/rocket.rs`](https://github.com/rwf2/rocket/blob/master/core/lib/src/rocket.rs) (Rocket application), [`core/lib/src/server.rs`](https://github.com/rwf2/rocket/blob/master/core/lib/src/server.rs) (HTTP server), [`core/lib/src/route/handler.rs`](https://github.com/rwf2/rocket/blob/master/core/lib/src/route/handler.rs) (Route handlers), [`core/lib/src/router/router.rs`](https://github.com/rwf2/rocket/blob/master/core/lib/src/router/router.rs) (Route matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application Setup"]
  node_rocket["Rocket application<br/>[rocket.rs]"]
  node_config["Configuration and state<br/>[config.rs]"]
  node_lifecycle["Launch lifecycle<br/>[lifecycle.rs]"]
  node_fairings["Fairings<br/>[fairings.rs]"]
end

subgraph group_runtime["HTTP Runtime"]
  node_listener["Network listeners<br/>[mod.rs]"]
  node_server["HTTP server<br/>[server.rs]"]
  node_request["Request and guards<br/>[request.rs]"]
  node_data["Request data<br/>[data.rs]"]
  node_router["Route matching<br/>[router.rs]"]
  node_route_handler["Route handlers<br/>[handler.rs]"]
  node_response["Response construction<br/>[response.rs]"]
  node_catchers["Error catchers<br/>[handler.rs]"]
end

subgraph group_http["HTTP Types"]
  node_http_types["HTTP and URI types<br/>[path_query.rs]"]
  node_cookies["Cookie handling<br/>[cookies.rs]"]
end

subgraph group_extensions["Framework Extensions"]
  node_file_server["Static file server<br/>[server.rs]"]
  node_templates["Dynamic templates<br/>[template.rs]"]
  node_template_context["Template discovery<br/>[context.rs]"]
  node_template_engines["Template engines<br/>[mod.rs]"]
  node_db_pools["Async database pools<br/>[database.rs]"]
  node_sync_db["Sync database pools<br/>[lib.rs]"]
  node_websockets["WebSockets<br/>[websocket.rs]"]
  node_local_client["Local test clients<br/>[client.rs]"]
  node_tls["TLS and mTLS<br/>[listener.rs]"]
end

subgraph group_macros["Compile-Time APIs"]
  node_macros["Route and launch macros<br/>[lib.rs]"]
end

node_developer(("Application developer"))
node_browser(("HTTP client"))

node_developer -->|"declares routes"| node_macros
node_developer -->|"mounts routes"| node_rocket
node_macros -.->|"generates handlers"| node_route_handler
node_rocket -.->|"uses configuration"| node_config
node_rocket -.->|"starts application"| node_lifecycle
node_rocket -.->|"attaches fairings"| node_fairings
node_rocket -.->|"starts serving"| node_server
node_server -->|"accepts connections"| node_listener
node_browser -->|"sends HTTP"| node_listener
node_server -->|"dispatches requests"| node_router
node_router -->|"matches request"| node_request
node_router -->|"selects route"| node_route_handler
node_route_handler -->|"builds response"| node_response
node_route_handler -->|"handles request"| node_request
node_route_handler -->|"consumes data"| node_data
node_router -->|"selects catcher"| node_catchers
node_server -->|"uses HTTP types"| node_http_types
node_request -->|"uses HTTP types"| node_http_types
node_response -->|"uses HTTP types"| node_http_types
node_request -->|"exposes cookies"| node_cookies
node_rocket -->|"mounts file server"| node_file_server
node_templates -->|"initializes context"| node_template_context
node_template_context -->|"initializes engines"| node_template_engines
node_templates -->|"renders templates"| node_template_engines
node_rocket -.->|"integrates pools"| node_db_pools
node_rocket -.->|"integrates pools"| node_sync_db
node_rocket -.->|"supports upgrades"| node_websockets
node_local_client -.->|"exercises server"| node_server
node_listener -.->|"supports TLS"| node_tls

click node_rocket "https://github.com/rwf2/rocket/blob/master/core/lib/src/rocket.rs"
click node_config "https://github.com/rwf2/rocket/blob/master/core/lib/src/config/config.rs"
click node_lifecycle "https://github.com/rwf2/rocket/blob/master/core/lib/src/lifecycle.rs"
click node_fairings "https://github.com/rwf2/rocket/blob/master/core/lib/src/fairing/fairings.rs"
click node_macros "https://github.com/rwf2/rocket/blob/master/core/codegen/src/lib.rs"
click node_http_types "https://github.com/rwf2/rocket/blob/master/core/http/src/uri/path_query.rs"
click node_listener "https://github.com/rwf2/rocket/blob/master/core/lib/src/listener/mod.rs"
click node_server "https://github.com/rwf2/rocket/blob/master/core/lib/src/server.rs"
click node_request "https://github.com/rwf2/rocket/blob/master/core/lib/src/request/request.rs"
click node_data "https://github.com/rwf2/rocket/blob/master/core/lib/src/data/data.rs"
click node_router "https://github.com/rwf2/rocket/blob/master/core/lib/src/router/router.rs"
click node_route_handler "https://github.com/rwf2/rocket/blob/master/core/lib/src/route/handler.rs"
click node_response "https://github.com/rwf2/rocket/blob/master/core/lib/src/response/response.rs"
click node_catchers "https://github.com/rwf2/rocket/blob/master/core/lib/src/catcher/handler.rs"
click node_cookies "https://github.com/rwf2/rocket/blob/master/core/lib/src/http/cookies.rs"
click node_file_server "https://github.com/rwf2/rocket/blob/master/core/lib/src/fs/server.rs"
click node_templates "https://github.com/rwf2/rocket/blob/master/contrib/dyn_templates/src/template.rs"
click node_template_context "https://github.com/rwf2/rocket/blob/master/contrib/dyn_templates/src/context.rs"
click node_template_engines "https://github.com/rwf2/rocket/blob/master/contrib/dyn_templates/src/engine/mod.rs"
click node_db_pools "https://github.com/rwf2/rocket/blob/master/contrib/db_pools/lib/src/database.rs"
click node_sync_db "https://github.com/rwf2/rocket/blob/master/contrib/sync_db_pools/lib/src/lib.rs"
click node_websockets "https://github.com/rwf2/rocket/blob/master/contrib/ws/src/websocket.rs"
click node_local_client "https://github.com/rwf2/rocket/blob/master/core/lib/src/local/client.rs"
click node_tls "https://github.com/rwf2/rocket/blob/master/core/lib/src/tls/listener.rs"

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_rocket,node_config,node_lifecycle,node_fairings,node_browser toneBlue
class node_listener,node_server,node_request,node_data,node_router,node_route_handler,node_response,node_catchers toneAmber
class node_http_types,node_cookies toneMint
class node_file_server,node_templates,node_template_context,node_template_engines,node_db_pools,node_sync_db,node_websockets,node_local_client,node_tls toneRose
class node_macros,node_developer toneIndigo
```

## Components

### Application Setup

- [Rocket application](https://github.com/rwf2/rocket/blob/master/core/lib/src/rocket.rs): `core/lib/src/rocket.rs`
- [Configuration and state](https://github.com/rwf2/rocket/blob/master/core/lib/src/config/config.rs): `core/lib/src/config/config.rs`
- [Launch lifecycle](https://github.com/rwf2/rocket/blob/master/core/lib/src/lifecycle.rs): `core/lib/src/lifecycle.rs`
- [Fairings](https://github.com/rwf2/rocket/blob/master/core/lib/src/fairing/fairings.rs): `core/lib/src/fairing/fairings.rs`

### HTTP Runtime

- [Network listeners](https://github.com/rwf2/rocket/blob/master/core/lib/src/listener/mod.rs): `core/lib/src/listener/mod.rs`
- [HTTP server](https://github.com/rwf2/rocket/blob/master/core/lib/src/server.rs): `core/lib/src/server.rs`
- [Request and guards](https://github.com/rwf2/rocket/blob/master/core/lib/src/request/request.rs): `core/lib/src/request/request.rs`
- [Request data](https://github.com/rwf2/rocket/blob/master/core/lib/src/data/data.rs): `core/lib/src/data/data.rs`
- [Route matching](https://github.com/rwf2/rocket/blob/master/core/lib/src/router/router.rs): `core/lib/src/router/router.rs`
- [Route handlers](https://github.com/rwf2/rocket/blob/master/core/lib/src/route/handler.rs): `core/lib/src/route/handler.rs`
- [Response construction](https://github.com/rwf2/rocket/blob/master/core/lib/src/response/response.rs): `core/lib/src/response/response.rs`
- [Error catchers](https://github.com/rwf2/rocket/blob/master/core/lib/src/catcher/handler.rs): `core/lib/src/catcher/handler.rs`

### HTTP Types

- [HTTP and URI types](https://github.com/rwf2/rocket/blob/master/core/http/src/uri/path_query.rs): `core/http/src/uri/path_query.rs`
- [Cookie handling](https://github.com/rwf2/rocket/blob/master/core/lib/src/http/cookies.rs): `core/lib/src/http/cookies.rs`

### Framework Extensions

- [Static file server](https://github.com/rwf2/rocket/blob/master/core/lib/src/fs/server.rs): `core/lib/src/fs/server.rs`
- [Dynamic templates](https://github.com/rwf2/rocket/blob/master/contrib/dyn_templates/src/template.rs): `contrib/dyn_templates/src/template.rs`
- [Template discovery](https://github.com/rwf2/rocket/blob/master/contrib/dyn_templates/src/context.rs): `contrib/dyn_templates/src/context.rs`
- [Template engines](https://github.com/rwf2/rocket/blob/master/contrib/dyn_templates/src/engine/mod.rs): `contrib/dyn_templates/src/engine/mod.rs`
- [Async database pools](https://github.com/rwf2/rocket/blob/master/contrib/db_pools/lib/src/database.rs): `contrib/db_pools/lib/src/database.rs`
- [Sync database pools](https://github.com/rwf2/rocket/blob/master/contrib/sync_db_pools/lib/src/lib.rs): `contrib/sync_db_pools/lib/src/lib.rs`
- [WebSockets](https://github.com/rwf2/rocket/blob/master/contrib/ws/src/websocket.rs): `contrib/ws/src/websocket.rs`
- [Local test clients](https://github.com/rwf2/rocket/blob/master/core/lib/src/local/client.rs): `core/lib/src/local/client.rs`
- [TLS and mTLS](https://github.com/rwf2/rocket/blob/master/core/lib/src/tls/listener.rs): `core/lib/src/tls/listener.rs`

### Compile-Time APIs

- [Route and launch macros](https://github.com/rwf2/rocket/blob/master/core/codegen/src/lib.rs): `core/codegen/src/lib.rs`

### Other components

- **Application developer**
- **HTTP client**

## Connections

- Application developer → Route and launch macros: declares routes (evidence: `README.md`)
- Application developer → Rocket application: mounts routes (evidence: `README.md`)
- Route and launch macros → Route handlers: generates handlers
- Rocket application → Configuration and state: uses configuration
- Rocket application → Launch lifecycle: starts application
- Rocket application → Fairings: attaches fairings
- Rocket application → HTTP server: starts serving
- HTTP server → Network listeners: accepts connections (evidence: `core/lib/src/server.rs`)
- HTTP client → Network listeners: sends HTTP (evidence: `README.md`)
- HTTP server → Route matching: dispatches requests (evidence: `core/lib/src/server.rs`)
- Route matching → Request and guards: matches request (evidence: `core/lib/src/router/router.rs`)
- Route matching → Route handlers: selects route (evidence: `core/lib/src/router/router.rs`)
- Route handlers → Response construction: builds response (evidence: `core/lib/src/route/handler.rs`)
- Route handlers → Request and guards: handles request (evidence: `core/lib/src/route/handler.rs`)
- Route handlers → Request data: consumes data (evidence: `core/lib/src/route/handler.rs`)
- Route matching → Error catchers: selects catcher (evidence: `core/lib/src/router/router.rs`)
- HTTP server → HTTP and URI types: uses HTTP types (evidence: `core/lib/src/server.rs`)
- Request and guards → HTTP and URI types: uses HTTP types
- Response construction → HTTP and URI types: uses HTTP types
- Request and guards → Cookie handling: exposes cookies
- Rocket application → Static file server: mounts file server (evidence: `core/lib/src/fs/server.rs`)
- Dynamic templates → Template discovery: initializes context (evidence: `contrib/dyn_templates/src/template.rs`)
- Template discovery → Template engines: initializes engines (evidence: `contrib/dyn_templates/src/context.rs`)
- Dynamic templates → Template engines: renders templates (evidence: `contrib/dyn_templates/src/engine/mod.rs`)
- Rocket application → Async database pools: integrates pools
- Rocket application → Sync database pools: integrates pools
- Rocket application → WebSockets: supports upgrades
- Local test clients → HTTP server: exercises server
- Network listeners → TLS and mTLS: supports TLS
