# jiffy-events/share architecture

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

- Interactive diagram: https://gitdiagram.com/jiffy-events/share
- Repository: https://github.com/jiffy-events/share

## Overview

#### Purpose and Entry Points
Jiffy Share is a self-hostable, temporary resource-sharing service for talks: speakers create a page, present a QR stage view, and audiences open a live public resource page. The Python application entry point is `jiffy_share/app.py`; deployment is container-oriented via `Dockerfile`, `docker-compose.dev.yml`, and Caddy reverse-proxy configuration in `Caddyfile`.

#### Application Composition
The app is organized as a Python backend with feature-focused route and service modules. Application setup, environment-derived settings, database initialization, static serving, and top-level concerns reside in:
- `jiffy_share/app.py`
- `jiffy_share/config.py`
- `jiffy_share/database.py`

Authentication, authorization, and rate limits are separate cross-cutting boundaries:
- `jiffy_share/auth.py`
- `jiffy_share/auth_routes.py`
- `jiffy_share/rate_limit.py`

#### Share Lifecycle and Ownership
The share domain owns creation, editing, expiry, and administrative control of temporary pages. Lifecycle logic is isolated from HTTP endpoints, while route modules expose the speaker/editor workflow:
- `jiffy_share/share/lifecycle.py`
- `jiffy_share/share/routes.py`
- `jiffy_share/share/edit_routes.py`

User ownership and organization-oriented access extend this model through user and admin routes plus speaker invitation flows:
- `jiffy_share/user_routes.py`
- `jiffy_share/share/admin.py`
- `jiffy_share/share/speaker_invites.py`

#### Public, Stage, and Real-Time Delivery
A created share is published through a link-based public route (`/s/{slug}` per README) and a separate stage-oriented QR experience. Public users need no account; protected deployment modes primarily gate creation and ordinary editing.
- `jiffy_share/share/public_routes.py`
- `jiffy_share/share/stream_routes.py`
- `jiffy_share/share/sse.py`

Server-Sent Events provide the live-update boundary between speaker mutations and open audience/stage clients. Rendering is backend-owned for page responses, with dedicated rendering modules:
- `jiffy_share/share/rendering.py`
- `jiffy_share/share/admin_rendering.py`

#### Resources, Files, and Offline Access
Shares contain ordered resource payloads such as links, notes, and uploaded files. Resource persistence/mutation and binary storage are separated:
- `jiffy_share/share/payloads.py`
- `jiffy_share/share/save_resources.py`
- `jiffy_share/share/storage.py`

Uploads and file-serving endpoints enforce the file-access boundary:
- `jiffy_share/share/uploads.py`
- `jiffy_share/share/file_routes.py`

The backend also supports a download queue, while browser clients can cache or retain audience resources for offline use:
- `jiffy_share/share/download_queue.py`
- `jiffy_share/share/download_queue_routes.py`
- `static/src/share/public/offline/`

#### Browser Clients
Static JavaScript implements distinct experiences rather than a generic SPA: speaker editor, public audience page, stage QR view, and speaker-invite flow. They communicate with backend APIs and react to real-time updates.
- `static/src/share/editor.js`
- `static/src/share/public.js`
- `static/src/share/stage.js`

The public client’s offline subsystem manages cache state, local copies, queue state, and service-worker communication:
- `static/src/share/public/offline/cache.js`
- `static/src/share/public/offline/downloadQueueController.js`
- `static/share-offline-worker.js`

#### Persistence and Operations
Relational schema evolution is managed with Alembic, covering shares, users/ownership, invitations, and download queues:
- `alembic/env.py`
- `alembic/versions/0001_initial_share_schema.py`
- `alembic/versions/0004_share_download_queue.py`

Runtime infrastructure is Python plus a Node 20+ JavaScript test environment. Docker/Caddy is the supported integrated deployment path; environment setup is driven by `.env` conventions and the guided `setup` script. Production and self-hosting operational boundaries are documented in `docs/SELF_HOSTING.md`.

Main entry points: [`jiffy_share/app.py`](https://github.com/jiffy-events/share/blob/main/jiffy_share/app.py) (Application setup), [`jiffy_share/share/public_routes.py`](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/public_routes.py) (Public and stage routes), [`jiffy_share/share/lifecycle.py`](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/lifecycle.py) (Share lifecycle), [`jiffy_share/share/routes.py`](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/routes.py) (Speaker editing routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Python backend"]
  node_app["Application setup<br/>Python entry point<br/>[app.py]"]
  node_config["Settings<br/>configuration<br/>[config.py]"]
  node_database[("Database layer<br/>persistence<br/>[database.py]")]
  node_auth["Auth &amp; rate limits<br/>cross-cutting security<br/>[auth.py]"]
  node_auth_routes["Authentication routes<br/>HTTP routes<br/>[auth_routes.py]"]
  node_share_routes["Speaker editing routes<br/>HTTP routes<br/>[routes.py]"]
  node_lifecycle["Share lifecycle<br/>domain service<br/>[lifecycle.py]"]
  node_ownership["Ownership &amp; invites<br/>access management<br/>[speaker_invites.py]"]
  node_public_routes["Public and stage routes<br/>HTTP delivery<br/>[public_routes.py]"]
  node_sse["Live update stream<br/>SSE<br/>[sse.py]"]
  node_rendering["Page rendering<br/>server rendering<br/>[rendering.py]"]
  node_resources["Resource persistence<br/>domain persistence<br/>[save_resources.py]"]
  node_file_storage["File storage &amp; serving<br/>binary storage<br/>[storage.py]"]
  node_download_queue["Download queue<br/>offline delivery<br/>[download_queue.py]"]
end

subgraph group_clients["Browser clients"]
  node_editor_client["Speaker editor<br/>browser JavaScript<br/>[editor.js]"]
  node_public_client["Audience client<br/>browser JavaScript<br/>[public.js]"]
  node_stage_client["Stage QR client<br/>browser JavaScript<br/>[stage.js]"]
  node_offline_client["Offline cache &amp; worker<br/>service worker subsystem"]
end

subgraph group_data_ops["Persistence &amp; operations"]
  node_migrations["Alembic migrations<br/>schema evolution<br/>[env.py]"]
  node_deployment{{"Container deployment<br/>Docker and reverse proxy"}}
end

node_config -->|"configures"| node_app
node_app -->|"initializes"| node_database
node_app -->|"mounts"| node_auth_routes
node_app -->|"mounts"| node_share_routes
node_app -->|"mounts"| node_public_routes
node_auth_routes -->|"uses"| node_auth
node_share_routes -->|"enforces"| node_auth
node_share_routes -->|"drives"| node_lifecycle
node_lifecycle -->|"checks access"| node_ownership
node_lifecycle -->|"updates resources"| node_resources
node_lifecycle -->|"publishes changes"| node_sse
node_resources -->|"persists"| node_database
node_resources -->|"stores files"| node_file_storage
node_public_routes -->|"renders"| node_rendering
node_public_routes -->|"opens stream"| node_sse
node_public_routes -->|"serves queue APIs"| node_download_queue
node_download_queue -->|"persists queue"| node_database
node_editor_client -->|"edits shares"| node_share_routes
node_public_client -->|"loads /s/&#123;slug&#125;"| node_public_routes
node_public_client -->|"receives updates"| node_sse
node_stage_client -->|"loads stage"| node_public_routes
node_stage_client -->|"receives updates"| node_sse
node_public_client -->|"manages offline copies"| node_offline_client
node_offline_client -->|"uses queue APIs"| node_download_queue
node_migrations -->|"evolves schema"| node_database
node_deployment -->|"runs"| node_app

click node_app "https://github.com/jiffy-events/share/blob/main/jiffy_share/app.py"
click node_config "https://github.com/jiffy-events/share/blob/main/jiffy_share/config.py"
click node_database "https://github.com/jiffy-events/share/blob/main/jiffy_share/database.py"
click node_auth "https://github.com/jiffy-events/share/blob/main/jiffy_share/auth.py"
click node_auth_routes "https://github.com/jiffy-events/share/blob/main/jiffy_share/auth_routes.py"
click node_share_routes "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/routes.py"
click node_lifecycle "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/lifecycle.py"
click node_ownership "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/speaker_invites.py"
click node_public_routes "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/public_routes.py"
click node_sse "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/sse.py"
click node_rendering "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/rendering.py"
click node_resources "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/save_resources.py"
click node_file_storage "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/storage.py"
click node_download_queue "https://github.com/jiffy-events/share/blob/main/jiffy_share/share/download_queue.py"
click node_editor_client "https://github.com/jiffy-events/share/blob/main/static/src/share/editor.js"
click node_public_client "https://github.com/jiffy-events/share/blob/main/static/src/share/public.js"
click node_stage_client "https://github.com/jiffy-events/share/blob/main/static/src/share/stage.js"
click node_offline_client "https://github.com/jiffy-events/share/blob/main/static/share-offline-worker.js"
click node_migrations "https://github.com/jiffy-events/share/blob/main/alembic/env.py"
click node_deployment "https://github.com/jiffy-events/share/blob/main/Dockerfile"

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_config,node_database,node_auth,node_auth_routes,node_share_routes,node_lifecycle,node_ownership,node_public_routes,node_sse,node_rendering,node_resources,node_file_storage,node_download_queue toneBlue
class node_editor_client,node_public_client,node_stage_client,node_offline_client toneAmber
class node_migrations,node_deployment toneMint
```

## Components

### Python backend

HTTP application, share domain, and cross-cutting controls.

- [Application setup](https://github.com/jiffy-events/share/blob/main/jiffy_share/app.py): Python entry point · Initializes settings, database, static serving, and route composition. · `jiffy_share/app.py`
- [Settings](https://github.com/jiffy-events/share/blob/main/jiffy_share/config.py): configuration · `jiffy_share/config.py`
- [Database layer](https://github.com/jiffy-events/share/blob/main/jiffy_share/database.py): persistence · `jiffy_share/database.py`
- [Auth & rate limits](https://github.com/jiffy-events/share/blob/main/jiffy_share/auth.py): cross-cutting security · Authentication, authorization, and request limits. · `jiffy_share/auth.py`
- [Authentication routes](https://github.com/jiffy-events/share/blob/main/jiffy_share/auth_routes.py): HTTP routes · `jiffy_share/auth_routes.py`
- [Speaker editing routes](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/routes.py): HTTP routes · Creation and ordinary editor workflow. · `jiffy_share/share/routes.py`
- [Share lifecycle](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/lifecycle.py): domain service · Owns share creation, editing, expiry, and control. · `jiffy_share/share/lifecycle.py`
- [Ownership & invites](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/speaker_invites.py): access management · User, admin, organization access, and speaker invitations. · `jiffy_share/share/speaker_invites.py`
- [Public and stage routes](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/public_routes.py): HTTP delivery · Serves public /s/{slug} and stage experiences. · `jiffy_share/share/public_routes.py`
- [Live update stream](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/sse.py): SSE · Pushes speaker mutations to open clients. · `jiffy_share/share/sse.py`
- [Page rendering](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/rendering.py): server rendering · Renders public, stage, and administrative responses. · `jiffy_share/share/rendering.py`
- [Resource persistence](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/save_resources.py): domain persistence · Stores ordered links, notes, and resource payloads. · `jiffy_share/share/save_resources.py`
- [File storage & serving](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/storage.py): binary storage · Separates uploads and protected file delivery. · `jiffy_share/share/storage.py`
- [Download queue](https://github.com/jiffy-events/share/blob/main/jiffy_share/share/download_queue.py): offline delivery · Backend queue and endpoints for retained audience files. · `jiffy_share/share/download_queue.py`

### Browser clients

Dedicated speaker, audience, and stage experiences.

- [Speaker editor](https://github.com/jiffy-events/share/blob/main/static/src/share/editor.js): browser JavaScript · `static/src/share/editor.js`
- [Audience client](https://github.com/jiffy-events/share/blob/main/static/src/share/public.js): browser JavaScript · Displays live resources and coordinates offline retention. · `static/src/share/public.js`
- [Stage QR client](https://github.com/jiffy-events/share/blob/main/static/src/share/stage.js): browser JavaScript · `static/src/share/stage.js`
- [Offline cache & worker](https://github.com/jiffy-events/share/blob/main/static/share-offline-worker.js): service worker subsystem · Caches resources and manages browser download state. · `static/share-offline-worker.js`

### Persistence & operations

Database schema and container deployment.

- [Alembic migrations](https://github.com/jiffy-events/share/blob/main/alembic/env.py): schema evolution · Defines shares, users, invitations, and download queue schema. · `alembic/env.py`
- [Container deployment](https://github.com/jiffy-events/share/blob/main/Dockerfile): Docker and reverse proxy · Docker/Caddy self-hosted deployment boundary. · `Dockerfile`

## Connections

- Settings → Application setup: configures
- Application setup → Database layer: initializes
- Application setup → Authentication routes: mounts
- Application setup → Speaker editing routes: mounts
- Application setup → Public and stage routes: mounts
- Authentication routes → Auth & rate limits: uses
- Speaker editing routes → Auth & rate limits: enforces
- Speaker editing routes → Share lifecycle: drives
- Share lifecycle → Ownership & invites: checks access
- Share lifecycle → Resource persistence: updates resources
- Share lifecycle → Live update stream: publishes changes
- Resource persistence → Database layer: persists
- Resource persistence → File storage & serving: stores files
- Public and stage routes → Page rendering: renders
- Public and stage routes → Live update stream: opens stream
- Public and stage routes → Download queue: serves queue APIs
- Download queue → Database layer: persists queue
- Speaker editor → Speaker editing routes: edits shares
- Audience client → Public and stage routes: loads /s/{slug}
- Audience client → Live update stream: receives updates
- Stage QR client → Public and stage routes: loads stage
- Stage QR client → Live update stream: receives updates
- Audience client → Offline cache & worker: manages offline copies
- Offline cache & worker → Download queue: uses queue APIs
- Alembic migrations → Database layer: evolves schema
- Container deployment → Application setup: runs
