# kuntalmajee2557/excalidraw-project architecture

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

- Interactive diagram: https://gitdiagram.com/kuntalmajee2557/excalidraw-project
- Repository: https://github.com/kuntalmajee2557/excalidraw-project

## Overview

##### Main Components
- Frontend Applications:
- • “excalidraw-frontend”: A Next.js app that provides the primary interactive drawing interface.
- • “web”: Another Next.js based frontend (possibly with complementary or alternative UI features).
- Backend Services:
- • “http-backend”: The HTTP server handling RESTful API calls, authentication, or other server-side logic.
- • “ws-backend”: The WebSocket server enabling real-time collaborative drawing by managing persistent socket connections.
- Shared Packages:
- • “backend-common” and “common”: Utilities and shared methods used across both frontend and backend.
- • “db”: Contains the Prisma schema, migrations, and database integration code.
- • • “ui”: Shared UI components reused in both frontend applications.
- • • “eslint-config” and “typescript-config”: Shared configuration files to maintain consistent coding standards across packages.
- Tooling & Monorepo Artifacts:
- • “turbo.json”, “pnpm-workspace.yaml”: These indicate the use of Turbo Repo and pnpm workspaces to manage the monorepo.

##### Relationships & Interactions
- The frontend applications communicate with both backend services:
- • The HTTP backend handles initial data requests, user sessions, or API interactions.
- • The WebSocket backend handles bidirectional, real-time data exchange for collaborative drawing (e.g., sending canvas updates to multiple users).
- Both backend services and frontend applications utilize shared packages for common logic, UI components, and configurations.
- The database, managed through the “db” package (with Prisma), is accessed by the backend services to persist data.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly distinguish between UI (frontends), business logic (HTTP backend), and real-time interaction (WS backend).
- Modular Design & Reusability: The use of shared packages (common, backend-common, ui) promotes code reuse across multiple applications.
- Monorepo Structure: Utilizes Turbo Repo and pnpm workspace to orchestrate all modules and packages under one repository.
- Real-time Communication: The inclusion of a dedicated WebSocket backend shows the adoption of a microservices pattern for handling real-time updates.

##### Relevant Technologies and Frameworks
- Next.js for the frontends.
- TypeScript for type-safe development across all packages.
- WebSockets for real-time communication.
- Prisma for the database layer.
- Tools like ESLint and TypeScript configurations standardized across the codebase.

- Start from the client perspective showing multiple users accessing the drawing interface.
- Finally, illustrate the shared packages and the database, showing how they support both the frontends and the backends.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        CLIENT("Clients"):::client
    end

    %% Frontend Applications
    subgraph "Frontend Applications"
        FE1("excalidraw-frontend"):::frontend
        FE2("web"):::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        BE1("http-backend"):::backend
        BE2("ws-backend"):::backend
    end

    %% Shared Packages
    subgraph "Shared Packages"
        SP1("backend-common"):::shared
        SP2("common"):::shared
        SP3("ui"):::shared
        SP4("db"):::shared
    end

    %% Shared Configurations
    subgraph "Shared Configurations"
        CONFIG1("eslint-config"):::config
        CONFIG2("typescript-config"):::config
    end

    %% Tooling & Monorepo Artifacts
    subgraph "Tooling & Monorepo Artifacts"
        ART1("Turbo Repo Configuration"):::artifact
        ART2("pnpm Workspace Configuration"):::artifact
    end

    %% Connections from Client to Frontends
    CLIENT -->|"access"| FE1
    CLIENT -->|"access"| FE2

    %% Frontend Applications interacting with Backend Services
    FE1 -->|"REST"| BE1
    FE1 -->|"WebSocket"| BE2
    FE2 -->|"REST"| BE1
    FE2 -->|"WebSocket"| BE2

    %% Frontends using Shared UI and Common Utilities
    FE1 -->|"uses"| SP3
    FE2 -->|"uses"| SP3
    FE1 -->|"utilizes"| SP2
    FE2 -->|"utilizes"| SP2

    %% Backends using Shared Logic and Database Access
    BE1 -->|"utilizes"| SP1
    BE2 -->|"utilizes"| SP1
    BE1 -->|"utilizes"| SP2
    BE2 -->|"utilizes"| SP2
    BE1 -->|"DB Ops"| SP4
    BE2 -->|"DB Ops"| SP4

    %% All major applications depend on Shared Configurations
    FE1 -->|"config"| CONFIG1
    FE1 -->|"config"| CONFIG2
    FE2 -->|"config"| CONFIG1
    FE2 -->|"config"| CONFIG2
    BE1 -->|"config"| CONFIG1
    BE1 -->|"config"| CONFIG2
    BE2 -->|"config"| CONFIG1
    BE2 -->|"config"| CONFIG2

    %% Tooling & Monorepo Artifacts supporting the repository structure
    CONFIG1 -->|"managed_by"| ART1
    CONFIG2 -->|"managed_by"| ART1
    SP1  -->|"workspace"| ART2
    SP2  -->|"workspace"| ART2
    SP3  -->|"workspace"| ART2
    SP4  -->|"workspace"| ART2
    FE1  -->|"workspace"| ART2
    FE2  -->|"workspace"| ART2
    BE1  -->|"workspace"| ART2
    BE2  -->|"workspace"| ART2

    %% Click Events
    click FE1 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/apps/excalidraw-frontend"
    click FE2 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/apps/web"
    click BE1 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/apps/http-backend"
    click BE2 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/apps/ws-backend"
    click SP1 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/packages/backend-common"
    click SP2 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/packages/common"
    click SP3 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/packages/ui"
    click SP4 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/packages/db"
    click CONFIG1 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/packages/eslint-config"
    click CONFIG2 "https://github.com/kuntalmajee2557/excalidraw-project/tree/main/packages/typescript-config"
    click ART1 "https://github.com/kuntalmajee2557/excalidraw-project/blob/main/turbo.json"
    click ART2 "https://github.com/kuntalmajee2557/excalidraw-project/blob/main/pnpm-workspace.yaml"

    %% Styles
    classDef client fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef frontend fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef shared fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef config fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
    classDef artifact fill:#D1C4E9,stroke:#5E35B1,stroke-width:2px;
```
