# dhaan-ish/wizzers architecture

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

- Interactive diagram: https://gitdiagram.com/dhaan-ish/wizzers
- Repository: https://github.com/dhaan-ish/wizzers

## Overview

##### Project's Main Purpose and Components
- The README and file structure reveal that Stylist AI offers:
- A text-to-outfit generation model (using Hugging Face’s DiffusionPipeline).
- A human-identification model (image classification using TensorFlow/Keras).
- An outfit-recommendation system (combining semantic image search with CLIP embeddings and Langchain, plus a vector database).
- A virtual try-on module (clothing segmentation, pose estimation, and image composition).
- A fashion chatbot (powered by a fine-tuned Mistral 7B model with LLAMA Index and Langchain integration).
- In addition, the project includes a React-based frontend and a Flask-based backend.

##### Primary Components
- Frontend (React)
- This as a separate client-side component that handles user interactions, displays the UI (e.g., outfit recommendations, chatbot interface, virtual try-on outputs), and sends requests via API calls.
- Backend (Flask API)
- Acts as the application server that receives requests from the frontend and orchestrates calls to the individual models.
- It manages business logic, handles file uploads (e.g., images for virtual try-on), and channels responses back to the user.
- Machine Learning Modules (each as a distinct component):
- Text-To-Outfit Generation:
- Uses Hugging Face’s pretrained diffusion model to generate outfit images based on text prompts.
- Human-Identification:
- Implements a neural network built on TensorFlow/Keras to classify images as “human” or “non-human” (crucial for verifying the user's input for the try-on process).
- Outfit-Recommendation:
- Integrates semantic search with sparse (BM25) and dense (CLIP embeddings) retrieval, likely storing/retrieving fashion metadata from a vector database.
- Virtual Try-On:
- Combines clothing segmentation, pose estimation, and image composition to overlay clothing items onto user images.
- Chat-Bot:
- Uses the Mistral 7B model fine-tuned through custom data along with LLAMA Index and Langchain embeddings to process and respond to user messages.
- External Services & Resources
- A note for external integrations such as Hugging Face, possibly a vector database (if used for recommendation persistence), and any external libraries like Gradio or LLAMA Index that may be hosted or externally accessed.

##### Relationships and Interactions
- Each interaction from the frontend (text prompt for outfit generation, image upload for virtual try-on, selection for recommendation, or chat query) should be represented as an API call.
- Text-To-Outfit Generation module: receives text input, returns a generated outfit image.
- Human-Identification module: processes images, verifies human presence.
- Virtual Try-On module: combines segmentation and pose estimation data to produce a composite image.
- Chatbot module: processes conversation and returns style advice.
- Data flow between modules where applicable (for example, the human-identification results could be used to decide if an image is valid for the virtual try-on).

##### Architectural Patterns and Technologies
- Separation of concerns:
- The UI (React) is fully decoupled from the business logic (Flask) and the ML processing pipelines.
- Orchestration pattern: the backend acts as a central coordinator for multiple microservices (ML pipelines) even if they aren’t deployed as standalone services.
- Mention middleware concerns such as authentication, logging, and error handling as part of the backend component (if applicable).
- Use of notebooks for experimentation (Jupyter Notebooks in separate subdirectories) as supporting artifacts for model training and testing, which feed into the deployed models.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Top Layer: User
    U["User"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["React Frontend"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Flask Backend API"]:::backend
    end

    %% Machine Learning Modules Layer
    subgraph "Machine Learning Modules"
        TTO["Text-To-Outfit Generation (Diffusion Pipeline)"]:::ml
        HI["Human-Identification (TensorFlow/Keras)"]:::ml
        OR["Outfit-Recommendation (Semantic & CLIP Embeddings)"]:::ml
        VT["Virtual Try-On (Clothing Segmentation & Pose Estimation)"]:::ml
        CB["Chat-Bot (Mistral 7B with LLAMA Index & Langchain)"]:::ml
    end

    %% External Services & Resources
    subgraph "External Services & Resources"
        HF["Hugging Face"]:::external
        VDB["Vector Database"]:::external
    end

    %% Data Flow from User to Frontend
    U -->|"User Input/UI Interaction"| FE

    %% Frontend calling Backend
    FE -->|"API Call"| BE

    %% Backend orchestrating ML Modules
    BE -->|"Process(TextPrompt)"| TTO
    BE -->|"Process(ImageInput)"| HI
    BE -->|"Process(Recommendation)"| OR
    BE -->|"Process(TryOn)"| VT
    BE -->|"Process(ChatQuery)"| CB

    %% ML Modules returning results to Backend
    TTO -->|"ReturnOutfitImage"| BE
    HI -->|"ReturnHumanValidation"| BE
    OR -->|"ReturnRecommendations"| BE
    VT -->|"ReturnCompositeImage"| BE
    CB -->|"ReturnChatResponse"| BE

    %% Additional data flow: Human-Identification informs Virtual Try-On
    HI -->|"ValidationCheck"| VT

    %% Backend responding to Frontend and then to User
    BE -->|"APIResponse"| FE
    FE -->|"DisplayResult"| U

    %% External integrations for ML Modules
    TTO -->|"Uses"| HF
    OR -->|"Queries"| VDB

    %% Click Events
    click FE "https://github.com/dhaan-ish/wizzers/tree/main/frontend/"
    click BE "https://github.com/dhaan-ish/wizzers/blob/main/backend/app.py"
    click TTO "https://github.com/dhaan-ish/wizzers/blob/main/Text-To-Outfit-Generator/TextToCloth.ipynb"
    click HI "https://github.com/dhaan-ish/wizzers/blob/main/Human-Identification/train.ipynb"
    click OR "https://github.com/dhaan-ish/wizzers/tree/main/Outfit-Recommendation/"
    click VT "https://github.com/dhaan-ish/wizzers/tree/main/Virtual-Try-On/"
    click CB "https://github.com/dhaan-ish/wizzers/blob/main/Chat-Bot/ChatBot.ipynb"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef ml fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFDFBA,stroke:#000,stroke-width:2px;
    classDef user fill:#FFFF99,stroke:#000,stroke-width:2px;
```
