# zmusaddique/scalable-chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/zmusaddique/scalable-chat-app
- Repository: https://github.com/zmusaddique/scalable-chat-app

## Overview

##### Project type and purpose
- This is a Turborepo-based monorepo containing multiple applications and shared packages.
- It includes two Next.js frontends (“web” and “docs”), a Node-based server (“apps/server”), and three shared packages (UI library, ESLint config, TypeScript config).
- The primary goal is to demonstrate how to develop, build, and cache multiple TypeScript projects together with shared code and configuration.

##### File structure
- Top-level directories:
- apps/
– docs/ (Next.js documentation site)
– web/ (Next.js primary web app)
– server/ (Node service exposing WebSocket)
- packages/
– ui/ (shared React component library)
– eslint-config/ (shared ESLint rules)
– typescript-config/ (shared tsconfig presets)
- turbo.json (build orchestration)
- package.json, .npmrc (root configuration)
- Each Next.js app has its own app directory, public assets, layout/page components, and context (web uses SocketProvider).
- apps/server contains a simple TypeScript entry point and a socket service.
- No database layer is present—real-time communication happens via WebSocket.

##### README for additional insights
- Confirms use of Next.js, React, TypeScript, ESLint, Prettier, Turborepo.
- Describes monorepo tasks: dev, build, remote caching via Vercel.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Root
    subgraph "Monorepo Root"
        TR["turbo.json"]:::infra
        RP["package.json"]:::infra
        NR[".npmrc"]:::infra
    end

    %% Shared Packages
    subgraph "Shared Packages"
        UI["@repo/ui"]:::packages
        ESLINT["@repo/eslint-config"]:::packages
        TSCONF["@repo/typescript-config"]:::packages
    end

    %% Applications
    subgraph "Applications"
        WEB["web (Next.js)"]:::apps
        DOCS["docs (Next.js)"]:::apps
        SERVER["server (Node WebSocket)"]:::apps
    end

    %% External Services
    VERCEL["Vercel Remote Cache"]:::external
    DEV["Developers / CI"]:::external

    %% Orchestration Node
    TURBO["Turborepo (task runner)"]:::infra

    %% Connections: Orchestration
    TURBO -->|runs dev/build/lint/type-check| TR
    TURBO -->|manages workspaces| RP
    TURBO -->|manages workspaces| NR
    TURBO -->|orchestrates| UI
    TURBO -->|orchestrates| ESLINT
    TURBO -->|orchestrates| TSCONF
    TURBO -->|orchestrates| WEB
    TURBO -->|orchestrates| DOCS
    TURBO -->|orchestrates| SERVER
    TURBO -->|caches builds| VERCEL

    %% Dependencies between workspaces
    WEB -->|imports UI components| UI
    WEB -->|inherits ESLint rules| ESLINT
    WEB -->|inherits TS configs| TSCONF
    DOCS -->|imports UI components| UI
    DOCS -->|inherits ESLint rules| ESLINT
    DOCS -->|inherits TS configs| TSCONF
    SERVER -->|inherits ESLint rules| ESLINT
    SERVER -->|inherits TS configs| TSCONF

    %% Runtime connection
    WEB -->|WebSocket| SERVER

    %% Developer Trigger
    DEV -->|runs turbo commands| TURBO

    %% Click Events
    click TR "https://github.com/zmusaddique/scalable-chat-app/blob/main/turbo.json"
    click RP "https://github.com/zmusaddique/scalable-chat-app/blob/main/package.json"
    click NR "https://github.com/zmusaddique/scalable-chat-app/blob/main/.npmrc"
    click UI "https://github.com/zmusaddique/scalable-chat-app/tree/main/packages/ui/"
    click ESLINT "https://github.com/zmusaddique/scalable-chat-app/tree/main/packages/eslint-config/"
    click TSCONF "https://github.com/zmusaddique/scalable-chat-app/tree/main/packages/typescript-config/"
    click WEB "https://github.com/zmusaddique/scalable-chat-app/tree/main/apps/web/"
    click DOCS "https://github.com/zmusaddique/scalable-chat-app/tree/main/apps/docs/"
    click SERVER "https://github.com/zmusaddique/scalable-chat-app/tree/main/apps/server/"

    %% Styles
    classDef apps fill:#D0E8FF,stroke:#005BBB,stroke-width:1px
    classDef packages fill:#E0F8E0,stroke:#2E8B57,stroke-width:1px
    classDef infra fill:#FFE8B0,stroke:#CC8400,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#777777,stroke-width:1px
```
