How rahulreddy006/quickblog works
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: adminRoutes.js Admin routes · Layout.jsx Admin shell · App.jsx App shell · blogController.js Blog logic
Components 24
Frontend
React/Vite single-page app for public reading and admin workflows.
- App shell · Bootstraps the SPA, routes, context, and shared composition.
frontend/src/App.jsx - Main entry · Application startup and global style loading.
frontend/src/main.jsx - App context · Shared client-side state for blog data and UI coordination.
frontend/src/context/AppContext.jsx - Public UI · Home and blog detail experience for browsing and reading posts.
frontend/src/pages/Home.jsx - Blog page · Renders rich article content, comments, sharing, and related reading.
frontend/src/pages/Blog.jsx - UI components · Reusable header, cards, lists, footer, loader, and newsletter UI.
frontend/src/components/Header.jsx - Admin shell · Protected admin routing and shared dashboard navigation.
frontend/src/pages/admin/Layout.jsx - Admin login · Admin sign-in entry point for obtaining access to protected actions.
frontend/src/components/admin/Login.jsx - Dashboard · Admin overview and content management landing page.
frontend/src/pages/admin/Dashboard.jsx - Add blog · Admin form for creating posts and requesting generated descriptions.
frontend/src/pages/admin/AddBlog.jsx - List blogs · Table-driven blog management for publish state and deletion.
frontend/src/pages/admin/ListBlog.jsx - Moderate comments · 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 · Wires middleware, routes, and application startup.
backend/server.js - Blog routes · Public API endpoints for blog listing, detail, comments, AI generation, and media flows.
backend/routes/blogRoutes.js - Admin routes · Privileged API endpoints for blog creation, updates, deletion, and moderation.
backend/routes/adminRoutes.js - Blog logic · Handles blog reads/writes, comment actions, and generation-related request handling.
backend/controllers/blogController.js - Admin logic · Implements protected admin operations and moderation workflows.
backend/controllers/adminController.js - Auth guard · JWT-based protection for sensitive admin endpoints.
backend/middleware/auth.js - Upload middleware · Multer-based image upload handling before media storage.
backend/middleware/multer.js - Blog model · Mongoose document for blog metadata and content.
backend/models/Blog.js - Comment model · Mongoose document for reader comments and moderation state.
backend/models/Comment.js
External services
Third-party systems used by the backend.
- MongoDB · System of record for blogs and comments.
- Gemini · Generates blog descriptions on the server side.
- ImageKit · Stores and serves optimized blog images.
Connections 35
- 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.