# abh14am/tempbin architecture

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

- Interactive diagram: https://gitdiagram.com/abh14am/tempbin
- Repository: https://github.com/abh14am/tempbin

## Overview

TempBin is a self-hosted, zero-knowledge pastebin: users compose notes in the browser, which encrypts content before sending it through the notes API to Redis; viewing retrieves ciphertext and decrypts it locally using the URL fragment key and, optionally, a password. The README also documents expiration, burn-after-read, search, recent notes, and an authenticated admin dashboard. The excerpts show the API, storage, and encryption calls; frontend rendering and some documented capabilities are included, but their unsampled implementation details are not inferred.

Main entry points: [`routers/notes.py`](https://github.com/abh14am/tempbin/blob/main/routers/notes.py) (Notes endpoints), [`static/app.js`](https://github.com/abh14am/tempbin/blob/main/static/app.js) (Pastebin interface), [`main.py`](https://github.com/abh14am/tempbin/blob/main/main.py) (FastAPI app), [`db.py`](https://github.com/abh14am/tempbin/blob/main/db.py) (Note records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser app"]
  node_browser["Pastebin interface<br/>[app.js]"]
  node_crypto["Client encryption<br/>[app.js]"]
  node_markdown["Markdown rendering<br/>[app.js]"]
  node_admin_ui["Admin dashboard<br/>[admin.html]"]
end

subgraph group_api["Notes API"]
  node_http["FastAPI app<br/>[main.py]"]
  node_notes_api["Notes endpoints<br/>[notes.py]"]
end

subgraph group_storage["Note storage"]
  node_note_store[("Note records<br/>[db.py]")]
  node_search["Search and listings<br/>[db.py]"]
end

subgraph group_security["Admin security"]
  node_admin_auth["Admin authentication<br/>[auth.py]"]
end

node_user(("Note user"))
node_redis[("Redis Stack")]
node_browser_crypto["Web Crypto API"]

node_user -->|"creates or views"| node_browser
node_browser -->|"encrypts and decrypts"| node_crypto
node_crypto -->|"uses"| node_browser_crypto
node_browser -->|"requests notes"| node_http
node_http -->|"routes requests"| node_notes_api
node_notes_api -->|"creates, reads, deletes"| node_note_store
node_notes_api -->|"searches and lists"| node_search
node_note_store -->|"reads and writes"| node_redis
node_search -->|"queries index"| node_redis
node_http -->|"guards dashboard"| node_admin_auth
node_notes_api -->|"guards admin list"| node_admin_auth
node_browser -->|"renders decrypted text"| node_markdown
node_user -.->|"opens dashboard"| node_admin_ui
node_notes_api -->|"applies expiration"| node_note_store

click node_browser "https://github.com/abh14am/tempbin/blob/main/static/app.js"
click node_crypto "https://github.com/abh14am/tempbin/blob/main/static/app.js"
click node_markdown "https://github.com/abh14am/tempbin/blob/main/static/app.js"
click node_admin_ui "https://github.com/abh14am/tempbin/blob/main/static/admin.html"
click node_http "https://github.com/abh14am/tempbin/blob/main/main.py"
click node_notes_api "https://github.com/abh14am/tempbin/blob/main/routers/notes.py"
click node_note_store "https://github.com/abh14am/tempbin/blob/main/db.py"
click node_search "https://github.com/abh14am/tempbin/blob/main/db.py"
click node_admin_auth "https://github.com/abh14am/tempbin/blob/main/auth.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_browser,node_crypto,node_markdown,node_admin_ui,node_user toneBlue
class node_http,node_notes_api,node_redis toneAmber
class node_note_store,node_search,node_browser_crypto toneMint
class node_admin_auth toneRose
```

## Components

### Browser app

- [Pastebin interface](https://github.com/abh14am/tempbin/blob/main/static/app.js): `static/app.js`
- [Client encryption](https://github.com/abh14am/tempbin/blob/main/static/app.js): `static/app.js`
- [Markdown rendering](https://github.com/abh14am/tempbin/blob/main/static/app.js): `static/app.js`
- [Admin dashboard](https://github.com/abh14am/tempbin/blob/main/static/admin.html): `static/admin.html`

### Notes API

- [FastAPI app](https://github.com/abh14am/tempbin/blob/main/main.py): `main.py`
- [Notes endpoints](https://github.com/abh14am/tempbin/blob/main/routers/notes.py): `routers/notes.py`

### Note storage

- [Note records](https://github.com/abh14am/tempbin/blob/main/db.py): `db.py`
- [Search and listings](https://github.com/abh14am/tempbin/blob/main/db.py): `db.py`

### Admin security

- [Admin authentication](https://github.com/abh14am/tempbin/blob/main/auth.py): `auth.py`

### Other components

- **Note user**
- **Redis Stack**
- **Web Crypto API**

## Connections

- Note user → Pastebin interface: creates or views (evidence: `static/app.js`)
- Pastebin interface → Client encryption: encrypts and decrypts (evidence: `static/app.js`)
- Client encryption → Web Crypto API: uses (evidence: `static/app.js`)
- Pastebin interface → FastAPI app: requests notes (evidence: `static/app.js`)
- FastAPI app → Notes endpoints: routes requests (evidence: `main.py`)
- Notes endpoints → Note records: creates, reads, deletes (evidence: `routers/notes.py`)
- Notes endpoints → Search and listings: searches and lists (evidence: `routers/notes.py`)
- Note records → Redis Stack: reads and writes (evidence: `db.py`)
- Search and listings → Redis Stack: queries index (evidence: `db.py`)
- FastAPI app → Admin authentication: guards dashboard (evidence: `main.py`)
- Notes endpoints → Admin authentication: guards admin list (evidence: `routers/notes.py`)
- Pastebin interface → Markdown rendering: renders decrypted text (evidence: `static/app.js`)
- Note user → Admin dashboard: opens dashboard (evidence: `README.md`)
- Notes endpoints → Note records: applies expiration (evidence: `routers/notes.py`)
