# noahskorner/google-docs-clone architecture

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

- Interactive diagram: https://gitdiagram.com/noahskorner/google-docs-clone
- Repository: https://github.com/noahskorner/google-docs-clone

## Overview

##### Project Type and Purpose
- This is a full-stack “Google Docs Clone” web application.
- Frontend: React + TypeScript + TailwindCSS.
- Backend: ExpressJS + Sequelize (Postgres) + Socket.IO.
- Purpose: real-time collaborative document editing with user authentication, sharing, and email verification.

##### File Structure Overview
a. Top-Level Directories
- client/ → React frontend
- server/ → Express backend
b. Frontend Highlights
- public/ → static HTML, manifest, robots.txt
- src/
- assets/css → Tailwind + custom styles
- components → Atom/Molecule/Organism hierarchy (UI)
- contexts & hooks → global state (auth, document, toast)
- pages → routing (login, register, document editor)
- services → API wrappers (auth, document, user)
c. Backend Highlights
- src/app.ts & src/server.ts → Express app initialization
- src/config → DB, environment, SMTP setup
- src/controllers → HTTP route handlers (auth, document, share, user)
- src/routes → route definitions
- src/middleware → auth guard, error handling
- src/services → business logic (user, document, mail)
- src/db/models → Sequelize models (User, Document, DocumentUser, RefreshToken, Role, etc.)
- Socket.IO integration likely in app.ts or server.ts
- seeders for initial DB data

##### README Insights
- Technologies: React, TypeScript, Tailwind, Express, Postgres, Socket.IO.
- Features: Auth (register/login/verify), document CRUD, real-time collaboration, toasts.
- API docs link: shows REST endpoints.
- Deployment: client on port 3000, server on 3001.
- Reflection: emphasis on Context API, custom hooks, service refactoring.

a. Main Components
1. Browser / React App
2. API Server (Express + Socket.IO)
3. Database (Postgres via Sequelize)
4. External SMTP Service (email verification)
b. Relationships & Data Flow
- React app → REST API (HTTP) for auth, document CRUD
- React app ↔ WebSocket (Socket.IO) for real-time edits
- API Server → Database (CRUD + join tables for sharing)
- API Server → SMTP service for email sending
c. Architectural Patterns & Principles
- Client-Server separation (SPA + REST + WebSockets)
- MVC-style on backend: controllers → services → models
- Database-backed role/permission system
- React Context + Hooks for state management
- Atomic design for UI components
d. Key Technologies & Frameworks
- Frontend: React, TypeScript, TailwindCSS, Socket.IO-client
- Backend: ExpressJS, Sequelize ORM, Socket.IO, Jest for tests
- Database: Postgres
- CI/Deployment hints: Procfile (Heroku), .env for configs

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client" 
        direction TB
        SPA["React SPA"]:::frontend
        subgraph "UI Layer"
            direction TB
            Atoms["Atoms"]:::frontend
            Molecules["Molecules"]:::frontend
            Organisms["Organisms"]:::frontend
        end
        subgraph "State Layer"
            direction TB
            Contexts["Contexts"]:::frontend
            Hooks["Custom Hooks"]:::frontend
        end
        subgraph "Service Layer"
            direction TB
            APIClient["REST API Client"]:::frontend
            SocketClient["Socket.IO Client"]:::frontend
        end
    end

    %% Server Side
    subgraph "Server"
        direction TB
        App["Express App + Socket.IO"]:::backend
        Config["Config (DB/Env/SMTP)"]:::backend
        subgraph "HTTP Layer"
            direction TB
            Routes["Routes"]:::backend
            Controllers["Controllers"]:::backend
        end
        subgraph "Business Layer"
            direction TB
            ServicesLayer["Services"]:::backend
        end
        subgraph "Data Layer"
            direction TB
            Models["Sequelize Models"]:::backend
            DBInit["DB Init & Seeders"]:::backend
        end
        subgraph "Middleware"
            direction TB
            AuthGuard["Auth Guard"]:::backend
            AsyncCatch["Async Error Catcher"]:::backend
            ErrorHandler["Global Error Handler"]:::backend
        end
    end

    %% External Systems
    Postgres["Postgres DB"]:::external
    SMTP["SMTP Service"]:::external

    %% Connections
    SPA -->|"renders UI"| Atoms
    SPA -->|"renders UI"| Molecules
    SPA -->|"renders UI"| Organisms
    SPA -->|"calls"| APIClient
    SPA -->|"connects"| SocketClient

    APIClient -->|"HTTP"| App
    SocketClient -->|"WebSocket"| App

    App -->|"loads"| Config
    App -->|"uses"| Routes
    Routes -->|"defines endpoints for"| Controllers
    Controllers -->|"invoke"| ServicesLayer
    ServicesLayer -->|"use"| Models
    ServicesLayer -->|"send email via"| SMTP
    Models -->|"CRUD operations on"| Postgres
    DBInit -->|"seed data in"| Postgres

    App -->|"applies"| AuthGuard
    App -->|"applies"| AsyncCatch
    App -->|"applies"| ErrorHandler

    Config -->|"provides settings to"| DBInit

    %% Click Events
    click SPA "https://github.com/noahskorner/google-docs-clone/blob/main/client/src/index.tsx"
    click Atoms "https://github.com/noahskorner/google-docs-clone/tree/main/client/src/components/atoms"
    click Molecules "https://github.com/noahskorner/google-docs-clone/tree/main/client/src/components/molecules"
    click Organisms "https://github.com/noahskorner/google-docs-clone/tree/main/client/src/components/organisms"
    click Contexts "https://github.com/noahskorner/google-docs-clone/tree/main/client/src/contexts"
    click Hooks "https://github.com/noahskorner/google-docs-clone/tree/main/client/src/hooks"
    click APIClient "https://github.com/noahskorner/google-docs-clone/blob/main/client/src/services/api.ts"
    click SocketClient "https://github.com/noahskorner/google-docs-clone/blob/main/client/src/services/api.ts"
    click App "https://github.com/noahskorner/google-docs-clone/blob/main/server/src/app.ts"
    click Config "https://github.com/noahskorner/google-docs-clone/tree/main/server/src/config"
    click Routes "https://github.com/noahskorner/google-docs-clone/tree/main/server/src/routes"
    click Controllers "https://github.com/noahskorner/google-docs-clone/tree/main/server/src/controllers"
    click ServicesLayer "https://github.com/noahskorner/google-docs-clone/tree/main/server/src/services"
    click Models "https://github.com/noahskorner/google-docs-clone/tree/main/server/src/db/models"
    click DBInit "https://github.com/noahskorner/google-docs-clone/blob/main/server/src/db/index.ts"
    click SMTP "https://github.com/noahskorner/google-docs-clone/blob/main/server/src/config/smtp.config.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef backend fill:#DFF6DD,stroke:#228B22
    classDef external fill:#FFD8B0,stroke:#FF8C00
```
