# zebangeth/ai-closet architecture

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

- Interactive diagram: https://gitdiagram.com/zebangeth/ai-closet
- Repository: https://github.com/zebangeth/ai-closet

## Overview

##### Main Components

A. Client-Side (Mobile App)
- UI Layer
- Screens (6 main screens identified in /src/screens)
- Components (organized by feature: clothing, outfit, virtualTryOn, common)
- State Management Layer
- Context Providers (ClothingContext, OutfitContext, VirtualTryOnContext)
- Data Layer
- AsyncStorage
- File System Storage
- Services Layer
- Background Removal Service
- Clothing Categorization Service
- Virtual Try-On Service

B. External AI Services
- Background Removal API (Birefnet)
- GPT-4 API (for categorization)
- Kolors by Kwai API (for virtual try-on)

**┌─────────────────────────────────────────────┐**
- UI Layer                    │
- ┌─────────┐  ┌─────────┐  ┌────────────┐  │
- Screens │  │  Views  │  │ Components │  │
- ┘  └─────────┘  └────────────┘  │
- ┤
- State Management Layer            │
- ┌─────────────────────────────────────────┐│
- React Context Providers          ││
- ┘│
- ┤
- Services Layer                 │
- ┌─────────┐  ┌─────────┐  ┌────────────┐  │
- BG     │  │Category │  │  Virtual   │  │
- Removal  │  │  API    │  │  Try-On    │  │
- ┘  └─────────┘  └────────────┘  │
- ┤
- Data Layer                    │
- ┌─────────────┐      ┌──────────────────┐ │
- AsyncStorage │      │ File System      │ │
- ┘      └──────────────────┘ │
- ┘

##### Important Relationships

- Data flow between screens and context providers
- Service integration with external APIs
- Storage mechanisms for different types of data
- Future cloud integration points

- AWS API Gateway
- Lambda Functions
- DynamoDB
- S3 Storage

##### Additional Details

- Annotations for key features like drag-and-drop in outfit canvas
- Cost-related information for AI services
- Rate limiting points for future implementation
- Where user credits will be checked in the future architecture

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        Screens["Screens"]
        click Screens "https://github.com/zebangeth/ai-closet/tree/main/src/screens"
        
        ClothingScreen["Clothing Management Screen"]
        click ClothingScreen "https://github.com/zebangeth/ai-closet/blob/main/src/screens/ClothingManagementScreen.tsx"
        
        OutfitScreen["Outfit Management Screen"]
        click OutfitScreen "https://github.com/zebangeth/ai-closet/blob/main/src/screens/OutfitManagementScreen.tsx"
        
        TryOnScreen["Virtual Try-On Screen"]
        click TryOnScreen "https://github.com/zebangeth/ai-closet/blob/main/src/screens/VirtualTryOnScreen.tsx"
        
        CanvasScreen["Outfit Canvas Screen"]
        click CanvasScreen "https://github.com/zebangeth/ai-closet/blob/main/src/screens/OutfitCanvasScreen.tsx"
        
        Components["Components"]
        ClothingComp["Clothing Components"]
        click ClothingComp "https://github.com/zebangeth/ai-closet/tree/main/src/components/clothing"
        
        OutfitComp["Outfit Components"]
        click OutfitComp "https://github.com/zebangeth/ai-closet/tree/main/src/components/outfit"
        
        TryOnComp["Virtual Try-On Components"]
        click TryOnComp "https://github.com/zebangeth/ai-closet/tree/main/src/components/virtualTryOn"
        
        CommonComp["Common Components"]
        click CommonComp "https://github.com/zebangeth/ai-closet/tree/main/src/components/common"
        
        Navigation["Navigation"]
        click Navigation "https://github.com/zebangeth/ai-closet/blob/main/src/navigation/index.tsx"
        
        Styles["Global Styles"]
        click Styles "https://github.com/zebangeth/ai-closet/blob/main/src/styles/globalStyles.ts"
    end

    subgraph StateManagement
        ClothingContext["Clothing Context"]
        click ClothingContext "https://github.com/zebangeth/ai-closet/blob/main/src/contexts/ClothingContext.tsx"
        
        OutfitContext["Outfit Context"]
        click OutfitContext "https://github.com/zebangeth/ai-closet/blob/main/src/contexts/OutfitContext.tsx"
        
        TryOnContext["Virtual Try-On Context"]
        click TryOnContext "https://github.com/zebangeth/ai-closet/blob/main/src/contexts/VirtualTryOnContext.tsx"
    end

    subgraph Services
        BGRemoval["Background Removal Service"]
        click BGRemoval "https://github.com/zebangeth/ai-closet/blob/main/src/services/BackgroundRemoval.ts"
        
        CategoryService["Clothing Categorization Service"]
        click CategoryService "https://github.com/zebangeth/ai-closet/blob/main/src/services/ClothingCategorization.ts"
        
        TryOnService["Virtual Try-On Service"]
        click TryOnService "https://github.com/zebangeth/ai-closet/blob/main/src/services/VirtualTryOn.ts"
    end

    subgraph DataLayer
        AsyncStorage["AsyncStorage"]
        click AsyncStorage "https://github.com/zebangeth/ai-closet/blob/main/src/utils/AsyncStorage.ts"
        
        ImageUtils["Image Utilities"]
        click ImageUtils "https://github.com/zebangeth/ai-closet/blob/main/src/utils/ImageUtils.ts"
        
        DataTypes["Data Types"]
        click DataTypes "https://github.com/zebangeth/ai-closet/tree/main/src/types"
        
        FileSystem["File System Storage"]
    end

    subgraph ExternalServices
        BirefnetAPI["Birefnet API"]
        GPT4API["GPT-4 API"]
        KolorsAPI["Kolors by Kwai API"]
    end

    %% Relationships
    Screens --> ClothingScreen & OutfitScreen & TryOnScreen & CanvasScreen
    Components --> ClothingComp & OutfitComp & TryOnComp & CommonComp
    
    ClothingScreen --> ClothingContext
    OutfitScreen --> OutfitContext
    TryOnScreen --> TryOnContext
    
    ClothingContext --> BGRemoval
    ClothingContext --> CategoryService
    TryOnContext --> TryOnService
    
    BGRemoval --> BirefnetAPI
    CategoryService --> GPT4API
    TryOnService --> KolorsAPI
    
    ClothingContext --> AsyncStorage
    OutfitContext --> AsyncStorage
    TryOnContext --> AsyncStorage
    
    AsyncStorage --> FileSystem
    ImageUtils --> FileSystem

    %% Styling
    classDef ui fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef state fill:#90EE90,stroke:#333,stroke-width:2px
    classDef service fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef data fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px

    class Screens,ClothingScreen,OutfitScreen,TryOnScreen,CanvasScreen,Components,ClothingComp,OutfitComp,TryOnComp,CommonComp,Navigation,Styles ui
    class ClothingContext,OutfitContext,TryOnContext state
    class BGRemoval,CategoryService,TryOnService service
    class AsyncStorage,ImageUtils,DataTypes,FileSystem data
    class BirefnetAPI,GPT4API,KolorsAPI external
```
