# gay22222/ai-matching-webapp architecture

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

- Interactive diagram: https://gitdiagram.com/gay22222/ai-matching-webapp
- Repository: https://github.com/gay22222/ai-matching-webapp

## Overview

##### Project type and purpose
- This is a full-stack web application (“AI Matching Webapp”) consisting of:
- frontend/: a Next.js client
- matching-backend/: a Node.js (Express) API server with Prisma, AI embedding pipelines, WebSocket messaging
- Purpose: a matchmaking/chat app using AI embeddings (Weaviate) to recommend user matches, real-time chat, notifications, and profile management.

##### File structure
- Top-level: frontend/ + matching-backend/
- frontend/:
- Next.js App Router under src/app, organized by route (discover, matches, message/[matchId], notifications, profile, settings)
- Components/hooks/context/redux slices in src/…
- Configuration: Dockerfile, docker-compose.yml, ESLint, Tailwind, postcss, next.config
- Public assets and environment files
- matching-backend/:
- Express structure: src/routes → controllers → services → repository → Prisma client
- AI pipelines under src/ai (convert/generate user JSON, embedServer, embedding, pipeline, user_data storage)
- Weaviate integration in src/ai/weaviate
- WebSocket helpers in src/utils/socketHelpers and src/sockets
- File uploads persisted under uploads/
- Prisma schema and seed scripts under src/prisma
- Scheduler/cron jobs in src/utils/scheduler
- Configuration: Dockerfile, docker-compose.yml, nodemon, requirements.txt

##### README for additional insights
- Confirms Next.js in frontend, Express/Prisma in backend
- Mentions Docker support
- Breakdown of responsibilities: AI embeddings, notifications/socket.io, chat, matchmaking logic, user management

##### Elements
- Clear component labels (e.g., Next.js Client, Express API, Prisma DB, Weaviate)
- UI components (blue rectangles)
- API/Services (green)

##### Final recommendations
- Don’t forget the Prisma seed & migration step as part of the DB lifecycle
- Where environment variables and configs (Docker Compose) tie components together

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Web UI (Next.js)" 
        direction TB
        UI["Next.js Client"]:::ui
    end

    %% Backend Layer
    subgraph "API & Services (Express)" 
        direction TB
        API["Express API Server"]:::api
        subgraph "Routes & Controllers"
            direction TB
            AuthRoute["Auth Routes"]:::api
            UserRoute["User Routes"]:::api
            MatchRoute["Match Routes"]:::api
            MessageRoute["Message Routes"]:::api
            NotificationRoute["Notification Routes"]:::api
            MetadataRoute["Metadata Routes"]:::api
            ReportsRoute["Reports Routes"]:::api
            UploadRoute["Upload Controller"]:::api
        end
        subgraph "Business Logic (Services)"
            direction TB
            AuthService["Auth Service"]:::service
            UserService["User Service"]:::service
            MatchService["Match Service"]:::service
            MessageService["Message Service"]:::service
            NotificationService["Notification Service"]:::service
            MetadataService["Metadata Service"]:::service
            ReportsService["Reports Service"]:::service
            UploadUtil["Upload Util"]:::service
        end
        subgraph "Data Access (Repositories)"
            direction TB
            AuthRepo["Auth Middleware/Repo"]:::service
            UserRepo["User Repository"]:::service
            MatchRepo["Match Repository"]:::service
            MessageRepo["Message Repository"]:::service
            NotificationRepo["Notification Repository"]:::service
            MetadataRepo["Metadata Repository"]:::service
            ReportsRepo["Reports Repository"]:::service
        end
        API --> AuthRoute
        API --> UserRoute
        API --> MatchRoute
        API --> MessageRoute
        API --> NotificationRoute
        API --> MetadataRoute
        API --> ReportsRoute
        API --> UploadRoute

        AuthRoute --> AuthService
        UserRoute --> UserService
        MatchRoute --> MatchService
        MessageRoute --> MessageService
        NotificationRoute --> NotificationService
        MetadataRoute --> MetadataService
        ReportsRoute --> ReportsService
        UploadRoute --> UploadUtil

        AuthService --> AuthRepo
        UserService --> UserRepo
        MatchService --> MatchRepo
        MessageService --> MessageRepo
        NotificationService --> NotificationRepo
        MetadataService --> MetadataRepo
        ReportsService --> ReportsRepo
    end

    %% Database Layer
    DB[(Prisma DB)]:::db

    %% Prisma Client
    Prisma["Prisma Client"]:::db

    %% AI Embedding Pipeline
    subgraph "AI Embedding Pipeline" 
        direction TB
        Convert["Convert JSON to Text"]:::service
        EmbedLogic["Embed User Text"]:::service
        Pipeline["Process Embeddings"]:::service
        EmbedServer["Embed Server"]:::service
        subgraph "Weaviate Integration"
            direction TB
            StoreVec["Store User Vector"]:::external
            SearchVec["Search Similar Users"]:::external
        end
    end

    %% Real-time Layer
    subgraph "Real-time (Socket.IO)"
        direction TB
        SocketHelpers["Socket Helpers"]:::service
        Sockets["Sockets"]:::service
    end

    %% Scheduler
    subgraph "Scheduler/Cron Jobs"
        direction TB
        Scheduler["Cron Scheduler"]:::job
    end

    %% File Storage
    subgraph "File Storage"
        direction TB
        Uploads["uploads/"]:::storage
    end

    %% Interactions
    UI -->|"HTTP REST (JSON)"| API
    UI -->|"WebSocket"| Sockets

    API --> Prisma
    Prisma --> DB

    API --> Convert
    Convert --> EmbedLogic
    EmbedLogic --> Pipeline
    Pipeline --> StoreVec
    Pipeline --> SearchVec
    EmbedServer --> Pipeline

    Scheduler --> Pipeline

    UploadUtil --> Uploads
    Uploads --> FileStorage["Stored Files"]:::storage

    %% WebSocket Events
    Sockets --> MessageService
    Sockets --> NotificationService

    %% Click Events
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/app"
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/components"
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/hooks"
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/context"
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/lib"
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/redux"
    click UI "https://github.com/gay22222/ai-matching-webapp/tree/main/frontend/src/ui"

    click API "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/app.js"
    click API "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/server.js"
    click AuthRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/auth.routes.js"
    click UserRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/user.routes.js"
    click MatchRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/match.routes.js"
    click MessageRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/message.routes.js"
    click NotificationRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/notifications.routes.js"
    click MetadataRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/metadata.routes.js"
    click ReportsRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/routes/reports.routes.js"
    click UploadRoute "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/controllers/upload.controller.js"

    click AuthService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/auth.service.js"
    click UserService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/user.service.js"
    click MatchService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/match.service.js"
    click MessageService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/message.service.js"
    click NotificationService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/notification.service.js"
    click MetadataService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/metadata.service.js"
    click ReportsService "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/services/reports.service.js"
    click UploadUtil "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/utils/upload.js"

    click AuthRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/middleware/auth.middleware.js"
    click MatchRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/repository/match.repository.js"
    click MessageRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/repository/message.repository.js"
    click NotificationRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/repository/notification.repository.js"
    click UserRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/repository/user.repository.js"
    click MetadataRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/repository/metadata.repository.js"
    click ReportsRepo "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/repository/reports.repository.js"

    click Prisma "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/prisma/client.js"
    click DB "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/prisma/schema.prisma"
    click DB "https://github.com/gay22222/ai-matching-webapp/tree/main/matching-backend/src/prisma/seeds"

    click Convert "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/ai/data/convertUserJsonToText.js"
    click EmbedLogic "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/ai/embedding/embedUserText.js"
    click Pipeline "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/ai/pipeline/processUserEmbedding.js"
    click EmbedServer "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/ai/embedServer.js"
    click StoreVec "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/ai/weaviate/storeUserVector.js"
    click SearchVec "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/ai/weaviate/searchSimilarUsers.js"

    click SocketHelpers "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/utils/socketHelpers.js"
    click Sockets "https://github.com/gay22222/ai-matching-webapp/tree/main/matching-backend/src/sockets"

    click Scheduler "https://github.com/gay22222/ai-matching-webapp/blob/main/matching-backend/src/utils/scheduler.js"

    click Uploads "https://github.com/gay22222/ai-matching-webapp/tree/main/matching-backend/uploads"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0066CC,color:#000
    classDef api fill:#DFF7DF,stroke:#28A745,color:#000
    classDef service fill:#FFF3CD,stroke:#FFC107,color:#000
    classDef db fill:#E2E3E5,stroke:#6C757D,color:#000
    classDef external fill:#F8D7DA,stroke:#DC3545,color:#000
    classDef job fill:#ECE7F2,stroke:#5A2590,color:#000
    classDef storage fill:#FFEFEF,stroke:#EA5455,color:#000
```
