How kanishk1420/bloggify-blogging-platform works
1. Bloggify is a two-tier monorepo: a React frontend in Frontend/ and a Node/Express backend in Backend/. The frontend is a single-page app that talks to the backend through HTTP API modules; the backend exposes REST endpoints and owns persistence, auth, and media handling.
2. The backend is organized around a classic MVC-style split. server.js/app.js bootstrap Express, then routes/ define endpoints, controller/ contains request logic, models/ define Mongoose schemas for User, Post, and Comment, and middleware/ handles auth and file upload concerns. utils/ holds shared helpers like JWT, email, OTP, and file/data conversion.
3. MongoDB is the primary system of record. User accounts, posts, comments, follow relationships, likes/dislikes, bookmarks, and profile data are all persisted through Mongoose models. The backend routes are the only place that should mutate this data, which makes the API the main architectural boundary.
4. Authentication is JWT-based with password hashing via bcrypt. The auth flow includes register, login, logout, token refetch, and password reset support. middleware/auth.js gates protected endpoints, so the frontend’s route access and redirection logic depends on whether a valid token-backed session exists.
5. Media upload is a separate pipeline. middleware/multer.js accepts multipart uploads, utils/dataUri.js converts files for upload, and Cloudinary is used as the external image host. That means post creation/editing and profile-image updates are not stored directly in MongoDB; the database stores references/URLs while Cloudinary stores the actual assets.
6. The backend’s feature domains map cleanly to the controller files: post.js for publishing, editing, reactions, bookmarks, search, feed, and analytics; comment.js for comment CRUD and post-thread retrieval; follow.js for follow/unfollow and follower lists; user.js for profile lookup, update, deletion, and search; auth.js for account/session lifecycle. This is the core business-logic layer of the system.
7. Engagement data is highly interconnected. A post can be liked, disliked, bookmarked, and commented on, while user profiles track followers/following and aggregate analytics. The analytics endpoint on the backend likely computes counts across these relationships and feeds the dashboard view in the frontend.
8. The frontend is a Vite-based React application with a route-driven UI. src/pages/ contains the screen-level boundaries such as Landing, Home, Auth, Post Details, Create/Edit Post, Profile, Followers/Following, Search, Reset Password, and Analytics. src/components/ holds reusable UI pieces like navbar, sidebar, loaders, skeletons, modals, post cards, comment actions, and layout wrappers.
9. State management is centralized with Redux Toolkit. The src/slices/ and src/redux/slices/ folders indicate global slices for auth/session, posts, and theme, while src/api/ contains request helpers for auth, posts, comments, and users. This is where server data is fetched, cached, and synchronized with the UI.
10. UX behavior is driven by client-side concerns rather than server rendering. The app includes theme initialization, dark/light toggling, mobile navigation, toast notifications, loading states, page transitions, and skeleton components. These are presentation-layer concerns that sit above the API boundary and do not affect persistence.
11. Routing and access control are an important frontend boundary. The app distinguishes unauthenticated landing/auth flows from authenticated content flows, and redirects users based on session state. That means the root route, /home, profile pages, and post management screens are guarded by client-side logic informed by the auth slice and backend token validation.
12. Search and discovery are separate experiences layered over the same backend data. The frontend pages for users, posts, trending/discovery, tags, and “who to follow” all consume server endpoints that filter or aggregate MongoDB data. The architecture favors server-side query endpoints over local filtering for these views.
13. Overall data flow is: user action in React -> API helper -> Express route -> controller -> model/database or Cloudinary/email service -> response -> Redux/UI update. The clean separation between presentation, API client, business logic, and persistence is the key structure to capture in an architecture diagram.
Main entry points: controller Controllers · App.jsx App shell · pages Pages · api API client
Components 17
Frontend
Vite + React SPA with route-driven UI and centralized state
- Client entry · Initializes the SPA and global providers
Frontend/src/main.jsx - App shell · Top-level app composition and route wiring
Frontend/src/App.jsx - Pages · Route-level screens for auth, home, posts, profiles, search, and analytics
Frontend/src/pages - UI kit · Navigation, layout, loaders, post actions, and profile widgets
Frontend/src/components - API client · Request helpers for auth, posts, comments, and users
Frontend/src/api - Redux store · Central state container for session, posts, and theme
Frontend/src/app/store.js - State slices · Auth, post, and theme state reducers and selectors
Frontend/src/slices - Theme UX · Theme initialization, page transitions, toasts, loading states, and responsive navigation
Frontend/src/components/ThemeInitializer.jsx - Route layout · Main layout wrapper that frames authenticated views
Frontend/src/components/Layout/MainLayout.jsx
Backend
Express API with MVC-style business logic and persistence
- Server bootstrap · Starts the backend process and HTTP server
Backend/server.js - Express app · Configures middleware and mounts route modules
Backend/app.js - Routes · REST endpoints for auth, posts, comments, follows, and users
Backend/routes - Controllers · Feature handlers for auth, posts, comments, follows, and users
Backend/controller - Middleware · JWT auth and multipart upload handling
Backend/middleware - Models · User, Post, and Comment persistence models
Backend/models - Utilities · JWT, email, OTP, and file/data conversion helpers
Backend/utils - Data stores · Primary record store plus external media hosting
Backend/data/data.js
Connections 19
- Client entry → App shell: boots · Client entry initializes the app shell
- App shell → Pages: routes to · App shell selects screen-level views
- App shell → Route layout: wraps · Authenticated views are composed inside the main layout
- Pages → UI kit: composes · Pages assemble reusable UI pieces
- Pages → API client: fetches via · Screens call HTTP modules for server data
- API client → Redux store: hydrates · Responses update centralized client state
- Redux store → State slices: combines · Store is built from feature slices
- Redux store → App shell: guards · Session state drives route access and redirects
- Theme UX → UI kit: affects · Theme and UX helpers influence shared UI behavior
- API client → Routes: calls · Frontend communicates with the backend API boundary
- Server bootstrap → Express app: starts · Server bootstrap loads the Express application
- Express app → Routes: mounts · Express app registers route modules
- Routes → Controllers: delegates · Routes hand off request handling to controllers
- Controllers → Middleware: uses · Protected and upload flows depend on middleware
- Controllers → Models: reads/writes · Controllers implement business operations over persisted entities
- Controllers → Utilities: uses · Controllers rely on JWT, email, OTP, and conversion helpers
- Models → Data stores: persists to · Mongoose models store core data in MongoDB
- Middleware → Data stores: uploads to · Multipart media is routed to Cloudinary while MongoDB stores references
- Utilities → Data stores: supports · Utility helpers support token, email, and file workflows