# waydansh/mernbloggingwebsite architecture

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

- Interactive diagram: https://gitdiagram.com/waydansh/mernbloggingwebsite
- Repository: https://github.com/waydansh/mernbloggingwebsite

## Overview

##### Project Type & Purpose
- This is a full-stack MERN (MongoDB, Express, React, Node) blogging website.
- The README describes a blog editor, Google authentication, dynamic pages, search, profiles, dashboard, nested comments, notifications, and mobile responsiveness.

##### Top-Level Structure
- Frontend (“blogging website – frontend”): a Vite-powered React app, Tailwind CSS, Editor.js integration, AWS/Firebase helper modules.
- Backend (“server”): an Express server (server.js), Mongoose schemas for Blog, Comment, Notification, User; Firebase Admin SDK for auth; uses a MongoDB database.

##### Main Components
a. Client / Browser (React SPA)
b. Static Hosting / CDN (Netlify or equivalent serving the built dist/)
c. Frontend App
- Routing & Pages (home, blog, dashboard, auth, profile, search, 404)
- Components (editor, blog list, comments, notifications, etc.)
- Common Services:
- Firebase SDK for Google Auth
- AWS SDK (e.g., S3) for media uploads
- API client for Node/Express
d. API Server (Node + Express)
- Authentication Layer (Firebase Admin SDK verifies tokens)
- Business Logic & Controllers (user, blog, comment, notification routes)
- Mongoose Models (User, Blog, Comment, Notification)
e. Database (MongoDB Atlas or Self-hosted)
f. External Services
- Firebase Auth
- AWS S3 (or equivalent) for image storage
g. Optional Dev/Config
- .env files, netlify.toml, postcss.config.js, tailwind.config.js, vite.config.js

##### Relationships & Data Flows
- User in Browser → (1) Google Auth via Firebase SDK → receives ID token
- Browser → (2) HTTP(S) API requests (with token) to Express server
- Server → (3) Verifies token via Firebase Admin SDK
- Server → (4) Reads/Writes documents in MongoDB
- Server → (5) Uploads/Retrieves media from AWS S3
- Server → (6) Emits or stores notifications in MongoDB
- Browser → (7) Polls or fetches notifications via API

##### Architectural Patterns & Principles
- Frontend: Component-based UI, Single-Page Application, client-side routing
- Backend: RESTful API, MVC-style separation with Mongoose models + controllers
- Stateless auth with JWT (Firebase)
- Externalizing media storage & auth to cloud services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        CDN["Static Hosting / CDN\n(Netlify - serves /dist)"]:::frontend
        Browser["Client / Browser\n(React SPA)"]:::frontend
        Pages["Routing & Pages\n(home, blog, dashboard,\nauth, profile, search, 404)"]:::frontend
        Components["Components\n(editor, blog list, comments,\nnotifications, etc.)"]:::frontend
        FirebaseSDK["Firebase SDK\n(Google Auth)"]:::frontend
        AWSSDK["AWS SDK\n(S3 uploads)"]:::frontend
        APIClient["API Client\n(session handling)"]:::frontend
        EditorComponent["Blog Editor\n(Editor.js integration)"]:::frontend
        Configs["Build & Deployment Configs\n(vite, tailwind, postcss,\nnetlify.toml)"]:::frontend

        CDN -->|"serves assets"| Browser
        Browser -->|"loads SPA"| Pages
        Browser -->|"loads SPA"| Components
        Browser -->|"loads configs"| Configs
        Browser -->|"uses"| FirebaseSDK
        Browser -->|"uses"| AWSSDK
        Browser -->|"uses"| APIClient
        Components -->|"includes"| EditorComponent
    end

    %% Backend Layer
    subgraph "Backend API Server"
        direction TB
        Express["Express Server\n(server.js)"]:::backend
        AuthLayer["Authentication Layer\n(Firebase Admin SDK)"]:::backend
        Controllers["Business Logic & Controllers\n(user, blog, comment,\nnotification routes)"]:::backend
        Models["Mongoose Models\n(User, Blog, Comment,\nNotification)"]:::backend

        Express -->|"initializes"| AuthLayer
        Express -->|"registers"| Controllers
        Controllers -->|"uses"| Models
    end

    %% Database
    subgraph "Database"
        direction TB
        MongoDB["MongoDB\n(Atlas or Self-hosted)"]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        S3["AWS S3\n(Media storage)"]:::external
    end

    %% Data Flows
    Browser -->|"1. Google Auth\n(get ID token)"| FirebaseAuth
    Browser -->|"2. API requests\n(with token)"| Express
    Express -->|"3. Verify Token"| AuthLayer
    AuthLayer -->|"calls"| FirebaseAuth
    Express -->|"4. Read/Write\nblog, comment,\nnotification"| MongoDB
    Express -->|"5. Upload/Retrieve\nmedia"| S3
    Express -->|"6. Emit/Store\nnotifications"| MongoDB
    Browser -->|"7. Fetch notifications"| Express

    %% Click Events - Frontend
    click Browser "https://github.com/waydansh/mernbloggingwebsite/tree/main/blogging website - frontend/src"
    click CDN "https://github.com/waydansh/mernbloggingwebsite/tree/main/blogging website - frontend/dist"
    click Pages "https://github.com/waydansh/mernbloggingwebsite/tree/main/blogging website - frontend/src/pages"
    click Components "https://github.com/waydansh/mernbloggingwebsite/tree/main/blogging website - frontend/src/components"
    click FirebaseSDK "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/src/common/firebase.jsx"
    click AWSSDK "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/src/common/aws.jsx"
    click APIClient "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/src/common/session.jsx"
    click EditorComponent "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/src/components/blog-editor.component.jsx"
    click Configs "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/vite.config.js"
    click Configs "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/tailwind.config.js"
    click Configs "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/postcss.config.js"
    click Configs "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/netlify.toml"
    click EditorComponent "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/src/pages/editor.pages.jsx"
    click Browser "https://github.com/waydansh/mernbloggingwebsite/blob/main/blogging website - frontend/.env"

    %% Click Events - Backend
    click Express "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/server.js"
    click AuthLayer "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/mern-blogging-website-b9bb3-firebase-adminsdk-fizqw-487294dc58.json"
    click Models "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/Schema/User.js"
    click Models "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/Schema/Blog.js"
    click Models "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/Schema/Comment.js"
    click Models "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/Schema/Notification.js"
    click Express "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/requests.rest"
    click Express "https://github.com/waydansh/mernbloggingwebsite/blob/main/server/.gitignore"

    %% Styles
    classDef frontend fill:#ccf,stroke:#338,stroke-width:1px
    classDef backend fill:#cfc,stroke:#383,stroke-width:1px
    classDef database fill:#ffcc99,stroke:#c60,stroke-width:1px
    classDef external fill:#e0ccff,stroke:#606,stroke-width:1px
```
