# mynavitechtus-minhnt3/figma-compare architecture

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

- Interactive diagram: https://gitdiagram.com/mynavitechtus-minhnt3/figma-compare
- Repository: https://github.com/mynavitechtus-minhnt3/figma-compare

## Overview

Figma Compare lets a user supply a design and implementation image, inspect them side by side or with a swipe comparison, and request AI-detected discrepancies with severity and locations. The Next.js page is the documented interaction hub; image preparation and API calls support it, while the Express backend serves Figma-image retrieval and AI comparison. Results and bounding-box overlays make findings inspectable. The page source was not sampled, so its internal event wiring is shown only where the README documents the workflow; unsampled backend behavior is not inferred.

Main entry points: [`figma-compare-web/app/page.tsx`](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/page.tsx) (Comparison Workspace), [`figma-compare-be/index.js`](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/index.js) (AI Comparison Endpoint), [`figma-compare-web/app/lib/api.ts`](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/api.ts) (Figma Image Client), [`figma-compare-web/app/lib/imageUtils.ts`](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/imageUtils.ts) (Image Preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Image Inputs"]
  node_page["Comparison Workspace<br/>[page.tsx]"]
  node_imageprep["Image Preparation<br/>[imageUtils.ts]"]
  node_figmafetch["Figma Image Client<br/>[api.ts]"]
end

subgraph group_analysis["Comparison Analysis"]
  node_comparisonview["Comparison Modes<br/>[page.tsx]"]
  node_compareclient["Comparison API Client<br/>[api.ts]"]
end

subgraph group_inspection["Results Inspection"]
  node_results["Analysis Results<br/>[ResultsPanel.tsx]"]
  node_overlay["Issue Overlays<br/>[BugOverlay.tsx]"]
end

subgraph group_backend["Backend Services"]
  node_figmaendpoint["Figma Image Endpoint<br/>[index.js]"]
  node_compareendpoint["AI Comparison Endpoint<br/>[index.js]"]
  node_uploads[("Temporary Uploads<br/>[index.js]")]
end

node_user(("User"))
node_figma{{"Figma API"}}
node_azure{{"Azure OpenAI"}}

node_user -->|"supplies images"| node_page
node_page -->|"resizes images"| node_imageprep
node_page -->|"fetches design"| node_figmafetch
node_page -->|"chooses mode"| node_comparisonview
node_page -->|"requests analysis"| node_compareclient
node_page -->|"shows findings"| node_results
node_page -->|"shows issue boxes"| node_overlay
node_figmafetch -->|"requests image URL"| node_figmaendpoint
node_compareclient -->|"posts image files"| node_compareendpoint
node_figmaendpoint -->|"requests rendered image"| node_figma
node_compareendpoint -->|"reads uploaded files"| node_uploads
node_compareendpoint -->|"sends image analysis"| node_azure

click node_page "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/page.tsx"
click node_imageprep "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/imageUtils.ts"
click node_figmafetch "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/api.ts"
click node_comparisonview "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/page.tsx"
click node_compareclient "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/api.ts"
click node_results "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/components/ResultsPanel/ResultsPanel.tsx"
click node_overlay "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/components/BugOverlay/BugOverlay.tsx"
click node_figmaendpoint "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/index.js"
click node_compareendpoint "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/index.js"
click node_uploads "https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/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_page,node_imageprep,node_figmafetch,node_user toneBlue
class node_comparisonview,node_compareclient toneAmber
class node_results,node_overlay,node_figma toneMint
class node_figmaendpoint,node_compareendpoint,node_uploads toneRose
class node_azure toneIndigo
```

## Components

### Image Inputs

- [Comparison Workspace](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/page.tsx): `figma-compare-web/app/page.tsx`
- [Image Preparation](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/imageUtils.ts): `figma-compare-web/app/lib/imageUtils.ts`
- [Figma Image Client](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/api.ts): `figma-compare-web/app/lib/api.ts`

### Comparison Analysis

- [Comparison Modes](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/page.tsx): `figma-compare-web/app/page.tsx`
- [Comparison API Client](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/lib/api.ts): `figma-compare-web/app/lib/api.ts`

### Results Inspection

- [Analysis Results](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/components/ResultsPanel/ResultsPanel.tsx): `figma-compare-web/app/components/ResultsPanel/ResultsPanel.tsx`
- [Issue Overlays](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-web/app/components/BugOverlay/BugOverlay.tsx): `figma-compare-web/app/components/BugOverlay/BugOverlay.tsx`

### Backend Services

- [Figma Image Endpoint](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/index.js): `figma-compare-be/index.js`
- [AI Comparison Endpoint](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/index.js): `figma-compare-be/index.js`
- [Temporary Uploads](https://github.com/mynavitechtus-minhnt3/figma-compare/blob/main/figma-compare-be/index.js): `figma-compare-be/index.js`

### Other components

- **User**
- **Figma API**
- **Azure OpenAI**

## Connections

- User → Comparison Workspace: supplies images (evidence: `README.md`)
- Comparison Workspace → Image Preparation: resizes images (evidence: `README.md`)
- Comparison Workspace → Figma Image Client: fetches design (evidence: `README.md`)
- Comparison Workspace → Comparison Modes: chooses mode (evidence: `README.md`)
- Comparison Workspace → Comparison API Client: requests analysis (evidence: `README.md`)
- Comparison Workspace → Analysis Results: shows findings (evidence: `README.md`)
- Comparison Workspace → Issue Overlays: shows issue boxes (evidence: `README.md`)
- Figma Image Client → Figma Image Endpoint: requests image URL (evidence: `figma-compare-web/app/lib/api.ts`)
- Comparison API Client → AI Comparison Endpoint: posts image files (evidence: `figma-compare-web/app/lib/api.ts`)
- Figma Image Endpoint → Figma API: requests rendered image (evidence: `figma-compare-be/index.js`)
- AI Comparison Endpoint → Temporary Uploads: reads uploaded files (evidence: `figma-compare-be/index.js`)
- AI Comparison Endpoint → Azure OpenAI: sends image analysis (evidence: `figma-compare-be/index.js`)
