# sachinmaurya96/ai_mock_interview architecture

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

- Interactive diagram: https://gitdiagram.com/sachinmaurya96/ai_mock_interview
- Repository: https://github.com/sachinmaurya96/ai_mock_interview

## Overview

a. Client Side:
- Web Browser: Represents the user interface that consumes the Next.js application.
b. Next.js Server:
- App Router: Split into various route groups:
– (auth) Group: Contains authentication layouts and pages (sign-in, sign-up).
– (root) Group: Contains core pages such as the main landing page and interview-related pages, including dynamic routes for specific interview IDs and nested feedback pages.
c. API Layer:
- /api/vapi: Contains server-side API resources. For example, the generate route is implemented in route.ts.
d. Firebase Integration:
- Firebase Admin and Client libraries: Managed under the “firebase” directory, handling authentication, database operations, or other Firebase services.
e. Utility and Business Logic:
- Lib Folder: Contains actions like auth.action.ts and general.action.ts, plus utility functions (lib/utils.ts) and an SDK for the VAPI integration (lib/vapi.sdk.ts).
f. UI Components:
- Components Folder: Hosts reusable UI components (e.g., Agent, AuthForm, InterviewCard) and UI primitives (button, form, input, label) in the “components/ui” subfolder.
g. Constants & Types:
- Constants and Types: These directories provide shared constants and type definitions for consistency across the project.
h. Configuration & Setup:
- Next.js config (next.config.ts), ESLint, PostCSS, and other project configuration files define build/deployment behavior.

##### Relationships and Interactions
a. Data Flow and Routing:
- Within the Next.js Server, split the flow into two primary paths:
– One path to authentication (handled by the “(auth)” group), and
– Another path to the core application pages (in the “(root)” group).
b. API Interactions:
- A component for API Services (using the /api/vapi endpoint) that receives requests from client interactions or server-side calls.
→ Indicate calls from either client pages or server actions (in the lib folder) to the API component.
c. Firebase Integration:
d. Utility Layers:
- Lib folder elements as supporting modules that abstract business logic and serve as intermediary layers between UI components and backend services.
e. UI Component Reuse:
- Reusable components within the UI block. Their internal interactions with the page-level components should be noted, portraying how they render data and capture user inputs.

##### Architectural Patterns and Technologies
a. Next.js App Router’s role in separating concerns (authentication vs. main application).
b. API-driven approach which decouples data generation (/api/vapi/generate) from UI rendering.
c. “Component-based Architecture” (multiple reusable components with UI consistency).
d. Mention the integration of external services like Firebase, which offloads authentication/data management.
e. Point out that configuration files (e.g., next.config.ts, eslint.config.mjs) signal the usage of best practices for build optimization and code quality.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Client Side
  Browser("Web Browser"):::client
  
  %% Next.js Server as a central node
  NextServer("Next.js Server"):::server
  
  Browser -->|"HTTP/HTTPS"| NextServer
  
  %% Routes Subgraph within Next.js Server
  subgraph "Routes"
    direction TB
    %% Authentication Routes
    subgraph "Auth Routes"
      direction TB
      AuthLayout("Auth Layout"):::server
      SignIn("Sign-In Page"):::server
      SignUp("Sign-Up Page"):::server
    end
    %% Core Application Routes
    subgraph "Core Application Routes"
      direction TB
      RootLayout("Core Layout"):::server
      HomePage("Landing Page"):::server
      InterviewList("Interview Page"):::server
      InterviewDetail("Interview Detail"):::server
      FeedbackPage("Interview Feedback"):::server
    end
  end

  %% Connect Next.js Server to its internal route groups
  NextServer --> AuthLayout
  NextServer --> RootLayout

  %% API Layer
  APIEndpoint("/api/vapi/generate Endpoint"):::api
  NextServer -->|"calls_API"| APIEndpoint

  %% Firebase Integration
  Firebase("Firebase Services"):::external
  NextServer -->|"integrates_with"| Firebase

  %% Libraries & Utilities Subgraph
  subgraph "Libraries & Utilities"
    direction TB
    AuthAction("Auth Action"):::lib
    GeneralAction("General Action"):::lib
    Utils("Utils"):::lib
    VAPISDK("VAPI SDK"):::lib
  end
  NextServer -->|"executes_logic"| AuthAction

  %% UI Components Subgraph
  subgraph "UI Components"
    direction TB
    Agent("Agent Component"):::ui
    AuthForm("AuthForm Component"):::ui
    InterviewCard("InterviewCard Component"):::ui
    Button("Button (UI)"):::ui
    Form("Form (UI)"):::ui
    Input("Input (UI)"):::ui
    Label("Label (UI)"):::ui
    Sonner("Sonner (UI)"):::ui
  end
  NextServer -->|"renders_UI"| Agent

  %% Constants & Types Subgraph
  subgraph "Constants & Types"
    direction TB
    Constants("Constants"):::config
    Types("Type Definitions"):::config
    VAPITypes("VAPI Types"):::config
  end
  NextServer -->|"uses_constants"| Constants
  NextServer --> Types
  NextServer --> VAPITypes

  %% Configuration & Setup Subgraph
  subgraph "Configuration & Setup"
    direction TB
    NextConfig("next.config"):::config
    ESLint("eslint.config"):::config
    PostCSS("postcss.config"):::config
    TSConfig("tsconfig"):::config
    Package("package.json"):::config
  end
  NextServer -->|"setup"| NextConfig
  NextServer --> ESLint
  NextServer --> PostCSS
  NextServer --> TSConfig
  NextServer --> Package

  %% Click Events
  click AuthLayout "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/(auth)/layout.tsx"
  click SignIn "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/(auth)/sign-in/page.tsx"
  click SignUp "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/(auth)/sign-up/page.tsx"
  click RootLayout "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/(root)/layout.tsx"
  click HomePage "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/(root)/page.tsx"
  click InterviewList "https://github.com/sachinmaurya96/ai_mock_interview/tree/main/app/(root)/interview"
  click InterviewDetail "https://github.com/sachinmaurya96/ai_mock_interview/tree/main/app/(root)/interview/[id]"
  click FeedbackPage "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/(root)/interview/[id]/feedback/page.tsx"
  click APIEndpoint "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/app/api/vapi/generate/route.ts"
  click Firebase "https://github.com/sachinmaurya96/ai_mock_interview/tree/main/firebase"
  click AuthAction "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/lib/actions/auth.action.ts"
  click GeneralAction "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/lib/actions/general.action.ts"
  click Utils "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/lib/utils.ts"
  click VAPISDK "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/lib/vapi.sdk.ts"
  click Agent "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/Agent.tsx"
  click AuthForm "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/AuthForm.tsx"
  click InterviewCard "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/InterviewCard.tsx"
  click Button "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/ui/button.tsx"
  click Form "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/ui/form.tsx"
  click Input "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/ui/input.tsx"
  click Label "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/ui/label.tsx"
  click Sonner "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/components/ui/sonner.tsx"
  click Constants "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/constants/index.ts"
  click Types "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/types/index.d.ts"
  click VAPITypes "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/types/vapi.d.ts"
  click NextConfig "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/next.config.ts"
  click ESLint "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/eslint.config.mjs"
  click PostCSS "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/postcss.config.mjs"
  click TSConfig "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/tsconfig.json"
  click Package "https://github.com/sachinmaurya96/ai_mock_interview/blob/main/package.json"

  %% Styles
  classDef client fill:#AEDFF7,stroke:#333,stroke-width:2px;
  classDef server fill:#FEB2B2,stroke:#900,stroke-width:2px;
  classDef api fill:#C6F6D5,stroke:#4A5568,stroke-width:2px;
  classDef external fill:#FBD38D,stroke:#D69E2E,stroke-width:2px;
  classDef lib fill:#E9D8FD,stroke:#6B46C1,stroke-width:2px;
  classDef ui fill:#FEEBC8,stroke:#D69E2E,stroke-width:2px;
  classDef config fill:#CFFAFE,stroke:#2C7A7B,stroke-width:2px;
```
