# adrianhajdin/ai_mock_interviews architecture

> Architecture diagram of the GitHub repository adrianhajdin/ai_mock_interviews, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adrianhajdin/ai_mock_interviews
- Repository: https://github.com/adrianhajdin/ai_mock_interviews

## Overview

##### Project type and purpose
- Project type: Full-stack web application built with Next.js (React)
- Purpose: Prepwise – a job interview preparation platform.
– Frontend for UI/UX and pages.
– Backend logic via Next.js API routes.
– Uses AI voice agents (Vapi), Google Gemini for question generation and feedback.
– Firebase for authentication and data persistence.

##### File structure
- app/
– Next.js “app router” folder containing:
- (auth) routes for sign-in / sign-up
- (root) routes for dashboard and interview flows
- api/vapi/generate/route.ts – serverless endpoint for question generation
- components/ & components/ui/
– Reusable UI components (Agent, InterviewCard, FormField, shadcn UI wrappers)
- lib/
– actions/ (auth.action.ts, general.action.ts) – business logic for Firebase and AI calls
– utils.ts – styling helpers and tech-logo resolution
– vapi.sdk.ts – wrapper around Vapi AI service
- firebase/
– admin.ts & client.ts – Firebase Admin SDK for backend and client SDK for front end
- constants/, types/
– Shared types and configuration
- public/
- Configuration files
– next.config.ts, tsconfig.json, postcss.config.mjs

##### README for additional insights
- Tech stack: Next.js, Firebase (Auth, Firestore), Tailwind CSS, Vapi AI, Google Gemini, shadcn/ui, Zod
- Features:
– Authentication via Firebase
– Interview creation with AI-generated questions
– Real-time AI-driven voice interviews (Vapi)
– Feedback scoring via Google Gemini prompt in general.action.ts

##### Key reminders
- Dynamic routing: illustrate interview/[id] and feedback subpages
- Detail interactions in lib/ (auth.action.ts vs. general.action.ts) as separate flows
- Don’t overcrowd: group related pages under one “Next.js Frontend” cluster but call out critical API routes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Frontend)" 
        direction TB
        SignIn["Sign-In Page"]:::frontend
        SignUp["Sign-Up Page"]:::frontend
        Dashboard["Dashboard Page"]:::frontend
        InterviewList["Interview List Page"]:::frontend
        InterviewDetail["Interview Detail Page"]:::frontend
        InterviewFeedback["Interview Feedback Page"]:::frontend
        FirebaseClientSDK["Firebase Client SDK"]:::service
    end

    %% Serverless/API Layer
    subgraph "Serverless/API"
        direction TB
        APIGenerate["API Route: /api/vapi/generate"]:::api
        AuthActions["Auth Actions (auth.action.ts)"]:::api
        GeneralActions["General Actions (general.action.ts)"]:::api
        VapiSDK["Vapi SDK (vapi.sdk.ts)"]:::service
        Utils["Utilities (utils.ts)"]:::service
    end

    %% Data & External Services
    subgraph "Data & External Services"
        direction TB
        FirebaseAuthService["Firebase Auth"]:::database
        FirestoreDB["Firestore Database"]:::database
        FirebaseAdminSDK["Firebase Admin SDK"]:::service
        VapiService["Vapi AI Service"]:::external
        GoogleGemini["Google Gemini AI"]:::external
        Config["Shared Constants (constants/index.ts)"]:::service
        Types["Shared Types (types/index.d.ts & types/vapi.d.ts)"]:::service
    end

    %% Data Flow Connections
    SignIn -->|"initiate auth"| FirebaseClientSDK
    SignUp -->|"initiate auth"| FirebaseClientSDK
    FirebaseClientSDK -->|"validate/login"| FirebaseAuthService
    FirebaseAuthService -->|"token"| FirebaseClientSDK
    FirebaseClientSDK -->|"fetch interviews"| FirestoreDB

    Dashboard -->|"reads interviews"| FirebaseClientSDK
    InterviewList -->|"reads interviews"| FirebaseClientSDK
    InterviewDetail -->|"reads interview data"| FirebaseClientSDK
    InterviewFeedback -->|"reads feedback data"| FirebaseClientSDK

    InterviewDetail -->|"request questions"| APIGenerate
    APIGenerate -->|"use SDK"| VapiSDK
    VapiSDK -->|"call service"| VapiService
    VapiService -->|"questions"| VapiSDK
    VapiSDK -->|"response"| APIGenerate
    APIGenerate -->|"return questions"| InterviewDetail

    InterviewFeedback -->|"request feedback"| GeneralActions
    GeneralActions -->|"call API"| GoogleGemini
    GoogleGemini -->|"feedback"| GeneralActions
    GeneralActions -->|"save feedback"| FirebaseAdminSDK
    FirebaseAdminSDK -->|"write/read"| FirestoreDB
    GeneralActions -->|"use util"| Utils

    AuthActions -->|"manage users"| FirebaseAdminSDK
    FirebaseAdminSDK -->|"admin auth ops"| FirebaseAuthService

    %% Shared config and types
    Config --> Utils
    Types --> Utils
    Types --> GeneralActions
    Types --> AuthActions
    Types --> VapiSDK

    %% Click Events
    click SignIn "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/(auth)/sign-in/page.tsx"
    click SignUp "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/(auth)/sign-up/page.tsx"
    click Dashboard "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/(root)/page.tsx"
    click InterviewList "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/(root)/interview/page.tsx"
    click InterviewDetail "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/(root)/interview/[id]/page.tsx"
    click InterviewFeedback "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/(root)/interview/[id]/feedback/page.tsx"
    click APIGenerate "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/app/api/vapi/generate/route.ts"
    click FirebaseAdminSDK "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/firebase/admin.ts"
    click FirebaseClientSDK "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/firebase/client.ts"
    click AuthActions "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/lib/actions/auth.action.ts"
    click GeneralActions "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/lib/actions/general.action.ts"
    click VapiSDK "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/lib/vapi.sdk.ts"
    click Utils "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/lib/utils.ts"
    click Config "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/constants/index.ts"
    click Types "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/types/index.d.ts"
    click Types "https://github.com/adrianhajdin/ai_mock_interviews/blob/main/types/vapi.d.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef api fill:#FCF0D6,stroke:#F0A500,stroke-width:1px
    classDef service fill:#DFFFE0,stroke:#2D8F0A,stroke-width:1px
    classDef database fill:#FFF0F0,stroke:#D7263D,stroke-width:1px
    classDef external fill:#E8F8F5,stroke:#17A2B8,stroke-width:1px
```
