# szeka9/pyrobusta architecture

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

- Interactive diagram: https://gitdiagram.com/szeka9/pyrobusta
- Repository: https://github.com/szeka9/pyrobusta

## Overview

PyRobusta is a memory-conscious MicroPython HTTP/1.1 server. Its main workflow starts with application configuration and optional feature setup, accepts client sockets, processes requests through a buffered HTTP state machine, dispatches routes, and streams responses. The graph also preserves documented security, multipart, and file-server capabilities. Some feature-to-engine wiring is unsampled, so those relationships are omitted or marked unverified rather than inferred as direct calls.

Main entry points: [`src/pyrobusta/application.py`](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/application.py) (Application runner), [`src/pyrobusta/protocol/http.py`](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http.py) (HTTP state machine), [`src/pyrobusta/bindings/http_connection.py`](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/bindings/http_connection.py) (HTTP connection), [`src/pyrobusta/protocol/http_basic_auth.py`](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_basic_auth.py) (Basic authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Application startup"]
  node_application["Application runner<br/>[application.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_network["Connections and buffers"]
  node_server["Socket server<br/>[http_server.py]"]
  node_http_connection["HTTP connection<br/>[http_connection.py]"]
  node_transport["Transport connection<br/>[connection.py]"]
  node_buffer["Fixed-size buffers<br/>[buffer.py]"]
end

subgraph group_http["HTTP processing"]
  node_http_engine["HTTP state machine<br/>[http.py]"]
  node_router["Route dispatch<br/>[http.py]"]
end

subgraph group_features["HTTP features"]
  node_multipart["Multipart handling<br/>[http_multipart.py]"]
  node_file_server["File API"]
  node_assets["Web assets<br/>[assets.py]"]
  node_basic_auth["Basic authentication<br/>[http_basic_auth.py]"]
  node_cookies["Signed cookies<br/>[http_cookie.py]"]
  node_http_security["Browser security<br/>[http_security.py]"]
end

subgraph group_support["Security and utilities"]
  node_iam["Users and roles<br/>[iam.py]"]
  node_crypto["Cryptography<br/>[crypto.py]"]
  node_path_utils["Path handling<br/>[lexpath.py]"]
  node_logging["Logging<br/>[logging.py]"]
end

node_client(("HTTP client"))
node_tls["TLS runtime"]

node_application -->|"loads"| node_config
node_application -->|"configures"| node_http_engine
node_application -->|"starts"| node_server
node_application -->|"loads when enabled"| node_iam
node_application -->|"patches when enabled"| node_multipart
node_application -->|"patches when enabled"| node_basic_auth
node_application -->|"patches when enabled"| node_file_server
node_application -->|"patches when enabled"| node_http_security
node_application -->|"configures when enabled"| node_tls
node_client -->|"opens connection"| node_server
node_server -->|"creates"| node_http_connection
node_server -->|"reserves pools"| node_buffer
node_http_connection -->|"extends"| node_transport
node_http_connection -->|"runs parser"| node_http_engine
node_http_connection -->|"reads and writes"| node_buffer
node_http_engine -->|"parses request bytes"| node_buffer
node_http_engine -->|"dispatches routes"| node_router
node_http_engine -->|"uses path parsing"| node_path_utils
node_http_connection -->|"streams response"| node_client
node_basic_auth -->|"checks user and roles"| node_iam
node_basic_auth -->|"uses sessions and CSRF"| node_cookies
node_basic_auth -->|"verifies credentials"| node_crypto
node_iam -->|"hashes passwords"| node_crypto
node_iam -->|"parses role paths"| node_path_utils
node_cookies -->|"signs tokens"| node_crypto
node_file_server -->|"serves installed assets"| node_assets
node_file_server -->|"validates paths"| node_path_utils
node_http_engine -.->|"parses multipart bodies"| node_multipart

click node_application "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/application.py"
click node_config "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/config.py"
click node_server "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/server/http_server.py"
click node_http_connection "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/bindings/http_connection.py"
click node_transport "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/transport/connection.py"
click node_buffer "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/stream/buffer.py"
click node_http_engine "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http.py"
click node_router "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http.py"
click node_multipart "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_multipart.py"
click node_file_server "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_file_server.py"
click node_assets "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/assets.py"
click node_basic_auth "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_basic_auth.py"
click node_cookies "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_cookie.py"
click node_http_security "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_security.py"
click node_iam "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/iam.py"
click node_crypto "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/crypto.py"
click node_path_utils "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/lexpath.py"
click node_logging "https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/logging.py"

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_application,node_config,node_client toneBlue
class node_server,node_http_connection,node_transport,node_buffer toneAmber
class node_http_engine,node_router toneMint
class node_multipart,node_file_server,node_assets,node_basic_auth,node_cookies,node_http_security toneRose
class node_iam,node_crypto,node_path_utils,node_logging,node_tls toneIndigo
```

## Components

### Application startup

- [Application runner](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/application.py): `src/pyrobusta/application.py`
- [Configuration](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/config.py): `src/pyrobusta/utils/config.py`

### Connections and buffers

- [Socket server](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/server/http_server.py): `src/pyrobusta/server/http_server.py`
- [HTTP connection](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/bindings/http_connection.py): `src/pyrobusta/bindings/http_connection.py`
- [Transport connection](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/transport/connection.py): `src/pyrobusta/transport/connection.py`
- [Fixed-size buffers](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/stream/buffer.py): `src/pyrobusta/stream/buffer.py`

### HTTP processing

- [HTTP state machine](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http.py): `src/pyrobusta/protocol/http.py`
- [Route dispatch](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http.py): `src/pyrobusta/protocol/http.py`

### HTTP features

- [Multipart handling](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_multipart.py): `src/pyrobusta/protocol/http_multipart.py`
- [File API](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_file_server.py): `src/pyrobusta/protocol/http_file_server.py`
- [Web assets](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/assets.py): `src/pyrobusta/utils/assets.py`
- [Basic authentication](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_basic_auth.py): `src/pyrobusta/protocol/http_basic_auth.py`
- [Signed cookies](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_cookie.py): `src/pyrobusta/protocol/http_cookie.py`
- [Browser security](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/protocol/http_security.py): `src/pyrobusta/protocol/http_security.py`

### Security and utilities

- [Users and roles](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/iam.py): `src/pyrobusta/utils/iam.py`
- [Cryptography](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/crypto.py): `src/pyrobusta/utils/crypto.py`
- [Path handling](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/lexpath.py): `src/pyrobusta/utils/lexpath.py`
- [Logging](https://github.com/szeka9/pyrobusta/blob/main/src/pyrobusta/utils/logging.py): `src/pyrobusta/utils/logging.py`

### Other components

- **HTTP client**
- **TLS runtime**

## Connections

- Application runner → Configuration: loads (evidence: `src/pyrobusta/application.py`)
- Application runner → HTTP state machine: configures (evidence: `src/pyrobusta/application.py`)
- Application runner → Socket server: starts (evidence: `src/pyrobusta/application.py`)
- Application runner → Users and roles: loads when enabled (evidence: `src/pyrobusta/application.py`)
- Application runner → Multipart handling: patches when enabled (evidence: `src/pyrobusta/application.py`)
- Application runner → Basic authentication: patches when enabled (evidence: `src/pyrobusta/application.py`)
- Application runner → File API: patches when enabled (evidence: `src/pyrobusta/application.py`)
- Application runner → Browser security: patches when enabled (evidence: `src/pyrobusta/application.py`)
- Application runner → TLS runtime: configures when enabled (evidence: `src/pyrobusta/application.py`)
- HTTP client → Socket server: opens connection (evidence: `src/pyrobusta/server/http_server.py`)
- Socket server → HTTP connection: creates (evidence: `src/pyrobusta/server/http_server.py`)
- Socket server → Fixed-size buffers: reserves pools (evidence: `src/pyrobusta/server/http_server.py`)
- HTTP connection → Transport connection: extends (evidence: `src/pyrobusta/bindings/http_connection.py`)
- HTTP connection → HTTP state machine: runs parser (evidence: `src/pyrobusta/bindings/http_connection.py`)
- HTTP connection → Fixed-size buffers: reads and writes (evidence: `src/pyrobusta/bindings/http_connection.py`)
- HTTP state machine → Fixed-size buffers: parses request bytes (evidence: `src/pyrobusta/protocol/http.py`)
- HTTP state machine → Route dispatch: dispatches routes (evidence: `README.md`)
- HTTP state machine → Path handling: uses path parsing (evidence: `src/pyrobusta/protocol/http.py`)
- HTTP connection → HTTP client: streams response (evidence: `src/pyrobusta/bindings/http_connection.py`)
- Basic authentication → Users and roles: checks user and roles (evidence: `src/pyrobusta/protocol/http_basic_auth.py`)
- Basic authentication → Signed cookies: uses sessions and CSRF (evidence: `src/pyrobusta/protocol/http_basic_auth.py`)
- Basic authentication → Cryptography: verifies credentials (evidence: `src/pyrobusta/protocol/http_basic_auth.py`)
- Users and roles → Cryptography: hashes passwords (evidence: `src/pyrobusta/utils/iam.py`)
- Users and roles → Path handling: parses role paths (evidence: `src/pyrobusta/utils/iam.py`)
- Signed cookies → Cryptography: signs tokens (evidence: `src/pyrobusta/protocol/http_cookie.py`)
- File API → Web assets: serves installed assets (evidence: `src/pyrobusta/protocol/http_file_server.py`)
- File API → Path handling: validates paths (evidence: `src/pyrobusta/protocol/http_file_server.py`)
- HTTP state machine → Multipart handling: parses multipart bodies
