# uditsharma04/codeswipe architecture

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

- Interactive diagram: https://gitdiagram.com/uditsharma04/codeswipe
- Repository: https://github.com/uditsharma04/codeswipe

## Overview

##### Main Components

a) Client-Side (Frontend Layer):
- Auth components (Login, Register)
- Core features (SwipePage, MatchesPage, ChatRoom)
- Layout components
- Profile management
- Context API (AuthContext) as a cross-cutting concern
- Services layer that communicates with the backend

b) Server-Side (Backend Layer):
- Express.js server with main route handlers
- Controller layer showing the different controllers
- Model layer with MongoDB schemas
- Middleware (especially auth middleware)
- WebSocket handler (Socket.io)

c) External Services:
- MongoDB Database
- GitHub integration (noted from githubService.js)

##### Component Relationships

- REST API calls between frontend services and backend controllers
- WebSocket connections for real-time features (chat, notifications)
- Database interactions from the backend
- Authentication flow with JWT

##### Specific Implementation Details

Create distinct sections for:
a) Frontend Architecture:
**React App**
- Components Layer
- Context Layer (Auth State)
- Services Layer
- Pages Layer

b) Backend Architecture:
**Express Server**
- Routes Layer
- Controllers Layer
- Models Layer
- Middleware Layer

##### Key Flows to Highlight

a) Authentication Flow:
- Login/Register → AuthService → Backend Auth Controller → JWT → Database

b) Matching Flow:
- SwipePage → SwipeService → Backend Swipe Controller → Database

c) Real-time Communication:
- ChatRoom → Socket.io → Message Controller → Database

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        direction TB
        RC[React Client]
        
        subgraph Components
            direction TB
            Auth["Authentication Components"]:::frontend
            Chat["ChatRoom"]:::frontend
            Prof["Profile Components"]:::frontend
            Layout["Layout Components"]:::frontend
            Nav["Navigation"]:::frontend
        end

        subgraph Pages
            direction TB
            SP["SwipePage"]:::frontend
            MP["MatchesPage"]:::frontend
            PP["ProfilePage"]:::frontend
        end

        subgraph Services
            direction TB
            AS["Auth Service"]:::service
            PS["Profile Service"]:::service
            SS["Swipe Service"]:::service
            MS["Match Service"]:::service
            GS["GitHub Service"]:::service
            WS["WebSocket Service"]:::service
            API["API Service"]:::service
        end

        AC["Auth Context"]:::context
    end

    subgraph Backend
        direction TB
        ES["Express Server"]:::backend

        subgraph Controllers
            direction TB
            AuthC["Auth Controller"]:::controller
            SwipeC["Swipe Controller"]:::controller
            MatchC["Match Controller"]:::controller
            MsgC["Message Controller"]:::controller
            ProfC["Profile Controller"]:::controller
        end

        subgraph Middleware
            direction TB
            AuthM["Auth Middleware"]:::middleware
        end

        subgraph Models
            direction TB
            UM["User Model"]:::model
            MM["Message Model"]:::model
        end

        SIO["Socket.IO Handler"]:::websocket
        DB["Database Config"]:::config
    end

    subgraph External
        direction TB
        MongoDB[(MongoDB)]:::database
        GitHub["GitHub API"]:::external
    end

    %% Connections
    RC --> Components
    RC --> Pages
    RC --> Services
    RC --> AC

    Services --> ES
    ES --> Controllers
    Controllers --> Models
    Models --> MongoDB
    GS --> GitHub
    
    SIO <--> WS
    AuthM --> Controllers

    %% Click Events
    click Auth "https://github.com/UditSharma04/codeSwipe/tree/main/client/src/components/auth/"
    click Chat "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/components/chat/ChatRoom.js"
    click Layout "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/components/layout/Layout.js"
    click Nav "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/components/layout/Navbar.js"
    click SP "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/pages/SwipePage.js"
    click MP "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/pages/MatchesPage.js"
    click PP "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/pages/ProfilePage.js"
    click AS "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/authService.js"
    click PS "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/profileService.js"
    click SS "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/swipeService.js"
    click MS "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/matchService.js"
    click GS "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/githubService.js"
    click WS "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/socket.js"
    click API "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/services/apiService.js"
    click AC "https://github.com/UditSharma04/codeSwipe/blob/main/client/src/context/AuthContext.js"
    click AuthC "https://github.com/UditSharma04/codeSwipe/blob/main/server/controllers/authcontroller.js"
    click AuthM "https://github.com/UditSharma04/codeSwipe/blob/main/server/middleware/authMiddleware.js"
    click UM "https://github.com/UditSharma04/codeSwipe/blob/main/server/models/User.js"
    click MM "https://github.com/UditSharma04/codeSwipe/blob/main/server/models/Message.js"
    click DB "https://github.com/UditSharma04/codeSwipe/blob/main/server/config/db.js"
    click ES "https://github.com/UditSharma04/codeSwipe/blob/main/server/server.js"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef service fill:#4CAF50,color:white
    classDef context fill:#9C27B0,color:white
    classDef backend fill:#607D8B,color:white
    classDef controller fill:#00BCD4,color:white
    classDef middleware fill:#FF9800,color:white
    classDef model fill:#F44336,color:white
    classDef database fill:#795548,color:white
    classDef external fill:#9E9E9E,color:white
    classDef websocket fill:#E91E63,color:white
    classDef config fill:#795548,color:white
```
