# kadapalanikith/hiremind-ai architecture

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

- Interactive diagram: https://gitdiagram.com/kadapalanikith/hiremind-ai
- Repository: https://github.com/kadapalanikith/hiremind-ai

## Overview

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: [`Backend/src/routes/interview.routes.js`](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/routes/interview.routes.js) (Interview Routes), [`Frontend/src/app.routes.jsx`](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/app.routes.jsx) (Routes), [`Backend/src/app.js`](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/app.js) (Express App), [`Backend/src/controllers/interview.controllers.js`](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/controllers/interview.controllers.js) (Interview Ctrl)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_shell["App Shell<br/>react-shell<br/>[App.jsx]"]
  node_frontend_routes["Routes<br/>client-router<br/>[app.routes.jsx]"]
  node_auth_context(("Auth State<br/>ui-state<br/>[auth.context.jsx]"))
  node_auth_guard{{"Protected<br/>route-guard<br/>[Protected.jsx]"}}
  node_auth_api["Auth API<br/>http-client<br/>[auth.api.js]"]
  node_auth_ui["Auth Pages<br/>feature-ui<br/>[Login.jsx]"]
  node_interview_context(("Interview State<br/>ui-state"))
  node_interview_ui["Interview UI<br/>feature-ui<br/>[Home.jsx]"]
  node_interview_api["Interview API<br/>http-client<br/>[interview.api.js]"]
end

subgraph group_backend["Backend"]
  node_server_entry["Server<br/>node-entry<br/>[server.js]"]
  node_app_bootstrap["Express App<br/>express-bootstrap<br/>[app.js]"]
  node_db_conn[("Mongo Conn<br/>database-config<br/>[database.js]")]
  node_auth_routes["Auth Routes<br/>route-layer<br/>[auth.routes.js]"]
  node_auth_controller["Auth Ctrl<br/>controller"]
  node_auth_middleware{{"JWT Guard<br/>middleware<br/>[auth.middleware.js]"}}
  node_user_model[("Users<br/>mongo-model<br/>[user.model.js]")]
  node_token_blacklist[("Blacklist<br/>mongo-model<br/>[blacklist.model.js]")]
  node_interview_routes["Interview Routes<br/>route-layer"]
  node_interview_controller["Interview Ctrl<br/>controller"]
  node_file_middleware["Upload Parse<br/>middleware<br/>[file.middleware.js]"]
  node_ai_service{{"AI Service<br/>ai-orchestrator<br/>[ai.service.js]"}}
  node_report_model[("Reports<br/>mongo-model")]
end

subgraph group_external["External"]
  node_mongo_db[("MongoDB<br/>datastore")]
  node_gemini(("Gemini<br/>llm-api"))
end

node_frontend_shell -->|"renders"| node_frontend_routes
node_frontend_routes -->|"protects"| node_auth_guard
node_frontend_routes -->|"navigates"| node_auth_ui
node_frontend_routes -->|"navigates"| node_interview_ui
node_auth_ui -->|"uses"| node_auth_context
node_auth_ui -->|"calls"| node_auth_api
node_auth_guard -->|"reads"| node_auth_context
node_interview_ui -->|"uses"| node_interview_context
node_interview_ui -->|"calls"| node_interview_api
node_server_entry -->|"starts"| node_app_bootstrap
node_app_bootstrap -->|"connects"| node_db_conn
node_app_bootstrap -->|"registers"| node_auth_routes
node_app_bootstrap -->|"registers"| node_interview_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"protects"| node_auth_middleware
node_auth_controller -->|"persists"| node_user_model
node_auth_controller -->|"invalidates"| node_token_blacklist
node_auth_middleware -->|"checks"| node_token_blacklist
node_user_model -->|"stores"| node_mongo_db
node_token_blacklist -->|"stores"| node_mongo_db
node_interview_routes -->|"protects"| node_auth_middleware
node_interview_routes -->|"uploads"| node_file_middleware
node_interview_routes -->|"dispatches"| node_interview_controller
node_interview_controller -->|"reads"| node_file_middleware
node_interview_controller -->|"orchestrates"| node_ai_service
node_interview_controller -->|"persists"| node_report_model
node_report_model -->|"stores"| node_mongo_db
node_ai_service -->|"calls"| node_gemini
node_ai_service -->|"structures"| node_report_model
node_auth_api -->|"requests"| node_auth_routes
node_interview_api -->|"requests"| node_interview_routes

click node_frontend_shell "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/App.jsx"
click node_frontend_routes "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/app.routes.jsx"
click node_auth_context "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/auth.context.jsx"
click node_auth_guard "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/components/Protected.jsx"
click node_auth_api "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/services/auth.api.js"
click node_auth_ui "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/pages/Login.jsx"
click node_interview_context "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/interview/interview.context.jsx"
click node_interview_ui "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/interview/pages/Home.jsx"
click node_interview_api "https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/interview/services/interview.api.js"
click node_server_entry "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/server.js"
click node_app_bootstrap "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/app.js"
click node_db_conn "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/config/database.js"
click node_auth_routes "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/routes/auth.routes.js"
click node_auth_controller "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/controllers/auth.controllers.js"
click node_auth_middleware "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/middlewares/auth.middleware.js"
click node_user_model "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/models/user.model.js"
click node_token_blacklist "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/models/blacklist.model.js"
click node_interview_routes "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/routes/interview.routes.js"
click node_interview_controller "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/controllers/interview.controllers.js"
click node_file_middleware "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/middlewares/file.middleware.js"
click node_ai_service "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/services/ai.service.js"
click node_report_model "https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/models/interviewReport.model.js"

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_frontend_shell,node_frontend_routes,node_auth_context,node_auth_guard,node_auth_api,node_auth_ui,node_interview_context,node_interview_ui,node_interview_api toneBlue
class node_server_entry,node_app_bootstrap,node_db_conn,node_auth_routes,node_auth_controller,node_auth_middleware,node_user_model,node_token_blacklist,node_interview_routes,node_interview_controller,node_file_middleware,node_ai_service,node_report_model toneAmber
class node_mongo_db,node_gemini toneMint
```

## Components

### Frontend

React/Vite client with auth and interview feature modules

- [App Shell](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/App.jsx): react-shell · Root UI shell for the client app · `Frontend/src/App.jsx`
- [Routes](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/app.routes.jsx): client-router · Client-side route definitions and composition · `Frontend/src/app.routes.jsx`
- [Auth State](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/auth.context.jsx): ui-state · Centralized auth state and session handling · `Frontend/src/features/auth/auth.context.jsx`
- [Protected](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/components/Protected.jsx): route-guard · Client-side protected route wrapper · `Frontend/src/features/auth/components/Protected.jsx`
- [Auth API](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/services/auth.api.js): http-client · Axios client for auth endpoints · `Frontend/src/features/auth/services/auth.api.js`
- [Auth Pages](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/auth/pages/Login.jsx): feature-ui · Login and registration screens · `Frontend/src/features/auth/pages/Login.jsx`
- [Interview State](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/interview/interview.context.jsx): ui-state · Centralized interview/report state · `Frontend/src/features/interview/interview.context.jsx`
- [Interview UI](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/interview/pages/Home.jsx): feature-ui · Dashboard and interview report screens · `Frontend/src/features/interview/pages/Home.jsx`
- [Interview API](https://github.com/kadapalanikith/hiremind-ai/blob/master/Frontend/src/features/interview/services/interview.api.js): http-client · 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](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/server.js): node-entry · Process entry point · `Backend/server.js`
- [Express App](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/app.js): express-bootstrap · Wires middleware, CORS, cookies, and routes · `Backend/src/app.js`
- [Mongo Conn](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/config/database.js): database-config · MongoDB connection setup · `Backend/src/config/database.js`
- [Auth Routes](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/routes/auth.routes.js): route-layer · Register, login, logout, and get-me routes · `Backend/src/routes/auth.routes.js`
- [Auth Ctrl](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/controllers/auth.controllers.js): controller · Authentication request handlers · `Backend/src/controllers/auth.controllers.js`
- [JWT Guard](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/middlewares/auth.middleware.js): middleware · Validates cookie-backed JWTs and blacklist status · `Backend/src/middlewares/auth.middleware.js`
- [Users](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/models/user.model.js): mongo-model · User account persistence · `Backend/src/models/user.model.js`
- [Blacklist](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/models/blacklist.model.js): mongo-model · Invalidated JWT storage · `Backend/src/models/blacklist.model.js`
- [Interview Routes](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/routes/interview.routes.js): route-layer · Report creation, listing, retrieval, and PDF endpoints · `Backend/src/routes/interview.routes.js`
- [Interview Ctrl](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/controllers/interview.controllers.js): controller · Report generation and retrieval handlers · `Backend/src/controllers/interview.controllers.js`
- [Upload Parse](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/middlewares/file.middleware.js): middleware · Multipart ingestion and resume file handling · `Backend/src/middlewares/file.middleware.js`
- [AI Service](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/services/ai.service.js): ai-orchestrator · Gemini orchestration with structured validation · `Backend/src/services/ai.service.js`
- [Reports](https://github.com/kadapalanikith/hiremind-ai/blob/master/Backend/src/models/interviewReport.model.js): mongo-model · Persisted interview report history · `Backend/src/models/interviewReport.model.js`

### External

Third-party and infrastructure dependencies

- **MongoDB**: datastore · Primary durable store
- **Gemini**: llm-api · External generative model provider

## Connections

- 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
