# burakorkmez/fullstack-chat-app architecture

> Architecture diagram of the GitHub repository burakorkmez/fullstack-chat-app, 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/burakorkmez/fullstack-chat-app
- Repository: https://github.com/burakorkmez/fullstack-chat-app

## Overview

##### Project type and purpose
- This is a full-stack, real-time chat application built with the MERN stack (MongoDB, Express, React, Node) plus Socket.io for WebSocket messaging, JWT for auth, Cloudinary for media uploads, TailwindCSS/DaisyUI for styling, and Zustand for client-side state.

##### File structure
- Top-level directories:
- backend/ – Node/Express server
- frontend/ – React single-page app
- backend/src organizes MVC: controllers, models, routes, middleware, lib (db connection, Cloudinary, Socket.io helper, utils), seeds.
- frontend/src splits into components, pages, constants, lib (axios, utils), store (Zustand hooks), styling config (Tailwind, Vite).

##### README for additional insights
- Real-time messaging via Socket.io
- JWT-based authentication/authorization
- MongoDB as the primary data store
- Cloudinary for image uploads
- Deployment instructions (build, start)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend"
        direction TB
        Client["Client (React SPA)"]:::frontend
        subgraph "HTTP Integration"
            direction TB
            Axios["Axios (HTTP Client)"]:::frontend
            UtilsC["Client Utilities"]:::frontend
        end
        subgraph "State Management"
            direction TB
            useAuth["useAuthStore.js"]:::frontend
            useChat["useChatStore.js"]:::frontend
            useTheme["useThemeStore.js"]:::frontend
        end
        SocketClient["Socket.io Client"]:::frontend
    end

    subgraph "Backend"
        direction TB
        Server["API Server (Express)"]:::backend
        subgraph "HTTP Routes"
            direction TB
            AuthRoute["auth.route.js"]:::backend
            MsgRoute["message.route.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthCtrl["auth.controller.js"]:::backend
            MsgCtrl["message.controller.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["user.model.js"]:::backend
            MsgModel["message.model.js"]:::backend
        end
        AuthMw["auth.middleware.js"]:::backend
        subgraph "Lib"
            direction TB
            DBConn["db.js"]:::backend
            SocketSrv["socket.js"]:::backend
            CloudLib["cloudinary.js"]:::backend
            UtilsB["utils.js"]:::backend
        end
    end

    MongoDB[(MongoDB)]:::database
    CloudinaryExt["Cloudinary"]:::external

    Client -->|HTTP Requests| Axios
    Axios -->|calls| AuthRoute
    Axios -->|calls| MsgRoute
    Client -->|WebSocket| SocketClient
    SocketClient -.->|connect| SocketSrv
    Server --> AuthRoute
    Server --> MsgRoute
    AuthRoute -->|handles| AuthCtrl
    MsgRoute -->|handles| MsgCtrl
    AuthCtrl -->|uses| UserModel
    MsgCtrl -->|uses| MsgModel
    AuthRoute -->|uses| AuthMw
    UserModel -->|CRUD| MongoDB
    MsgModel -->|CRUD| MongoDB
    DBConn -->|connects| MongoDB
    SocketSrv -->|emits/events| MsgCtrl
    AuthCtrl -->|issues JWT| Client
    CloudLib -->|uploads| CloudinaryExt

    click Client "https://github.com/burakorkmez/fullstack-chat-app/tree/master/frontend/src"
    click Axios "https://github.com/burakorkmez/fullstack-chat-app/blob/master/frontend/src/lib/axios.js"
    click UtilsC "https://github.com/burakorkmez/fullstack-chat-app/blob/master/frontend/src/lib/utils.js"
    click useAuth "https://github.com/burakorkmez/fullstack-chat-app/blob/master/frontend/src/store/useAuthStore.js"
    click useChat "https://github.com/burakorkmez/fullstack-chat-app/blob/master/frontend/src/store/useChatStore.js"
    click useTheme "https://github.com/burakorkmez/fullstack-chat-app/blob/master/frontend/src/store/useThemeStore.js"
    click SocketClient "https://github.com/burakorkmez/fullstack-chat-app/blob/master/frontend/src/main.jsx"
    click AuthRoute "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/routes/auth.route.js"
    click MsgRoute "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/routes/message.route.js"
    click AuthCtrl "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/controllers/auth.controller.js"
    click MsgCtrl "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/controllers/message.controller.js"
    click UserModel "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/models/user.model.js"
    click MsgModel "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/models/message.model.js"
    click AuthMw "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/middleware/auth.middleware.js"
    click DBConn "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/lib/db.js"
    click SocketSrv "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/lib/socket.js"
    click CloudLib "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/lib/cloudinary.js"
    click UtilsB "https://github.com/burakorkmez/fullstack-chat-app/blob/master/backend/src/lib/utils.js"

    classDef frontend fill:#E0F7FA,stroke:#0277BD,color:#000
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#000
    classDef database fill:#FFF3E0,stroke:#EF6C00,color:#000
    classDef external fill:#ECEFF1,stroke:#546E7A,color:#000
```
