# saiguggilla2004/interview-prep architecture

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

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

## Overview

##### Project type and purpose
- This is a full-stack Next.js application using the App Router.
- It provides user authentication (sign-in, sign-up) and interview management pages (viewing interviews by ID, giving feedback).
- It exposes a custom API endpoint under `/app/api/vapi/generate` and integrates with Firebase (for auth) and an external “vapi” service via a custom SDK.

##### File structure
Top-level directories/files and their roles:
- app/
– Contains Next.js “app router” pages and layouts.
– `(auth)` subfolder: sign-in, sign-up flows (client-side)
– `(root)` subfolder: main app post-auth, dynamic interview routes, feedback pages
– app/api/vapi/generate: a serverless API route to invoke the vapi generation endpoint
- components/
– Reusable React components (UI and domain-specific)
– ui/ subfolder: styled primitives (button, input, form, label)
- lib/
– Business logic actions (`auth.action.ts`, `general.action.ts`)
– Utility functions (`utils.ts`) and the vapi SDK (`vapi.sdk.ts`)
- firebase/
– Admin and client SDK configurations for Firebase Auth
- constants/, types/
– Shared constants and TypeScript definitions
- public/
– Static assets (e.g., cover images)
- Config files: next.config.ts, tailwind.config.js, postcss.config.mjs, tsconfig.json

##### README insights
- Standard Next.js boilerplate, optimized font loading, Vercel deployment.

##### Components & interactions
a. Main components:
1) Browser (React UI in Next.js pages and components)
2) Next.js Server (App Router + server-side rendering + API routes)
3) Firebase Auth (client SDK for sign-in/up, admin SDK for server-side token verification)
4) External “vapi” service (via `lib/vapi.sdk.ts`)
5) Internal business-logic layer (`lib/actions`)
6) Static asset store (public/)
b. Relationships and data flows:
- Browser ↔ Next.js UI (page navigation, form submissions)
- Browser → Firebase client SDK → Firebase Auth (user sign-in/up)
- Browser ↔ Next.js API routes (e.g., POST `/api/vapi/generate`)
- API route → lib/vapi.sdk → External vapi service
- Next.js server → Firebase admin SDK (validate tokens / protect routes)
- UI components consume data from Next.js server or call client actions in lib/actions
c. Architectural patterns & principles:
– Next.js App Router (file-based routing, server & client components)
– Separation of concerns: pages (routing/controllers), components (views), lib (services/models)
– Use of serverless functions for backend logic (`app/api/...`)
– Authentication middleware via Firebase
d. Key technologies/frameworks:
– Next.js (React, App Router, SSR/SSG)
– React components + TypeScript
– Tailwind CSS (via `tailwind.config.js`)
– Firebase Auth (client & admin)
– External vapi service (via custom SDK)
– Sonner (toast UI)

##### Detailed capture
– Show how `lib/actions` and `lib/vapi.sdk` plug into both client and server contexts.
– Include the public asset store feeding static content to the UI.
– Emphasize separation: components/ui vs. domain components vs. layouts.
– Optionally denote middleware or layout wrappers (`app/layout.tsx`, `(auth)/layout.tsx`).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser
    subgraph "Browser (Client)"
        Browser["Browser"]:::frontend
        FirebaseClient["Firebase Client SDK"]:::external
    end

    %% Next.js Server
    subgraph "Next.js Server"
        %% Global Layout
        GlobalLayout["App Layout (app/layout.tsx)"]:::frontend

        subgraph "UI Layer"
            AuthLayout["Auth Layout"]:::frontend
            SignIn["Sign-In Page"]:::frontend
            SignUp["Sign-Up Page"]:::frontend
            RootLayout["Root Layout"]:::frontend
            RootPage["Main Page"]:::frontend
            InterviewList["Interview List"]:::frontend
            InterviewDetail["Interview Detail"]:::frontend
            Feedback["Feedback Page"]:::frontend
            PublicAssets["Static Assets (public/)"]:::external
        end

        subgraph "API Layer"
            VapiEndpoint["POST /api/vapi/generate"]:::backend
        end

        subgraph "Business Logic"
            AuthAction["auth.action.ts"]:::backend
            GeneralAction["general.action.ts"]:::backend
            VapiSDK["vapi.sdk.ts"]:::backend
            Utils["utils.ts"]:::backend
        end
    end

    %% External Services
    subgraph "External Services"
        FirebaseAuth["Firebase Auth"]:::external
        AdminSDK["Firebase Admin SDK"]:::external
        VapiService["External vapi Service"]:::external
    end

    %% Connections
    Browser --> SignIn
    Browser --> SignUp
    Browser --> RootPage
    Browser --> VapiEndpoint
    SignIn -->|uses| FirebaseClient
    SignUp -->|uses| FirebaseClient
    FirebaseClient --> FirebaseAuth
    VapiEndpoint --> VapiSDK
    VapiSDK --> VapiService
    VapiEndpoint --> AuthAction
    VapiEndpoint --> GeneralAction
    VapiEndpoint --> AdminSDK
    RootPage --> AdminSDK
    InterviewList --> AdminSDK
    InterviewDetail --> AdminSDK
    Feedback --> AdminSDK
    PublicAssets --> SignIn
    PublicAssets --> SignUp
    PublicAssets --> RootPage
    PublicAssets --> InterviewList
    PublicAssets --> InterviewDetail
    PublicAssets --> Feedback

    %% Click Events
    click SignIn "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(auth)/sign-in/page.tsx"
    click SignUp "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(auth)/sign-up/page.tsx"
    click AuthLayout "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(auth)/layout.tsx"
    click RootPage "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(root)/page.tsx"
    click RootLayout "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(root)/layout.tsx"
    click InterviewList "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(root)/interview/page.tsx"
    click InterviewDetail "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(root)/interview/[id]/page.tsx"
    click Feedback "https://github.com/saiguggilla2004/interview-prep/blob/main/app/(root)/interview/[id]/feedback/page.tsx"
    click VapiEndpoint "https://github.com/saiguggilla2004/interview-prep/blob/main/app/api/vapi/generate/route.ts"
    click FirebaseClient "https://github.com/saiguggilla2004/interview-prep/blob/main/firebase/client.ts"
    click AdminSDK "https://github.com/saiguggilla2004/interview-prep/blob/main/firebase/admin.ts"
    click VapiSDK "https://github.com/saiguggilla2004/interview-prep/blob/main/lib/vapi.sdk.ts"
    click AuthAction "https://github.com/saiguggilla2004/interview-prep/blob/main/lib/actions/auth.action.ts"
    click GeneralAction "https://github.com/saiguggilla2004/interview-prep/blob/main/lib/actions/general.action.ts"
    click Utils "https://github.com/saiguggilla2004/interview-prep/blob/main/lib/utils.ts"
    click GlobalLayout "https://github.com/saiguggilla2004/interview-prep/blob/main/app/layout.tsx"

    %% Styles
    classDef frontend fill:#a2d2ff,stroke:#333,stroke-width:1px
    classDef backend fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef external fill:#ffd8a8,stroke:#333,stroke-width:1px
```
