# leoheinn/fontfinder architecture

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

- Interactive diagram: https://gitdiagram.com/leoheinn/fontfinder
- Repository: https://github.com/leoheinn/fontfinder

## Overview

Font Finder accepts a screenshot in a static browser page, sends it to a FastAPI endpoint, and returns a validated font category, family suggestions, and approximate size. The backend checks uploads and rate limits before calling Gemini, with model fallback and response validation; the page presents the result and links font names to Google Fonts. The frontend capabilities and request flow are documented in ReadMe.md; backend relationships reflect the shown endpoint and helper calls. The single-page implementation was not sampled, so its internal UI details are based on README descriptions.

Main entry points: [`backend/main.py`](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py) (Detect endpoint), [`index.html`](https://github.com/leoheinn/fontfinder/blob/main/index.html) (Image input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_image_input["Image input<br/>[index.html]"]
  node_client_checks["Client checks<br/>[index.html]"]
  node_wait_status["Progress status<br/>[index.html]"]
  node_result_card["Result card<br/>[index.html]"]
  node_theme_reset["Theme and reset<br/>[index.html]"]
  node_font_search["Font search links<br/>[index.html]"]
end

subgraph group_api["API and safeguards"]
  node_detect_api["Detect endpoint<br/>[main.py]"]
  node_upload_validation["Upload validation<br/>[main.py]"]
  node_request_limits["Body and CORS limits<br/>[main.py]"]
  node_rate_limiter["Rate limiter<br/>[main.py]"]
  node_response_parser["Response parser<br/>[main.py]"]
  node_result_schema["Result schema<br/>[main.py]"]
end

subgraph group_inference["Font inference"]
  node_gemini_call["Gemini fallback<br/>[main.py]"]
end

node_user(("User"))
node_google_fonts["Google Fonts"]
node_gemini_api["Gemini API"]

node_user -->|"adds image"| node_image_input
node_image_input -->|"checks image"| node_client_checks
node_client_checks -->|"posts upload"| node_detect_api
node_detect_api -->|"validates upload"| node_upload_validation
node_detect_api -->|"checks limit"| node_rate_limiter
node_detect_api -->|"requests analysis"| node_gemini_call
node_gemini_call -->|"sends image"| node_gemini_api
node_gemini_call -->|"parses reply"| node_response_parser
node_response_parser -->|"validates fields"| node_result_schema
node_request_limits -->|"guards requests"| node_detect_api
node_detect_api -->|"waits for reply"| node_wait_status
node_detect_api -->|"returns result"| node_result_card
node_user -->|"changes display"| node_theme_reset
node_result_card -->|"links suggestions"| node_font_search
node_font_search -->|"opens search"| node_google_fonts

click node_image_input "https://github.com/leoheinn/fontfinder/blob/main/index.html"
click node_client_checks "https://github.com/leoheinn/fontfinder/blob/main/index.html"
click node_wait_status "https://github.com/leoheinn/fontfinder/blob/main/index.html"
click node_result_card "https://github.com/leoheinn/fontfinder/blob/main/index.html"
click node_theme_reset "https://github.com/leoheinn/fontfinder/blob/main/index.html"
click node_font_search "https://github.com/leoheinn/fontfinder/blob/main/index.html"
click node_detect_api "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"
click node_upload_validation "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"
click node_request_limits "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"
click node_rate_limiter "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"
click node_response_parser "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"
click node_result_schema "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"
click node_gemini_call "https://github.com/leoheinn/fontfinder/blob/main/backend/main.py"

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_image_input,node_client_checks,node_wait_status,node_result_card,node_theme_reset,node_font_search,node_user toneBlue
class node_detect_api,node_upload_validation,node_request_limits,node_rate_limiter,node_response_parser,node_result_schema toneAmber
class node_gemini_call,node_gemini_api toneMint
class node_google_fonts toneIndigo
```

## Components

### Browser experience

- [Image input](https://github.com/leoheinn/fontfinder/blob/main/index.html): `index.html`
- [Client checks](https://github.com/leoheinn/fontfinder/blob/main/index.html): `index.html`
- [Progress status](https://github.com/leoheinn/fontfinder/blob/main/index.html): `index.html`
- [Result card](https://github.com/leoheinn/fontfinder/blob/main/index.html): `index.html`
- [Theme and reset](https://github.com/leoheinn/fontfinder/blob/main/index.html): `index.html`
- [Font search links](https://github.com/leoheinn/fontfinder/blob/main/index.html): `index.html`

### API and safeguards

- [Detect endpoint](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`
- [Upload validation](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`
- [Body and CORS limits](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`
- [Rate limiter](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`
- [Response parser](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`
- [Result schema](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`

### Font inference

- [Gemini fallback](https://github.com/leoheinn/fontfinder/blob/main/backend/main.py): `backend/main.py`

### Other components

- **User**
- **Google Fonts**
- **Gemini API**

## Connections

- User → Image input: adds image (evidence: `ReadMe.md`)
- Image input → Client checks: checks image (evidence: `ReadMe.md`)
- Client checks → Detect endpoint: posts upload (evidence: `ReadMe.md`)
- Detect endpoint → Upload validation: validates upload (evidence: `backend/main.py`)
- Detect endpoint → Rate limiter: checks limit (evidence: `backend/main.py`)
- Detect endpoint → Gemini fallback: requests analysis (evidence: `backend/main.py`)
- Gemini fallback → Gemini API: sends image (evidence: `ReadMe.md`)
- Gemini fallback → Response parser: parses reply (evidence: `backend/main.py`)
- Response parser → Result schema: validates fields (evidence: `backend/main.py`)
- Body and CORS limits → Detect endpoint: guards requests (evidence: `backend/main.py`)
- Detect endpoint → Progress status: waits for reply (evidence: `ReadMe.md`)
- Detect endpoint → Result card: returns result (evidence: `ReadMe.md`)
- User → Theme and reset: changes display (evidence: `ReadMe.md`)
- Result card → Font search links: links suggestions (evidence: `ReadMe.md`)
- Font search links → Google Fonts: opens search (evidence: `ReadMe.md`)
