# rafifnurfariz/photopip architecture

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

- Interactive diagram: https://gitdiagram.com/rafifnurfariz/photopip
- Repository: https://github.com/rafifnurfariz/photopip

## Overview

PhotoPip is a browser-based photo booth: users choose a print layout, capture or upload photos into its slots, decorate the resulting composition, and download a print-ready PNG or JPEG. The documented flow is split between capture and editing; the renderer and export helpers are an important internal layer. The README says photo processing stays in the browser and the server serves frame and sticker catalogs. Source excerpts and the index support several module links; unsampled UI and API wiring is not inferred.

Main entry points: [`src/features/studio/studio.tsx`](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/studio.tsx) (Studio workflow), [`src/features/editor/editor.tsx`](https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/editor.tsx) (Editor workspace), [`src/shared-tools/composition/render.ts`](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/render.ts) (Composition renderer), [`src/features/studio/hooks/use-capture-session.ts`](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/hooks/use-capture-session.ts) (Capture session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture studio"]
  node_studio["Studio workflow<br/>[studio.tsx]"]
  node_camera["Browser camera<br/>[use-camera.ts]"]
  node_capture_session["Capture session"]
  node_upload["Photo upload<br/>[image-upload.ts]"]
  node_templates_ui["Layout selector"]
  node_export_ui["Export controls<br/>[export-bar.tsx]"]
end

subgraph group_editor["Composition editor"]
  node_editor["Editor workspace<br/>[editor.tsx]"]
  node_canvas["Interactive canvas"]
  node_panels["Edit controls"]
  node_history["Undo history<br/>[history.ts]"]
end

subgraph group_render["Rendering and export"]
  node_geometry["Print geometry<br/>[geometry.ts]"]
  node_renderer["Composition renderer<br/>[render.ts]"]
  node_export["Image export<br/>[export.ts]"]
end

subgraph group_catalog["Catalogs and assets"]
  node_templates["Print layouts<br/>[templates.ts]"]
  node_frames["Frame catalog<br/>[frames.ts]"]
  node_frame_packs["Frame packs<br/>[frame-pack.ts]"]
  node_stickers["Sticker catalog<br/>[stickers.ts]"]
  node_fonts["Font catalog<br/>[fonts.ts]"]
  node_filters["Photo filters<br/>[photo-filters.ts]"]
end

subgraph group_service["Catalog services"]
  node_frames_api["Frame catalog API<br/>[route.ts]"]
  node_frames_scan["Frame discovery<br/>[scan.ts]"]
  node_stickers_api["Sticker catalog API<br/>[route.ts]"]
  node_stickers_scan["Sticker discovery<br/>[scan.ts]"]
  node_fonts_api["Font catalog API<br/>[route.ts]"]
  node_fonts_scan["Font discovery<br/>[scan.ts]"]
end

node_user(("Photo booth user"))
node_browser(("Browser"))

node_user -->|"uses"| node_studio
node_studio -->|"starts camera"| node_camera
node_studio -.->|"manages capture"| node_capture_session
node_capture_session -->|"captures photos"| node_camera
node_capture_session -->|"reads uploads"| node_upload
node_studio -->|"shows layouts"| node_templates_ui
node_templates_ui -->|"lists layouts"| node_templates
node_studio -->|"opens editor"| node_editor
node_editor -->|"controls canvas"| node_canvas
node_editor -->|"shows controls"| node_panels
node_editor -->|"uses history"| node_history
node_canvas -->|"uses layout"| node_geometry
node_canvas -->|"renders composition"| node_renderer
node_renderer -->|"calculates placement"| node_geometry
node_studio -->|"shows export"| node_export_ui
node_export_ui -.->|"downloads image"| node_export
node_renderer -->|"uses frame data"| node_frames
node_renderer -->|"resolves fonts"| node_fonts
node_editor -->|"uses frames"| node_frames
node_editor -->|"uses stickers"| node_stickers
node_frames_scan -->|"discovers packs"| node_frame_packs
node_frames_api -->|"routes to"| node_frames_scan
node_stickers_api -->|"routes to"| node_stickers_scan
node_fonts_api -->|"routes to"| node_fonts_scan
node_fonts_scan -->|"reads catalog"| node_fonts
node_browser -.->|"requests catalog"| node_frames_api
node_browser -.->|"requests catalog"| node_stickers_api
node_user -->|"downloads result"| node_browser

click node_studio "https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/studio.tsx"
click node_camera "https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/camera/use-camera.ts"
click node_capture_session "https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/hooks/use-capture-session.ts"
click node_upload "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/image-upload.ts"
click node_templates_ui "https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/components/template-selector.tsx"
click node_templates "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/templates.ts"
click node_editor "https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/editor.tsx"
click node_canvas "https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/hooks/use-editor-canvas.ts"
click node_panels "https://github.com/rafifnurfariz/photopip/tree/master/src/features/editor/components"
click node_history "https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/history.ts"
click node_geometry "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/geometry.ts"
click node_renderer "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/render.ts"
click node_export "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/export.ts"
click node_export_ui "https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/components/export-bar.tsx"
click node_frames "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/frames.ts"
click node_frame_packs "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/frame-pack.ts"
click node_stickers "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/stickers.ts"
click node_fonts "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/fonts.ts"
click node_filters "https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/photo-filters.ts"
click node_frames_api "https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/frames/route.ts"
click node_frames_scan "https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/frames/scan.ts"
click node_stickers_api "https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/stickers/route.ts"
click node_stickers_scan "https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/stickers/scan.ts"
click node_fonts_api "https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/fonts/route.ts"
click node_fonts_scan "https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/fonts/scan.ts"

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_studio,node_camera,node_capture_session,node_upload,node_templates_ui,node_export_ui,node_user,node_browser toneBlue
class node_editor,node_canvas,node_panels,node_history toneAmber
class node_geometry,node_renderer,node_export toneMint
class node_templates,node_frames,node_frame_packs,node_stickers,node_fonts,node_filters toneRose
class node_frames_api,node_frames_scan,node_stickers_api,node_stickers_scan,node_fonts_api,node_fonts_scan toneIndigo
```

## Components

### Capture studio

- [Studio workflow](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/studio.tsx): `src/features/studio/studio.tsx`
- [Browser camera](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/camera/use-camera.ts): `src/features/studio/camera/use-camera.ts`
- [Capture session](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/hooks/use-capture-session.ts): `src/features/studio/hooks/use-capture-session.ts`
- [Photo upload](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/image-upload.ts): `src/shared-tools/image-upload.ts`
- [Layout selector](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/components/template-selector.tsx): `src/features/studio/components/template-selector.tsx`
- [Export controls](https://github.com/rafifnurfariz/photopip/blob/master/src/features/studio/components/export-bar.tsx): `src/features/studio/components/export-bar.tsx`

### Composition editor

- [Editor workspace](https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/editor.tsx): `src/features/editor/editor.tsx`
- [Interactive canvas](https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/hooks/use-editor-canvas.ts): `src/features/editor/hooks/use-editor-canvas.ts`
- [Edit controls](https://github.com/rafifnurfariz/photopip/tree/master/src/features/editor/components): `src/features/editor/components`
- [Undo history](https://github.com/rafifnurfariz/photopip/blob/master/src/features/editor/history.ts): `src/features/editor/history.ts`

### Rendering and export

- [Print geometry](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/geometry.ts): `src/shared-tools/composition/geometry.ts`
- [Composition renderer](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/render.ts): `src/shared-tools/composition/render.ts`
- [Image export](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/composition/export.ts): `src/shared-tools/composition/export.ts`

### Catalogs and assets

- [Print layouts](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/templates.ts): `src/shared-tools/catalog/templates.ts`
- [Frame catalog](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/frames.ts): `src/shared-tools/catalog/frames.ts`
- [Frame packs](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/frame-pack.ts): `src/shared-tools/catalog/frame-pack.ts`
- [Sticker catalog](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/stickers.ts): `src/shared-tools/catalog/stickers.ts`
- [Font catalog](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/fonts.ts): `src/shared-tools/catalog/fonts.ts`
- [Photo filters](https://github.com/rafifnurfariz/photopip/blob/master/src/shared-tools/catalog/photo-filters.ts): `src/shared-tools/catalog/photo-filters.ts`

### Catalog services

- [Frame catalog API](https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/frames/route.ts): `src/app/api/frames/route.ts`
- [Frame discovery](https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/frames/scan.ts): `src/app/api/frames/scan.ts`
- [Sticker catalog API](https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/stickers/route.ts): `src/app/api/stickers/route.ts`
- [Sticker discovery](https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/stickers/scan.ts): `src/app/api/stickers/scan.ts`
- [Font catalog API](https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/fonts/route.ts): `src/app/api/fonts/route.ts`
- [Font discovery](https://github.com/rafifnurfariz/photopip/blob/master/src/app/api/fonts/scan.ts): `src/app/api/fonts/scan.ts`

### Other components

- **Photo booth user**
- **Browser**

## Connections

- Photo booth user → Studio workflow: uses
- Studio workflow → Browser camera: starts camera (evidence: `src/features/studio/studio.tsx`)
- Studio workflow → Capture session: manages capture (evidence: `src/features/studio/studio.tsx`)
- Capture session → Browser camera: captures photos (evidence: `src/features/studio/hooks/use-capture-session.ts`)
- Capture session → Photo upload: reads uploads (evidence: `src/features/studio/hooks/use-capture-session.ts`)
- Studio workflow → Layout selector: shows layouts (evidence: `src/features/studio/studio.tsx`)
- Layout selector → Print layouts: lists layouts (evidence: `src/features/studio/components/template-selector.tsx`)
- Studio workflow → Editor workspace: opens editor (evidence: `src/features/studio/studio.tsx`)
- Editor workspace → Interactive canvas: controls canvas (evidence: `src/features/editor/editor.tsx`)
- Editor workspace → Edit controls: shows controls (evidence: `src/features/editor/editor.tsx`)
- Editor workspace → Undo history: uses history (evidence: `src/features/editor/editor.tsx`)
- Interactive canvas → Print geometry: uses layout (evidence: `src/features/editor/hooks/use-editor-canvas.ts`)
- Interactive canvas → Composition renderer: renders composition (evidence: `src/features/editor/hooks/use-editor-canvas.ts`)
- Composition renderer → Print geometry: calculates placement (evidence: `src/shared-tools/composition/render.ts`)
- Studio workflow → Export controls: shows export (evidence: `src/features/studio/studio.tsx`)
- Export controls → Image export: downloads image
- Composition renderer → Frame catalog: uses frame data (evidence: `src/shared-tools/composition/render.ts`)
- Composition renderer → Font catalog: resolves fonts (evidence: `src/shared-tools/composition/render.ts`)
- Editor workspace → Frame catalog: uses frames (evidence: `src/features/editor/editor.tsx`)
- Editor workspace → Sticker catalog: uses stickers (evidence: `src/features/editor/editor.tsx`)
- Frame discovery → Frame packs: discovers packs (evidence: `src/app/api/frames/scan.ts`)
- Frame catalog API → Frame discovery: routes to (evidence: `src/app/api/frames/route.ts`)
- Sticker catalog API → Sticker discovery: routes to (evidence: `src/app/api/stickers/route.ts`)
- Font catalog API → Font discovery: routes to (evidence: `src/app/api/fonts/route.ts`)
- Font discovery → Font catalog: reads catalog (evidence: `src/app/api/fonts/scan.ts`)
- Browser → Frame catalog API: requests catalog
- Browser → Sticker catalog API: requests catalog
- Photo booth user → Browser: downloads result
