# yashksaini-coder/pair-pal architecture

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

- Interactive diagram: https://gitdiagram.com/yashksaini-coder/pair-pal
- Repository: https://github.com/yashksaini-coder/pair-pal

## Overview

##### Project type and purpose
- This is a full-stack web application built on Next.js (React), designed as a matchmaking/chat system.
- It supports user authentication via NextAuth (GitHub OAuth), user profiles, swipe-style matching, messaging, and profile syncing with GitHub.

##### File structure
- src/app – UI routes and pages (React components rendered server/client).
– app/api – Next.js API route handlers grouped by feature: auth, github, matches, messages, profiles, swipe.
– app/auth, app/chat, app/matches, app/swipe, app/profile – pages and layouts for each feature.
- src/components – shared React components and UI primitives (Tailwind, custom UI kit).
- src/lib – core business logic and integrations:
– db.ts – database connection/ORM (Prisma? or similar)
– github.ts – GitHub API wrappers
– matching.ts – match-making algorithm
– utils.ts, extractUrls.ts – helpers
- src/models – TypeScript models/entities for User, Match, Message, Swipe.
- src/hooks – client hooks (useMobile).
- Configuration: next.config.ts, postcss.config.mjs, pnpm-workspace.yaml, tsconfig.json.

##### README for additional insights
- Standard Next.js boilerplate, uses next/font, deploys to Vercel.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Layer
    subgraph "Browser (Client)"
        direction TB
        Home["Home Page"]:::frontend
        SwipeUI["Swipe UI"]:::frontend
        MatchesList["Matches List"]:::frontend
        ChatUI["Chat UI"]:::frontend
        ProfilePage["Profile Page"]:::frontend
        SignIn["Sign-in Page"]:::frontend
        AuthError["Auth Error Page"]:::frontend
        SessionProvider["Session Provider"]:::frontend
        ThemeProvider["Theme Provider"]:::frontend
        ThemeToggle["Theme Toggle"]:::frontend
        Navigation["Navigation"]:::frontend
        Footer["Footer"]:::frontend
        SwipeCard["Swipe Card"]:::frontend
        MatchCard["Match Card"]:::frontend
        MatchNotification["Match Notification"]:::frontend
        LinkPreview["Link Preview"]:::frontend
        AuthButtons["Auth Buttons"]:::frontend
        HeroSection["Hero Section"]:::frontend
        LanguageBadge["Language Badge"]:::frontend
        UIPrimitives["UI Primitives Library"]:::frontend
        UseMobile["useMobile Hook"]:::frontend
    end

    %% Server Layer
    subgraph "Server"
        direction TB

        subgraph "Web Framework (Next.js App Router)"
            direction TB
            AppRouter["Next.js App Router"]:::framework
        end

        subgraph "API Layer"
            direction TB
            AuthAPI["NextAuth Route"]:::api
            GitHubProfileAPI["GitHub Fetch Profile"]:::api
            GitHubSyncAPI["GitHub Sync Profile"]:::api
            MatchesAPI["Matches API"]:::api
            SwipeAPI["Swipe API"]:::api
            MessagesAPI["Messages API"]:::api
            ProfilesAPI["Profiles API"]:::api
        end

        subgraph "Business Logic (src/lib)"
            direction TB
            DBConn["Database Connection"]:::biz
            GitHubWrapper["GitHub API Wrapper"]:::biz
            MatchingAlgo["Matching Algorithm"]:::biz
            URLExtractor["URL Extraction Utility"]:::biz
            Utils["General Helpers"]:::biz
        end

        subgraph "Data Models (src/models)"
            direction TB
            UserModel["User Model"]:::model
            MatchModel["Match Model"]:::model
            SwipeModel["Swipe Model"]:::model
            MessageModel["Message Model"]:::model
        end

        Database["Database"]:::db
        ExternalAuth["External OAuth (GitHub)"]:::external
    end

    %% Connections
    Home -->|renders| AppRouter
    SwipeUI -->|renders| AppRouter
    MatchesList -->|renders| AppRouter
    ChatUI -->|renders| AppRouter
    ProfilePage -->|renders| AppRouter
    SignIn -->|renders| AppRouter
    AuthError -->|renders| AppRouter

    Home -->|fetch| ProfilesAPI
    SwipeUI -->|fetch| SwipeAPI
    MatchesList -->|fetch| MatchesAPI
    ChatUI -->|fetch| MessagesAPI
    ProfilePage -->|fetch| ProfilesAPI
    SignIn -->|auth| AuthAPI

    AppRouter --> AuthAPI
    AppRouter --> GitHubProfileAPI
    AppRouter --> GitHubSyncAPI
    AuthAPI -->|validate session| DBConn
    AuthAPI -->|calls| ExternalAuth
    GitHubProfileAPI -->|reads/writes| DBConn
    GitHubProfileAPI -->|calls| ExternalAuth
    GitHubSyncAPI -->|calls| GitHubWrapper
    GitHubSyncAPI -->|reads/writes| DBConn

    SwipeAPI -->|uses| DBConn
    SwipeAPI -->|uses| MatchingAlgo
    MatchesAPI -->|queries| DBConn
    MessagesAPI -->|queries| DBConn
    ProfilesAPI -->|queries| DBConn

    DBConn --> Database

    MatchingAlgo -->|reads| UserModel
    MatchingAlgo -->|reads/writes| MatchModel
    URLExtractor -->|util| Utils

    %% Click Events - Client
    click Home "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/page.tsx"
    click SwipeUI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/swipe/page.tsx"
    click MatchesList "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/matches/page.tsx"
    click ChatUI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/chat/[matchId]/page.tsx"
    click ProfilePage "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/profile/page.tsx"
    click SignIn "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/auth/signin/page.tsx"
    click AuthError "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/auth/error/page.tsx"
    click SessionProvider "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/session-provider.tsx"
    click ThemeProvider "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/theme-provider.tsx"
    click ThemeToggle "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/theme-toggle.tsx"
    click Navigation "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/navigation.tsx"
    click Footer "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/footer-section.tsx"
    click SwipeCard "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/swipe-card.tsx"
    click MatchCard "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/match-card.tsx"
    click MatchNotification "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/match-notification.tsx"
    click LinkPreview "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/link-preview.tsx"
    click AuthButtons "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/auth-buttons.tsx"
    click HeroSection "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/hero-section-1.tsx"
    click LanguageBadge "https://github.com/yashksaini-coder/pair-pal/blob/master/src/components/language-badge.tsx"
    click UIPrimitives "https://github.com/yashksaini-coder/pair-pal/tree/master/src/components/ui"
    click UseMobile "https://github.com/yashksaini-coder/pair-pal/blob/master/src/hooks/use-mobile.ts"

    %% Click Events - Server
    click AppRouter "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/layout.tsx"
    click AuthAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/auth/[...nextauth]/route.ts"
    click GitHubProfileAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/github/profile/route.ts"
    click GitHubSyncAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/github/sync/route.ts"
    click MatchesAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/matches/route.ts"
    click SwipeAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/swipe/route.ts"
    click MessagesAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/messages/route.ts"
    click ProfilesAPI "https://github.com/yashksaini-coder/pair-pal/blob/master/src/app/api/profiles/route.ts"
    click DBConn "https://github.com/yashksaini-coder/pair-pal/blob/master/src/lib/db.ts"
    click GitHubWrapper "https://github.com/yashksaini-coder/pair-pal/blob/master/src/lib/github.ts"
    click MatchingAlgo "https://github.com/yashksaini-coder/pair-pal/blob/master/src/lib/matching.ts"
    click URLExtractor "https://github.com/yashksaini-coder/pair-pal/blob/master/src/lib/extractUrls.ts"
    click Utils "https://github.com/yashksaini-coder/pair-pal/blob/master/src/lib/utils.ts"
    click UserModel "https://github.com/yashksaini-coder/pair-pal/blob/master/src/models/User.ts"
    click MatchModel "https://github.com/yashksaini-coder/pair-pal/blob/master/src/models/Match.ts"
    click SwipeModel "https://github.com/yashksaini-coder/pair-pal/blob/master/src/models/Swipe.ts"
    click MessageModel "https://github.com/yashksaini-coder/pair-pal/blob/master/src/models/Message.ts"

    %% Styles
    classDef frontend fill:#DCEEFB,stroke:#0366D6,color:#0366D6
    classDef framework fill:#E0F2F1,stroke:#00695C,color:#00695C
    classDef api fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef biz fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef model fill:#FFFDE7,stroke:#F9A825,color:#F9A825
    classDef db fill:#ECEFF1,stroke:#37474F,color:#37474F,shape:cylinder
    classDef external fill:#FCE4EC,stroke:#C2185B,color:#C2185B
```
