How anshitsharma05/infojolt works
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: Store.js Redux store · App.jsx App shell · controllers Controllers · pages Pages
Components 23
Frontend
React/Vite SPA, UI, routing, and client state.
- App shell · Top-level client application wiring routes, providers, and bootstrap logic.
infojolt/src/App.jsx - Entry point · Browser bootstrap that mounts the React app.
infojolt/src/main.jsx - Auth bootstrap · Initial auth-state hydration before protected routes render.
infojolt/src/components/AuthBootstrap.jsx - Route guards · Client-side access control for guest-only and authenticated screens.
infojolt/src/components/ProtectedRoute.jsx - API client · Centralized backend request configuration used by the UI.
infojolt/src/config/api.js - Redux store · Composes client state slices and persistence handling.
infojolt/src/redux/Store.js - Auth state · Session and identity state for login, signup, and protected views.
infojolt/src/redux/authSlice.js - Blog state · Client state for blog content, lists, and editing flows.
infojolt/src/redux/blogSlice.js - Comment state · Client state for comment threads and comment actions.
infojolt/src/redux/commentSlice.js - Theme state · Persistent UI theme preference.
infojolt/src/redux/themeSlice.js - Shared UI · Reusable layout and widget components for the SPA.
infojolt/src/components - Pages · Primary app screens for browsing, auth, profile, and content creation.
infojolt/src/pages
Backend
Express API, controllers, middleware, and persistence.
- Server · Backend application entry point that wires middleware, routes, and startup.
backend/server.js - Routes · Resource-oriented API endpoints for users, blogs, and comments.
backend/routes - Controllers · Request handlers that implement the API behavior for each resource.
backend/controllers - Auth middleware · Server-side protection for authenticated API access.
backend/middleware/isAuthenticated.js - Upload middleware · Multipart upload handling used by blog media flows.
backend/middleware/multer.js - DB connect · MongoDB connection setup for the Node service.
backend/database/db.js - Models · Persistence models for users, blogs, and comments.
backend/models - Backend utils · Helpers for auth cookies, file transforms, and media upload integration.
backend/utils
External services
Third-party storage, auth, and AI dependencies.
- Cloudinary · External image storage and delivery used by the upload pipeline.
- MongoDB · Primary system of record for application data.
- Gemini API · External AI service used for grammar and spelling assistance.
Connections 22
- 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.