# urigo/whatsapp-clone-tutorial architecture

> Architecture diagram of the GitHub repository urigo/whatsapp-clone-tutorial, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/urigo/whatsapp-clone-tutorial
- Repository: https://github.com/urigo/whatsapp-clone-tutorial

## Overview

##### Project Type and Purpose
- This is a full-stack tutorial repository (“WhatsApp Clone Tutorial”) that walks learners through building a hybrid web/mobile chat app.
- It comprises three concerns:
- A React-based client (with Hooks, Suspense, Styled-Components, Material-UI, TypeScript, Apollo Client)
- A Node.js GraphQL server (Apollo Server, GraphQL Modules, PostgreSQL, REST fallback)
- A documentation engine (.tortilla) that generates step-by-step Markdown manuals from templates and views

##### File Structure
- Top-level directories:
· .gitmodules → client and server submodules
· .tortilla/manuals → templates (.tmpl) + view files (.md) for tutorial generation
· assets/ → screenshots and media per tutorial step
· client/ → React front-end project
· server/ → GraphQL back-end project
· package.json → root orchestration (likely installs .tortilla CLI, builds docs)
- Look inside client/ and server/ for standard project layouts (src/, public/, schema/, modules/, etc.) indicating separation of UI, business logic, schema definitions, and database layers.

##### README for Additional Insights
- The tutorial evolves through 17+ steps, introducing features in sequence: basic React, styling, REST, GraphQL, testing, routing, caching, mutations, subscriptions, authentication, PostgreSQL, REST APIs, modularity, performance, etc.
- Key technologies: React, Styled-Components, Material-UI, TypeScript, Apollo GraphQL, GraphQL Code Generator, GraphQL Inspector, PostgreSQL.
- The goal is not only to build a chat app but to demonstrate best practices, migrations, and ecosystem alignment.

a. Main Components
- User Interface (Browser/Mobile)
- React Client
- UI Library (Material-UI + Styled-Components)
- Apollo Client (Queries, Mutations, Subscriptions, Cache)
- Generated TS Types (GraphQL Code Generator)
- API Layer
- Apollo Server (HTTP + WebSocket gateway)
- GraphQL Modules (schema + resolver organization)
- Optional REST endpoints
- Database
- PostgreSQL for persistence
- Dev/Docs Pipeline
- .tortilla engine (Markdown template → tutorial pages)

b. Relationships and Data Flows
- Client → Server via GraphQL HTTP (Queries/Mutations)
- Server → Client via WebSocket (Subscriptions)
- Server → Database via SQL drivers
- Codegen tool reads GraphQL schema and emits TypeScript definitions for both client and server

c. Architectural Patterns / Design Principles
- Client-Server decoupling
- Schema-first GraphQL design
- Modular back-end via GraphQL Modules
- Incremental feature layering (reflecting tutorial steps)
- Type safety across boundaries with generated types

d. Key Technologies to Annotate
- React, React Hooks, Suspense
- Styled-Components, Material-UI
- Apollo Client, Apollo Server
- GraphQL Modules, GraphQL Code Generator, GraphQL Inspector
- PostgreSQL
- Node.js

## Diagram (Mermaid)

```mermaid
graph TD
    U["User (Browser/Mobile)"]:::external

    subgraph "React Client"
        direction TB
        UI["UI: Material-UI + Styled-Components"]:::frontend
        Hooks["React Hooks + Suspense"]:::frontend
        AC["Apollo Client<br>Queries, Mutations, Subscriptions, Cache"]:::frontend
        GT["Generated TS Types"]:::frontend
    end

    subgraph "Apollo Server"
        direction TB
        Modules["GraphQL Modules<br>Schema & Resolvers"]:::backend
        REST["REST Fallback Endpoints"]:::backend
        Auth["Authentication Module"]:::backend
    end

    DB["PostgreSQL"]:::database

    subgraph "Tooling & Docs"
        direction TB
        Codegen["GraphQL Code Generator<br>TS Types"]:::tooling
        DocEngine[".tortilla Engine"]:::tooling
        Templates["Tutorial Templates (.tmpl)"]:::tooling
        Views["Tutorial Views (.md)"]:::tooling
        Assets["Tutorial Assets"]:::tooling
        Orchestration["Root Orchestration (package.json)"]:::tooling
    end

    U --> UI
    UI --> AC
    AC -->|"HTTP Queries/Mutations"| Modules
    AC <-->|"WebSocket Subscriptions"| Modules
    AC --> REST
    Modules -->|SQL Queries| DB
    REST -->|HTTP Requests| DB
    Modules -.->|Schema Input| Codegen
    Codegen -.-> GT
    DocEngine --> Templates
    DocEngine --> Views
    Assets --> DocEngine
    Orchestration --> UI
    Orchestration --> Modules
    Orchestration --> DocEngine

    click UI "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/client/"
    click AC "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/client/"
    click GT "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/client/"
    click Modules "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/server/"
    click REST "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/server/"
    click DB "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/server/"
    click DocEngine "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/.tortilla/"
    click Templates "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/.tortilla/manuals/templates/"
    click Views "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/.tortilla/manuals/views/"
    click Assets "https://github.com/urigo/whatsapp-clone-tutorial/tree/master/assets/"
    click Orchestration "https://github.com/urigo/whatsapp-clone-tutorial/blob/master/package.json"

    classDef frontend fill:#AEDFF7,stroke:#0366d6,color:#000;
    classDef backend fill:#FFE4B5,stroke:#d2691e,color:#000;
    classDef database fill:#D5E8D4,stroke:#82b366,color:#000;
    classDef tooling fill:#F3E5F5,stroke:#9c27b0,color:#000;
    classDef external fill:#E0E0E0,stroke:#9e9e9e,color:#000;
```
