# sahastrawin/ai-interview-agent architecture

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

- Interactive diagram: https://gitdiagram.com/sahastrawin/ai-interview-agent
- Repository: https://github.com/sahastrawin/ai-interview-agent

## Overview

InterviewIQ is an AI mock-interview platform. Users authenticate, configure an interview (optionally using resume analysis), answer generated questions, and receive feedback and a scored report; they can also review history and buy credits. The README documents these capabilities and API boundaries, while sampled controller code confirms AI calls, credit deductions, answer evaluation, persistence, and payment verification. Several frontend page internals and route definitions were not sampled, so those connections follow documented API responsibilities rather than inferred call details.

Main entry points: [`client/src/App.jsx`](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/App.jsx) (App routing), [`server/routes/interview.route.js`](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/interview.route.js) (Interview routes), [`server/models/user.model.js`](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/user.model.js) (User records), [`server/index.js`](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/index.js) (Express API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_authpage["Google sign-in<br/>[Auth.jsx]"]
  node_interviewpage["Interview flow<br/>[InterviewPage.jsx]"]
  node_setup["Interview setup<br/>[Step1SetUp.jsx]"]
  node_session["Live interview<br/>[Step2Interview.jsx]"]
  node_reportui["Report view<br/>[Step3Report.jsx]"]
  node_history["Interview history"]
  node_pricing["Credit plans<br/>[Pricing.jsx]"]
  node_state["User state<br/>[userSlice.js]"]
end

subgraph group_api["API and workflows"]
  node_server["Express API<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_userroutes["User routes<br/>[user.route.js]"]
  node_interviewroutes["Interview routes<br/>[interview.route.js]"]
  node_paymentroutes["Payment routes<br/>[payment.route.js]"]
  node_authctrl["Auth workflow<br/>[auth.controller.js]"]
  node_userctrl["Current user<br/>[user.controller.js]"]
  node_interviewctrl["Interview workflow"]
  node_paymentctrl["Payment workflow"]
  node_authmw["JWT verification<br/>[isAuth.js]"]
end

subgraph group_data["Persistence"]
  node_users[("User records<br/>[user.model.js]")]
  node_interviews[("Interview records<br/>[interview.model.js]")]
  node_payments[("Payment records<br/>[payment.model.js]")]
end

subgraph group_integrations["External services"]
  node_firebase["Firebase Auth<br/>[firebase.js]"]
  node_ai["OpenRouter AI"]
  node_razorservice["Razorpay client"]
end

node_person(("Candidate"))
node_openrouter{{"OpenRouter service"}}
node_razorpay{{"Razorpay gateway"}}
node_mongodb[("MongoDB")]

node_person -->|"uses"| node_app
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_interviewpage
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_pricing
node_app -->|"routes to"| node_reportui
node_authpage -->|"signs in with"| node_firebase
node_authpage -->|"posts credentials"| node_authroutes
node_authpage -->|"updates"| node_state
node_app -->|"loads current user"| node_userroutes
node_interviewpage -->|"presents setup"| node_setup
node_interviewpage -->|"runs session"| node_session
node_interviewpage -->|"requests interview APIs"| node_interviewroutes
node_history -->|"requests history"| node_interviewroutes
node_reportui -->|"requests report"| node_interviewroutes
node_pricing -->|"requests payment APIs"| node_paymentroutes
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_userroutes
node_server -->|"mounts"| node_interviewroutes
node_server -->|"mounts"| node_paymentroutes
node_authroutes -->|"dispatches"| node_authctrl
node_userroutes -->|"guards"| node_authmw
node_userroutes -->|"dispatches"| node_userctrl
node_interviewroutes -->|"guards"| node_authmw
node_interviewroutes -->|"dispatches"| node_interviewctrl
node_paymentroutes -->|"guards"| node_authmw
node_paymentroutes -->|"dispatches"| node_paymentctrl
node_authctrl -->|"finds or creates"| node_users
node_userctrl -->|"reads"| node_users
node_interviewctrl -->|"checks and deducts credits"| node_users
node_interviewctrl -->|"creates and updates"| node_interviews
node_interviewctrl -->|"requests parsing, questions, evaluation"| node_ai
node_ai -->|"calls"| node_openrouter
node_paymentctrl -->|"creates orders"| node_razorservice
node_razorservice -->|"calls"| node_razorpay
node_paymentctrl -->|"creates and updates"| node_payments
node_paymentctrl -->|"adds credits"| node_users
node_users -->|"persists in"| node_mongodb
node_interviews -->|"persists in"| node_mongodb
node_payments -->|"persists in"| node_mongodb

click node_app "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/App.jsx"
click node_authpage "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/Auth.jsx"
click node_interviewpage "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/InterviewPage.jsx"
click node_setup "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/components/Step1SetUp.jsx"
click node_session "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/components/Step2Interview.jsx"
click node_reportui "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/components/Step3Report.jsx"
click node_history "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/InterviewHistory.jsx"
click node_pricing "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/Pricing.jsx"
click node_state "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/redux/userSlice.js"
click node_firebase "https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/utils/firebase.js"
click node_server "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/index.js"
click node_authroutes "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/auth.route.js"
click node_userroutes "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/user.route.js"
click node_interviewroutes "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/interview.route.js"
click node_paymentroutes "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/payment.route.js"
click node_authctrl "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/auth.controller.js"
click node_userctrl "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/user.controller.js"
click node_interviewctrl "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/interview.controller.js"
click node_paymentctrl "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/payment.controller.js"
click node_authmw "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/middlewares/isAuth.js"
click node_users "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/user.model.js"
click node_interviews "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/interview.model.js"
click node_payments "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/payment.model.js"
click node_ai "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/services/openRouter.service.js"
click node_razorservice "https://github.com/sahastrawin/ai-interview-agent/blob/main/server/services/razorpay.service.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_app,node_authpage,node_interviewpage,node_setup,node_session,node_reportui,node_history,node_pricing,node_state toneBlue
class node_server,node_authroutes,node_userroutes,node_interviewroutes,node_paymentroutes,node_authctrl,node_userctrl,node_interviewctrl,node_paymentctrl,node_authmw,node_mongodb toneAmber
class node_users,node_interviews,node_payments,node_openrouter toneMint
class node_firebase,node_ai,node_razorservice toneRose
class node_person,node_razorpay toneIndigo
```

## Components

### Client experience

- [App routing](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Google sign-in](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/Auth.jsx): `client/src/pages/Auth.jsx`
- [Interview flow](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/InterviewPage.jsx): `client/src/pages/InterviewPage.jsx`
- [Interview setup](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/components/Step1SetUp.jsx): `client/src/components/Step1SetUp.jsx`
- [Live interview](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/components/Step2Interview.jsx): `client/src/components/Step2Interview.jsx`
- [Report view](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/components/Step3Report.jsx): `client/src/components/Step3Report.jsx`
- [Interview history](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/InterviewHistory.jsx): `client/src/pages/InterviewHistory.jsx`
- [Credit plans](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/pages/Pricing.jsx): `client/src/pages/Pricing.jsx`
- [User state](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/redux/userSlice.js): `client/src/redux/userSlice.js`

### API and workflows

- [Express API](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/index.js): `server/index.js`
- [Auth routes](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/auth.route.js): `server/routes/auth.route.js`
- [User routes](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/user.route.js): `server/routes/user.route.js`
- [Interview routes](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/interview.route.js): `server/routes/interview.route.js`
- [Payment routes](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/routes/payment.route.js): `server/routes/payment.route.js`
- [Auth workflow](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/auth.controller.js): `server/controllers/auth.controller.js`
- [Current user](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/user.controller.js): `server/controllers/user.controller.js`
- [Interview workflow](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/interview.controller.js): `server/controllers/interview.controller.js`
- [Payment workflow](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/controllers/payment.controller.js): `server/controllers/payment.controller.js`
- [JWT verification](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/middlewares/isAuth.js): `server/middlewares/isAuth.js`

### Persistence

- [User records](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/user.model.js): `server/models/user.model.js`
- [Interview records](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/interview.model.js): `server/models/interview.model.js`
- [Payment records](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/models/payment.model.js): `server/models/payment.model.js`

### External services

- [Firebase Auth](https://github.com/sahastrawin/ai-interview-agent/blob/main/client/src/utils/firebase.js): `client/src/utils/firebase.js`
- [OpenRouter AI](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/services/openRouter.service.js): `server/services/openRouter.service.js`
- [Razorpay client](https://github.com/sahastrawin/ai-interview-agent/blob/main/server/services/razorpay.service.js): `server/services/razorpay.service.js`

### Other components

- **Candidate**
- **OpenRouter service**
- **Razorpay gateway**
- **MongoDB**

## Connections

- Candidate → App routing: uses
- App routing → Google sign-in: routes to
- App routing → Interview flow: routes to
- App routing → Interview history: routes to
- App routing → Credit plans: routes to
- App routing → Report view: routes to
- Google sign-in → Firebase Auth: signs in with
- Google sign-in → Auth routes: posts credentials
- Google sign-in → User state: updates
- App routing → User routes: loads current user
- Interview flow → Interview setup: presents setup
- Interview flow → Live interview: runs session
- Interview flow → Interview routes: requests interview APIs
- Interview history → Interview routes: requests history
- Report view → Interview routes: requests report
- Credit plans → Payment routes: requests payment APIs
- Express API → Auth routes: mounts
- Express API → User routes: mounts
- Express API → Interview routes: mounts
- Express API → Payment routes: mounts
- Auth routes → Auth workflow: dispatches
- User routes → JWT verification: guards
- User routes → Current user: dispatches
- Interview routes → JWT verification: guards
- Interview routes → Interview workflow: dispatches
- Payment routes → JWT verification: guards
- Payment routes → Payment workflow: dispatches
- Auth workflow → User records: finds or creates
- Current user → User records: reads
- Interview workflow → User records: checks and deducts credits
- Interview workflow → Interview records: creates and updates
- Interview workflow → OpenRouter AI: requests parsing, questions, evaluation
- OpenRouter AI → OpenRouter service: calls
- Payment workflow → Razorpay client: creates orders
- Razorpay client → Razorpay gateway: calls
- Payment workflow → Payment records: creates and updates
- Payment workflow → User records: adds credits
- User records → MongoDB: persists in
- Interview records → MongoDB: persists in
- Payment records → MongoDB: persists in
