# thedarkking01/ai-interview-prep architecture

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

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

## Overview

##### Project Overview & Components
- This is a full-stack web application built with Next.js that assists users in preparing for technical interviews using AI technologies. It features secure authentication via Firebase, interactive AI-driven interviews (using VAPI AI and Google Gemini), and a modern, responsive UI enhanced with ShadCN/UI and Tailwind CSS.
- The application is structured with clear distinctions between different functional areas such as authentication, interview management, and API endpoints.

##### Main Components
a. Frontend User Interface:
- Pages & Layouts: Represent the Next.js “app” directory structure, showing separate layouts for (auth) and (root) sections.
- Authentication Pages: Sign-up and sign-in pages (under app/(auth)), handling user login and registration.
- Interview Pages: Including interview creation, the live interview page (with AI-driven interactions), and feedback display pages.
- Components & UI Elements: Nodes representing reusable components (e.g., AuthForm, InterviewCard, Agent, FormField) and UI libraries (coming from components/ui folder and usage of ShadCN/UI).
- Global Styling: The global styles from app/globals.css and Tailwind CSS integration.

b. Backend / API & Server-side Logic:
- API Routes: Within app/api/vapi, specifically the generate route used to create interview questions powered by VAPI AI.
- Server-side Logic: Business logic implemented in lib (actions for authentication and interview feedback) and utility functions in lib/utils.ts.
- Authentication Backend: Firebase integration found in firebase/admin.ts and firebase/client.ts processes handling authentication, session management, and potential realtime functionality.

c. External Services & Integrations:
- VAPI AI: Responsible for generating interview questions (and possibly powering voice interactions).
- Google Gemini: Used for providing advanced AI feedback and coaching.
- Firebase: For authenticating users and managing their data.

d. Supporting Modules:
- Constants and Type Definitions: In directories such as constants and types, ensuring data integrity (with Zod) and type safety across the application.

##### Relationships & Data Flow
- A clear connection from the backend (API & server-side actions) to Firebase for managing authentication and possibly to external APIs (VAPI AI and Google Gemini) for generating content and feedback.
- User actions → Frontend (Next.js Pages/Components) → API Endpoints/Backend Logic → External Service (Firebase/VAPI/Google Gemini) → Response back to frontend.

##### Architectural Patterns & Design Principles
- MVC-like Separation: Maintain clear separation between view (app pages and components), business logic (lib/actions, API routes), and integration (firebase and external services).

##### Implementation Steps
- Drill down into each major component:
- For UI, illustrate the separate flows for authentication (app/(auth)) and main application pages (app/(root)).
- For backend, detail the API route that uses VAPI AI and the logic handling interactions (lib/actions).
- How Firebase authentication integrates with both the client (firebase/client.ts) and server side (firebase/admin.ts).

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User"]:::user

    subgraph "Presentation Layer"
        GL["Global Layout"]:::frontend
        GS["Global Styles"]:::frontend
        ALAuth["Auth Layout"]:::frontend
        SIP["Sign-In Page"]:::frontend
        SUP["Sign-Up Page"]:::frontend
        RL["Root Layout"]:::frontend
        HP["Home Page"]:::frontend
        IV["Interview Page"]:::frontend
        ID["Interview Detail Page"]:::frontend
        FP["Feedback Page"]:::frontend
        AF["AuthForm Component"]:::frontend
        IC["InterviewCard Component"]:::frontend
        AG["Agent Component"]:::frontend
        FF["FormField Component"]:::frontend
        DT["DisplayTechIcons Component"]:::frontend
        UB["UIButton (UI Library)"]:::frontend
        UF["UIForm (UI Library)"]:::frontend
        UI["UIInput (UI Library)"]:::frontend
        UL["UILabel (UI Library)"]:::frontend
        US["UISonner (UI Library)"]:::frontend
    end

    subgraph "Application Layer"
        API["API Route: /vapi/generate"]:::backend
        AA["Auth Action"]:::backend
        GA["General Action"]:::backend
        UT["Utils"]:::backend
        SDK["VAPI SDK"]:::backend
    end

    subgraph "Supporting Modules"
        CM["Constants"]:::backend
        TD["Type Definitions"]:::backend
    end

    subgraph "Infrastructure Layer"
        FClient["Firebase (Client)"]:::infra
        FAdmin["Firebase (Admin)"]:::infra
        VAPI["VAPI AI"]:::infra
        Gemini["Google Gemini"]:::infra
    end

    %% Flow from User to Presentation Layer
    U --> GL
    U --> GS
    U --> ALAuth
    U --> SIP
    U --> SUP
    U --> RL
    U --> HP
    U --> IV
    U --> ID
    U --> FP
    U --> AF
    U --> IC
    U --> AG
    U --> FF
    U --> DT
    U --> UB
    U --> UF
    U --> UI
    U --> UL
    U --> US

    %% Presentation Layer to Application Layer
    HP -->|"API_Call"| API
    IV -->|"API_Call"| API
    SIP -->|"API_Call"| API
    SUP -->|"API_Call"| API
    AF -->|"API_Call"| API
    IC -->|"API_Call"| API

    %% API Route to Business Logic
    API -->|"Triggers"| AA
    API -->|"Triggers"| GA
    API -->|"Uses"| UT
    API -->|"Uses"| SDK

    %% Business Logic to Supporting Modules
    AA --> CM
    AA --> TD
    GA --> CM
    GA --> TD
    UT --> CM
    UT --> TD
    SDK --> CM
    SDK --> TD

    %% Business Logic and Presentation interactions with Infrastructure
    AA -->|"Calls"| FAdmin
    SIP -->|"Client_Auth"| FClient
    SUP -->|"Client_Auth"| FClient
    GA -->|"Generates"| VAPI
    GA -->|"Feedback"| Gemini

    %% Styling definitions
    classDef user fill:#fefea1,stroke:#333,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef backend fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef infra fill:#f9d6ac,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend User Interface – Pages & Layouts
    click GL "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/layout.tsx"
    click GS "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/globals.css"
    click ALAuth "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(auth)/layout.tsx"
    click SIP "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(auth)/sign-in/page.tsx"
    click SUP "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(auth)/sign-up/page.tsx"
    click RL "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(root)/layout.tsx"
    click HP "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(root)/page.tsx"
    click IV "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(root)/interview/page.tsx"
    click ID "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(root)/interview/[id]/page.tsx"
    click FP "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/(root)/interview/[id]/feedback/page.tsx"

    %% Click Events for UI Components & Elements
    click AF "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/AuthForm.tsx"
    click IC "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/InterviewCard.tsx"
    click AG "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/Agent.tsx"
    click FF "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/FormField.tsx"
    click DT "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/DisplayTechIcons.tsx"
    click UB "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/ui/button.tsx"
    click UF "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/ui/form.tsx"
    click UI "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/ui/input.tsx"
    click UL "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/ui/label.tsx"
    click US "https://github.com/thedarkking01/ai-interview-prep/blob/main/components/ui/sonner.tsx"

    %% Click Events for Backend / API & Server-side Logic
    click API "https://github.com/thedarkking01/ai-interview-prep/blob/main/app/api/vapi/generate/route.ts"
    click AA "https://github.com/thedarkking01/ai-interview-prep/blob/main/lib/actions/auth.action.ts"
    click GA "https://github.com/thedarkking01/ai-interview-prep/blob/main/lib/actions/general.action.ts"
    click UT "https://github.com/thedarkking01/ai-interview-prep/blob/main/lib/utils.ts"
    click SDK "https://github.com/thedarkking01/ai-interview-prep/blob/main/lib/vapi.sdk.ts"

    %% Click Events for Authentication Backend
    click FClient "https://github.com/thedarkking01/ai-interview-prep/blob/main/firebase/client.ts"
    click FAdmin "https://github.com/thedarkking01/ai-interview-prep/blob/main/firebase/admin.ts"

    %% Click Events for Supporting Modules
    click CM "https://github.com/thedarkking01/ai-interview-prep/blob/main/constants/index.ts"
    click TD "https://github.com/thedarkking01/ai-interview-prep/blob/main/types/index.d.ts"
    %% Additional Type Definitions for VAPI
    subgraph "Extra Types" [ ]
        T2["VAPI Types"]:::backend
    end
    click T2 "https://github.com/thedarkking01/ai-interview-prep/blob/main/types/vapi.d.ts"
```
