How khushi2706/blog-app-using-mern-stack works
1. This is a classic MERN-style 3-tier application: a React single-page client in client/, an Express/Node API in server/, and MongoDB as the persistence layer accessed through Mongoose models.
2. The main runtime boundary is browser vs. API server. The React app renders the UI, handles navigation and user interactions, and sends requests to the backend using the API base configuration in client/src/config.js.
3. The frontend is organized by feature components under client/src/componets/:
- authentication: Login.js
- content listing and details: Blogs.js, Blog.js, BlogDetail.js, UserBlogs.js
- CRUD actions: AddBlogs.js, UpdateBlog.js, DeleteBlogs.js
- shared chrome: Header.js
- helper logic: utils.js
This indicates the UI is centered around blog browsing plus author-side management.
4. The client also has a small app-wide structure around App.js, index.js, styling files, and store/, which suggests centralized state management for user/session or shared blog data. client/utils/theme.js indicates UI theming is also part of the presentation layer.
5. The backend entrypoint is server/server.js, which likely boots Express, attaches middleware, registers routes, and connects to MongoDB through server/config/db.js. The .env.example confirms database configuration is environment-driven.
6. API routing is split by domain:
- server/routes/user-routes.js
- server/routes/blog-routes.js
These routes delegate to the matching controllers in server/controller/, keeping HTTP concerns separate from business logic.
7. The controllers are the business-logic boundary:
- user-contoller.js handles authentication/user-related actions
- blog-controller.js handles blog creation, update, deletion, and retrieval
The presence of ApiError.js and ApiResponse.js suggests the backend standardizes success/error payloads across endpoints.
8. Persistence is modeled explicitly with MongoDB documents in server/model/User.js and server/model/Blog.js. This is the main domain boundary: users own or author blogs, and blog data is queried both for personal views and for “other user blogs.”
9. The README’s functional scope matches the data flow: user logs in through the client, the client talks to the user routes for authentication, then blog actions are sent to the blog routes, which read/write MongoDB via the models and return structured responses to the UI.
10. Deployment is containerized. docker-compose.yaml orchestrates the client and server services, server/Dockerfile packages the API, and client/Dockerfile plus client/nginx.conf indicate the production frontend is built and served as static assets through Nginx. This creates a clean split between the frontend web server and the API container.
11. There is also a GitHub Actions workflow under .github/workflows/, but it appears ancillary to the app’s core runtime architecture and is not central to request/data flow.
12. For an architecture diagram, the key boxes are: browser/React UI, Express API, MongoDB, and the container/deployment layer that ties client and server together. The main arrows are: UI requests → API routes/controllers → Mongoose models → MongoDB → structured responses back to the UI.
Main entry points: index.js App shell · server.js Server boot · user-contoller.js User controller · blog-controller.js Blog controller
Components 23
Client
React single-page app and presentation layer
- Browser UI · User-facing React application in the browser
client/src/App.js - App shell · Top-level app bootstrap and routing shell
client/src/index.js - Header · Shared chrome and navigation
client/src/componets/Header.js - Login · Authentication and sign-in flow
client/src/componets/Login.js - Blog feed · Blog browsing and detail views
client/src/componets/Blogs.js - Blog CRUD · Create, update, and delete blog actions
client/src/componets/AddBlogs.js - Store · Shared client state and session/blog coordination
client/src/store/index.js - API config · Backend base URL and request configuration
client/src/config.js - Theme · Shared presentation and theme tokens
client/src/utils/theme.js
Server
Express API and MongoDB access
- Server boot · Express startup, middleware, and route wiring
server/server.js - DB connect · MongoDB connection setup
server/config/db.js - User routes · Authentication and user-related endpoints
server/routes/user-routes.js - Blog routes · Blog-related endpoints
server/routes/blog-routes.js - User controller · User login and account business logic
server/controller/user-contoller.js - Blog controller · Blog CRUD and retrieval business logic
server/controller/blog-controller.js - User model · User document schema and persistence
server/model/User.js - Blog model · Blog document schema and persistence
server/model/Blog.js - Api response · Standard success and error response helpers
server/utils/ApiResponse.js - Api error · Standardized API error helper
server/utils/ApiError.js - MongoDB · Primary persistence layer
Deployment
Containerization and runtime wiring
- Client image · Frontend build and Nginx serving container
client/Dockerfile - Server image · API container image
server/Dockerfile - Compose stack · Local orchestration for client and server services
docker-compose.yaml
Connections 28
- Browser UI → App shell: renders · Top-level React runtime is bootstrapped through the app shell
- App shell → Header: uses · Shared chrome is composed into the app shell
- App shell → Login: routes to · Login view is part of the client navigation flow
- App shell → Blog feed: routes to · Browsing and detail views are part of the main UI flow
- App shell → Blog CRUD: routes to · Author actions are exposed through the app shell
- App shell → Store: shares state · App-wide state coordinates auth and blog data
- App shell → Theme: themes · Presentation is styled through shared theme utilities
- Blog feed → API config: calls API · UI requests use the configured backend base URL
- Login → API config: calls API · Authentication requests are sent to the backend
- Blog CRUD → API config: calls API · Create/update/delete actions are sent to the backend
- API config → Server boot: requests · Client traffic targets the Express server
- Server boot → DB connect: connects · Server initializes the MongoDB connection
- Server boot → User routes: mounts · User endpoints are registered on the server
- Server boot → Blog routes: mounts · Blog endpoints are registered on the server
- User routes → User controller: delegates · Route handlers defer to user business logic
- Blog routes → Blog controller: delegates · Route handlers defer to blog business logic
- User controller → User model: reads/writes · Authentication logic uses the user schema
- Blog controller → Blog model: reads/writes · Blog logic uses the blog schema
- User controller → Api response: formats · Responses are standardized before returning to clients
- Blog controller → Api response: formats · Responses are standardized before returning to clients
- User controller → Api error: raises · Business errors are normalized through the error helper
- Blog controller → Api error: raises · Business errors are normalized through the error helper
- User model → MongoDB: persists · User documents are stored in MongoDB
- Blog model → MongoDB: persists · Blog documents are stored in MongoDB
- Compose stack → Client image: orchestrates · Compose starts the frontend container
- Compose stack → Server image: orchestrates · Compose starts the API container
- Client image → Browser UI: serves · Production frontend image serves the client application
- Server image → Server boot: runs · Server image runs the Express API