# minhkhoa1243/momo_ai_agent architecture

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

- Interactive diagram: https://gitdiagram.com/minhkhoa1243/momo_ai_agent
- Repository: https://github.com/minhkhoa1243/momo_ai_agent

## Overview

This repository contains the outfit/virtual-try-on service (role C) within MOMO AI Agent: users submit a reference outfit image, receive garment items, compose product-backed outfit combinations, then request a render on a matched mannequin. The graph also shows image loading/storage and provider assembly as internal layers, plus product-search and image-embedding capabilities. Evidence is strongest for the API routes and render lifecycle; some provider wiring is documented by the dependency container, while unsampled internals are not expanded.

Main entry points: [`role-c-outfit/app/outfit/deps.py`](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/deps.py) (Provider assembly), [`role-c-outfit/app/outfit/render_service.py`](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/render_service.py) (Render orchestration), [`role-c-outfit/app/outfit/router.py`](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/router.py) (Outfit API), [`role-c-outfit/app/outfit/compose.py`](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/compose.py) (Outfit composition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and contracts"]
  node_api["Outfit API<br/>[router.py]"]
  node_contracts["API models<br/>[schemas.py]"]
end

subgraph group_outfit["Outfit workflows"]
  node_decompose["Outfit decomposition<br/>[decompose.py]"]
  node_compose["Outfit composition<br/>[compose.py]"]
  node_rules["Styling rules<br/>[rules.py]"]
  node_mannequin["Mannequin matching<br/>[mannequin.py]"]
  node_render_service["Render orchestration<br/>[render_service.py]"]
  node_trace["Pipeline tracing<br/>[trace.py]"]
end

subgraph group_media["Image and render infrastructure"]
  node_flatlay["Flat-lay builder<br/>[flatlay.py]"]
  node_loader["Image loader<br/>[loader.py]"]
  node_storage[("Image storage<br/>[storage.py]")]
  node_jobstore[("Job store<br/>[jobstore.py]")]
  node_assets["Local image assets<br/>[assets.py]"]
  node_jobs["Image preparation jobs<br/>[common.py]"]
  node_scenarios["Render scenarios<br/>[scenarios.py]"]
end

subgraph group_providers["Providers and integration"]
  node_container["Provider assembly<br/>[deps.py]"]
  node_vision["Vision analysis<br/>[vision.py]"]
  node_product_search["Product search adapter<br/>[product_search.py]"]
  node_render_provider["Try-on render providers<br/>[render.py]"]
  node_embedding["Image embedding<br/>[embedding.py]"]
  node_settings["Provider settings<br/>[config.py]"]
end

node_user(("User / client"))
node_external_search["MOMO product pipeline"]
node_vision_service["Gemini vision service"]
node_render_service_ext["Virtual try-on service"]

node_user -->|"sends requests"| node_api
node_api -->|"routes analysis"| node_decompose
node_api -->|"routes composition"| node_compose
node_api -->|"starts render"| node_render_service
node_api -->|"matches profile"| node_mannequin
node_api -->|"validates payloads"| node_contracts
node_container -->|"builds service"| node_decompose
node_container -->|"builds service"| node_compose
node_container -->|"builds service"| node_render_service
node_container -->|"selects provider"| node_vision
node_container -->|"selects adapter"| node_product_search
node_container -->|"builds service"| node_flatlay
node_container -->|"builds chain"| node_render_provider
node_container -->|"selects backend"| node_storage
node_container -->|"selects backend"| node_jobstore
node_container -->|"creates loader"| node_loader
node_container -->|"reads configuration"| node_settings
node_decompose -->|"analyzes image"| node_vision
node_vision -.->|"calls when configured"| node_vision_service
node_decompose -->|"loads source image"| node_loader
node_compose -.->|"finds candidates"| node_product_search
node_compose -->|"scores combinations"| node_rules
node_compose -.->|"creates preview"| node_flatlay
node_product_search -.->|"queries products"| node_external_search
node_render_service -->|"stores job state"| node_jobstore
node_render_service -->|"stores completed image"| node_storage
node_render_service -->|"tries render chain"| node_render_provider
node_render_service -.->|"loads garment images"| node_loader
node_render_service -->|"uses fallback preview"| node_flatlay
node_render_provider -.->|"requests virtual try-on"| node_render_service_ext
node_flatlay -->|"loads item images"| node_loader
node_flatlay -.->|"saves preview"| node_storage
node_assets -->|"writes generated assets"| node_storage
node_embedding -->|"reads image pixels"| node_loader
node_jobs -->|"boots providers"| node_container
node_jobs -->|"ensures local assets"| node_assets
node_scenarios -->|"uses outfit models"| node_contracts
node_render_service -.->|"records render steps"| node_trace

click node_api "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/router.py"
click node_contracts "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/schemas.py"
click node_container "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/deps.py"
click node_decompose "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/decompose.py"
click node_vision "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/vision.py"
click node_compose "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/compose.py"
click node_rules "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/rules.py"
click node_product_search "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/adapters/product_search.py"
click node_flatlay "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/flatlay.py"
click node_mannequin "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/mannequin.py"
click node_render_service "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/render_service.py"
click node_render_provider "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/render.py"
click node_loader "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/loader.py"
click node_storage "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/storage.py"
click node_jobstore "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/jobstore.py"
click node_assets "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/assets.py"
click node_embedding "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/embedding.py"
click node_trace "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/trace.py"
click node_settings "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/config.py"
click node_jobs "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/jobs/common.py"
click node_scenarios "https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/jobs/scenarios.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_contracts,node_user toneBlue
class node_decompose,node_compose,node_rules,node_mannequin,node_render_service,node_trace toneAmber
class node_flatlay,node_loader,node_storage,node_jobstore,node_assets,node_jobs,node_scenarios toneMint
class node_container,node_vision,node_product_search,node_render_provider,node_embedding,node_settings toneRose
class node_external_search,node_vision_service,node_render_service_ext toneIndigo
```

## Components

### API and contracts

- [Outfit API](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/router.py): `role-c-outfit/app/outfit/router.py`
- [API models](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/schemas.py): `role-c-outfit/app/outfit/schemas.py`

### Outfit workflows

- [Outfit decomposition](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/decompose.py): `role-c-outfit/app/outfit/decompose.py`
- [Outfit composition](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/compose.py): `role-c-outfit/app/outfit/compose.py`
- [Styling rules](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/rules.py): `role-c-outfit/app/outfit/rules.py`
- [Mannequin matching](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/mannequin.py): `role-c-outfit/app/outfit/mannequin.py`
- [Render orchestration](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/render_service.py): `role-c-outfit/app/outfit/render_service.py`
- [Pipeline tracing](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/trace.py): `role-c-outfit/app/outfit/trace.py`

### Image and render infrastructure

- [Flat-lay builder](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/flatlay.py): `role-c-outfit/app/outfit/flatlay.py`
- [Image loader](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/loader.py): `role-c-outfit/app/outfit/providers/loader.py`
- [Image storage](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/storage.py): `role-c-outfit/app/outfit/providers/storage.py`
- [Job store](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/jobstore.py): `role-c-outfit/app/outfit/providers/jobstore.py`
- [Local image assets](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/assets.py): `role-c-outfit/app/outfit/assets.py`
- [Image preparation jobs](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/jobs/common.py): `role-c-outfit/jobs/common.py`
- [Render scenarios](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/jobs/scenarios.py): `role-c-outfit/jobs/scenarios.py`

### Providers and integration

- [Provider assembly](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/deps.py): `role-c-outfit/app/outfit/deps.py`
- [Vision analysis](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/vision.py): `role-c-outfit/app/outfit/providers/vision.py`
- [Product search adapter](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/adapters/product_search.py): `role-c-outfit/app/outfit/adapters/product_search.py`
- [Try-on render providers](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/render.py): `role-c-outfit/app/outfit/providers/render.py`
- [Image embedding](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/providers/embedding.py): `role-c-outfit/app/outfit/providers/embedding.py`
- [Provider settings](https://github.com/minhkhoa1243/momo_ai_agent/blob/main/role-c-outfit/app/outfit/config.py): `role-c-outfit/app/outfit/config.py`

### Other components

- **User / client**
- **MOMO product pipeline**
- **Gemini vision service**
- **Virtual try-on service**

## Connections

- User / client → Outfit API: sends requests (evidence: `role-c-outfit/app/outfit/router.py`)
- Outfit API → Outfit decomposition: routes analysis (evidence: `role-c-outfit/app/outfit/router.py`)
- Outfit API → Outfit composition: routes composition (evidence: `role-c-outfit/app/outfit/router.py`)
- Outfit API → Render orchestration: starts render (evidence: `role-c-outfit/app/outfit/router.py`)
- Outfit API → Mannequin matching: matches profile (evidence: `role-c-outfit/app/outfit/router.py`)
- Outfit API → API models: validates payloads (evidence: `role-c-outfit/app/outfit/router.py`)
- Provider assembly → Outfit decomposition: builds service (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Outfit composition: builds service (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Render orchestration: builds service (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Vision analysis: selects provider (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Product search adapter: selects adapter (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Flat-lay builder: builds service (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Try-on render providers: builds chain (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Image storage: selects backend (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Job store: selects backend (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Image loader: creates loader (evidence: `role-c-outfit/app/outfit/deps.py`)
- Provider assembly → Provider settings: reads configuration (evidence: `role-c-outfit/app/outfit/deps.py`)
- Outfit decomposition → Vision analysis: analyzes image (evidence: `role-c-outfit/app/outfit/decompose.py`)
- Vision analysis → Gemini vision service: calls when configured
- Outfit decomposition → Image loader: loads source image (evidence: `role-c-outfit/app/outfit/decompose.py`)
- Outfit composition → Product search adapter: finds candidates
- Outfit composition → Styling rules: scores combinations (evidence: `role-c-outfit/app/outfit/compose.py`)
- Outfit composition → Flat-lay builder: creates preview
- Product search adapter → MOMO product pipeline: queries products
- Render orchestration → Job store: stores job state (evidence: `role-c-outfit/app/outfit/render_service.py`)
- Render orchestration → Image storage: stores completed image (evidence: `role-c-outfit/app/outfit/render_service.py`)
- Render orchestration → Try-on render providers: tries render chain (evidence: `role-c-outfit/app/outfit/render_service.py`)
- Render orchestration → Image loader: loads garment images
- Render orchestration → Flat-lay builder: uses fallback preview (evidence: `role-c-outfit/app/outfit/render_service.py`)
- Try-on render providers → Virtual try-on service: requests virtual try-on
- Flat-lay builder → Image loader: loads item images (evidence: `role-c-outfit/app/outfit/flatlay.py`)
- Flat-lay builder → Image storage: saves preview
- Local image assets → Image storage: writes generated assets (evidence: `role-c-outfit/app/outfit/assets.py`)
- Image embedding → Image loader: reads image pixels (evidence: `role-c-outfit/app/outfit/providers/embedding.py`)
- Image preparation jobs → Provider assembly: boots providers (evidence: `role-c-outfit/jobs/common.py`)
- Image preparation jobs → Local image assets: ensures local assets (evidence: `role-c-outfit/jobs/common.py`)
- Render scenarios → API models: uses outfit models (evidence: `role-c-outfit/jobs/scenarios.py`)
- Render orchestration → Pipeline tracing: records render steps (evidence: `role-c-outfit/app/outfit/render_service.py`)
