# ankit-gope007/vibechat architecture

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

- Interactive diagram: https://gitdiagram.com/ankit-gope007/vibechat
- Repository: https://github.com/ankit-gope007/vibechat

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack real-time one-to-one chat application (“Vibe Chat”) with a Next.js + Tailwind CSS frontend, a Node.js/Express + Socket.IO backend, and MongoDB for persistence.
- Key features: unique username, instant messaging via WebSockets, responsive UI.

##### File structure
- Top level:
- client/ – Next.js app (app directory, components, API routes, public assets, styles, config files)
- server/ – Express API (controllers, routes, models, middlewares, utils, db init)
- Frontend patterns: Next.js App Router (`src/app/*`), custom Provider, ProtectedRoute, global middleware for auth, Socket.IO client.
- Backend patterns: MVC-like separation (routes → controllers → models), error handling utils (`ApiError`, `asyncHandler`), middleware for auth & file upload, Socket.IO server logic likely in `app.js` or `index.js`.
- Config/build/deploy files: package.json in both, lint/build configs, deployment targets (Vercel for client, Render for server).

##### README for additional insights
- Tech stack confirms Next.js, Tailwind CSS, Node.js, Express, Socket.IO, MongoDB.
- Live demo hosts front and back separately.
- Mentions future media sharing and group chat, hinting at extensibility points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Next.js App)"
        direction TB
        GlobalLayout["layout.js"]:::frontend
        GlobalStyles["globals.css"]:::frontend
        ProtectedRoute["ProtectedRoute.js"]:::frontend
        Provider["Provider.js"]:::frontend
        Middleware["middleware.js"]:::frontend
        APIRoutes["apiRoutes.js"]:::frontend
        SocketClient["socket.js"]:::websocket
        Store["store/index.js"]:::frontend

        subgraph "Pages"
            direction TB
            ChatPage["chat/page.js"]:::frontend
            ProfilePage["profile/page.js"]:::frontend
            FeedbackPage["feedback/page.js"]:::frontend
            AboutPage["aboutme/page.js"]:::frontend
        end

        subgraph "Components & Utils"
            direction TB
            ChatComponents["chat/components"]:::frontend
            UIPrimitives["ui"]:::frontend
            UtilsLib["utils.js"]:::frontend
        end
    end

    %% Server Side
    subgraph "Server (Express + Socket.IO)"
        direction TB
        AppEntry["app.js / index.js"]:::backend
        DBInit["db/index.js"]:::backend

        subgraph "Routes"
            direction TB
            ProfileRoute["Profile.route.js"]:::backend
            ContactsRoute["Contacts.route.js"]:::backend
            RequestsRoute["Request.route.js"]:::backend
            MessagesRoute["Message.route.js"]:::backend
            ContactMeRoute["ContactMe.route.js"]:::backend
            FeedbackRoute["Feedback.route.js"]:::backend
        end

        subgraph "Controllers"
            direction TB
            ProfileCtrl["Profile.controller.js"]:::backend
            ContactsCtrl["Contacts.controller.js"]:::backend
            RequestCtrl["Request.controller.js"]:::backend
            MessageCtrl["Message.controller.js"]:::backend
            ContactMeCtrl["ContactMe.controller.js"]:::backend
            FeedbackCtrl["Feedback.controller.js"]:::backend
        end

        subgraph "Models"
            direction TB
            ProfileModel["Profile.model.js"]:::backend
            ContactModel["ContactMe.model.js"]:::backend
            ContactsModel["Contacts.model.js"]:::backend
            RequestModel["Request.model.js"]:::backend
            MessageModel["Message.model.js"]:::backend
            FeedbackModel["Feedback.model.js"]:::backend
        end

        subgraph "Middlewares & Utils"
            direction TB
            AuthMW["auth.middleware.js"]:::backend
            MulterMW["multer.middleware.js"]:::backend
            ApiError["ApiError.js"]:::backend
            ApiResponse["ApiResponse.js"]:::backend
            AsyncHandler["asyncHandler.js"]:::backend
            Cloudinary["cloudinary.js"]:::backend
        end
    end

    %% External Services
    DB["MongoDB Atlas"]:::db
    CloudinaryExt["Cloudinary (future)"]:::db

    %% Data Flows
    GlobalLayout --> APIRoutes
    APIRoutes -->|REST| ProfileRoute
    APIRoutes -->|REST| ContactsRoute
    APIRoutes -->|REST| RequestsRoute
    APIRoutes -->|REST| MessagesRoute
    APIRoutes -->|REST| ContactMeRoute
    APIRoutes -->|REST| FeedbackRoute

    ProfileRoute --> ProfileCtrl --> ProfileModel --> DB
    ContactsRoute --> ContactsCtrl --> ContactsModel --> DB
    RequestsRoute --> RequestCtrl --> RequestModel --> DB
    MessagesRoute --> MessageCtrl --> MessageModel --> DB
    ContactMeRoute --> ContactMeCtrl --> ContactModel --> DB
    FeedbackRoute --> FeedbackCtrl --> FeedbackModel --> DB

    Middleware --> ProfileRoute
    AuthMW --> ProfileRoute
    MulterMW --> FeedbackRoute

    AppEntry --> DBInit --> DB
    AppEntry --> MessageCtrl
    SocketClient -->|WebSocket| AppEntry
    AppEntry -->|init WebSocket| SocketClient
    AppEntry -->|uses| AuthMW

    %% Click Events
    click GlobalLayout "https://github.com/ankit-gope007/vibechat/blob/main/client/src/app/layout.js"
    click GlobalStyles "https://github.com/ankit-gope007/vibechat/blob/main/client/src/app/globals.css"
    click ProtectedRoute "https://github.com/ankit-gope007/vibechat/blob/main/client/src/component/ProtectedRoute.js"
    click Provider "https://github.com/ankit-gope007/vibechat/blob/main/client/src/component/Provider.js"
    click Middleware "https://github.com/ankit-gope007/vibechat/blob/main/client/src/middleware.js"
    click APIRoutes "https://github.com/ankit-gope007/vibechat/blob/main/client/src/apiRoutes.js"
    click SocketClient "https://github.com/ankit-gope007/vibechat/blob/main/client/src/socket.js"
    click Store "https://github.com/ankit-gope007/vibechat/blob/main/client/src/store/index.js"
    click ChatPage "https://github.com/ankit-gope007/vibechat/blob/main/client/src/app/chat/page.js"
    click ProfilePage "https://github.com/ankit-gope007/vibechat/blob/main/client/src/app/profile/page.js"
    click FeedbackPage "https://github.com/ankit-gope007/vibechat/blob/main/client/src/app/feedback/page.js"
    click AboutPage "https://github.com/ankit-gope007/vibechat/blob/main/client/src/app/aboutme/page.js"
    click ChatComponents "https://github.com/ankit-gope007/vibechat/tree/main/client/src/app/chat/components"
    click UIPrimitives "https://github.com/ankit-gope007/vibechat/tree/main/client/src/components/ui"
    click UtilsLib "https://github.com/ankit-gope007/vibechat/blob/main/client/src/lib/utils.js"
    click AppEntry "https://github.com/ankit-gope007/vibechat/blob/main/server/src/app.js"
    click DBInit "https://github.com/ankit-gope007/vibechat/blob/main/server/src/db/index.js"
    click ProfileRoute "https://github.com/ankit-gope007/vibechat/blob/main/server/src/routes/Profile.route.js"
    click ContactsRoute "https://github.com/ankit-gope007/vibechat/blob/main/server/src/routes/Contacts.route.js"
    click RequestsRoute "https://github.com/ankit-gope007/vibechat/blob/main/server/src/routes/Request.route.js"
    click MessagesRoute "https://github.com/ankit-gope007/vibechat/blob/main/server/src/routes/Message.route.js"
    click ContactMeRoute "https://github.com/ankit-gope007/vibechat/blob/main/server/src/routes/ContactMe.route.js"
    click FeedbackRoute "https://github.com/ankit-gope007/vibechat/blob/main/server/src/routes/Feedback.route.js"
    click ProfileCtrl "https://github.com/ankit-gope007/vibechat/blob/main/server/src/controllers/Profile.controller.js"
    click ContactsCtrl "https://github.com/ankit-gope007/vibechat/blob/main/server/src/controllers/Contacts.controller.js"
    click RequestCtrl "https://github.com/ankit-gope007/vibechat/blob/main/server/src/controllers/Request.controller.js"
    click MessageCtrl "https://github.com/ankit-gope007/vibechat/blob/main/server/src/controllers/Message.controller.js"
    click ContactMeCtrl "https://github.com/ankit-gope007/vibechat/blob/main/server/src/controllers/ContactMe.controller.js"
    click FeedbackCtrl "https://github.com/ankit-gope007/vibechat/blob/main/server/src/controllers/Feedback.controller.js"
    click ProfileModel "https://github.com/ankit-gope007/vibechat/blob/main/server/src/models/Profile.model.js"
    click ContactModel "https://github.com/ankit-gope007/vibechat/blob/main/server/src/models/ContactMe.model.js"
    click ContactsModel "https://github.com/ankit-gope007/vibechat/blob/main/server/src/models/Contacts.model.js"
    click RequestModel "https://github.com/ankit-gope007/vibechat/blob/main/server/src/models/Request.model.js"
    click MessageModel "https://github.com/ankit-gope007/vibechat/blob/main/server/src/models/Message.model.js"
    click FeedbackModel "https://github.com/ankit-gope007/vibechat/blob/main/server/src/models/Feedback.model.js"
    click AuthMW "https://github.com/ankit-gope007/vibechat/blob/main/server/src/middlewares/auth.middleware.js"
    click MulterMW "https://github.com/ankit-gope007/vibechat/blob/main/server/src/middlewares/multer.middleware.js"
    click ApiError "https://github.com/ankit-gope007/vibechat/blob/main/server/src/utils/ApiError.js"
    click ApiResponse "https://github.com/ankit-gope007/vibechat/blob/main/server/src/utils/ApiResponse.js"
    click AsyncHandler "https://github.com/ankit-gope007/vibechat/blob/main/server/src/utils/asyncHandler.js"
    click Cloudinary "https://github.com/ankit-gope007/vibechat/blob/main/server/src/utils/cloudinary.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#007bff,color:#004085
    classDef backend fill:#d4edda,stroke:#28a745,color:#155724
    classDef websocket fill:#fff3cd,stroke:#ffc107,color:#856404
    classDef db fill:#e2e3e5,stroke:#6c757d,color:#383d41
```
