# heychhavi/fashion-ai-assistant architecture

> Architecture diagram of the GitHub repository heychhavi/fashion-ai-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/heychhavi/fashion-ai-assistant
- Repository: https://github.com/heychhavi/fashion-ai-assistant

## Overview

##### Project Type and Purpose
- The project is a full-stack, AI-driven personal styling assistant. Its main purpose is to analyze users’ style preferences through image analysis (using Google’s Gemini 1.5 Flash model) and to integrate with Shopify for product recommendations and purchases.
- The README provides an overview of the intelligent styling recommendations, while the file tree shows the main Python scripts and configurations (e.g., app.py, shopify_client.py, style_analyzer.py) that implement the different functional layers.

##### Analyzing the File Structure
- Key Files:
- app.py: Serves as the entry point and likely runs the Streamlit-based user interface.
- shopify_client.py: Handles Shopify API communications.
- style_analyzer.py: Integrates with AI (Gemini API) for image-based style analysis.
- create_dummy_products.py & dummy_products.json: Used to simulate and test Shopify product data during development.
- test_shopify_updated.py: Contains testing routines for validating Shopify-related functionalities.
- Configuration and Environment:
- .env.example outlines crucial environment variables like API keys and store credentials.
- .devcontainer folder indicates support for development containerization.
- Supplementary Documents:
- README.md, SHOPIFY_SETUP.md, and SYNOPSIS.md provide further setup instructions and system usage details.

##### Key Architectural Components
a. User Interface Layer:
- Implemented via Streamlit (app.py) which handles:
- Image uploads.
- Preference inputs.
- Displaying recommendations.
b. Application (Business Logic) Layer:
- Central coordination of style analysis, recommendation generation, and cart management.
- Likely split between app.py and integrated modules such as style_analyzer.py.
c. Service Integration Layer:
- Consists of API-specific components:
- shopify_client.py: Handles real-time e-commerce integration with Shopify.
- style_analyzer.py: Communicates with the Gemini AI API for visual analysis.
- create_dummy_products.py supports generating test data for developing product features.
d. External Services:
- Google Gemini API: For advanced image processing and style recognition.
- Shopify Storefront/Access APIs: For fetching product catalogs, pricing, availability, and cart functionalities.
- Possible additional external storage or session management services for image data.

##### Relationships and Data Flow
- User actions (image uploads and preference selections) in the Streamlit UI.
- The UI sending data to the Application Logic.
- The Application Logic invoking the style analysis module, which then calls the external Gemini API.
- Once the style analysis is complete, the system generates recommendations and uses the shopify_client module to fetch product data from Shopify.
- The products are then shown back in the UI with options for quick purchase.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- UI (presentation) is decoupled from business logic and service integrations.
- Modularity:
- Dedicated modules for Shopify API interactions and style analysis.
- Environment-based Configuration:
- Usage of environment variables and containerization (.env file and .devcontainer) for consistent development and deployment setups.
- Testing:
- Inclusion of test modules (e.g., test_shopify_updated.py) to ensure quality and reliability in integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI["User Interface (Streamlit UI)"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        BL["Business Logic (Core Coordination)"]:::logic
    end

    %% Integration Layer
    subgraph "Integration Layer"
        SA["Style Analysis Module"]:::module
        SC["Shopify API Client"]:::module
    end

    %% External APIs
    subgraph "External APIs"
        GG["Google Gemini API"]:::external
        SE["Shopify External API"]:::external
    end

    %% Development & Configuration
    subgraph "Development & Config"
        TS["Test Suite"]:::dev
        DP["Dummy Products"]:::dev
        EF["Env File (.env.example)"]:::dev
        DC["Dev Container (.devcontainer)"]:::dev
        RD["README.md"]:::dev
        SSU["SHOPIFY_SETUP.md"]:::dev
        SYN["SYNOPSIS.md"]:::dev
        AIS["AI Wardrobe Synopsis.html"]:::dev
    end

    %% Main Flow: UI to Business Logic and back
    UI -->|"sendsData"| BL
    BL -->|"callsStyleAnalysis"| SA
    SA -->|"callsGemini"| GG
    GG -->|"returnsAnalysis"| SA
    BL -->|"callsShopify"| SC
    SC -->|"fetchesFrom"| SE
    SE -->|"returnsProducts"| SC
    SA -->|"returnsAnalysis"| BL
    SC -->|"returnsProducts"| BL
    BL -->|"displaysRecommendations"| UI

    %% Development connections
    TS ---|"tests"| BL
    DP ---|"providesDummyData"| SC

    %% Click events
    click UI "https://github.com/heychhavi/fashion-ai-assistant/blob/main/app.py"
    click BL "https://github.com/heychhavi/fashion-ai-assistant/blob/main/app.py"
    click SA "https://github.com/heychhavi/fashion-ai-assistant/blob/main/style_analyzer.py"
    click SC "https://github.com/heychhavi/fashion-ai-assistant/blob/main/shopify_client.py"
    click TS "https://github.com/heychhavi/fashion-ai-assistant/blob/main/test_shopify_updated.py"
    click DP "https://github.com/heychhavi/fashion-ai-assistant/blob/main/create_dummy_products.py"
    click EF "https://github.com/heychhavi/fashion-ai-assistant/blob/main/.env.example"
    click DC "https://github.com/heychhavi/fashion-ai-assistant/blob/main/.devcontainer"
    click RD "https://github.com/heychhavi/fashion-ai-assistant/blob/main/README.md"
    click SSU "https://github.com/heychhavi/fashion-ai-assistant/blob/main/SHOPIFY_SETUP.md"
    click SYN "https://github.com/heychhavi/fashion-ai-assistant/blob/main/SYNOPSIS.md"
    click AIS "https://github.com/heychhavi/fashion-ai-assistant/blob/main/AI_Wardrobe_Synopsis.html"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef module fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef external fill:#F08080,stroke:#000,stroke-width:2px;
    classDef dev fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
