# code100x/ai-interviewer architecture

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

- Interactive diagram: https://gitdiagram.com/code100x/ai-interviewer
- Repository: https://github.com/code100x/ai-interviewer

## Overview

#### Purpose and Topology
AI Interviewer is a Bun/Turbo monorepo implementing an AI-driven interview workflow: a browser client collects interview setup and conducts a voice-oriented session; a backend orchestrates interview generation, persistence, repository context, and result/feedback delivery. Main applications are `apps/frontend` and `apps/backend`.

#### Backend Service and API Boundary
The backend entry point is `apps/backend/index.ts`; an alternate/experimental entry appears in `apps/backend/index2.js`. It exposes the server-side API consumed by the frontend and owns orchestration boundaries between client requests, AI interaction, persistence, and external repository data. Shared backend request/result shapes are represented in `apps/backend/types.ts` and `apps/backend/result.ts`.

#### Interview Orchestration
The central backend flow appears to be: receive interview parameters, establish or retrieve interview state, run the interview interaction, and return/store an evaluation result. Sideband communication logic is isolated in `apps/backend/sideband.ts`, separating server-controlled session/event handling from the browser-facing connection. This is the critical control-plane boundary for real-time AI interview behavior.

#### Persistence and Interview Records
Prisma provides the data-access layer through `apps/backend/db.ts` and `apps/backend/prisma/schema.prisma`. Versioned migrations show the domain evolved from initial storage to time-related fields and feedback capture: `apps/backend/prisma/migrations/20260512204521_init/migration.sql`, `apps/backend/prisma/migrations/20260607215140_added_time/migration.sql`, and `apps/backend/prisma/migrations/20260607224558_added_feedback/migration.sql`. The database is the durable source for interview lifecycle state and generated feedback.

#### External Context Acquisition
GitHub repository scraping is isolated behind `apps/backend/scrapers/github.ts`. This forms an external-service boundary: interview setup or evaluation can enrich prompts/context from a supplied GitHub repository without embedding provider-specific retrieval logic in API or database code.

#### Frontend Application Flow
The browser app mounts from `apps/frontend/src/frontend.tsx` / `apps/frontend/src/index.ts` and composes its primary experience in `apps/frontend/src/App.tsx`. The UI progresses through setup input, interview participation, and output review via `apps/frontend/src/components/Form.tsx`, `apps/frontend/src/components/Interview.tsx`, and `apps/frontend/src/components/Result.tsx`. `apps/frontend/src/components/VoiceOrb.tsx` is the focused presentation component for voice/session state.

#### Runtime, Build, and Shared Foundations
Bun is the material runtime across the repository, with the frontend built through `apps/frontend/build.ts` and backend dependencies defined in `apps/backend/package.json`. Turbo coordinates workspace tasks via `turbo.json`. Reusable UI primitives are separately packaged in `packages/ui/src/button.tsx` and `packages/ui/src/card.tsx`; shared linting and TypeScript policy reside in `packages/eslint-config` and `packages/typescript-config`.

Main entry points: [`apps/backend/index.ts`](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/index.ts) (Backend API), [`apps/frontend/src/App.tsx`](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/App.tsx) (Application shell), [`apps/frontend/src/components/Interview.tsx`](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Interview.tsx) (Interview session), [`apps/backend/sideband.ts`](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/sideband.ts) (Interview orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser client"]
  node_browser_entry["Browser entry<br/>React entry<br/>[frontend.tsx]"]
  node_app["Application shell<br/>React composition<br/>[App.tsx]"]
  node_setup_form["Interview setup<br/>UI flow<br/>[Form.tsx]"]
  node_interview_ui["Interview session<br/>UI flow<br/>[Interview.tsx]"]
  node_voice_orb["Voice state<br/>presentation component<br/>[VoiceOrb.tsx]"]
  node_result_ui["Result review<br/>UI flow<br/>[Result.tsx]"]
end

subgraph group_backend["Backend service"]
  node_backend_api{{"Backend API<br/>Bun server<br/>[index.ts]"}}
  node_contracts["Request and result contracts<br/>shared backend types<br/>[types.ts]"]
  node_interview_orchestrator["Interview orchestration<br/>control plane<br/>[sideband.ts]"]
  node_github_scraper{{"GitHub context retrieval<br/>external adapter<br/>[github.ts]"}}
end

subgraph group_data["Persistence"]
  node_prisma_access["Prisma data access<br/>database adapter<br/>[db.ts]"]
  node_interview_store[("Interview records<br/>durable data model<br/>[schema.prisma]")]
end

subgraph group_foundation["Workspace foundation"]
  node_frontend_build["Frontend build<br/>Bun build script<br/>[build.ts]"]
  node_turbo["Turbo workspace tasks<br/>task orchestrator<br/>[turbo.json]"]
  node_ui_primitives["UI primitives<br/>shared component package<br/>[button.tsx]"]
end

node_browser_entry -->|"mounts"| node_app
node_app -->|"composes"| node_setup_form
node_app -->|"composes"| node_interview_ui
node_app -->|"composes"| node_result_ui
node_interview_ui -->|"shows session state"| node_voice_orb
node_setup_form -->|"submits parameters"| node_backend_api
node_interview_ui -->|"conducts session"| node_backend_api
node_result_ui -->|"retrieves evaluation"| node_backend_api
node_backend_api -->|"uses"| node_contracts
node_backend_api -->|"delegates session control"| node_interview_orchestrator
node_interview_orchestrator -->|"enriches with repository context"| node_github_scraper
node_interview_orchestrator -->|"loads and saves state"| node_prisma_access
node_prisma_access -->|"persists"| node_interview_store
node_app -->|"uses"| node_ui_primitives
node_frontend_build -->|"builds"| node_browser_entry
node_turbo -->|"coordinates"| node_frontend_build
node_turbo -->|"coordinates"| node_backend_api

click node_browser_entry "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/frontend.tsx"
click node_app "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/App.tsx"
click node_setup_form "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Form.tsx"
click node_interview_ui "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Interview.tsx"
click node_voice_orb "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/VoiceOrb.tsx"
click node_result_ui "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Result.tsx"
click node_backend_api "https://github.com/code100x/ai-interviewer/blob/main/apps/backend/index.ts"
click node_contracts "https://github.com/code100x/ai-interviewer/blob/main/apps/backend/types.ts"
click node_interview_orchestrator "https://github.com/code100x/ai-interviewer/blob/main/apps/backend/sideband.ts"
click node_github_scraper "https://github.com/code100x/ai-interviewer/blob/main/apps/backend/scrapers/github.ts"
click node_prisma_access "https://github.com/code100x/ai-interviewer/blob/main/apps/backend/db.ts"
click node_interview_store "https://github.com/code100x/ai-interviewer/blob/main/apps/backend/prisma/schema.prisma"
click node_frontend_build "https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/build.ts"
click node_turbo "https://github.com/code100x/ai-interviewer/blob/main/turbo.json"
click node_ui_primitives "https://github.com/code100x/ai-interviewer/blob/main/packages/ui/src/button.tsx"

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_browser_entry,node_app,node_setup_form,node_interview_ui,node_voice_orb,node_result_ui toneBlue
class node_backend_api,node_contracts,node_interview_orchestrator,node_github_scraper toneAmber
class node_prisma_access,node_interview_store toneMint
class node_frontend_build,node_turbo,node_ui_primitives toneRose
```

## Components

### Browser client

- [Browser entry](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/frontend.tsx): React entry · `apps/frontend/src/frontend.tsx`
- [Application shell](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/App.tsx): React composition · `apps/frontend/src/App.tsx`
- [Interview setup](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Form.tsx): UI flow · `apps/frontend/src/components/Form.tsx`
- [Interview session](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Interview.tsx): UI flow · `apps/frontend/src/components/Interview.tsx`
- [Voice state](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/VoiceOrb.tsx): presentation component · `apps/frontend/src/components/VoiceOrb.tsx`
- [Result review](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/src/components/Result.tsx): UI flow · `apps/frontend/src/components/Result.tsx`

### Backend service

- [Backend API](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/index.ts): Bun server · Client-facing orchestration boundary. · `apps/backend/index.ts`
- [Request and result contracts](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/types.ts): shared backend types · `apps/backend/types.ts`
- [Interview orchestration](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/sideband.ts): control plane · Establishes state, drives interaction, and produces evaluation. · `apps/backend/sideband.ts`
- [GitHub context retrieval](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/scrapers/github.ts): external adapter · `apps/backend/scrapers/github.ts`

### Persistence

- [Prisma data access](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/db.ts): database adapter · `apps/backend/db.ts`
- [Interview records](https://github.com/code100x/ai-interviewer/blob/main/apps/backend/prisma/schema.prisma): durable data model · Stores lifecycle state and generated feedback. · `apps/backend/prisma/schema.prisma`

### Workspace foundation

- [Frontend build](https://github.com/code100x/ai-interviewer/blob/main/apps/frontend/build.ts): Bun build script · `apps/frontend/build.ts`
- [Turbo workspace tasks](https://github.com/code100x/ai-interviewer/blob/main/turbo.json): task orchestrator · `turbo.json`
- [UI primitives](https://github.com/code100x/ai-interviewer/blob/main/packages/ui/src/button.tsx): shared component package · `packages/ui/src/button.tsx`

## Connections

- Browser entry → Application shell: mounts
- Application shell → Interview setup: composes
- Application shell → Interview session: composes
- Application shell → Result review: composes
- Interview session → Voice state: shows session state
- Interview setup → Backend API: submits parameters
- Interview session → Backend API: conducts session
- Result review → Backend API: retrieves evaluation
- Backend API → Request and result contracts: uses
- Backend API → Interview orchestration: delegates session control
- Interview orchestration → GitHub context retrieval: enriches with repository context
- Interview orchestration → Prisma data access: loads and saves state
- Prisma data access → Interview records: persists
- Application shell → UI primitives: uses
- Frontend build → Browser entry: builds
- Turbo workspace tasks → Frontend build: coordinates
- Turbo workspace tasks → Backend API: coordinates
