# rahulreddy006/quickblog architecture

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

- Interactive diagram: https://gitdiagram.com/rahulreddy006/quickblog
- Repository: https://github.com/rahulreddy006/quickblog

## Overview

1. **Overall shape**
   - QuickBlog is split into two deployable parts: a **React/Vite frontend** and an **Express/MongoDB backend**.
   - The frontend handles all user-facing reading and admin UI; the backend exposes JSON APIs for blogs, comments, authentication, AI generation, and media handling.

2. **Frontend boundary**
   - The frontend is a single-page app built with **React Router** and organized by **pages**, **components**, and a shared **AppContext**.
   - `App.jsx` is the main composition point, while `main.jsx` bootstraps the app and global styles.

3. **Public blog experience**
   - Public pages include **Home** and **Blog** views.
   - The home experience supports blog browsing, category filtering, search, and animated UI elements.
   - The blog detail page renders rich blog content, comments, social sharing, and related reading interactions.

4. **Admin experience**
   - Admin routes are isolated under `pages/admin` and `components/admin`.
   - The admin area includes **login**, **dashboard analytics**, **add blog**, **list/manage blogs**, and **comment moderation**.
   - UI components like `Sidebar`, `BlogTableItem`, and `CommentsTableItem` support table-driven management workflows.

5. **Backend API structure**
   - The backend is organized by responsibility:
     - **routes** define HTTP endpoints,
     - **controllers** hold business logic,
     - **models** map MongoDB documents,
     - **middleware** enforces auth and handles uploads,
     - **configs** encapsulate external service setup.
   - `server.js` is the entry point that wires middleware, routes, and app startup.

6. **Data model and persistence**
   - MongoDB is the system of record.
   - `Blog` stores blog metadata and content, while `Comment` stores reader comments and moderation state.
   - Mongoose is used as the ODM layer, so all blog/comment reads and writes flow through these models.

7. **Authentication and admin protection**
   - Admin access is protected with **JWT-based auth**.
   - The `auth` middleware gates sensitive endpoints such as creating blogs, toggling publish state, deleting content, and approving comments.
   - This creates a clear boundary between public read APIs and privileged admin operations.

8. **Image upload and optimization flow**
   - Blog thumbnails are uploaded through middleware built around **multer**.
   - Images are pushed to **ImageKit**, and the resulting optimized URL is stored in MongoDB.
   - The README indicates the intent is fast delivery via transformed/compressed WebP assets on the frontend.

9. **AI content generation flow**
   - The backend integrates with **Google Gemini** for blog description generation.
   - Admins submit a title, the backend calls Gemini, and the generated SEO-friendly description is returned to the editor.
   - This keeps API keys and AI logic fully server-side.

10. **Request/response flow**
   - Typical reader flow: frontend fetches published blog lists or a single post from the backend, then renders them client-side.
   - Typical admin flow: frontend logs in, receives a token, then sends authenticated requests to manage blogs/comments.
   - Comment submission is public, but moderation occurs later in the admin panel.

11. **External service dependencies**
   - **MongoDB**: persistence for blogs and comments.
   - **Google Gemini**: AI text generation.
   - **ImageKit**: media storage and optimization.
   - These services materially affect the architecture because the backend acts as the integration layer for all three.

12. **Deployment/runtime shape**
   - The project is prepared for **Vercel deployment** on both frontend and backend, with serverless-friendly configuration present in each side.
   - The backend note about extended timeout matters because AI generation can be slower than normal request handling.

13. **Architecture summary for a diagram**
   - Draw the frontend as two logical zones: **public reader UI** and **admin dashboard UI**.
   - Draw the backend as a central API layer splitting into **blog**, **admin/auth**, **comments**, **AI generation**, and **image upload** paths.
   - Connect backend to **MongoDB**, **Gemini**, and **ImageKit** as external services, with JWT middleware guarding admin-only routes.

Main entry points: [`backend/routes/adminRoutes.js`](https://github.com/rahulreddy006/quickblog/blob/main/backend/routes/adminRoutes.js) (Admin routes), [`frontend/src/pages/admin/Layout.jsx`](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Layout.jsx) (Admin shell), [`frontend/src/App.jsx`](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/App.jsx) (App shell), [`backend/controllers/blogController.js`](https://github.com/rahulreddy006/quickblog/blob/main/backend/controllers/blogController.js) (Blog logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>React entry<br/>[App.jsx]"]
  node_frontend_main["Main entry<br/>Vite entry<br/>[main.jsx]"]
  node_frontend_context["App context<br/>client state<br/>[AppContext.jsx]"]
  node_frontend_public["Public UI<br/>reader pages<br/>[Home.jsx]"]
  node_frontend_blog_page["Blog page<br/>post view<br/>[Blog.jsx]"]
  node_frontend_components["UI components<br/>shared widgets<br/>[Header.jsx]"]
  node_frontend_admin_shell["Admin shell<br/>admin layout<br/>[Layout.jsx]"]
  node_frontend_admin_login["Admin login<br/>auth screen<br/>[Login.jsx]"]
  node_frontend_admin_dash["Dashboard<br/>analytics page<br/>[Dashboard.jsx]"]
  node_frontend_admin_add["Add blog<br/>editor page<br/>[AddBlog.jsx]"]
  node_frontend_admin_list["List blogs<br/>management page<br/>[ListBlog.jsx]"]
  node_frontend_admin_comments["Moderate comments<br/>moderation page<br/>[Comments.jsx]"]
end

subgraph group_backend["Backend"]
  node_backend_server["API server<br/>Express entry<br/>[server.js]"]
  node_backend_blog_routes["Blog routes<br/>HTTP routes<br/>[blogRoutes.js]"]
  node_backend_admin_routes["Admin routes<br/>HTTP routes<br/>[adminRoutes.js]"]
  node_backend_blog_controller["Blog logic<br/>controller<br/>[blogController.js]"]
  node_backend_admin_controller["Admin logic<br/>controller<br/>[adminController.js]"]
  node_backend_auth["Auth guard<br/>middleware<br/>[auth.js]"]
  node_backend_upload["Upload middleware<br/>[multer.js]"]
  node_backend_blog_model[("Blog model<br/>MongoDB model<br/>[Blog.js]")]
  node_backend_comment_model[("Comment model<br/>MongoDB model<br/>[Comment.js]")]
end

subgraph group_external["External services"]
  node_db[("MongoDB<br/>database")]
  node_gemini{{"Gemini<br/>AI service"}}
  node_imagekit{{"ImageKit<br/>media service"}}
end

node_frontend_main -->|"bootstraps"| node_frontend_app
node_frontend_app -->|"provides state"| node_frontend_context
node_frontend_app -->|"routes to"| node_frontend_public
node_frontend_app -->|"routes to"| node_frontend_blog_page
node_frontend_app -->|"routes to"| node_frontend_admin_shell
node_frontend_admin_shell -->|"auth entry"| node_frontend_admin_login
node_frontend_admin_shell -->|"admin home"| node_frontend_admin_dash
node_frontend_admin_shell -->|"manage content"| node_frontend_admin_add
node_frontend_admin_shell -->|"manage content"| node_frontend_admin_list
node_frontend_admin_shell -->|"manage content"| node_frontend_admin_comments
node_frontend_public -->|"uses"| node_frontend_components
node_frontend_blog_page -->|"uses"| node_frontend_components
node_frontend_admin_dash -->|"uses"| node_frontend_components
node_frontend_admin_list -->|"uses"| node_frontend_components
node_backend_server -->|"mounts"| node_backend_blog_routes
node_backend_server -->|"mounts"| node_backend_admin_routes
node_backend_blog_routes -->|"delegates"| node_backend_blog_controller
node_backend_admin_routes -->|"delegates"| node_backend_admin_controller
node_backend_admin_routes -->|"protects"| node_backend_auth
node_backend_blog_controller -->|"reads/writes"| node_backend_blog_model
node_backend_blog_controller -->|"reads/writes"| node_backend_comment_model
node_backend_admin_controller -->|"reads/writes"| node_backend_blog_model
node_backend_admin_controller -->|"moderates"| node_backend_comment_model
node_backend_blog_model -->|"stores"| node_db
node_backend_comment_model -->|"stores"| node_db
node_backend_blog_controller -->|"generates text"| node_gemini
node_backend_blog_controller -->|"uploads media"| node_imagekit
node_backend_admin_controller -->|"accepts files"| node_backend_upload
node_frontend_public -->|"fetches content"| node_backend_blog_routes
node_frontend_blog_page -->|"fetches comments"| node_backend_blog_routes
node_frontend_admin_login -->|"authenticates"| node_backend_admin_routes
node_frontend_admin_dash -->|"manages"| node_backend_admin_routes
node_frontend_admin_add -->|"creates post"| node_backend_blog_routes
node_frontend_admin_list -->|"updates posts"| node_backend_admin_routes
node_frontend_admin_comments -->|"moderates"| node_backend_admin_routes

click node_frontend_app "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/App.jsx"
click node_frontend_main "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/main.jsx"
click node_frontend_context "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/context/AppContext.jsx"
click node_frontend_public "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/Home.jsx"
click node_frontend_blog_page "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/Blog.jsx"
click node_frontend_components "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/components/Header.jsx"
click node_frontend_admin_shell "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Layout.jsx"
click node_frontend_admin_login "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/components/admin/Login.jsx"
click node_frontend_admin_dash "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Dashboard.jsx"
click node_frontend_admin_add "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/AddBlog.jsx"
click node_frontend_admin_list "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/ListBlog.jsx"
click node_frontend_admin_comments "https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Comments.jsx"
click node_backend_server "https://github.com/rahulreddy006/quickblog/blob/main/backend/server.js"
click node_backend_blog_routes "https://github.com/rahulreddy006/quickblog/blob/main/backend/routes/blogRoutes.js"
click node_backend_admin_routes "https://github.com/rahulreddy006/quickblog/blob/main/backend/routes/adminRoutes.js"
click node_backend_blog_controller "https://github.com/rahulreddy006/quickblog/blob/main/backend/controllers/blogController.js"
click node_backend_admin_controller "https://github.com/rahulreddy006/quickblog/blob/main/backend/controllers/adminController.js"
click node_backend_auth "https://github.com/rahulreddy006/quickblog/blob/main/backend/middleware/auth.js"
click node_backend_upload "https://github.com/rahulreddy006/quickblog/blob/main/backend/middleware/multer.js"
click node_backend_blog_model "https://github.com/rahulreddy006/quickblog/blob/main/backend/models/Blog.js"
click node_backend_comment_model "https://github.com/rahulreddy006/quickblog/blob/main/backend/models/Comment.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_app,node_frontend_main,node_frontend_context,node_frontend_public,node_frontend_blog_page,node_frontend_components,node_frontend_admin_shell,node_frontend_admin_login,node_frontend_admin_dash,node_frontend_admin_add,node_frontend_admin_list,node_frontend_admin_comments toneBlue
class node_backend_server,node_backend_blog_routes,node_backend_admin_routes,node_backend_blog_controller,node_backend_admin_controller,node_backend_auth,node_backend_upload,node_backend_blog_model,node_backend_comment_model toneAmber
class node_db,node_gemini,node_imagekit toneMint
```

## Components

### Frontend

React/Vite single-page app for public reading and admin workflows.

- [App shell](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/App.jsx): React entry · Bootstraps the SPA, routes, context, and shared composition. · `frontend/src/App.jsx`
- [Main entry](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/main.jsx): Vite entry · Application startup and global style loading. · `frontend/src/main.jsx`
- [App context](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/context/AppContext.jsx): client state · Shared client-side state for blog data and UI coordination. · `frontend/src/context/AppContext.jsx`
- [Public UI](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/Home.jsx): reader pages · Home and blog detail experience for browsing and reading posts. · `frontend/src/pages/Home.jsx`
- [Blog page](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/Blog.jsx): post view · Renders rich article content, comments, sharing, and related reading. · `frontend/src/pages/Blog.jsx`
- [UI components](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/components/Header.jsx): shared widgets · Reusable header, cards, lists, footer, loader, and newsletter UI. · `frontend/src/components/Header.jsx`
- [Admin shell](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Layout.jsx): admin layout · Protected admin routing and shared dashboard navigation. · `frontend/src/pages/admin/Layout.jsx`
- [Admin login](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/components/admin/Login.jsx): auth screen · Admin sign-in entry point for obtaining access to protected actions. · `frontend/src/components/admin/Login.jsx`
- [Dashboard](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Dashboard.jsx): analytics page · Admin overview and content management landing page. · `frontend/src/pages/admin/Dashboard.jsx`
- [Add blog](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/AddBlog.jsx): editor page · Admin form for creating posts and requesting generated descriptions. · `frontend/src/pages/admin/AddBlog.jsx`
- [List blogs](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/ListBlog.jsx): management page · Table-driven blog management for publish state and deletion. · `frontend/src/pages/admin/ListBlog.jsx`
- [Moderate comments](https://github.com/rahulreddy006/quickblog/blob/main/frontend/src/pages/admin/Comments.jsx): moderation page · Review and moderate reader comments from the admin area. · `frontend/src/pages/admin/Comments.jsx`

### Backend

Express API, business logic, data access, and integrations.

- [API server](https://github.com/rahulreddy006/quickblog/blob/main/backend/server.js): Express entry · Wires middleware, routes, and application startup. · `backend/server.js`
- [Blog routes](https://github.com/rahulreddy006/quickblog/blob/main/backend/routes/blogRoutes.js): HTTP routes · Public API endpoints for blog listing, detail, comments, AI generation, and media flows. · `backend/routes/blogRoutes.js`
- [Admin routes](https://github.com/rahulreddy006/quickblog/blob/main/backend/routes/adminRoutes.js): HTTP routes · Privileged API endpoints for blog creation, updates, deletion, and moderation. · `backend/routes/adminRoutes.js`
- [Blog logic](https://github.com/rahulreddy006/quickblog/blob/main/backend/controllers/blogController.js): controller · Handles blog reads/writes, comment actions, and generation-related request handling. · `backend/controllers/blogController.js`
- [Admin logic](https://github.com/rahulreddy006/quickblog/blob/main/backend/controllers/adminController.js): controller · Implements protected admin operations and moderation workflows. · `backend/controllers/adminController.js`
- [Auth guard](https://github.com/rahulreddy006/quickblog/blob/main/backend/middleware/auth.js): middleware · JWT-based protection for sensitive admin endpoints. · `backend/middleware/auth.js`
- [Upload middleware](https://github.com/rahulreddy006/quickblog/blob/main/backend/middleware/multer.js): middleware · Multer-based image upload handling before media storage. · `backend/middleware/multer.js`
- [Blog model](https://github.com/rahulreddy006/quickblog/blob/main/backend/models/Blog.js): MongoDB model · Mongoose document for blog metadata and content. · `backend/models/Blog.js`
- [Comment model](https://github.com/rahulreddy006/quickblog/blob/main/backend/models/Comment.js): MongoDB model · Mongoose document for reader comments and moderation state. · `backend/models/Comment.js`

### External services

Third-party systems used by the backend.

- **MongoDB**: database · System of record for blogs and comments.
- **Gemini**: AI service · Generates blog descriptions on the server side.
- **ImageKit**: media service · Stores and serves optimized blog images.

## Connections

- Main entry → App shell: bootstraps · Starts the SPA and mounts the main composition.
- App shell → App context: provides state · Shares application data and UI state across pages.
- App shell → Public UI: routes to · Displays public home and blog views.
- App shell → Blog page: routes to · Displays the article detail experience.
- App shell → Admin shell: routes to · Enters protected admin navigation.
- Admin shell → Admin login: auth entry · Shows login when the admin session is missing.
- Admin shell → Dashboard: admin home · Shows dashboard analytics and management overview.
- Admin shell → Add blog: manage content · Opens the add blog workflow.
- Admin shell → List blogs: manage content · Opens blog list and publish controls.
- Admin shell → Moderate comments: manage content · Opens comment moderation.
- Public UI → UI components: uses · Composes shared public UI widgets.
- Blog page → UI components: uses · Composes reading, comment, and sharing UI widgets.
- Dashboard → UI components: uses · Reuses shared admin UI pieces.
- List blogs → UI components: uses · Uses table and layout components for management screens.
- API server → Blog routes: mounts · Registers public API endpoints.
- API server → Admin routes: mounts · Registers privileged admin API endpoints.
- Blog routes → Blog logic: delegates · Routes public blog operations to business logic.
- Admin routes → Admin logic: delegates · Routes admin operations to business logic.
- Admin routes → Auth guard: protects · Applies JWT authorization to sensitive endpoints.
- Blog logic → Blog model: reads/writes · Persists and retrieves blog documents.
- Blog logic → Comment model: reads/writes · Persists and retrieves comments and moderation state.
- Admin logic → Blog model: reads/writes · Creates, updates, and deletes blog records.
- Admin logic → Comment model: moderates · Approves or manages comments.
- Blog model → MongoDB: stores · Blog documents live in MongoDB.
- Comment model → MongoDB: stores · Comment documents live in MongoDB.
- Blog logic → Gemini: generates text · Requests AI-generated blog descriptions.
- Blog logic → ImageKit: uploads media · Sends blog images to optimized storage.
- Admin logic → Upload middleware: accepts files · Uses multer-based upload handling for media ingestion.
- Public UI → Blog routes: fetches content · Reads published blogs and blog details from the API.
- Blog page → Blog routes: fetches comments · Submits and loads comment-related data.
- Admin login → Admin routes: authenticates · Sends login requests to obtain admin access.
- Dashboard → Admin routes: manages · Calls protected admin APIs for dashboard actions.
- Add blog → Blog routes: creates post · Sends create requests and requests AI description generation.
- List blogs → Admin routes: updates posts · Sends publish, edit, and delete actions.
- Moderate comments → Admin routes: moderates · Sends comment moderation actions.
