# ashishghadigaonkar/ai-mock-interview architecture

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

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

## Overview

##### Project Type and Purpose
- This is a full-stack, server-rendered Next.js application (“Prepwise”) for job interview preparation.
- It uses Next.js’s new App Router (app/ directory) for UI routes and API routes, Firebase for authentication and data storage, and external AI services (Vapi AI voice agents and Google Gemini) for question generation, mock interviewing, and feedback analysis.

##### File-Structure Analysis
- Top-level folders:
- app/ – Next.js server & client components (layout.tsx, page.tsx, nested route segments for auth and interviews)
- app/api/vapi/… – API route handlers that proxy requests to Vapi AI
- components/ – reusable React UI components and shadcn/ui primitives
- lib/ – shared utilities, Vapi SDK wrapper, and server actions for feedback generation
- firebase/ – Firebase admin (server) and client configuration
- constants/, types/ – static data and TypeScript interfaces
- Key configuration: next.config.ts, tsconfig.json, postcss.config.mjs

##### README Insights
- Tech stack: Next.js, Firebase (Auth & Firestore), Tailwind CSS, Vapi AI, Google Gemini, Zod, shadcn/ui
- Features highlight: email/password auth, interview creation with voice-agent question generation, live interview simulation, AI-driven feedback, interview dashboard.

##### Main Components & Interactions
a. Frontend UI (Next.js App)
- Client-side React Components under app/ and components/
- Layouts for authenticated vs. root pages
- Pages: Sign In/Up, Dashboard, Interview Details, Feedback
b. Backend / API Layer (Next.js Server)
- Server Components and API Route handlers (app/api/vapi/generate/route.ts)
- Server Actions in lib/actions to call AI for feedback
c. Firebase Service
- Auth: signin, signup flows via firebase/client.ts
- Firestore (or Realtime DB) via firebase/admin.ts to store interview metadata, transcripts, feedback
d. External AI Services
- Vapi AI Voice Agents (generate questions, conduct voice interview)
- Google Gemini (underlying LLM used by Vapi)
e. Utilities & SDK
- lib/vapi.sdk.ts wraps Vapi REST/WebSocket calls
- lib/utils.ts for shared helpers (classnames, random covers)

##### Architectural Patterns & Design Principles
- Separation of concerns: UI components vs. API routes vs. services
- Next.js App Router: server vs. client components, colocation of route handlers
- API Proxy pattern: Next.js API routes mediate between client and Vapi AI
- “Backend for Frontend” style: Next.js server acts as BFF to Firebase and AI services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User Browser"]:::external

    %% Next.js Client UI Layer
    subgraph "UI Layer"
        direction TB
        NextApp["Next.js App Router (UI Routes & Layouts)"]:::internal
        GlobalLayout["Global App Layout (layout.tsx)"]:::internal
        GlobalStyles["Global Styles (globals.css)"]:::internal
        subgraph "Auth Pages"
            direction TB
            AuthLayout["Auth Layout (app/(auth)/layout.tsx)"]:::internal
            SignIn["Sign In Page (sign-in/page.tsx)"]:::internal
            SignUp["Sign Up Page (sign-up/page.tsx)"]:::internal
        end
        subgraph "Root Pages"
            direction TB
            RootLayout["Root Layout (app/(root)/layout.tsx)"]:::internal
            Dashboard["Dashboard (page.tsx)"]:::internal
            InterviewsList["Interviews List (interview/page.tsx)"]:::internal
            InterviewDetails["Interview Details ([id]/page.tsx)"]:::internal
            FeedbackPage["Feedback Page (feedback/page.tsx)"]:::internal
        end
    end

    %% Next.js Server BFF
    subgraph "Next.js Server (BFF)" 
        direction TB
        APIGenerate["API Route: /api/vapi/generate (route.ts)"]:::internal
        subgraph "Server Actions"
            direction TB
            AuthAction["Auth Actions (auth.action.ts)"]:::internal
            GeneralAction["General Actions (general.action.ts)"]:::internal
        end
        VapiSDK["Vapi SDK Wrapper (lib/vapi.sdk.ts)"]:::internal
        Utils["Utilities (lib/utils.ts)"]:::internal
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth & Firestore"]:::external
        VapiAI["Vapi AI Voice Agent"]:::external
        GoogleGemini["Google Gemini"]:::external
        CDN["Static Assets CDN"]:::external
    end

    %% Interactions
    User --> NextApp
    NextApp -->|"Auth Token →"| FirebaseAuth
    NextApp -->|"Fetch Assets →"| CDN
    NextApp --> NextServer
    NextServer -->|POST /api/vapi/generate| APIGenerate
    APIGenerate -->|Proxy Request| VapiAI
    VapiAI -->|Uses| GoogleGemini
    APIGenerate -->|Response: Questions| NextServer
    NextServer -->|Write Metadata| FirebaseAuth
    NextServer --> AuthAction
    NextServer --> GeneralAction
    AuthAction --> FirebaseAuth
    GeneralAction --> VapiAI
    GeneralAction --> FirebaseAuth
    NextServer --> VapiSDK
    NextServer --> Utils

    %% Click Events
    click NextApp "https://github.com/ashishghadigaonkar/ai-mock-interview/tree/main/app/"
    click GlobalLayout "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/layout.tsx"
    click GlobalStyles "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/globals.css"
    click AuthLayout "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(auth)/layout.tsx"
    click SignIn "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(auth)/sign-in/page.tsx"
    click SignUp "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(auth)/sign-up/page.tsx"
    click RootLayout "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(root)/layout.tsx"
    click Dashboard "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(root)/page.tsx"
    click InterviewsList "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(root)/interview/page.tsx"
    click InterviewDetails "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(root)/interview/[id]/page.tsx"
    click FeedbackPage "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/(root)/interview/[id]/feedback/page.tsx"
    click APIGenerate "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/app/api/vapi/generate/route.ts"
    click AuthAction "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/lib/actions/auth.action.ts"
    click GeneralAction "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/lib/actions/general.action.ts"
    click VapiSDK "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/lib/vapi.sdk.ts"
    click Utils "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/lib/utils.ts"
    click FirebaseAuth "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/firebase/client.ts"
    click FirebaseAuth "https://github.com/ashishghadigaonkar/ai-mock-interview/blob/main/firebase/admin.ts"

    %% Styles
    classDef internal fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef external fill:#E8F5E9,stroke:#A5D6A7,stroke-width:1px
    class NextApp,GlobalLayout,GlobalStyles,AuthLayout,SignIn,SignUp,RootLayout,Dashboard,InterviewsList,InterviewDetails,FeedbackPage,APIGenerate,AuthAction,GeneralAction,VapiSDK,Utils internal
    class User,FirebaseAuth,VapiAI,GoogleGemini,CDN external
```
