# sandeeprage/momentstamp architecture

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

- Interactive diagram: https://gitdiagram.com/sandeeprage/momentstamp
- Repository: https://github.com/sandeeprage/momentstamp

## Overview

Momentstamp is a private, browser-based photobooth for two people in different places. A host creates a booth and shares an expiring invite; guests request entry, and the host admits one. The participants connect peer-to-peer, take portraits, and create and download matching photo strips locally. The Worker and each booth’s Durable Object coordinate room membership and signaling, while the browser handles camera access, photo transfer, styling, and export. The README documents the broader workflow; some UI and API details are not shown in the excerpts.

Main entry points: [`public/app.js`](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js) (Booth interface), [`src/index.js`](https://github.com/sandeeprage/momentstamp/blob/main/src/index.js) (Booth room), [`public/strip.js`](https://github.com/sandeeprage/momentstamp/blob/main/public/strip.js) (Strip renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_webapp["Booth interface<br/>[app.js]"]
  node_invite["Invite entry<br/>[app.js]"]
  node_browser(("Participant browser"))
end

subgraph group_coordination["Room coordination"]
  node_worker["Worker API<br/>[index.js]"]
  node_room["Booth room<br/>[index.js]"]
  node_roomstate[("Room state<br/>[index.js]")]
end

subgraph group_media["Live media"]
  node_camera["Camera previews<br/>[app.js]"]
  node_peer["Peer connection<br/>[app.js]"]
  node_capture["Portrait capture<br/>[app.js]"]
  node_turn["Cloudflare TURN"]
end

subgraph group_strip["Photo strip"]
  node_compose["Strip composition<br/>[app.js]"]
  node_styling["Strip styling<br/>[app.js]"]
  node_renderer["Strip renderer<br/>[strip.js]"]
  node_export["Local downloads<br/>[app.js]"]
end

node_host(("Host"))
node_guest(("Guest"))

node_host -->|"creates booth"| node_webapp
node_guest -->|"opens invite"| node_invite
node_invite -->|"enters booth"| node_webapp
node_webapp -->|"requests room"| node_worker
node_worker -->|"coordinates room"| node_room
node_room -->|"reads and writes"| node_roomstate
node_host -->|"approves guest"| node_room
node_room -->|"provides room events"| node_webapp
node_webapp -->|"requests camera"| node_camera
node_camera -->|"supplies previews"| node_peer
node_webapp -->|"requests ICE servers"| node_worker
node_worker -->|"fetches credentials"| node_turn
node_peer -->|"sends signaling"| node_room
node_peer -->|"exchanges photos"| node_capture
node_capture -->|"provides portraits"| node_compose
node_host -->|"styles strip"| node_styling
node_styling -->|"renders style"| node_renderer
node_renderer -->|"composes locally"| node_compose
node_compose -->|"exports image"| node_export
node_styling -->|"shares changes"| node_peer
node_export -->|"downloads locally"| node_browser

click node_webapp "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_invite "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_camera "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_peer "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_capture "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_compose "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_styling "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_renderer "https://github.com/sandeeprage/momentstamp/blob/main/public/strip.js"
click node_export "https://github.com/sandeeprage/momentstamp/blob/main/public/app.js"
click node_worker "https://github.com/sandeeprage/momentstamp/blob/main/src/index.js"
click node_room "https://github.com/sandeeprage/momentstamp/blob/main/src/index.js"
click node_roomstate "https://github.com/sandeeprage/momentstamp/blob/main/src/index.js"

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_webapp,node_invite,node_browser toneBlue
class node_worker,node_room,node_roomstate toneAmber
class node_camera,node_peer,node_capture,node_turn toneMint
class node_compose,node_styling,node_renderer,node_export toneRose
class node_host,node_guest toneIndigo
```

## Components

### Browser experience

- [Booth interface](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- [Invite entry](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- **Participant browser**

### Room coordination

- [Worker API](https://github.com/sandeeprage/momentstamp/blob/main/src/index.js): `src/index.js`
- [Booth room](https://github.com/sandeeprage/momentstamp/blob/main/src/index.js): `src/index.js`
- [Room state](https://github.com/sandeeprage/momentstamp/blob/main/src/index.js): `src/index.js`

### Live media

- [Camera previews](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- [Peer connection](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- [Portrait capture](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- **Cloudflare TURN**

### Photo strip

- [Strip composition](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- [Strip styling](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`
- [Strip renderer](https://github.com/sandeeprage/momentstamp/blob/main/public/strip.js): `public/strip.js`
- [Local downloads](https://github.com/sandeeprage/momentstamp/blob/main/public/app.js): `public/app.js`

### Other components

- **Host**
- **Guest**

## Connections

- Host → Booth interface: creates booth (evidence: `README.md`)
- Guest → Invite entry: opens invite (evidence: `README.md`)
- Invite entry → Booth interface: enters booth (evidence: `public/app.js`)
- Booth interface → Worker API: requests room (evidence: `public/app.js`)
- Worker API → Booth room: coordinates room (evidence: `README.md`)
- Booth room → Room state: reads and writes (evidence: `src/index.js`)
- Host → Booth room: approves guest (evidence: `README.md`)
- Booth room → Booth interface: provides room events (evidence: `README.md`)
- Booth interface → Camera previews: requests camera (evidence: `public/app.js`)
- Camera previews → Peer connection: supplies previews (evidence: `README.md`)
- Booth interface → Worker API: requests ICE servers (evidence: `src/index.js`)
- Worker API → Cloudflare TURN: fetches credentials (evidence: `src/index.js`)
- Peer connection → Booth room: sends signaling (evidence: `README.md`)
- Peer connection → Portrait capture: exchanges photos (evidence: `README.md`)
- Portrait capture → Strip composition: provides portraits (evidence: `public/app.js`)
- Host → Strip styling: styles strip (evidence: `README.md`)
- Strip styling → Strip renderer: renders style (evidence: `public/app.js`)
- Strip renderer → Strip composition: composes locally (evidence: `public/app.js`)
- Strip composition → Local downloads: exports image (evidence: `README.md`)
- Strip styling → Peer connection: shares changes (evidence: `README.md`)
- Local downloads → Participant browser: downloads locally (evidence: `README.md`)
