# talaganarajesh/heydrop architecture

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

- Interactive diagram: https://gitdiagram.com/talaganarajesh/heydrop
- Repository: https://github.com/talaganarajesh/heydrop

## Overview

##### Project type and purpose
- This is a full-stack Next.js chat application with real-time rooms, message storage, and file uploads.
- The frontend is rendered via Next.js (React + SSR/ISR), and the backend consists of Next.js API routes that encapsulate business logic and data storage.

##### File structure
- Top-level “app” directory: file-based routing for pages (`app/page.tsx`, `app/[roomId]/page.tsx`) and API endpoints (`app/api/.../route.ts`).
- “components” & “components/ui”: reusable React UI components and primitives.
- “hooks”: custom React hooks (`use-mobile`, `use-toast`).
- “lib”: core business logic and data-access layers (in-memory store, Redis client, storage abstractions, type definitions, utilities).
- “store”: client-side state management (Zustand store for room state).
- “public”: static assets and service worker for PWA support.
- Config and build files (Next.js configs, Tailwind, PostCSS, tsconfig).

##### README for additional insights
- Confirms Next.js 13+ “app” directory usage, SSR/ISR, optimized fonts, and Vercel deployment.

##### Main components and their relationships
a. FRONTEND
- **Browser Client**: renders React UI, holds Zustand store, invokes API routes via fetch/Axios.
- **Next.js Rendering Layer**: SSR/ISR of pages and layouts (`app/layout.tsx`, `app/page.tsx`, `app/[roomId]/page.tsx`).
- **UI Components**: from `components/` and `components/ui/`.

b. BACKEND/API
- **Next.js API Routes** (`app/api/*/route.ts`): HTTP endpoints for rooms, messages, status, debug, cleanup, uploads.
- **Business Logic Layer** (`lib/*`): memory-store & Redis data store abstractions, storage interface (file uploads), utility functions, type definitions.

c. DATA STORES
- **In-Memory Store** (`lib/memory-store.ts`): ephemeral storage for development or ephemeral data.
- **Redis** (`lib/redis.ts`): persistent, pub/sub for real-time messaging.
- **File Storage** (`lib/storage.ts` + uploadthing integration in `app/api/uploadthing/route.ts`).

d. EXTERNAL/INFRA
- **UploadThing**: external file‐upload service.
- **Vercel Edge Functions** (deployed API routes).
- **Service Worker** (`public/sw.js`): PWA caching and offline support.

##### Architectural patterns and design principles
- **File-based Routing**: clear separation of pages vs. API.
- **Layered Architecture**: UI → API → Business Logic → Data Stores.
- **Separation of Concerns**: React components in `components/`, logic in `lib/`, state in `store/`.
- **Hooks + Zustand**: composable state management on client.
- **PWA and SSR**: offline support, caching, and server-side rendering.

- Clear labels for all components and data stores.
- Related files/services into logical lanes or containers (Frontend, Backend, Data Layer, External).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser)" 
        direction TB
        Browser["Browser Client\n(React UI & State)"]:::frontend
        SW["Service Worker"]:::frontend
    end

    %% Next.js Rendering Layer
    SSR["Next.js Rendering Layer\n(app/layout.tsx,\napp/page.tsx,\napp/[roomId]/page.tsx)"]:::frontend

    %% Backend Layer
    subgraph "Backend"
        direction TB
        API["Next.js API Routes"]:::backend
        BL["Business Logic Layer"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        IM[("In-Memory Store")]:::database
        REDIS[("Redis Data Store")]:::database
        FILEDB[("File Storage")]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        UPLOADTHING["UploadThing Service"]:::external
    end

    %% Static Assets
    subgraph "PWA & Static Assets"
        direction TB
        MANIFEST["Manifest\n(public/manifest.json)"]:::frontend
        WORKBOX["Workbox SW\n(public/workbox-4754cb34.js)"]:::frontend
    end

    %% Connections
    Browser -->|"Initial SSR (HTTP)"| SSR
    Browser -->|"Fetch/POST API (REST)"| API
    SSR -->|"Invokes React UI Components"| Browser
    SW <-->|"Cache Assets & Offline"| Browser

    API -->|"Invoke Business Logic"| BL
    BL -->|"Read/Write"| IM
    BL -->|"Pub/Sub & Persist"| REDIS
    BL -->|"Store Files"| FILEDB
    BL -->|"Upload API Calls"| UPLOADTHING

    %% Click Events - Frontend
    click Browser "https://github.com/talaganarajesh/heydrop/tree/main/components/"
    click SW "https://github.com/talaganarajesh/heydrop/blob/main/public/sw.js"

    %% Click Events - UI Components & Hooks & Store
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/ContentCard.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/ContentGrid.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/ContentInput.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/CreateRoomButton.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/FileUpload.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/ImageUpload.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/RoomHeader.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/components/theme-provider.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/tree/main/components/ui/"

    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/hooks/use-mobile.tsx"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/hooks/use-toast.ts"
    click Browser "https://github.com/talaganarajesh/heydrop/blob/main/store/roomStore.ts"

    %% Click Events - SSR
    click SSR "https://github.com/talaganarajesh/heydrop/blob/main/app/layout.tsx"
    click SSR "https://github.com/talaganarajesh/heydrop/blob/main/app/globals.css"
    click SSR "https://github.com/talaganarajesh/heydrop/blob/main/app/page.tsx"
    click SSR "https://github.com/talaganarajesh/heydrop/blob/main/app/[roomId]/page.tsx"

    %% Click Events - API Routes
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/rooms/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/rooms/[roomId]/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/rooms/[roomId]/messages/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/test/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/test-room/[roomId]/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/status/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/debug/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/cleanup/route.ts"
    click API "https://github.com/talaganarajesh/heydrop/blob/main/app/api/uploadthing/route.ts"

    %% Click Events - Business Logic
    click BL "https://github.com/talaganarajesh/heydrop/blob/main/lib/types.ts"
    click BL "https://github.com/talaganarajesh/heydrop/blob/main/lib/utils.ts"
    click BL "https://github.com/talaganarajesh/heydrop/blob/main/lib/storage.ts"
    click BL "https://github.com/talaganarajesh/heydrop/blob/main/lib/memory-store.ts"
    click BL "https://github.com/talaganarajesh/heydrop/blob/main/lib/redis.ts"

    %% Click Events - Data Stores
    click FILEDB "https://github.com/talaganarajesh/heydrop/blob/main/lib/storage.ts"
    click IM "https://github.com/talaganarajesh/heydrop/blob/main/lib/memory-store.ts"
    click REDIS "https://github.com/talaganarajesh/heydrop/blob/main/lib/redis.ts"

    %% Click Events - Static Assets
    click MANIFEST "https://github.com/talaganarajesh/heydrop/blob/main/public/manifest.json"
    click WORKBOX "https://github.com/talaganarajesh/heydrop/blob/main/public/workbox-4754cb34.js"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#90CAF9,color:#0D47A1
    classDef backend fill:#E8F5E9,stroke:#A5D6A7,color:#1B5E20
    classDef database fill:#FFF3E0,stroke:#FFCC80,color:#E65100
    classDef external fill:#F3E5F5,stroke:#CE93D8,color:#4A148C
```
