# dipesh1203/scribble_hub architecture

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

- Interactive diagram: https://gitdiagram.com/dipesh1203/scribble_hub
- Repository: https://github.com/dipesh1203/scribble_hub

## Overview

##### Project type and purpose
- This is a Turborepo-based full-stack real-time collaborative drawing and chat application.
- It contains three “apps” in the monorepo:
- scribbledraw-frontend (Next.js + React + Konva for canvas + NextAuth)
- http-backend (Node.js/TypeScript REST API for auth, rooms, chat)
- ws-backend (Node.js/TypeScript WebSocket server for realtime drawing events)
- Shared packages:
- packages/common (shared types, server.address constants)
- packages/db (Prisma schema + migrations, DB access)
- packages/ui (shared React component library)
- packages/eslint-config & packages/typescript-config for toolchain config

##### File structure
- Top-level “apps” directory holds three independently runnable services.
- “packages” directory holds internal libraries and configuration.
- Root contains PNPM/Turbo configs, Docker compose files, GitHub Actions workflows for CI/CD.
- Apps reference shared packages via workspace imports (e.g. `@repo/common`, `@repo/db`, `@repo/ui`).

##### README for additional insights
- Confirms a Turborepo monorepo with multiple apps & shared packages.
- Mentions TypeScript, ESLint, Prettier, remote caching – but does not detail the drawn app itself.

##### Detail
- NextAuth endpoints in frontend under API layer.
- Dockerfiles and GitHub Actions per service for a deployment-centric view.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["scribbledraw-frontend<br>(Next.js/React/Konva/NextAuth)"]:::frontend
    end

    subgraph "HTTP API Layer"
        HTTP["http-backend<br>(Node.js/Express/TypeScript)"]:::httpapi
    end

    subgraph "WebSocket Layer"
        WS["ws-backend<br>(Node.js/TypeScript WebSocket)"]:::wsapi
    end

    DB[(PostgreSQL)]:::database

    subgraph "Shared Libraries"
        COM["packages/common"]:::shared
        DBPKG["packages/db"]:::shared
        UI["packages/ui"]:::shared
        ESL["packages/eslint-config"]:::shared
        TSC["packages/typescript-config"]:::shared
    end

    subgraph "Config & Deployment"
        PNPM["pnpm-workspace.yaml / turbo.json"]:::config
        DOCKER["docker-compose.yml & Dockerfiles"]:::config
        CI["GitHub Actions Workflows"]:::config
    end

    %% Data Flows
    FE -->|"HTTP REST"| HTTP
    FE <-->|"WS messages"| WS
    HTTP -->|"Prisma queries"| DB
    WS -->|"Prisma queries"| DB

    %% Shared Imports
    FE -.-> COM
    FE -.-> UI
    HTTP -.-> COM
    HTTP -.-> DBPKG
    WS -.-> COM
    WS -.-> DBPKG

    %% Deployment & CI Links
    PNPM -.-> FE
    PNPM -.-> HTTP
    PNPM -.-> WS
    DOCKER -.-> FE
    DOCKER -.-> HTTP
    DOCKER -.-> WS
    CI -.-> FE
    CI -.-> HTTP
    CI -.-> WS

    %% Click Events
    click FE "https://github.com/dipesh1203/scribble_hub/tree/staging/apps/scribbledraw-frontend"
    click HTTP "https://github.com/dipesh1203/scribble_hub/tree/staging/apps/http-backend"
    click WS "https://github.com/dipesh1203/scribble_hub/tree/staging/apps/ws-backend"
    click COM "https://github.com/dipesh1203/scribble_hub/tree/staging/packages/common"
    click DBPKG "https://github.com/dipesh1203/scribble_hub/tree/staging/packages/db"
    click UI "https://github.com/dipesh1203/scribble_hub/tree/staging/packages/ui"
    click ESL "https://github.com/dipesh1203/scribble_hub/tree/staging/packages/eslint-config"
    click TSC "https://github.com/dipesh1203/scribble_hub/tree/staging/packages/typescript-config"
    click PNPM "https://github.com/dipesh1203/scribble_hub/blob/staging/pnpm-workspace.yaml"
    click DOCKER "https://github.com/dipesh1203/scribble_hub/blob/staging/docker-compose.yml"
    click CI "https://github.com/dipesh1203/scribble_hub/blob/staging/.github/workflows/cd_backend.yml"

    %% Styles
    classDef frontend fill:#d0e7ff,stroke:#0366d6,color:#0366d6;
    classDef httpapi fill:#d4f8d4,stroke:#28a745,color:#22863a;
    classDef wsapi fill:#ffe1b3,stroke:#d18600,color:#d18600;
    classDef shared fill:#f0f0f0,stroke:#999,color:#555;
    classDef database fill:#f2f2f2,stroke:#666,color:#333,shape:cylinder;
    classDef config fill:#e7f3ff,stroke:#005cc5,color:#005cc5;
```
