# anshitsharma05/infojolt architecture

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

- Interactive diagram: https://gitdiagram.com/anshitsharma05/infojolt
- Repository: https://github.com/anshitsharma05/infojolt

## Overview

1. **Overall shape**
   - InfoJolt is split into two deployable parts: a **React/Vite frontend** in `infojolt/` and an **Express/Node backend** in `backend/`.
   - The frontend is a single-page app; the backend exposes HTTP routes for authentication, blogs, comments, uploads, and profile/user actions.

2. **Frontend boundary**
   - The React app is organized around **pages**, **reusable components**, and a **Redux store**.
   - `src/config/api.js` centralizes backend API access, so the UI talks to the server through a single network boundary rather than direct DB access.

3. **Routing and protected screens**
   - `ProtectedRoute.jsx` and `GuestRoute.jsx` gate access based on auth state.
   - Pages like `Dashboard`, `CreateBlog`, `UpdateBlog`, `Profile`, and `YourBlog` are the authenticated workspace; `Login` and `Signup` are guest-only entry points.
   - `AuthBootstrap.jsx` likely hydrates auth state on app start before the route tree renders.

4. **Frontend state model**
   - Redux slices separate concerns into `authSlice`, `blogSlice`, `commentSlice`, and `themeSlice`.
   - This indicates three core client-side data domains: identity/session, blog content, and comments, plus persistent theme preference.
   - `Store.js` is the state composition point; `Redux Persist` is used for saving at least theme and likely auth-related UI state.

5. **UI composition**
   - The app uses **Tailwind CSS** plus **Radix/shadcn-style primitives** in `src/components/ui`.
   - Shared feature components like `Navbar`, `Sidebar`, `Hero`, `BlogCard`, `CommentBox`, and `PopularAuthors` assemble into the main pages.
   - This suggests a component-driven UI with layout shells and content widgets rather than page-specific one-off markup.

6. **Backend API layer**
   - The backend is organized by resource: `user.route.js`, `blog.route.js`, and `comment.route.js`.
   - Each route delegates to a matching controller folder, keeping HTTP handling separate from business logic.
   - `server.js` is the application entry point and likely wires middleware, routes, and database startup.

7. **Persistence layer**
   - MongoDB is accessed through Mongoose models: `user.model.js`, `blog.model.js`, and `comment.model.js`.
   - This is the primary system of record for users, posts, and comments.
   - `database/db.js` encapsulates the database connection, creating a clean boundary between server startup and persistence setup.

8. **Authentication and access control**
   - Authentication uses **JWTs stored in HttpOnly cookies**, with cookies managed via `utils/authCookie.js`.
   - `middleware/isAuthenticated.js` protects private API routes on the server side.
   - The auth flow is therefore enforced at two layers: client route gating and server request authorization.

9. **Media upload pipeline**
   - Image handling is a dedicated backend flow: `multer` accepts uploads, `dataUri.js` converts files for upload, and `cloudinary.js` sends them to Cloudinary.
   - The blog creation/update path likely includes this pipeline so posts can reference externally hosted images instead of storing binaries in MongoDB.

10. **Blog and comment data flow**
   - Blog content is created in the frontend editor, submitted to the backend, stored in MongoDB, and then rendered in listing and detail pages such as `Blog`, `BlogView`, `SearchList`, and `YourBlog`.
   - Comments follow a similar loop: the client comment UI talks to comment routes/controllers, which persist comments and return them for blog detail and comment pages.

11. **AI-assisted writing**
   - The README indicates Gemini API integration for grammar/spelling assistance on blog titles and descriptions.
   - Architecturally, this is an external service dependency used during content authoring, not a core storage or rendering subsystem.

12. **Operational and deployment notes**
   - The backend expects environment variables for MongoDB, JWT, Cloudinary, Gemini, and frontend origin, confirming that it depends on multiple external services.
   - `vercel.json` in the frontend suggests the SPA is intended for Vercel-style deployment, while the backend is a separate Node service.
   - Net effect: the app is a classic **client/API/service** architecture with MongoDB for state, Cloudinary for media, and Gemini for writing assistance.

Main entry points: [`infojolt/src/redux/Store.js`](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/Store.js) (Redux store), [`infojolt/src/App.jsx`](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/App.jsx) (App shell), [`backend/controllers`](https://github.com/anshitsharma05/infojolt/tree/main/backend/controllers) (Controllers), [`infojolt/src/pages`](https://github.com/anshitsharma05/infojolt/tree/main/infojolt/src/pages) (Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_node_frontend_app["App shell<br/>React SPA<br/>[App.jsx]"]
  node_node_frontend_main["Entry point<br/>Vite entry<br/>[main.jsx]"]
  node_node_frontend_bootstrap["Auth bootstrap<br/>session hydrate<br/>[AuthBootstrap.jsx]"]
  node_node_frontend_routes["Route guards<br/>auth gating<br/>[ProtectedRoute.jsx]"]
  node_node_frontend_api["API client<br/>HTTP boundary<br/>[api.js]"]
  node_node_frontend_store["Redux store<br/>state composition<br/>[Store.js]"]
  node_node_frontend_authslice["Auth state<br/>redux slice<br/>[authSlice.js]"]
  node_node_frontend_blogslice["Blog state<br/>redux slice<br/>[blogSlice.js]"]
  node_node_frontend_commentslice["Comment state<br/>redux slice<br/>[commentSlice.js]"]
  node_node_frontend_themeslice["Theme state<br/>redux slice<br/>[themeSlice.js]"]
  node_node_frontend_ui["Shared UI<br/>component library"]
  node_node_frontend_pages["Pages<br/>screen layer"]
end

subgraph group_backend["Backend"]
  node_node_backend_server["Server<br/>Express entry<br/>[server.js]"]
  node_node_backend_routes["Routes"]
  node_node_backend_controllers["Controllers<br/>business logic"]
  node_node_backend_authmw["Auth middleware<br/>request guard<br/>[isAuthenticated.js]"]
  node_node_backend_uploadmw["Upload middleware<br/>file ingest<br/>[multer.js]"]
  node_node_backend_db["DB connect<br/>mongoose setup<br/>[db.js]"]
  node_node_backend_models["Models<br/>mongoose schemas"]
  node_node_backend_utils["Backend utils<br/>integration helpers"]
end

subgraph group_external["External services"]
  node_node_cloudinary(("Cloudinary<br/>media host"))
  node_node_mongo[("MongoDB<br/>document store")]
  node_node_gemini(("Gemini API<br/>writing assist"))
end

node_node_frontend_main -->|"mounts"| node_node_frontend_app
node_node_frontend_app -->|"hydrates"| node_node_frontend_bootstrap
node_node_frontend_app -->|"protects"| node_node_frontend_routes
node_node_frontend_app -->|"uses"| node_node_frontend_store
node_node_frontend_store -->|"includes"| node_node_frontend_authslice
node_node_frontend_store -->|"includes"| node_node_frontend_blogslice
node_node_frontend_store -->|"includes"| node_node_frontend_commentslice
node_node_frontend_store -->|"includes"| node_node_frontend_themeslice
node_node_frontend_pages -->|"composes"| node_node_frontend_ui
node_node_frontend_pages -->|"calls"| node_node_frontend_api
node_node_frontend_routes -->|"gates"| node_node_frontend_pages
node_node_backend_server -->|"mounts"| node_node_backend_routes
node_node_backend_server -->|"connects"| node_node_backend_db
node_node_backend_routes -->|"delegates"| node_node_backend_controllers
node_node_backend_controllers -->|"uses"| node_node_backend_models
node_node_backend_routes -->|"guards"| node_node_backend_authmw
node_node_backend_controllers -->|"uses"| node_node_backend_utils
node_node_backend_utils -->|"uploads"| node_node_cloudinary
node_node_backend_models -->|"persists to"| node_node_mongo
node_node_frontend_pages -.->|"assisted by"| node_node_gemini
node_node_backend_uploadmw -->|"feeds"| node_node_backend_utils
node_node_backend_controllers -->|"accepts uploads"| node_node_backend_uploadmw

click node_node_frontend_app "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/App.jsx"
click node_node_frontend_main "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/main.jsx"
click node_node_frontend_bootstrap "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/components/AuthBootstrap.jsx"
click node_node_frontend_routes "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/components/ProtectedRoute.jsx"
click node_node_frontend_api "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/config/api.js"
click node_node_frontend_store "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/Store.js"
click node_node_frontend_authslice "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/authSlice.js"
click node_node_frontend_blogslice "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/blogSlice.js"
click node_node_frontend_commentslice "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/commentSlice.js"
click node_node_frontend_themeslice "https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/themeSlice.js"
click node_node_frontend_ui "https://github.com/anshitsharma05/infojolt/tree/main/infojolt/src/components"
click node_node_frontend_pages "https://github.com/anshitsharma05/infojolt/tree/main/infojolt/src/pages"
click node_node_backend_server "https://github.com/anshitsharma05/infojolt/blob/main/backend/server.js"
click node_node_backend_routes "https://github.com/anshitsharma05/infojolt/tree/main/backend/routes"
click node_node_backend_controllers "https://github.com/anshitsharma05/infojolt/tree/main/backend/controllers"
click node_node_backend_authmw "https://github.com/anshitsharma05/infojolt/blob/main/backend/middleware/isAuthenticated.js"
click node_node_backend_uploadmw "https://github.com/anshitsharma05/infojolt/blob/main/backend/middleware/multer.js"
click node_node_backend_db "https://github.com/anshitsharma05/infojolt/blob/main/backend/database/db.js"
click node_node_backend_models "https://github.com/anshitsharma05/infojolt/tree/main/backend/models"
click node_node_backend_utils "https://github.com/anshitsharma05/infojolt/tree/main/backend/utils"

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_node_frontend_app,node_node_frontend_main,node_node_frontend_bootstrap,node_node_frontend_routes,node_node_frontend_api,node_node_frontend_store,node_node_frontend_authslice,node_node_frontend_blogslice,node_node_frontend_commentslice,node_node_frontend_themeslice,node_node_frontend_ui,node_node_frontend_pages toneBlue
class node_node_backend_server,node_node_backend_routes,node_node_backend_controllers,node_node_backend_authmw,node_node_backend_uploadmw,node_node_backend_db,node_node_backend_models,node_node_backend_utils toneAmber
class node_node_cloudinary,node_node_mongo,node_node_gemini toneMint
```

## Components

### Frontend

React/Vite SPA, UI, routing, and client state.

- [App shell](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/App.jsx): React SPA · Top-level client application wiring routes, providers, and bootstrap logic. · `infojolt/src/App.jsx`
- [Entry point](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/main.jsx): Vite entry · Browser bootstrap that mounts the React app. · `infojolt/src/main.jsx`
- [Auth bootstrap](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/components/AuthBootstrap.jsx): session hydrate · Initial auth-state hydration before protected routes render. · `infojolt/src/components/AuthBootstrap.jsx`
- [Route guards](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/components/ProtectedRoute.jsx): auth gating · Client-side access control for guest-only and authenticated screens. · `infojolt/src/components/ProtectedRoute.jsx`
- [API client](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/config/api.js): HTTP boundary · Centralized backend request configuration used by the UI. · `infojolt/src/config/api.js`
- [Redux store](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/Store.js): state composition · Composes client state slices and persistence handling. · `infojolt/src/redux/Store.js`
- [Auth state](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/authSlice.js): redux slice · Session and identity state for login, signup, and protected views. · `infojolt/src/redux/authSlice.js`
- [Blog state](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/blogSlice.js): redux slice · Client state for blog content, lists, and editing flows. · `infojolt/src/redux/blogSlice.js`
- [Comment state](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/commentSlice.js): redux slice · Client state for comment threads and comment actions. · `infojolt/src/redux/commentSlice.js`
- [Theme state](https://github.com/anshitsharma05/infojolt/blob/main/infojolt/src/redux/themeSlice.js): redux slice · Persistent UI theme preference. · `infojolt/src/redux/themeSlice.js`
- [Shared UI](https://github.com/anshitsharma05/infojolt/tree/main/infojolt/src/components): component library · Reusable layout and widget components for the SPA. · `infojolt/src/components`
- [Pages](https://github.com/anshitsharma05/infojolt/tree/main/infojolt/src/pages): screen layer · Primary app screens for browsing, auth, profile, and content creation. · `infojolt/src/pages`

### Backend

Express API, controllers, middleware, and persistence.

- [Server](https://github.com/anshitsharma05/infojolt/blob/main/backend/server.js): Express entry · Backend application entry point that wires middleware, routes, and startup. · `backend/server.js`
- [Routes](https://github.com/anshitsharma05/infojolt/tree/main/backend/routes): http routes · Resource-oriented API endpoints for users, blogs, and comments. · `backend/routes`
- [Controllers](https://github.com/anshitsharma05/infojolt/tree/main/backend/controllers): business logic · Request handlers that implement the API behavior for each resource. · `backend/controllers`
- [Auth middleware](https://github.com/anshitsharma05/infojolt/blob/main/backend/middleware/isAuthenticated.js): request guard · Server-side protection for authenticated API access. · `backend/middleware/isAuthenticated.js`
- [Upload middleware](https://github.com/anshitsharma05/infojolt/blob/main/backend/middleware/multer.js): file ingest · Multipart upload handling used by blog media flows. · `backend/middleware/multer.js`
- [DB connect](https://github.com/anshitsharma05/infojolt/blob/main/backend/database/db.js): mongoose setup · MongoDB connection setup for the Node service. · `backend/database/db.js`
- [Models](https://github.com/anshitsharma05/infojolt/tree/main/backend/models): mongoose schemas · Persistence models for users, blogs, and comments. · `backend/models`
- [Backend utils](https://github.com/anshitsharma05/infojolt/tree/main/backend/utils): integration helpers · Helpers for auth cookies, file transforms, and media upload integration. · `backend/utils`

### External services

Third-party storage, auth, and AI dependencies.

- **Cloudinary**: media host · External image storage and delivery used by the upload pipeline.
- **MongoDB**: document store · Primary system of record for application data.
- **Gemini API**: writing assist · External AI service used for grammar and spelling assistance.

## Connections

- Entry point → App shell: mounts · Browser entry mounts the application shell.
- App shell → Auth bootstrap: hydrates · App initializes authentication state before rendering routes.
- App shell → Route guards: protects · Route tree uses client-side access guards.
- App shell → Redux store: uses · App is backed by centralized Redux state.
- Redux store → Auth state: includes · Session and identity state.
- Redux store → Blog state: includes · Blog domain state.
- Redux store → Comment state: includes · Comment domain state.
- Redux store → Theme state: includes · Theme preference state.
- Pages → Shared UI: composes · Pages are assembled from shared reusable components.
- Pages → API client: calls · Screens send requests through the centralized API client.
- Route guards → Pages: gates · Authenticated and guest flows split across pages.
- Server → Routes: mounts · Server registers resource routes.
- Server → DB connect: connects · Server startup initializes persistence connection.
- Routes → Controllers: delegates · Routes hand off request handling to controllers.
- Controllers → Models: uses · Controllers read and write persisted data through models.
- Routes → Auth middleware: guards · Private endpoints are protected by auth middleware.
- Controllers → Backend utils: uses · Controllers rely on shared helpers for cookies and media handling.
- Backend utils → Cloudinary: uploads · Media helpers send processed images to Cloudinary.
- Models → MongoDB: persists to · Mongoose models store domain data in MongoDB.
- Pages → Gemini API: assisted by · Authoring flow uses AI assistance for writing polish.
- Upload middleware → Backend utils: feeds · Multipart uploads are transformed and forwarded for storage.
- Controllers → Upload middleware: accepts uploads · Blog creation and update flows include file ingestion.
