# nileshpandey05/wavechat architecture

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

- Interactive diagram: https://gitdiagram.com/nileshpandey05/wavechat
- Repository: https://github.com/nileshpandey05/wavechat

## Overview

##### Project type and purpose
- This is a full-stack, real-time chat application (“WaveChat”) organized as a Turborepo monorepo.
- It consists of three services in /apps (Next.js web client, Express HTTP API, ws-based WebSocket server), shared packages in /packages (Prisma DB client, shared types, auth utilities, UI components), and uses Docker/Docker Compose for deployment.

##### File structure
- Top-level directories:
- apps/http-server – Express.js REST API (authentication, user management, chat history REST endpoints)
- apps/ws-server – WebSocket server (real-time messaging)
- apps/web – Next.js frontend (pages, components, chat UI)
- packages/db – Prisma schema + migrations + generated client
- packages/backend-common – shared server logic (JWT handling, configuration)
- packages/common – shared TypeScript interfaces/types
- packages/ui – shared React UI primitives
- Configuration files: docker-related files, Turborepo config (turbo.json), TS configs, GitHub Actions workflows

##### README for additional insights
- Tech stack: Express.js + ws for backend, PostgreSQL + Prisma ORM, JWT + bcrypt for auth, Next.js + Tailwind + shadcn/UI for frontend
- CI/CD with GitHub Actions, container orchestration with Docker Compose

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FN["Next.js Frontend"]:::frontend
    end

    %% API Layer
    subgraph "Backend Services"
        API["Express HTTP API"]:::backend
        WS["WebSocket Server"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["PostgreSQL + Prisma"]:::persistence
    end

    %% Shared Packages
    subgraph "Shared Packages"
        COMMON["common (Types)"]:::shared
        BACKEND_COMMON["backend-common"]:::shared
        UI_PKG["ui (React Primitives)"]:::shared
    end

    %% Infrastructure
    subgraph "Infrastructure"
        DOCKER["Docker Compose"]:::infra
        CI["GitHub Actions"]:::infra
    end

    %% Relationships
    User["User"]:::external -->|uses| FN
    FN -->|REST API calls| API
    FN -->|WebSocket connection| WS
    API -->|CRUD via Prisma| DB
    WS -->|Persist messages| DB
    API -->|imports types| COMMON
    WS -->|imports types| COMMON
    API -->|imports auth utils| BACKEND_COMMON
    WS -->|imports auth utils| BACKEND_COMMON
    FN -->|uses UI components| UI_PKG
    FN -->|shares types| COMMON

    %% Click Events
    click FN "https://github.com/nileshpandey05/wavechat/tree/main/apps/web"
    click API "https://github.com/nileshpandey05/wavechat/blob/main/apps/http-server/src/index.ts"
    click WS "https://github.com/nileshpandey05/wavechat/blob/main/apps/ws-server/src/index.ts"
    click DB "https://github.com/nileshpandey05/wavechat/blob/main/packages/db/prisma/schema.prisma"
    click BACKEND_COMMON "https://github.com/nileshpandey05/wavechat/blob/main/packages/backend-common/src/config.ts"
    click COMMON "https://github.com/nileshpandey05/wavechat/blob/main/packages/common/src/types.ts"
    click UI_PKG "https://github.com/nileshpandey05/wavechat/tree/main/packages/ui/src"
    click DOCKER "https://github.com/nileshpandey05/wavechat/blob/main/docker-compose.yml"
    click CI "https://github.com/nileshpandey05/wavechat/blob/main/.github/workflows/build.yml"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40;
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20;
    classDef persistence fill:#FFF8E1,stroke:#F9A825,color:#BF360C;
    classDef shared fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef infra fill:#FCE4EC,stroke:#C2185B,color:#880E4F;
    classDef external fill:#ECEFF1,stroke:#37474F,color:#263238;
```
