# rishabh55122/outfit architecture

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

- Interactive diagram: https://gitdiagram.com/rishabh55122/outfit
- Repository: https://github.com/rishabh55122/outfit

## Overview

##### Project type and purpose
- OutfitAI Studio is a full-stack, serverless web application built on Next.js (App Router), React and Tailwind CSS.
- Its purpose is to let users upload wardrobe items, select style/occasion preferences, and receive AI-powered outfit suggestions.

##### File structure
- src/app – Next.js pages and layouts (layout.tsx, page.tsx)
- src/components – reusable UI building blocks:
- ui/… (buttons, dialogs, inputs, etc.)
- outfit/… (ItemPreview, OutfitCard, OutfitDisplay)
- layout/… (Header, Footer)
- src/hooks – custom React hooks (use-mobile, use-toast)
- src/lib – utility functions (utils.ts)
- src/ai – server-side AI logic executed as Next.js serverless functions (genkit.ts, flows/generate-item-image-flow.ts, flows/suggest-outfit.ts)
- next.config.ts, tailwind.config.ts – configuration and build settings

##### README for insights
- Confirms Next.js + React + Tailwind stack
- Describes AI integration (Google AI) for image generation and outfit suggestions
- No persistent database; session data and uploaded items live in memory or client state

##### Main components & interactions
a. Frontend (Client)
- React/Next.js pages (src/app)
- Presentation layer (UI components)
- State management (client-side for uploaded items, preferences)
- File-upload widget → sends images to serverless API
b. Backend / Serverless Layer
- Next.js serverless API endpoints (src/ai flows)
- genkit.ts abstracts API calls to Google AI
- generate-item-image-flow.ts (optional image enhancement)
- suggest-outfit.ts (core outfit suggestion logic)
c. External Services
- Google AI API for text/image generation
- Vercel (or equivalent) for hosting and edge CDN
d. (Optional) Asset Hosting
- Static assets served by Next.js (public folder or CDN)

##### Architectural patterns & design principles
- Separation of concerns: UI vs. AI business logic
- Serverless micro-functions for AI orchestration
- Component-based React design for UI reuse
- Responsive, mobile-first design guided by hooks and Tailwind
- Tokenization of AI calls in genkit for easy swapping of providers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actor and Hosting
    Browser["Browser"]:::external
    Vercel["Vercel Edge/CDN"]:::host

    %% Client Side Application
    subgraph "Frontend Application (Next.js)" 
        direction TB
        AppShell["Layout Component"]:::frontend
        HomePage["Home/Page Component"]:::frontend
        subgraph "UI Components Library"
            direction TB
            UIlib["UI Components"]:::frontend
        end
        subgraph "Layout UI Components"
            direction TB
            Header["Header"]:::frontend
            Footer["Footer"]:::frontend
        end
        subgraph "Outfit UI Components"
            direction TB
            ItemPreview["ItemPreview"]:::frontend
            OutfitCard["OutfitCard"]:::frontend
            OutfitDisplay["OutfitDisplay"]:::frontend
            LoadingSpinner["LoadingSpinner"]:::frontend
        end
        subgraph "Custom Hooks"
            direction TB
            useMobile["useMobile"]:::frontend
            useToast["useToast"]:::frontend
        end
        Utils["Utility Functions"]:::frontend
    end

    %% Serverless AI Layer
    subgraph "Serverless AI Layer"
        direction TB
        Genkit["Genkit Abstraction"]:::backend
        GenAIImage["Generate Item Image Flow"]:::backend
        GenOutfit["Suggest Outfit Flow"]:::backend
        DevEndpoint["Dev Endpoint (Mock)"]:::backend
    end

    %% External AI Service
    GoogleAI["Google AI API"]:::external

    %% Configuration Files
    nextConfig["next.config.ts"]:::external
    tailwindConfig["tailwind.config.ts"]:::external

    %% Data Flows
    Browser -->|"Fetch HTML/CSS/JS"| Vercel
    Vercel -->|"Serve App"| Browser

    Browser -->|"User Interactions"| HomePage
    HomePage -->|"Uses UI Components"| UIlib
    HomePage -->|"Renders Header/Footer"| Header
    HomePage -->|"Renders Header/Footer"| Footer
    HomePage -->|"Renders Outfit UI"| ItemPreview
    HomePage -->|"Renders Outfit UI"| OutfitCard
    HomePage -->|"Renders Outfit UI"| OutfitDisplay
    HomePage -->|"Renders Outfit UI"| LoadingSpinner
    HomePage -->|"Invokes Hooks"| useMobile
    HomePage -->|"Invokes Hooks"| useToast
    HomePage -->|"Imports Utils"| Utils

    HomePage -->|"POST images+prefs /api/generate-image"| GenAIImage
    HomePage -->|"POST prefs /api/suggest-outfit"| GenOutfit
    HomePage -->|"Local Dev API"| DevEndpoint

    GenAIImage -->|"calls"| Genkit
    GenOutfit -->|"calls"| Genkit
    DevEndpoint -->|"calls"| Genkit

    Genkit -->|"RPC/HTTP"| GoogleAI
    GoogleAI -->|"Response"| Genkit

    Genkit -->|"200 image URL"| GenAIImage
    Genkit -->|"200 outfit data"| GenOutfit

    GenAIImage -->|"200 image URL"| HomePage
    GenOutfit -->|"200 outfit data"| HomePage

    %% Config links
    click AppShell "https://github.com/rishabh55122/outfit/blob/main/src/app/layout.tsx"
    click HomePage "https://github.com/rishabh55122/outfit/blob/main/src/app/page.tsx"
    click UIlib "https://github.com/rishabh55122/outfit/tree/main/src/components/ui"
    click Header "https://github.com/rishabh55122/outfit/blob/main/src/components/layout/Header.tsx"
    click Footer "https://github.com/rishabh55122/outfit/blob/main/src/components/layout/Footer.tsx"
    click ItemPreview "https://github.com/rishabh55122/outfit/blob/main/src/components/outfit/ItemPreview.tsx"
    click OutfitCard "https://github.com/rishabh55122/outfit/blob/main/src/components/outfit/OutfitCard.tsx"
    click OutfitDisplay "https://github.com/rishabh55122/outfit/blob/main/src/components/outfit/OutfitDisplay.tsx"
    click LoadingSpinner "https://github.com/rishabh55122/outfit/blob/main/src/components/outfit/LoadingSpinner.tsx"
    click useMobile "https://github.com/rishabh55122/outfit/blob/main/src/hooks/use-mobile.tsx"
    click useToast "https://github.com/rishabh55122/outfit/blob/main/src/hooks/use-toast.ts"
    click Utils "https://github.com/rishabh55122/outfit/blob/main/src/lib/utils.ts"
    click Genkit "https://github.com/rishabh55122/outfit/blob/main/src/ai/genkit.ts"
    click GenAIImage "https://github.com/rishabh55122/outfit/blob/main/src/ai/flows/generate-item-image-flow.ts"
    click GenOutfit "https://github.com/rishabh55122/outfit/blob/main/src/ai/flows/suggest-outfit.ts"
    click DevEndpoint "https://github.com/rishabh55122/outfit/blob/main/src/ai/dev.ts"
    click nextConfig "https://github.com/rishabh55122/outfit/blob/main/next.config.ts"
    click tailwindConfig "https://github.com/rishabh55122/outfit/blob/main/tailwind.config.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#333,stroke-width:1px
    classDef host fill:#FFF5BA,stroke:#333,stroke-width:1px
```
