# chetan1930/ai-interview architecture

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

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

## Overview

PrepAI is a Next.js interview-preparation and resume-analysis application. Its main workflow collects a job description or role, generates tailored preparation material, and presents it for study; separate flows support mock interviews, chat imports, and resume feedback. Authentication and API-key management support these features, while session history is exposed through API routes and MongoDB models. The README describes locally persisted browser state, but sampled code also includes database-backed session APIs. Some UI-to-API links are documented broadly rather than shown in sampled route calls.

Main entry points: [`lib/ai.ts`](https://github.com/chetan1930/ai-interview/blob/master/lib/ai.ts) (AI Generation), [`app/api/sessions/route.ts`](https://github.com/chetan1930/ai-interview/blob/master/app/api/sessions/route.ts) (Session API), [`lib/mongodb.ts`](https://github.com/chetan1930/ai-interview/blob/master/lib/mongodb.ts) (MongoDB Connector), [`app/api/keys/route.ts`](https://github.com/chetan1930/ai-interview/blob/master/app/api/keys/route.ts) (Key Management API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Interview Preparation"]
  node_jdprep["JD Preparation<br/>[page.tsx]"]
  node_roleprep["Role Preparation<br/>[page.tsx]"]
  node_prepresults["Prep Results"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
end

subgraph group_practice["Practice and Imports"]
  node_mock["Mock Interview<br/>[page.tsx]"]
  node_chatimport["Chat Import<br/>[page.tsx]"]
  node_chatview["Chat Messages<br/>[chat-message.tsx]"]
  node_voice["Voice Recorder<br/>[voice-recorder.tsx]"]
end

subgraph group_resume["Resume Analysis"]
  node_resumeui["Resume Analyzer<br/>[page.tsx]"]
  node_resumeupload["Resume Upload<br/>[resume-upload.tsx]"]
  node_resumeresults["Resume Results"]
end

subgraph group_platform["Accounts and Settings"]
  node_login["Login and Signup<br/>[page.tsx]"]
  node_authcontext["Auth Context<br/>[auth.tsx]"]
  node_authapi["Auth API<br/>[route.ts]"]
  node_keysettings["API Key Settings<br/>[page.tsx]"]
  node_keyapi["Key Management API<br/>[route.ts]"]
end

subgraph group_core["AI and Data"]
  node_sessionsapi["Session API<br/>[route.ts]"]
  node_sessionmodel[("Session Records<br/>[Session.ts]")]
  node_aimodule["AI Generation<br/>[ai.ts]"]
  node_prompts["Prompt Builders<br/>[prompts.ts]"]
  node_providerkeys[("Provider Keys<br/>[ApiKey.ts]")]
  node_mongodb["MongoDB Connector<br/>[mongodb.ts]"]
end

node_candidate(("Candidate"))
node_gemini["Google Gemini"]
node_openai["OpenAI"]
node_anthropic["Anthropic"]

node_candidate -->|"enters JD"| node_jdprep
node_candidate -->|"enters role"| node_roleprep
node_jdprep -->|"requests generation"| node_aimodule
node_roleprep -->|"requests generation"| node_aimodule
node_aimodule -.->|"returns prep"| node_prepresults
node_candidate -->|"starts practice"| node_mock
node_mock -->|"renders messages"| node_chatview
node_mock -->|"uses recorder"| node_voice
node_candidate -->|"imports conversation"| node_chatimport
node_chatimport -->|"loads recent imports"| node_sessionsapi
node_candidate -->|"analyzes resume"| node_resumeui
node_resumeui -.->|"accepts resume"| node_resumeupload
node_resumeui -->|"requests analysis"| node_aimodule
node_aimodule -.->|"returns analysis"| node_resumeresults
node_candidate -->|"signs in"| node_login
node_login -->|"calls auth"| node_authcontext
node_authapi -->|"connects database"| node_mongodb
node_authapi -.->|"serves auth requests"| node_authcontext
node_candidate -.->|"manages keys"| node_keysettings
node_keyapi -->|"connects database"| node_mongodb
node_keyapi -->|"reads and writes"| node_providerkeys
node_keyapi -.->|"provides key records"| node_aimodule
node_aimodule -->|"loads user keys"| node_providerkeys
node_aimodule -->|"connects for keys"| node_mongodb
node_sessionsapi -->|"connects database"| node_mongodb
node_sessionsapi -->|"reads and writes"| node_sessionmodel
node_dashboard -.->|"shows recent sessions"| node_sessionsapi
node_aimodule -->|"builds prompts"| node_prompts
node_aimodule -->|"generates content"| node_gemini
node_aimodule -->|"generates content"| node_openai
node_aimodule -->|"generates content"| node_anthropic

click node_jdprep "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/interview-prep/page.tsx"
click node_roleprep "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/interview-prep/page.tsx"
click node_prepresults "https://github.com/chetan1930/ai-interview/blob/master/components/interview/interview-results.tsx"
click node_dashboard "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/dashboard/page.tsx"
click node_mock "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/voice-interview/page.tsx"
click node_chatimport "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/chat-import/page.tsx"
click node_chatview "https://github.com/chetan1930/ai-interview/blob/master/components/chat/chat-message.tsx"
click node_voice "https://github.com/chetan1930/ai-interview/blob/master/components/voice/voice-recorder.tsx"
click node_resumeui "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/resume-analyzer/page.tsx"
click node_resumeupload "https://github.com/chetan1930/ai-interview/blob/master/components/resume/resume-upload.tsx"
click node_resumeresults "https://github.com/chetan1930/ai-interview/blob/master/components/resume/analysis-results.tsx"
click node_login "https://github.com/chetan1930/ai-interview/blob/master/app/login/page.tsx"
click node_authcontext "https://github.com/chetan1930/ai-interview/blob/master/contexts/auth.tsx"
click node_authapi "https://github.com/chetan1930/ai-interview/blob/master/app/api/auth/signup/route.ts"
click node_keysettings "https://github.com/chetan1930/ai-interview/blob/master/app/(app)/settings/page.tsx"
click node_keyapi "https://github.com/chetan1930/ai-interview/blob/master/app/api/keys/route.ts"
click node_sessionsapi "https://github.com/chetan1930/ai-interview/blob/master/app/api/sessions/route.ts"
click node_sessionmodel "https://github.com/chetan1930/ai-interview/blob/master/lib/models/Session.ts"
click node_aimodule "https://github.com/chetan1930/ai-interview/blob/master/lib/ai.ts"
click node_prompts "https://github.com/chetan1930/ai-interview/blob/master/lib/prompts.ts"
click node_providerkeys "https://github.com/chetan1930/ai-interview/blob/master/lib/models/ApiKey.ts"
click node_mongodb "https://github.com/chetan1930/ai-interview/blob/master/lib/mongodb.ts"

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_jdprep,node_roleprep,node_prepresults,node_dashboard toneBlue
class node_mock,node_chatimport,node_chatview,node_voice toneAmber
class node_resumeui,node_resumeupload,node_resumeresults toneMint
class node_login,node_authcontext,node_authapi,node_keysettings,node_keyapi toneRose
class node_sessionsapi,node_sessionmodel,node_aimodule,node_prompts,node_providerkeys,node_mongodb,node_candidate,node_gemini,node_openai,node_anthropic toneIndigo
```

## Components

### Interview Preparation

- [JD Preparation](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/interview-prep/page.tsx): `app/(app)/interview-prep/page.tsx`
- [Role Preparation](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/interview-prep/page.tsx): `app/(app)/interview-prep/page.tsx`
- [Prep Results](https://github.com/chetan1930/ai-interview/blob/master/components/interview/interview-results.tsx): `components/interview/interview-results.tsx`
- [Dashboard](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`

### Practice and Imports

- [Mock Interview](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/voice-interview/page.tsx): `app/(app)/voice-interview/page.tsx`
- [Chat Import](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/chat-import/page.tsx): `app/(app)/chat-import/page.tsx`
- [Chat Messages](https://github.com/chetan1930/ai-interview/blob/master/components/chat/chat-message.tsx): `components/chat/chat-message.tsx`
- [Voice Recorder](https://github.com/chetan1930/ai-interview/blob/master/components/voice/voice-recorder.tsx): `components/voice/voice-recorder.tsx`

### Resume Analysis

- [Resume Analyzer](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/resume-analyzer/page.tsx): `app/(app)/resume-analyzer/page.tsx`
- [Resume Upload](https://github.com/chetan1930/ai-interview/blob/master/components/resume/resume-upload.tsx): `components/resume/resume-upload.tsx`
- [Resume Results](https://github.com/chetan1930/ai-interview/blob/master/components/resume/analysis-results.tsx): `components/resume/analysis-results.tsx`

### Accounts and Settings

- [Login and Signup](https://github.com/chetan1930/ai-interview/blob/master/app/login/page.tsx): `app/login/page.tsx`
- [Auth Context](https://github.com/chetan1930/ai-interview/blob/master/contexts/auth.tsx): `contexts/auth.tsx`
- [Auth API](https://github.com/chetan1930/ai-interview/blob/master/app/api/auth/signup/route.ts): `app/api/auth/signup/route.ts`
- [API Key Settings](https://github.com/chetan1930/ai-interview/blob/master/app/(app)/settings/page.tsx): `app/(app)/settings/page.tsx`
- [Key Management API](https://github.com/chetan1930/ai-interview/blob/master/app/api/keys/route.ts): `app/api/keys/route.ts`

### AI and Data

- [Session API](https://github.com/chetan1930/ai-interview/blob/master/app/api/sessions/route.ts): `app/api/sessions/route.ts`
- [Session Records](https://github.com/chetan1930/ai-interview/blob/master/lib/models/Session.ts): `lib/models/Session.ts`
- [AI Generation](https://github.com/chetan1930/ai-interview/blob/master/lib/ai.ts): `lib/ai.ts`
- [Prompt Builders](https://github.com/chetan1930/ai-interview/blob/master/lib/prompts.ts): `lib/prompts.ts`
- [Provider Keys](https://github.com/chetan1930/ai-interview/blob/master/lib/models/ApiKey.ts): `lib/models/ApiKey.ts`
- [MongoDB Connector](https://github.com/chetan1930/ai-interview/blob/master/lib/mongodb.ts): `lib/mongodb.ts`

### Other components

- **Candidate**
- **Google Gemini**
- **OpenAI**
- **Anthropic**

## Connections

- Candidate → JD Preparation: enters JD (evidence: `README.md`)
- Candidate → Role Preparation: enters role (evidence: `README.md`)
- JD Preparation → AI Generation: requests generation (evidence: `README.md`)
- Role Preparation → AI Generation: requests generation (evidence: `README.md`)
- AI Generation → Prep Results: returns prep
- Candidate → Mock Interview: starts practice (evidence: `README.md`)
- Mock Interview → Chat Messages: renders messages (evidence: `app/(app)/voice-interview/page.tsx`)
- Mock Interview → Voice Recorder: uses recorder (evidence: `app/(app)/voice-interview/page.tsx`)
- Candidate → Chat Import: imports conversation (evidence: `app/(app)/chat-import/page.tsx`)
- Chat Import → Session API: loads recent imports (evidence: `app/(app)/chat-import/page.tsx`)
- Candidate → Resume Analyzer: analyzes resume (evidence: `README.md`)
- Resume Analyzer → Resume Upload: accepts resume
- Resume Analyzer → AI Generation: requests analysis (evidence: `README.md`)
- AI Generation → Resume Results: returns analysis
- Candidate → Login and Signup: signs in (evidence: `app/login/page.tsx`)
- Login and Signup → Auth Context: calls auth (evidence: `app/login/page.tsx`)
- Auth API → MongoDB Connector: connects database (evidence: `app/api/auth/signup/route.ts`)
- Auth API → Auth Context: serves auth requests
- Candidate → API Key Settings: manages keys
- Key Management API → MongoDB Connector: connects database (evidence: `app/api/keys/route.ts`)
- Key Management API → Provider Keys: reads and writes (evidence: `app/api/keys/route.ts`)
- Key Management API → AI Generation: provides key records
- AI Generation → Provider Keys: loads user keys (evidence: `lib/ai.ts`)
- AI Generation → MongoDB Connector: connects for keys (evidence: `lib/ai.ts`)
- Session API → MongoDB Connector: connects database (evidence: `app/api/sessions/route.ts`)
- Session API → Session Records: reads and writes (evidence: `app/api/sessions/route.ts`)
- Dashboard → Session API: shows recent sessions
- AI Generation → Prompt Builders: builds prompts (evidence: `lib/ai.ts`)
- AI Generation → Google Gemini: generates content (evidence: `lib/ai.ts`)
- AI Generation → OpenAI: generates content (evidence: `lib/ai.ts`)
- AI Generation → Anthropic: generates content (evidence: `lib/ai.ts`)
