# pavankumarmurugan/cmpu9010-team-project-group-1 architecture

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

- Interactive diagram: https://gitdiagram.com/pavankumarmurugan/cmpu9010-team-project-group-1
- Repository: https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1

## Overview

##### Main System Components

A. Frontend Layer (React.js):
- User Interface Components (/smartwardrobe-frontend/src/Components)
- State Management (Redux store)
- Asset Management
- Routing and Navigation

B. Backend Layer (Nest.js):
- API Gateway
- Authentication Service
- Core Business Logic
- Data Access Layer
- WebSocket Service (for real-time features)

C. AI/ML Services:
- Image Search Service (CLIP model)
- Natural Language Processing
- Recommendation Engine
- Virtual Try-On Service

D. Data Storage:
- PostgreSQL with pgvector
- Redis Cache
- AWS S3 (for media storage)

**[Client Layer]**
- ↓↑
**[API Gateway / Load Balancer]**
- ↓↑
**[Application Services Layer]**
- ↓↑
**[AI/ML Services Layer]**
- ↓↑
**[Data Layer]**

##### Key Interactions to Highlight

A. Authentication Flow:
- JWT-based authentication
- Refresh token mechanism
- Password reset flow

B. Product Search Flows:
- Text-based search with NLP
- Image-based search with CLIP
- Hybrid search capabilities

C. Real-time Features:
- WebSocket connections for chat
- Notification system
- Friend request handling

D. AI Processing Pipeline:
- Image vector embedding
- Text embedding
- Recommendation processing
- Virtual try-on processing

##### Important Architectural Patterns

- Clean Architecture (as evidenced by the backend structure)
- Repository Pattern
- CQRS Pattern (for search operations)
- Event-Driven Architecture (for real-time features)

##### External Services Integration
- AWS Services
- SendGrid for emails
- Firebase services
- Content Delivery Network

##### Specific Implementation Details

A. Search Services:
**[User Query] → [Query Processor] → [Vector Embedding] → [FAISS Index] → [Results Ranking] → [Response]**

B. Chat System:
**[WebSocket Gateway] → [Chat Service] → [Message Queue] → [Persistence Layer]**

C. Recommendation Engine:
**[User Behavior] → [Feature Extraction] → [ML Model] → [Ranking System] → [Recommendations]**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef data fill:#e67e22,stroke:#d35400,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Client Layer
    subgraph ClientLayer
        UI["UI Components"]:::frontend
        StateManagement["Redux Store"]:::frontend
        Assets["Assets"]:::frontend
    end

    %% API Gateway Layer
    APIGateway["API Gateway"]:::infra

    %% Application Services Layer
    subgraph AppServices
        AuthService["Authentication Service"]:::backend
        CoreLogic["Core Business Logic"]:::backend
        WebSocket["WebSocket Service"]:::backend
        DataAccess["Data Access Layer"]:::backend
        UserMgmt["User Management"]:::backend
        ProductMgmt["Product Management"]:::backend
        ChatSystem["Chat System"]:::backend
    end

    %% AI/ML Services Layer
    subgraph AIServices
        ImageSearch["Image Search (CLIP)"]:::ai
        NLPService["NLP Service"]:::ai
        RecEngine["Recommendation Engine"]:::ai
        VirtualTryOn["Virtual Try-On"]:::ai
    end

    %% Data Layer
    subgraph DataLayer
        PostgreSQL[(PostgreSQL/pgvector)]:::data
        Redis[(Redis Cache)]:::data
        S3[(AWS S3)]:::data
    end

    %% Connections
    ClientLayer --> APIGateway
    APIGateway --> AppServices
    AppServices --> AIServices
    AppServices --> DataLayer
    AIServices --> DataLayer

    %% Click Events
    click UI "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-frontend/src/Components/"
    click StateManagement "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-frontend/src/redux/"
    click Assets "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-frontend/src/Assets/"
    click CoreLogic "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/core/"
    click AuthService "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/infrastructure/frameworks/passport/"
    click WebSocket "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/infrastructure/services/web-sockets/"
    click DataAccess "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/infrastructure/frameworks/data-services/"
    click ImageSearch "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-AI/pgvector-image-search/"
    click NLPService "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-AI/NLP-text-search/"
    click VirtualTryOn "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-AI/Vitual-try-on/"
    click RecEngine "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/use-cases/recommendation/"
    click ChatSystem "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/infrastructure/controllers/chat/"
    click UserMgmt "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/use-cases/user/"
    click ProductMgmt "https://github.com/pavankumarmurugan/cmpu9010-team-project-group-1/tree/develop/smartwardrobe-backend/src/use-cases/product/"

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        AI["AI/ML Service"]:::ai
        DataStore["Data Storage"]:::data
        Infrastructure["Infrastructure"]:::infra
    end
```
