# abhishekprajapati1/talker architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekprajapati1/talker
- Repository: https://github.com/abhishekprajapati1/talker

## Overview

##### Project type and purpose
- This is a full-stack, real-time chat web application (“Talker”) built with Next.js on the client side and NestJS on the server side.
- Purpose: enable user registration/login, manage a contact book, and provide real-time messaging via WebSockets, backed by a SQLite database through Prisma ORM.

##### File structure
- Top-level folders:
- backend/ – NestJS project using modules (auth, user, chat, contact, token, utility), Prisma (schema + migrations), controllers, services, guards, gateway for socket.io
- client/ – Next.js 13 (“app” directory) with React components, TailwindCSS, Redux Toolkit store, TanStack Query, socket.io-client, and utility libs for API calls & hooks
- Config files:
- backend/nest-cli.json, tsconfig.json/build; package.json, pnpm lock
- client/next.config.mjs, tailwind.config.ts, postcss.config.js, tsconfig.json, package.json, pnpm lock
- Patterns & modules:
- NestJS uses the modular architecture (each feature folder under src/ is a module)
- Prisma for database access and migrations
- REST controllers + WebSocket gateway (chat.gateway.ts)
- Next.js “app” routes for protected vs. auth pages; shared UI components & libs

##### README for additional insights
- Tech Stack callouts:
- Client: NextJS, Redux Toolkit, TailwindCSS, MUI, TanStack Query, Axios, DayJS, socket.io-client
- Server: NestJS + ExpressAdapter, SQLite, PrismaORM, Swagger, socket.io
- Features outline confirms contact book, real-time messaging, JWT rotation, double-layer auth (REST + WS)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (NextJS)" 
        direction TB
        Pages["NextJS App Routes"]:::frontend
        Components["UI Components"]:::frontend
        Store["Redux Store"]:::frontend
        APIClient["Axios & TanStack Query"]:::frontend
        SocketClient["Socket.IO Client"]:::frontend
        UseSocket["useSocket Hook"]:::frontend
        subgraph "Auth Routes"
            direction TB
            AuthLayout["Auth Layout"]:::frontend
            LoginPage["Login Page"]:::frontend
            RegisterPage["Register Page"]:::frontend
        end
        subgraph "Protected Routes"
            direction TB
            ProtectedLayout["Protected Layout"]:::frontend
        end
        OAuthFB["FacebookAuthButton"]:::frontend
        OAuthG["GoogleAuthButton"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (NestJS)"
        direction TB
        subgraph "REST Modules"
            direction TB
            AuthModule["AuthController\nAuthService"]:::backend
            UserModule["UserController\nUserService"]:::backend
            ContactModule["ContactController\nContactService"]:::backend
            TokenModule["TokenService"]:::backend
            UtilityModule["UtilityService"]:::backend
        end
        subgraph "WebSocket Module"
            direction TB
            ChatModule["ChatGateway\nChatService"]:::backend
        end
        PrismaModule["PrismaService\nPrismaModule"]:::backend
    end

    %% Database
    DB["SQLite Database"]:::datastore

    %% Data Flows - REST
    Pages -->|"dispatch actions"| Store
    Store -->|"uses"| APIClient
    APIClient -->|"/auth, /user, /contact"| AuthModule
    APIClient -->|"/user"| UserModule
    APIClient -->|"/contact"| ContactModule
    AuthModule -->|"uses"| PrismaModule
    UserModule -->|"uses"| PrismaModule
    ContactModule -->|"uses"| PrismaModule

    %% Data Flows - WebSocket
    Pages -->|"opens WS"| SocketClient
    SocketClient -->|"useSocket()"| UseSocket
    UseSocket -->|"connect"| ChatModule
    ChatModule -->|"persist message"| PrismaModule
    ChatModule -->|"emit events"| SocketClient

    %% Database Connection
    PrismaModule -->|"read/write"| DB

    %% Click Events - Frontend
    click Pages "https://github.com/abhishekprajapati1/talker/tree/main/client/app"
    click Components "https://github.com/abhishekprajapati1/talker/tree/main/client/components"
    click Store "https://github.com/abhishekprajapati1/talker/tree/main/client/store"
    click APIClient "https://github.com/abhishekprajapati1/talker/blob/main/client/libs/api.ts"
    click SocketClient "https://github.com/abhishekprajapati1/talker/blob/main/client/libs/Socket.ts"
    click UseSocket "https://github.com/abhishekprajapati1/talker/blob/main/client/libs/hooks/useSocket.ts"
    click AuthLayout "https://github.com/abhishekprajapati1/talker/blob/main/client/app/(auth)/layout.tsx"
    click LoginPage "https://github.com/abhishekprajapati1/talker/blob/main/client/app/(auth)/login/page.tsx"
    click RegisterPage "https://github.com/abhishekprajapati1/talker/blob/main/client/app/(auth)/register/page.tsx"
    click ProtectedLayout "https://github.com/abhishekprajapati1/talker/blob/main/client/app/(protected)/layout.tsx"
    click OAuthFB "https://github.com/abhishekprajapati1/talker/blob/main/client/components/FacebookAuthButton.tsx"
    click OAuthG "https://github.com/abhishekprajapati1/talker/blob/main/client/components/GoogleAuthButton.tsx"

    %% Click Events - Backend
    click AuthModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/auth"
    click UserModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/user"
    click ContactModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/contact"
    click ChatModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/chat"
    click TokenModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/token"
    click UtilityModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/utility"
    click PrismaModule "https://github.com/abhishekprajapati1/talker/tree/main/backend/src/prisma"
    click DB "https://github.com/abhishekprajapati1/talker/blob/main/backend/prisma/dev.db"

    %% Styles
    classDef frontend fill:#B3D7F7,stroke:#0B5394,color:#073763
    classDef backend fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef datastore fill:#FDEBD0,stroke:#B9770E,color:#7E5109
```
