# cheazer/gemini-multimodal-workshop architecture

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

- Interactive diagram: https://gitdiagram.com/cheazer/gemini-multimodal-workshop
- Repository: https://github.com/cheazer/gemini-multimodal-workshop

## Overview

Snap & Ask is a browser-based multimodal Gemini app. Users add an image, choose a preset or question, then request either a streamed text answer or schema-shaped JSON. The UI manages image preparation and browser-local API-key storage; the main module coordinates those inputs and the Gemini calls. README capabilities include sample images, several preset applications, and both response modes. The sampled files show the main wiring; sample assets and page markup are not represented as source components.

Main entry points: [`src/main.js`](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/main.js) (App coordinator), [`src/ui.js`](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/ui.js) (Image, key and output UI), [`src/gemini.js`](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js) (Text response), [`src/presets.js`](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/presets.js) (App presets and schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Browser interface"]
  node_ui["Image, key and output UI<br/>[ui.js]"]
  node_main["App coordinator<br/>[main.js]"]
end

subgraph group_request["Prompt and presets"]
  node_presets["App presets and schemas<br/>[presets.js]"]
  node_contents["Multimodal contents<br/>[gemini.js]"]
end

subgraph group_ai["Gemini requests"]
  node_stream["Text response<br/>[gemini.js]"]
  node_structured["Structured response<br/>[gemini.js]"]
end

node_user(("User"))
node_gemini{{"Google Gemini API"}}
node_browserstorage[("Browser local storage")]
node_sampleimages["Sample images"]

node_user -->|"chooses image/key"| node_ui
node_ui -->|"reads/writes key"| node_browserstorage
node_main -->|"reads inputs; updates output"| node_ui
node_main -->|"loads preset"| node_presets
node_main -->|"loads sample"| node_ui
node_ui -->|"fetches image"| node_sampleimages
node_main -->|"builds contents"| node_contents
node_main -->|"requests streaming answer"| node_stream
node_main -->|"requests JSON answer"| node_structured
node_stream -->|"streams generation"| node_gemini
node_structured -->|"generates JSON"| node_gemini

click node_ui "https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/ui.js"
click node_main "https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/main.js"
click node_presets "https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/presets.js"
click node_contents "https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js"
click node_stream "https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js"
click node_structured "https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js"
click node_sampleimages "https://github.com/cheazer/gemini-multimodal-workshop/tree/main/public/samples"

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_ui,node_main,node_user toneBlue
class node_presets,node_contents,node_browserstorage toneAmber
class node_stream,node_structured,node_gemini toneMint
class node_sampleimages toneTeal
```

## Components

### Browser interface

- [Image, key and output UI](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/ui.js): `src/ui.js`
- [App coordinator](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/main.js): `src/main.js`

### Prompt and presets

- [App presets and schemas](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/presets.js): `src/presets.js`
- [Multimodal contents](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js): `src/gemini.js`

### Gemini requests

- [Text response](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js): `src/gemini.js`
- [Structured response](https://github.com/cheazer/gemini-multimodal-workshop/blob/main/src/gemini.js): `src/gemini.js`

### Other components

- **User**
- **Google Gemini API**
- **Browser local storage**
- [Sample images](https://github.com/cheazer/gemini-multimodal-workshop/tree/main/public/samples): `public/samples`

## Connections

- User → Image, key and output UI: chooses image/key (evidence: `src/ui.js`)
- Image, key and output UI → Browser local storage: reads/writes key (evidence: `src/ui.js`)
- App coordinator → Image, key and output UI: reads inputs; updates output (evidence: `src/main.js`)
- App coordinator → App presets and schemas: loads preset (evidence: `src/main.js`)
- App coordinator → Image, key and output UI: loads sample (evidence: `src/main.js`)
- Image, key and output UI → Sample images: fetches image (evidence: `src/ui.js`)
- App coordinator → Multimodal contents: builds contents (evidence: `src/main.js`)
- App coordinator → Text response: requests streaming answer (evidence: `src/main.js`)
- App coordinator → Structured response: requests JSON answer (evidence: `src/main.js`)
- Text response → Google Gemini API: streams generation (evidence: `src/gemini.js`)
- Structured response → Google Gemini API: generates JSON (evidence: `src/gemini.js`)
