# sujpatel/ai-agent-clothes architecture

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

- Interactive diagram: https://gitdiagram.com/sujpatel/ai-agent-clothes
- Repository: https://github.com/sujpatel/ai-agent-clothes

## Overview

This is the FastAPI backend for an AI wardrobe and outfit assistant. A user authenticates, uploads a garment photo or submits a flat-lay for detection and review, then confirms items for storage and search. For recommendations, the API retrieves available wardrobe candidates and asks Gemini to choose an outfit, optionally using live weather; it saves the conversation so the user can refine the result. The graph follows the sampled API and service calls, with README-documented integrations and capabilities included where source excerpts were limited.

Main entry points: [`app/main.py`](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/main.py) (FastAPI routes), [`app/ingestion.py`](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/ingestion.py) (Garment tagging), [`app/detection.py`](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/detection.py) (Garment detection), [`app/vectorstore.py`](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/vectorstore.py) (Wardrobe index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_auth["JWT verification<br/>[auth.py]"]
end

subgraph group_wardrobe["Wardrobe ingestion"]
  node_uploads["Image validation<br/>[uploads.py]"]
  node_detect["Garment detection<br/>[detection.py]"]
  node_tag["Garment tagging<br/>[ingestion.py]"]
  node_model["Clothing attributes<br/>[models.py]"]
  node_eval["Flat-lay evaluation<br/>[eval_flatlay.py]"]
end

subgraph group_recommend["Outfit recommendation"]
  node_compose["Outfit composition<br/>[composition.py]"]
  node_weather["Weather lookup<br/>[weather.py]"]
  node_retry["Gemini retries<br/>[gemini_utils.py]"]
end

subgraph group_persistence["Data and storage"]
  node_photos["Photo storage<br/>[photo_store.py]"]
  node_vectors[("Wardrobe index<br/>[vectorstore.py]")]
  node_embeddings["Text embeddings<br/>[embeddings.py]"]
  node_sessions[("Conversation sessions<br/>[session_store.py]")]
end

subgraph group_integrations["External services"]
  node_gemini["Gemini API"]
  node_pinecone[("Pinecone")]
  node_supabase[("Supabase")]
  node_openmeteo["Open-Meteo"]
end

node_user(("Mobile app user"))

node_user -->|"sends requests"| node_api
node_api -->|"verifies identity"| node_auth
node_api -->|"validates images"| node_uploads
node_api -->|"detects batch items"| node_detect
node_api -->|"tags items"| node_tag
node_api -->|"uploads and fetches"| node_photos
node_api -->|"manages wardrobe"| node_vectors
node_api -->|"requests outfit"| node_compose
node_api -->|"loads and saves"| node_sessions
node_detect -->|"provides crop hints"| node_tag
node_tag -->|"returns attributes"| node_model
node_tag -->|"requests tags"| node_gemini
node_detect -->|"requests boxes"| node_gemini
node_tag -->|"uses retry wrapper"| node_retry
node_detect -->|"uses retry wrapper"| node_retry
node_vectors -->|"embeds descriptions"| node_embeddings
node_vectors -->|"queries and updates"| node_pinecone
node_vectors -->|"deletes photo"| node_photos
node_compose -->|"retrieves candidates"| node_vectors
node_compose -->|"chooses outfit"| node_gemini
node_compose -->|"calls tool"| node_weather
node_weather -->|"fetches conditions"| node_openmeteo
node_sessions -->|"reads and writes"| node_supabase
node_photos -->|"stores photos"| node_supabase
node_auth -->|"verifies against JWKS"| node_supabase
node_eval -->|"evaluates detection"| node_detect
node_eval -->|"evaluates tagging"| node_tag

click node_api "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/main.py"
click node_auth "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/auth.py"
click node_uploads "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/uploads.py"
click node_detect "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/detection.py"
click node_tag "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/ingestion.py"
click node_model "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/models.py"
click node_photos "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/photo_store.py"
click node_vectors "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/vectorstore.py"
click node_embeddings "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/embeddings.py"
click node_sessions "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/session_store.py"
click node_compose "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/composition.py"
click node_weather "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/weather.py"
click node_retry "https://github.com/sujpatel/ai-agent-clothes/blob/main/app/gemini_utils.py"
click node_eval "https://github.com/sujpatel/ai-agent-clothes/blob/main/eval_flatlay.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_api,node_auth,node_user toneBlue
class node_uploads,node_detect,node_tag,node_model,node_eval toneAmber
class node_compose,node_weather,node_retry toneMint
class node_photos,node_vectors,node_embeddings,node_sessions toneRose
class node_gemini,node_pinecone,node_supabase,node_openmeteo toneIndigo
```

## Components

### API and identity

- [FastAPI routes](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/main.py): `app/main.py`
- [JWT verification](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/auth.py): `app/auth.py`

### Wardrobe ingestion

- [Image validation](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/uploads.py): `app/uploads.py`
- [Garment detection](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/detection.py): `app/detection.py`
- [Garment tagging](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/ingestion.py): `app/ingestion.py`
- [Clothing attributes](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/models.py): `app/models.py`
- [Flat-lay evaluation](https://github.com/sujpatel/ai-agent-clothes/blob/main/eval_flatlay.py): `eval_flatlay.py`

### Outfit recommendation

- [Outfit composition](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/composition.py): `app/composition.py`
- [Weather lookup](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/weather.py): `app/weather.py`
- [Gemini retries](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/gemini_utils.py): `app/gemini_utils.py`

### Data and storage

- [Photo storage](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/photo_store.py): `app/photo_store.py`
- [Wardrobe index](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/vectorstore.py): `app/vectorstore.py`
- [Text embeddings](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/embeddings.py): `app/embeddings.py`
- [Conversation sessions](https://github.com/sujpatel/ai-agent-clothes/blob/main/app/session_store.py): `app/session_store.py`

### External services

- **Gemini API**
- **Pinecone**
- **Supabase**
- **Open-Meteo**

### Other components

- **Mobile app user**

## Connections

- Mobile app user → FastAPI routes: sends requests (evidence: `README.md`)
- FastAPI routes → JWT verification: verifies identity (evidence: `app/main.py`)
- FastAPI routes → Image validation: validates images (evidence: `app/main.py`)
- FastAPI routes → Garment detection: detects batch items (evidence: `app/main.py`)
- FastAPI routes → Garment tagging: tags items (evidence: `app/main.py`)
- FastAPI routes → Photo storage: uploads and fetches (evidence: `app/main.py`)
- FastAPI routes → Wardrobe index: manages wardrobe (evidence: `app/main.py`)
- FastAPI routes → Outfit composition: requests outfit (evidence: `app/main.py`)
- FastAPI routes → Conversation sessions: loads and saves (evidence: `app/main.py`)
- Garment detection → Garment tagging: provides crop hints (evidence: `README.md`)
- Garment tagging → Clothing attributes: returns attributes (evidence: `app/ingestion.py`)
- Garment tagging → Gemini API: requests tags (evidence: `README.md`)
- Garment detection → Gemini API: requests boxes (evidence: `README.md`)
- Garment tagging → Gemini retries: uses retry wrapper (evidence: `app/ingestion.py`)
- Garment detection → Gemini retries: uses retry wrapper (evidence: `app/detection.py`)
- Wardrobe index → Text embeddings: embeds descriptions (evidence: `app/vectorstore.py`)
- Wardrobe index → Pinecone: queries and updates (evidence: `app/vectorstore.py`)
- Wardrobe index → Photo storage: deletes photo (evidence: `app/vectorstore.py`)
- Outfit composition → Wardrobe index: retrieves candidates (evidence: `app/composition.py`)
- Outfit composition → Gemini API: chooses outfit (evidence: `app/composition.py`)
- Outfit composition → Weather lookup: calls tool (evidence: `app/composition.py`)
- Weather lookup → Open-Meteo: fetches conditions (evidence: `README.md`)
- Conversation sessions → Supabase: reads and writes (evidence: `app/session_store.py`)
- Photo storage → Supabase: stores photos (evidence: `app/photo_store.py`)
- JWT verification → Supabase: verifies against JWKS (evidence: `README.md`)
- Flat-lay evaluation → Garment detection: evaluates detection (evidence: `eval_flatlay.py`)
- Flat-lay evaluation → Garment tagging: evaluates tagging (evidence: `eval_flatlay.py`)
