# khushi2706/blog-app-using-mern-stack architecture

> Architecture diagram of the GitHub repository khushi2706/blog-app-using-mern-stack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khushi2706/blog-app-using-mern-stack
- Repository: https://github.com/khushi2706/blog-app-using-mern-stack

## Overview

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: [`client/src/index.js`](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/index.js) (App shell), [`server/server.js`](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/server.js) (Server boot), [`server/controller/user-contoller.js`](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/controller/user-contoller.js) (User controller), [`server/controller/blog-controller.js`](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/controller/blog-controller.js) (Blog controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_browser_ui(("Browser UI<br/>runtime<br/>[App.js]"))
  node_app_shell["App shell<br/>react entry<br/>[index.js]"]
  node_header["Header<br/>ui component<br/>[Header.js]"]
  node_auth_ui["Login<br/>auth view<br/>[Login.js]"]
  node_blog_feed["Blog feed<br/>listing views<br/>[Blogs.js]"]
  node_blog_crud["Blog CRUD<br/>editor views<br/>[AddBlogs.js]"]
  node_client_state[("Store<br/>state<br/>[index.js]")]
  node_api_config["API config<br/>client config<br/>[config.js]"]
  node_theme["Theme<br/>ui styling<br/>[theme.js]"]
end

subgraph group_server["Server"]
  node_server_boot(("Server boot<br/>express entry<br/>[server.js]"))
  node_db_connect[("DB connect<br/>mongo config<br/>[db.js]")]
  node_user_routes["User routes<br/>api routes<br/>[user-routes.js]"]
  node_blog_routes["Blog routes<br/>api routes<br/>[blog-routes.js]"]
  node_user_ctrl["User controller<br/>auth logic<br/>[user-contoller.js]"]
  node_blog_ctrl["Blog controller<br/>blog logic<br/>[blog-controller.js]"]
  node_user_model[("User model<br/>mongoose model<br/>[User.js]")]
  node_blog_model[("Blog model<br/>mongoose model<br/>[Blog.js]")]
  node_api_io["Api response<br/>shared utils<br/>[ApiResponse.js]"]
  node_api_error["Api error<br/>shared utils<br/>[ApiError.js]"]
  node_mongo_db[("MongoDB<br/>datastore")]
end

subgraph group_deploy["Deployment"]
  node_client_container["Client image<br/>docker build"]
  node_server_container["Server image<br/>docker build"]
  node_compose{{"Compose stack<br/>deployment"}}
end

node_browser_ui -->|"renders"| node_app_shell
node_app_shell -->|"uses"| node_header
node_app_shell -->|"routes to"| node_auth_ui
node_app_shell -->|"routes to"| node_blog_feed
node_app_shell -->|"routes to"| node_blog_crud
node_app_shell -->|"shares state"| node_client_state
node_app_shell -->|"themes"| node_theme
node_blog_feed -->|"calls API"| node_api_config
node_auth_ui -->|"calls API"| node_api_config
node_blog_crud -->|"calls API"| node_api_config
node_api_config -->|"requests"| node_server_boot
node_server_boot -->|"connects"| node_db_connect
node_server_boot -->|"mounts"| node_user_routes
node_server_boot -->|"mounts"| node_blog_routes
node_user_routes -->|"delegates"| node_user_ctrl
node_blog_routes -->|"delegates"| node_blog_ctrl
node_user_ctrl -->|"reads/writes"| node_user_model
node_blog_ctrl -->|"reads/writes"| node_blog_model
node_user_ctrl -->|"formats"| node_api_io
node_blog_ctrl -->|"formats"| node_api_io
node_user_ctrl -->|"raises"| node_api_error
node_blog_ctrl -->|"raises"| node_api_error
node_user_model -->|"persists"| node_mongo_db
node_blog_model -->|"persists"| node_mongo_db
node_compose -->|"orchestrates"| node_client_container
node_compose -->|"orchestrates"| node_server_container
node_client_container -->|"serves"| node_browser_ui
node_server_container -->|"runs"| node_server_boot

click node_browser_ui "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/App.js"
click node_app_shell "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/index.js"
click node_header "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/Header.js"
click node_auth_ui "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/Login.js"
click node_blog_feed "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/Blogs.js"
click node_blog_crud "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/AddBlogs.js"
click node_client_state "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/store/index.js"
click node_api_config "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/config.js"
click node_theme "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/utils/theme.js"
click node_server_boot "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/server.js"
click node_db_connect "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/config/db.js"
click node_user_routes "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/routes/user-routes.js"
click node_blog_routes "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/routes/blog-routes.js"
click node_user_ctrl "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/controller/user-contoller.js"
click node_blog_ctrl "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/controller/blog-controller.js"
click node_user_model "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/model/User.js"
click node_blog_model "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/model/Blog.js"
click node_api_io "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/utils/ApiResponse.js"
click node_api_error "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/utils/ApiError.js"
click node_client_container "https://github.com/khushi2706/blog-app-using-mern-stack/tree/main/client/Dockerfile"
click node_server_container "https://github.com/khushi2706/blog-app-using-mern-stack/tree/main/server/Dockerfile"
click node_compose "https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/docker-compose.yaml"

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_browser_ui,node_app_shell,node_header,node_auth_ui,node_blog_feed,node_blog_crud,node_client_state,node_api_config,node_theme toneBlue
class node_server_boot,node_db_connect,node_user_routes,node_blog_routes,node_user_ctrl,node_blog_ctrl,node_user_model,node_blog_model,node_api_io,node_api_error,node_mongo_db toneAmber
class node_client_container,node_server_container,node_compose toneMint
```

## Components

### Client

React single-page app and presentation layer

- [Browser UI](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/App.js): runtime · User-facing React application in the browser · `client/src/App.js`
- [App shell](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/index.js): react entry · Top-level app bootstrap and routing shell · `client/src/index.js`
- [Header](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/Header.js): ui component · Shared chrome and navigation · `client/src/componets/Header.js`
- [Login](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/Login.js): auth view · Authentication and sign-in flow · `client/src/componets/Login.js`
- [Blog feed](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/Blogs.js): listing views · Blog browsing and detail views · `client/src/componets/Blogs.js`
- [Blog CRUD](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/componets/AddBlogs.js): editor views · Create, update, and delete blog actions · `client/src/componets/AddBlogs.js`
- [Store](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/store/index.js): state · Shared client state and session/blog coordination · `client/src/store/index.js`
- [API config](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/config.js): client config · Backend base URL and request configuration · `client/src/config.js`
- [Theme](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/client/src/utils/theme.js): ui styling · Shared presentation and theme tokens · `client/src/utils/theme.js`

### Server

Express API and MongoDB access

- [Server boot](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/server.js): express entry · Express startup, middleware, and route wiring · `server/server.js`
- [DB connect](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/config/db.js): mongo config · MongoDB connection setup · `server/config/db.js`
- [User routes](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/routes/user-routes.js): api routes · Authentication and user-related endpoints · `server/routes/user-routes.js`
- [Blog routes](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/routes/blog-routes.js): api routes · Blog-related endpoints · `server/routes/blog-routes.js`
- [User controller](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/controller/user-contoller.js): auth logic · User login and account business logic · `server/controller/user-contoller.js`
- [Blog controller](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/controller/blog-controller.js): blog logic · Blog CRUD and retrieval business logic · `server/controller/blog-controller.js`
- [User model](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/model/User.js): mongoose model · User document schema and persistence · `server/model/User.js`
- [Blog model](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/model/Blog.js): mongoose model · Blog document schema and persistence · `server/model/Blog.js`
- [Api response](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/utils/ApiResponse.js): shared utils · Standard success and error response helpers · `server/utils/ApiResponse.js`
- [Api error](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/server/utils/ApiError.js): shared utils · Standardized API error helper · `server/utils/ApiError.js`
- **MongoDB**: datastore · Primary persistence layer

### Deployment

Containerization and runtime wiring

- [Client image](https://github.com/khushi2706/blog-app-using-mern-stack/tree/main/client/Dockerfile): docker build · Frontend build and Nginx serving container · `client/Dockerfile`
- [Server image](https://github.com/khushi2706/blog-app-using-mern-stack/tree/main/server/Dockerfile): docker build · API container image · `server/Dockerfile`
- [Compose stack](https://github.com/khushi2706/blog-app-using-mern-stack/blob/main/docker-compose.yaml): deployment · Local orchestration for client and server services · `docker-compose.yaml`

## Connections

- 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
