# privatebin/privatebin architecture

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

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

## Overview

PrivateBin is a zero-knowledge pastebin: the browser encrypts paste content before sending it, and the server stores and serves the encrypted payload. The principal path runs from browser interaction through the PHP request controller, paste model, and configured storage backend; reads return data for browser-side decryption. Discussions, expiration and burn-after-reading, traffic controls, translations, rendering, and URL-shortener integrations are additional capabilities. Relationships reflect the excerpts, SOURCE INDEX references, or README; unsampled implementation details are not inferred.

Main entry points: [`lib/Controller.php`](https://github.com/privatebin/privatebin/blob/master/lib/Controller.php) (Request controller), [`lib/Data/AbstractData.php`](https://github.com/privatebin/privatebin/blob/master/lib/Data/AbstractData.php) (Data interface), [`lib/Configuration.php`](https://github.com/privatebin/privatebin/blob/master/lib/Configuration.php) (Configuration), [`lib/Model/Paste.php`](https://github.com/privatebin/privatebin/blob/master/lib/Model/Paste.php) (Paste model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_browser_app["Browser client<br/>[privatebin.js]"]
  node_browser_template["Bootstrap template<br/>[bootstrap5.php]"]
end

subgraph group_server["Request and presentation"]
  node_entry["HTTP entry<br/>[index.php]"]
  node_controller["Request controller<br/>[Controller.php]"]
  node_request["Request parsing<br/>[Request.php]"]
  node_view["Page rendering<br/>[View.php]"]
  node_template_switch["Template selection"]
end

subgraph group_domain["Paste domain"]
  node_paste_model["Paste model<br/>[Paste.php]"]
  node_comment_model["Discussion model<br/>[Comment.php]"]
  node_model_factory["Model factory<br/>[Model.php]"]
end

subgraph group_storage["Persistence"]
  node_data_abstraction["Data interface<br/>[AbstractData.php]"]
  node_filesystem[("Filesystem backend<br/>[Filesystem.php]")]
  node_database[("Database backend<br/>[Database.php]")]
  node_gcs[("Cloud storage")]
  node_s3[("S3 storage<br/>[S3Storage.php]")]
end

subgraph group_support["Shared services"]
  node_configuration["Configuration<br/>[Configuration.php]"]
  node_traffic["Traffic limiter<br/>[TrafficLimiter.php]"]
  node_salt["Server salt<br/>[ServerSalt.php]"]
  node_i18n["Translations<br/>[I18n.php]"]
  node_json["JSON encoding<br/>[Json.php]"]
  node_proxies["Shortener proxies<br/>[AbstractProxy.php]"]
  node_filter["Input filtering<br/>[Filter.php]"]
  node_format["Paste format<br/>[FormatV2.php]"]
end

node_user(("Paste user"))

node_user -->|"uses"| node_browser_app
node_browser_app -->|"sends encrypted data"| node_entry
node_entry -->|"starts"| node_controller
node_controller -->|"reads"| node_request
node_controller -->|"dispatches"| node_model_factory
node_controller -->|"checks limits"| node_traffic
node_controller -->|"routes shortener"| node_proxies
node_controller -->|"uses"| node_filter
node_controller -->|"uses"| node_format
node_controller -->|"renders"| node_view
node_controller -->|"selects template"| node_template_switch
node_controller -->|"translates output"| node_i18n
node_controller -->|"encodes response"| node_json
node_model_factory -->|"creates"| node_paste_model
node_paste_model -->|"loads discussions"| node_comment_model
node_paste_model -->|"reads and writes"| node_data_abstraction
node_data_abstraction -->|"implemented by"| node_filesystem
node_data_abstraction -->|"implemented by"| node_database
node_data_abstraction -->|"implemented by"| node_gcs
node_data_abstraction -->|"implemented by"| node_s3
node_configuration -->|"configures backend"| node_filesystem
node_configuration -->|"configures backend"| node_database
node_configuration -->|"configures backend"| node_gcs
node_configuration -->|"configures backend"| node_s3
node_traffic -->|"derives visitor key"| node_salt
node_salt -->|"persists salt"| node_data_abstraction
node_browser_template -.->|"hosts interface"| node_browser_app

click node_browser_app "https://github.com/privatebin/privatebin/blob/master/js/privatebin.js"
click node_browser_template "https://github.com/privatebin/privatebin/blob/master/tpl/bootstrap5.php"
click node_entry "https://github.com/privatebin/privatebin/blob/master/index.php"
click node_controller "https://github.com/privatebin/privatebin/blob/master/lib/Controller.php"
click node_request "https://github.com/privatebin/privatebin/blob/master/lib/Request.php"
click node_view "https://github.com/privatebin/privatebin/blob/master/lib/View.php"
click node_template_switch "https://github.com/privatebin/privatebin/blob/master/lib/TemplateSwitcher.php"
click node_paste_model "https://github.com/privatebin/privatebin/blob/master/lib/Model/Paste.php"
click node_comment_model "https://github.com/privatebin/privatebin/blob/master/lib/Model/Comment.php"
click node_model_factory "https://github.com/privatebin/privatebin/blob/master/lib/Model.php"
click node_data_abstraction "https://github.com/privatebin/privatebin/blob/master/lib/Data/AbstractData.php"
click node_filesystem "https://github.com/privatebin/privatebin/blob/master/lib/Data/Filesystem.php"
click node_database "https://github.com/privatebin/privatebin/blob/master/lib/Data/Database.php"
click node_gcs "https://github.com/privatebin/privatebin/blob/master/lib/Data/GoogleCloudStorage.php"
click node_s3 "https://github.com/privatebin/privatebin/blob/master/lib/Data/S3Storage.php"
click node_configuration "https://github.com/privatebin/privatebin/blob/master/lib/Configuration.php"
click node_traffic "https://github.com/privatebin/privatebin/blob/master/lib/Persistence/TrafficLimiter.php"
click node_salt "https://github.com/privatebin/privatebin/blob/master/lib/Persistence/ServerSalt.php"
click node_i18n "https://github.com/privatebin/privatebin/blob/master/lib/I18n.php"
click node_json "https://github.com/privatebin/privatebin/blob/master/lib/Json.php"
click node_proxies "https://github.com/privatebin/privatebin/blob/master/lib/Proxy/AbstractProxy.php"
click node_filter "https://github.com/privatebin/privatebin/blob/master/lib/Filter.php"
click node_format "https://github.com/privatebin/privatebin/blob/master/lib/FormatV2.php"

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_browser_app,node_browser_template,node_user toneBlue
class node_entry,node_controller,node_request,node_view,node_template_switch toneAmber
class node_paste_model,node_comment_model,node_model_factory toneMint
class node_data_abstraction,node_filesystem,node_database,node_gcs,node_s3 toneRose
class node_configuration,node_traffic,node_salt,node_i18n,node_json,node_proxies,node_filter,node_format toneIndigo
```

## Components

### Browser experience

- [Browser client](https://github.com/privatebin/privatebin/blob/master/js/privatebin.js): `js/privatebin.js`
- [Bootstrap template](https://github.com/privatebin/privatebin/blob/master/tpl/bootstrap5.php): `tpl/bootstrap5.php`

### Request and presentation

- [HTTP entry](https://github.com/privatebin/privatebin/blob/master/index.php): `index.php`
- [Request controller](https://github.com/privatebin/privatebin/blob/master/lib/Controller.php): `lib/Controller.php`
- [Request parsing](https://github.com/privatebin/privatebin/blob/master/lib/Request.php): `lib/Request.php`
- [Page rendering](https://github.com/privatebin/privatebin/blob/master/lib/View.php): `lib/View.php`
- [Template selection](https://github.com/privatebin/privatebin/blob/master/lib/TemplateSwitcher.php): `lib/TemplateSwitcher.php`

### Paste domain

- [Paste model](https://github.com/privatebin/privatebin/blob/master/lib/Model/Paste.php): `lib/Model/Paste.php`
- [Discussion model](https://github.com/privatebin/privatebin/blob/master/lib/Model/Comment.php): `lib/Model/Comment.php`
- [Model factory](https://github.com/privatebin/privatebin/blob/master/lib/Model.php): `lib/Model.php`

### Persistence

- [Data interface](https://github.com/privatebin/privatebin/blob/master/lib/Data/AbstractData.php): `lib/Data/AbstractData.php`
- [Filesystem backend](https://github.com/privatebin/privatebin/blob/master/lib/Data/Filesystem.php): `lib/Data/Filesystem.php`
- [Database backend](https://github.com/privatebin/privatebin/blob/master/lib/Data/Database.php): `lib/Data/Database.php`
- [Cloud storage](https://github.com/privatebin/privatebin/blob/master/lib/Data/GoogleCloudStorage.php): `lib/Data/GoogleCloudStorage.php`
- [S3 storage](https://github.com/privatebin/privatebin/blob/master/lib/Data/S3Storage.php): `lib/Data/S3Storage.php`

### Shared services

- [Configuration](https://github.com/privatebin/privatebin/blob/master/lib/Configuration.php): `lib/Configuration.php`
- [Traffic limiter](https://github.com/privatebin/privatebin/blob/master/lib/Persistence/TrafficLimiter.php): `lib/Persistence/TrafficLimiter.php`
- [Server salt](https://github.com/privatebin/privatebin/blob/master/lib/Persistence/ServerSalt.php): `lib/Persistence/ServerSalt.php`
- [Translations](https://github.com/privatebin/privatebin/blob/master/lib/I18n.php): `lib/I18n.php`
- [JSON encoding](https://github.com/privatebin/privatebin/blob/master/lib/Json.php): `lib/Json.php`
- [Shortener proxies](https://github.com/privatebin/privatebin/blob/master/lib/Proxy/AbstractProxy.php): `lib/Proxy/AbstractProxy.php`
- [Input filtering](https://github.com/privatebin/privatebin/blob/master/lib/Filter.php): `lib/Filter.php`
- [Paste format](https://github.com/privatebin/privatebin/blob/master/lib/FormatV2.php): `lib/FormatV2.php`

### Other components

- **Paste user**

## Connections

- Paste user → Browser client: uses (evidence: `README.md`)
- Browser client → HTTP entry: sends encrypted data (evidence: `README.md`)
- HTTP entry → Request controller: starts (evidence: `index.php`)
- Request controller → Request parsing: reads (evidence: `lib/Controller.php`)
- Request controller → Model factory: dispatches (evidence: `lib/Controller.php`)
- Request controller → Traffic limiter: checks limits (evidence: `lib/Controller.php`)
- Request controller → Shortener proxies: routes shortener (evidence: `lib/Controller.php`)
- Request controller → Input filtering: uses (evidence: `lib/Controller.php`)
- Request controller → Paste format: uses (evidence: `lib/Controller.php`)
- Request controller → Page rendering: renders (evidence: `lib/Controller.php`)
- Request controller → Template selection: selects template (evidence: `lib/Controller.php`)
- Request controller → Translations: translates output (evidence: `lib/Controller.php`)
- Request controller → JSON encoding: encodes response (evidence: `lib/Controller.php`)
- Model factory → Paste model: creates (evidence: `lib/Model.php`)
- Paste model → Discussion model: loads discussions (evidence: `lib/Model/Paste.php`)
- Paste model → Data interface: reads and writes
- Data interface → Filesystem backend: implemented by (evidence: `lib/Data/Filesystem.php`)
- Data interface → Database backend: implemented by (evidence: `lib/Data/Database.php`)
- Data interface → Cloud storage: implemented by (evidence: `lib/Data/GoogleCloudStorage.php`)
- Data interface → S3 storage: implemented by (evidence: `lib/Data/S3Storage.php`)
- Configuration → Filesystem backend: configures backend (evidence: `lib/Configuration.php`)
- Configuration → Database backend: configures backend (evidence: `lib/Configuration.php`)
- Configuration → Cloud storage: configures backend (evidence: `lib/Configuration.php`)
- Configuration → S3 storage: configures backend (evidence: `lib/Configuration.php`)
- Traffic limiter → Server salt: derives visitor key (evidence: `lib/Persistence/TrafficLimiter.php`)
- Server salt → Data interface: persists salt (evidence: `lib/Persistence/ServerSalt.php`)
- Bootstrap template → Browser client: hosts interface
