# geraldman/whisp architecture

> Architecture diagram of the GitHub repository geraldman/whisp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/geraldman/whisp
- Repository: https://github.com/geraldman/whisp

## Overview

##### Project type and purpose
- This is a full-stack web application built on Next.js (App Router).
- It provides user authentication (login/register) and real-time chat functionality.
- Firebase (Auth + Firestore) is used as the backend services platform.

##### File structure
- app/ — your Next.js “app” directory
– app/login, app/register, app/chat/[chatid] pages
– app/components/messageComponent.tsx, messageinput.tsx etc.
– app/actions/auth.ts (wrapper for Firebase Auth calls)
- firebase/firebase.ts — initializes Firebase SDK (Auth & Firestore)
- public/ — static assets
- config files (next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs)

##### README for additional insights
- Bootstrapped with create-next-app
- Uses next/font for font optimization
- Standard npm scripts (dev, build, start) and deploys easily on Vercel

##### Main components
a. Client (Browser)
– React components (Login, Register, Chat UI)
– next/link + next/router for navigation
– Firebase Client SDK
b. Next.js Server / Edge Runtime
– App Router (server-side rendering and static generation)
– API routes if any (none explicitly shown, so likely direct client-to-Firebase)
c. Firebase Services
– Authentication (email/password)
– Firestore (chat messages collection)
d. Deployment / CDN
– Vercel (for hosting static & SSR assets) or similar

##### Relationships & interactions
- Browser ↔ Next.js Server
– Initial page requests (SSR/SSG)
- Browser → Firebase Auth
– signInWithEmailAndPassword, createUserWithEmailAndPassword
- Browser → Firestore
– onSnapshot (subscribe to chat messages), addDoc (send message)
- Vercel CDN sits in front of Next.js Server for caching static content

##### Architectural patterns & design principles
- Full-stack server-less: minimal backend code, leverage BaaS (Firebase)
- App Router (Next.js 13+) for colocation of UI and data-loading code
- Separation of concerns:
– /app/actions for authentication logic
– /app/components for reusable UI
– /firebase for service initialization
- Client-centric data flow: the client talks directly to Firebase, reducing the need for custom API layers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)"
        style ClientLayer fill:#E3F2FD,stroke:#90CAF9,stroke-width:2px
        CL_Login["Login Page"]:::client
        CL_Register["Register Page"]:::client
        CL_Chat["Chat UI Page"]:::client
        CL_MessageComp["Message Component"]:::client
        CL_MessageInput["Message Input Component"]:::client
        CL_Layout["Global Layout"]:::client
        CL_MessageBox["Message Box"]:::client
    end

    %% Next.js Server/Edge
    subgraph "Next.js App Router" 
        style NextLayer fill:#E8F5E9,stroke:#66BB6A,stroke-width:2px
        NS_Routes["Route Definitions"]:::server
        NS_Root["App Root Page"]:::server
        NS_AuthAction["Auth Wrapper (actions/auth.ts)"]:::service
        NS_GlobalStyles["Global Styles"]:::file
    end

    %% Firebase BaaS
    subgraph "Firebase Services"
        style BaaSLayer fill:#F1F8E9,stroke:#AED581,stroke-width:2px
        FB_Auth["Firebase Auth"]:::auth
        FB_Firestore["Firestore Database"]:::db
        FB_Init["Firebase SDK Setup"]:::service
    end

    %% Configuration Files
    subgraph "Config & Manifest"
        style ConfigLayer fill:#FFF3E0,stroke:#FFB74D,stroke-width:2px
        CFG_Next["next.config.ts"]:::file
        CFG_TS["tsconfig.json"]:::file
        CFG_ESLint["eslint.config.mjs"]:::file
        CFG_PostCSS["postcss.config.mjs"]:::file
        CFG_Pkg["package.json"]:::file
        CFG_PkgLock["package-lock.json"]:::file
    end

    %% Deployment
    Vercel["Vercel CDN"]:::cloud

    %% Connections
    CL_Login -->|Navigates via next/link| NS_Routes
    CL_Register -->|Navigates via next/link| NS_Routes
    CL_Chat -->|Navigates via next/router| NS_Routes
    CL_Layout --> NS_Root
    CL_MessageBox --> CL_Chat
    CL_MessageComp --> CL_Chat
    CL_MessageInput --> CL_Chat

    CL_Login -->|calls signInWithEmailAndPassword| FB_Auth
    CL_Register -->|calls createUserWithEmailAndPassword| FB_Auth
    CL_Chat -->|onSnapshot/addDoc| FB_Firestore

    NS_Routes --> NS_Root
    NS_Root --> FB_Init
    FB_Init --> FB_Auth
    FB_Init --> FB_Firestore

    Vercel --> NS_Routes
    Vercel --> NS_Root

    CFG_Next --- NS_Root
    CFG_TS --- NS_Root
    CFG_ESLint --- NS_Root
    CFG_PostCSS --- NS_Root
    CFG_Pkg --- NS_Root
    CFG_PkgLock --- NS_Root

    %% Click Events
    click CL_Login "https://github.com/geraldman/whisp/blob/main/app/login/page.tsx"
    click CL_Register "https://github.com/geraldman/whisp/blob/main/app/register/page.tsx"
    click CL_Chat "https://github.com/geraldman/whisp/blob/main/app/chat/[chatid]/page.tsx"
    click CL_MessageComp "https://github.com/geraldman/whisp/blob/main/app/components/messageComponent.tsx"
    click CL_MessageInput "https://github.com/geraldman/whisp/blob/main/app/components/messageinput.tsx"
    click CL_Layout "https://github.com/geraldman/whisp/blob/main/app/layout.tsx"
    click CL_MessageBox "https://github.com/geraldman/whisp/blob/main/app/layout/messageBox.tsx"
    click NS_Routes "https://github.com/geraldman/whisp/blob/main/app/routes.ts"
    click NS_Root "https://github.com/geraldman/whisp/blob/main/app/page.tsx"
    click NS_AuthAction "https://github.com/geraldman/whisp/blob/main/app/actions/auth.ts"
    click FB_Init "https://github.com/geraldman/whisp/blob/main/firebase/firebase.ts"
    click NS_GlobalStyles "https://github.com/geraldman/whisp/blob/main/app/globals.css"
    click CFG_Next "https://github.com/geraldman/whisp/blob/main/next.config.ts"
    click CFG_TS "https://github.com/geraldman/whisp/blob/main/tsconfig.json"
    click CFG_ESLint "https://github.com/geraldman/whisp/blob/main/eslint.config.mjs"
    click CFG_PostCSS "https://github.com/geraldman/whisp/blob/main/postcss.config.mjs"
    click CFG_Pkg "https://github.com/geraldman/whisp/blob/main/package.json"
    click CFG_PkgLock "https://github.com/geraldman/whisp/blob/main/package-lock.json"

    %% Styles
    classDef client fill:#BBDEFB,stroke:#2196F3,stroke-width:1px
    classDef server fill:#C8E6C9,stroke:#4CAF50,stroke-width:1px
    classDef service fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
    classDef db fill:#A5D6A7,stroke:#388E3C,stroke-width:1px
    classDef auth fill:#DCEDC8,stroke:#689F38,stroke-width:1px
    classDef cloud fill:#ECEFF1,stroke:#90A4AE,stroke-width:1px
    classDef file fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px
```
