How kadapalanikith/hiremind-ai works
1. Overall shape
- HireMind AI is a two-app monorepo: a React/Vite frontend and a Node/Express backend.
- The frontend is a thin UI/client layer; the backend owns authentication, resume upload parsing, AI orchestration, and persistence.
2. Frontend boundary
- Frontend/src is organized by feature, not by page type: auth and interview each have their own context, hooks, API client, pages, and SCSS.
- App.jsx and app.routes.jsx define the app shell and client-side routing.
- Protected.jsx is the main client-side guard, but real enforcement still happens on the server via JWT middleware.
3. Frontend data flow
- UI components call feature-specific Axios services (auth.api.js, interview.api.js).
- Auth state is centralized in auth.context.jsx; interview/report state is centralized in interview.context.jsx.
- The frontend primarily consumes JSON APIs plus one download endpoint that returns a PDF stream.
4. Backend entry and composition
- server.js is the process entry point; src/app.js wires Express middleware, CORS, cookies, and route registration.
- The backend is split into standard layers: routes → controllers → services/models.
- src/config/database.js manages the MongoDB connection.
5. Authentication subsystem
- auth.routes.js and auth.controllers.js implement register/login/logout/get-me.
- Users are stored in user.model.js; passwords are hashed before persistence.
- JWTs are sent as HTTP-only cookies, and auth.middleware.js validates requests for protected routes.
6. Logout invalidation
- The backend does not rely on cookie clearing alone.
- blacklist.model.js stores invalidated JWTs so a logged-out token cannot be reused if the cookie is replayed.
- This makes logout a real server-side security boundary, not just a client-side session reset.
7. Interview report subsystem
- interview.routes.js and interview.controllers.js manage report creation, listing, retrieval, and PDF resume generation.
- interviewReport.model.js stores the full generated report, including match score, question sets, skill gaps, and preparation plan.
- Reports are associated with the authenticated user, so report history is per-account.
8. File upload and resume parsing
- The report-generation endpoint accepts multipart/form-data with a resume PDF plus text inputs for self-description and job description.
- file.middleware.js handles upload ingestion, and the backend extracts text from the uploaded resume before sending it to AI.
- This upload/parse path is the bridge between raw user files and structured AI output.
9. AI orchestration
- src/services/ai.service.js is the core intelligence layer.
- It calls Google Gemini and constrains the response with structured schema validation so the app gets predictable JSON instead of freeform text.
- That service is used both for the interview report and the AI-polished resume PDF flow.
10. PDF generation path
- The backend also exposes a resume PDF endpoint that transforms generated content into a downloadable PDF.
- This is a separate output path from the stored interview report: one produces persisted JSON in MongoDB, the other produces a binary document response.
11. Persistence model
- MongoDB is the durable store for three concepts: users, blacklisted tokens, and interview reports.
- The report document is the heaviest record and acts as the long-term history object for the dashboard.
12. Request protection and trust boundaries
- Protected interview endpoints require a valid cookie-backed JWT.
- The server checks both token integrity and blacklist status before any user-scoped report access.
- This means the main trust boundary is the Express auth middleware, not the frontend route guard.
13. Primary end-to-end flow
- User registers/logs in on the React app.
- The browser receives an HTTP-only auth cookie.
- The user submits resume/job-description data.
- The backend parses the PDF, calls Gemini, validates the structured result, stores the report in MongoDB, and returns the generated report to the UI.
14. What to diagram as the main subsystems
- Frontend UI shell and auth/report feature modules.
- Express API layer with auth and interview routers.
- Auth security layer: JWT cookie + blacklist.
- Interview processing pipeline: upload → parse → AI → validate → persist.
- External dependencies: MongoDB and Google Gemini.
Main entry points: interview.routes.js Interview Routes · app.routes.jsx Routes · app.js Express App · interview.controllers.js Interview Ctrl
Components 24
Frontend
React/Vite client with auth and interview feature modules
- App Shell · Root UI shell for the client app
Frontend/src/App.jsx - Routes · Client-side route definitions and composition
Frontend/src/app.routes.jsx - Auth State · Centralized auth state and session handling
Frontend/src/features/auth/auth.context.jsx - Protected · Client-side protected route wrapper
Frontend/src/features/auth/components/Protected.jsx - Auth API · Axios client for auth endpoints
Frontend/src/features/auth/services/auth.api.js - Auth Pages · Login and registration screens
Frontend/src/features/auth/pages/Login.jsx - Interview State · Centralized interview/report state
Frontend/src/features/interview/interview.context.jsx - Interview UI · Dashboard and interview report screens
Frontend/src/features/interview/pages/Home.jsx - Interview API · Axios client for report and PDF endpoints
Frontend/src/features/interview/services/interview.api.js
Backend
Express API with auth, upload, AI orchestration, and persistence
- Server · Process entry point
Backend/server.js - Express App · Wires middleware, CORS, cookies, and routes
Backend/src/app.js - Mongo Conn · MongoDB connection setup
Backend/src/config/database.js - Auth Routes · Register, login, logout, and get-me routes
Backend/src/routes/auth.routes.js - Auth Ctrl · Authentication request handlers
Backend/src/controllers/auth.controllers.js - JWT Guard · Validates cookie-backed JWTs and blacklist status
Backend/src/middlewares/auth.middleware.js - Users · User account persistence
Backend/src/models/user.model.js - Blacklist · Invalidated JWT storage
Backend/src/models/blacklist.model.js - Interview Routes · Report creation, listing, retrieval, and PDF endpoints
Backend/src/routes/interview.routes.js - Interview Ctrl · Report generation and retrieval handlers
Backend/src/controllers/interview.controllers.js - Upload Parse · Multipart ingestion and resume file handling
Backend/src/middlewares/file.middleware.js - AI Service · Gemini orchestration with structured validation
Backend/src/services/ai.service.js - Reports · Persisted interview report history
Backend/src/models/interviewReport.model.js
External
Third-party and infrastructure dependencies
- MongoDB · Primary durable store
- Gemini · External generative model provider
Connections 31
- App Shell → Routes: renders · Root shell mounts the routed client app
- Routes → Protected: protects · Routes wrap protected areas with client-side guard
- Routes → Auth Pages: navigates · Routes expose auth pages
- Routes → Interview UI: navigates · Routes expose interview dashboard pages
- Auth Pages → Auth State: uses · Auth pages read and update auth state
- Auth Pages → Auth API: calls · Auth pages submit credentials through API client
- Protected → Auth State: reads · Guard checks session state before rendering
- Interview UI → Interview State: uses · Interview UI reads report state
- Interview UI → Interview API: calls · Interview UI requests reports and downloads PDFs
- Server → Express App: starts · Process entry initializes the Express app
- Express App → Mongo Conn: connects · App bootstrap initializes MongoDB connection
- Express App → Auth Routes: registers · Auth routes are mounted on the app
- Express App → Interview Routes: registers · Interview routes are mounted on the app
- Auth Routes → Auth Ctrl: dispatches · Route handlers delegate to auth controller
- Auth Routes → JWT Guard: protects · Protected auth endpoints enforce JWT checks
- Auth Ctrl → Users: persists · Users are created and queried through the user model
- Auth Ctrl → Blacklist: invalidates · Logout writes revoked tokens to blacklist
- JWT Guard → Blacklist: checks · Middleware rejects blacklisted tokens
- Users → MongoDB: stores · User records persist in MongoDB
- Blacklist → MongoDB: stores · Blacklisted JWTs persist in MongoDB
- Interview Routes → JWT Guard: protects · Interview endpoints require authenticated users
- Interview Routes → Upload Parse: uploads · Report creation accepts multipart resume uploads
- Interview Routes → Interview Ctrl: dispatches · Interview route handlers delegate to controller
- Interview Ctrl → Upload Parse: reads · Controller consumes parsed resume content
- Interview Ctrl → AI Service: orchestrates · Controller requests AI-generated report data
- Interview Ctrl → Reports: persists · Generated reports are stored per user
- Reports → MongoDB: stores · Interview reports persist in MongoDB
- AI Service → Gemini: calls · AI service invokes Google Gemini
- AI Service → Reports: structures · Service produces validated report-shaped output
- Auth API → Auth Routes: requests · Frontend auth client talks to auth API routes
- Interview API → Interview Routes: requests · Frontend interview client talks to report API routes