# tharanitharan-m/prepwise architecture

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

- Interactive diagram: https://gitdiagram.com/tharanitharan-m/prepwise
- Repository: https://github.com/tharanitharan-m/prepwise

## Overview

##### Project type and purpose
- This is a full-stack web application called “PrepWise,” built with Next.js for both the frontend and backend.
- It provides AI-powered mock interviews with real-time voice interaction, secure authentication, and persistent storage of interview data and feedback.

##### File structure
- app/…: Next.js 13 “app router” directory, containing:
- (auth) routes for sign-in and sign-up
- (root) protected user area with interview listing, custom interview creation, interview sessions, and feedback pages
- app/api/vapi routes for VAPI voice endpoints (custom-interview and generate)
- components/: reusable React UI components and custom Shadcn UI wrappers
- lib/actions and lib/utils: client-side and server-side helper functions for authentication, interview management, and general utilities
- firebase/: modules to initialize Firebase Admin (server) and Client SDKs
- types/ and constants/: shared TypeScript definitions and application constants
- public/: static assets (covers)
- Configuration files: next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs

##### README for additional insights
- Frontend: Next.js, React, Tailwind CSS, Shadcn UI, React Hook Form, Zod
- Backend: Next.js API Routes, Firebase Auth & Firestore, VAPI Voice API, Google Gemini AI
- Deployment target: Vercel

a. Main components
- Client Browser / Web App (Next.js React pages & components)
- Next.js Server (SSR/Edge functions handling API routes)
- Firebase Authentication & Firestore (Auth, user data, interviews, feedback)
- VAPI Voice API (real-time audio streaming and transcription)
- Google Gemini AI (question generation and transcript analysis)
- Vercel (hosting and CDN)

b. Component interactions
1. User interacts with the React UI in the browser.
2. Authentication requests → Next.js API → Firebase Auth.
3. On “Generate Interview”: UI POST → /api/vapi/custom-interview → server calls Google Gemini AI, stores interview template in Firestore.
4. Starting a live interview: UI connects via WebSocket or fetch to /api/vapi/generate → VAPI Voice API streams audio, server proxies requests, responses transcribed in real time.
5. Interview transcript returned to server → /api/vapi/generate calls Google Gemini AI for feedback → feedback saved to Firestore.
6. UI fetches interview data and feedback from Firestore via Next.js data fetching.

c. Architectural patterns & principles
- Separation of concerns: UI layer (pages + components) vs. business logic (lib/actions) vs. data layer (Fire-store + SDK wrappers)
- Edge functions / serverless API patterns via Next.js API Routes
- Modular component design (Shadcn UI + custom components)
- Real-time streaming integration with external voice API

d. Key technologies
- Next.js 13 App Router
- React & Shadcn UI
- Tailwind CSS
- Firebase Auth & Firestore
- VAPI Voice API & @vapi/ai-web
- Google Gemini AI
- React Hook Form + Zod for form validation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser)" 
        direction TB
        AppRouter["Next.js App Router"]:::frontend
        AuthLayout["Auth Layout"]:::frontend
        SignIn["Sign-In Page"]:::frontend
        SignUp["Sign-Up Page"]:::frontend
        RootLayout["Root Layout"]:::frontend
        RootHome["Dashboard Home"]:::frontend
        CustomInterviewPage["Custom Interview Page"]:::frontend
        InterviewList["Interview List Page"]:::frontend
        InterviewSession["Interview Session Page"]:::frontend
        FeedbackPage["Feedback Page"]:::frontend
        ComponentsDir["Reusable Components"]:::frontend
        UIWrappersDir["Shadcn UI Wrappers"]:::frontend
        GlobalsCSS["Global Styles"]:::config
    end

    %% Backend Layer
    subgraph "Backend (Next.js Serverless)" 
        direction TB
        CustomInterviewAPI["/api/vapi/custom-interview"]:::backend
        GenerateAPI["/api/vapi/generate"]:::backend
        AuthActions["Auth Actions"]:::backend
        InterviewActions["Interview Actions"]:::backend
        GeneralActions["General Actions"]:::backend
        Utils["Utils"]:::backend
        VapiSDK["VAPI SDK Integration"]:::backend
        FirebaseAdmin["Firebase Admin SDK"]:::backend
        FirebaseClient["Firebase Client SDK"]:::backend
        EnvVars["Environment Variables"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        Firestore["Firestore"]:::db
        VAPIVOICE["VAPI Voice API"]:::external
        GeminiAI["Google Gemini AI"]:::external
        Vercel["Vercel Hosting"]:::external
    end

    %% Data Flow
    AppRouter -->|"HTTP Requests"| CustomInterviewAPI
    AppRouter -->|"HTTP Requests"| GenerateAPI
    SignIn -->|calls| AuthActions
    SignUp -->|calls| AuthActions
    AuthActions -->|Admin SDK| FirebaseAdmin
    FirebaseClient -->|reads/writes| Firestore
    CustomInterviewAPI -->|uses| VapiSDK
    CustomInterviewAPI -->|stores template| Firestore
    GenerateAPI -->|streams audio| VAPIVOICE
    GenerateAPI -->|transcript| GeminiAI
    GenerateAPI -->|stores feedback| Firestore
    AppRouter -->|fetches data| FirebaseClient
    EnvVars -->|provide keys| CustomInterviewAPI
    EnvVars -->|provide keys| GenerateAPI

    %% External connections
    AuthActions -->|HTTPS| FirebaseAuth
    FirebaseAdmin -->|Admin calls| FirebaseAuth
    VapiSDK -->|HTTPS| VAPIVOICE
    GenerateAPI -->|HTTPS| GeminiAI
    AppRouter -->|deploy| Vercel
    CustomInterviewAPI -->|deploy| Vercel
    GenerateAPI -->|deploy| Vercel

    %% Click Events
    click AppRouter "https://github.com/tharanitharan-m/prepwise/tree/main/app/"
    click AuthLayout "https://github.com/tharanitharan-m/prepwise/blob/main/app/(auth)/layout.tsx"
    click SignIn "https://github.com/tharanitharan-m/prepwise/blob/main/app/(auth)/sign-in/page.tsx"
    click SignUp "https://github.com/tharanitharan-m/prepwise/blob/main/app/(auth)/sign-up/page.tsx"
    click RootLayout "https://github.com/tharanitharan-m/prepwise/blob/main/app/(root)/layout.tsx"
    click RootHome "https://github.com/tharanitharan-m/prepwise/blob/main/app/(root)/page.tsx"
    click CustomInterviewPage "https://github.com/tharanitharan-m/prepwise/blob/main/app/(root)/custom-interview/page.tsx"
    click InterviewList "https://github.com/tharanitharan-m/prepwise/blob/main/app/(root)/interview/page.tsx"
    click InterviewSession "https://github.com/tharanitharan-m/prepwise/blob/main/app/(root)/interview/[id]/page.tsx"
    click FeedbackPage "https://github.com/tharanitharan-m/prepwise/blob/main/app/(root)/interview/[id]/feedback/page.tsx"
    click CustomInterviewAPI "https://github.com/tharanitharan-m/prepwise/blob/main/app/api/vapi/custom-interview/route.ts"
    click GenerateAPI "https://github.com/tharanitharan-m/prepwise/blob/main/app/api/vapi/generate/route.ts"
    click ComponentsDir "https://github.com/tharanitharan-m/prepwise/tree/main/components/"
    click UIWrappersDir "https://github.com/tharanitharan-m/prepwise/blob/main/components/ui/button.tsx"
    click AuthActions "https://github.com/tharanitharan-m/prepwise/blob/main/lib/actions/auth.action.ts"
    click AuthActions "https://github.com/tharanitharan-m/prepwise/blob/main/lib/actions/auth.actions.ts"
    click InterviewActions "https://github.com/tharanitharan-m/prepwise/blob/main/lib/actions/interview.actions.ts"
    click GeneralActions "https://github.com/tharanitharan-m/prepwise/blob/main/lib/actions/general.action.ts"
    click GeneralActions "https://github.com/tharanitharan-m/prepwise/blob/main/lib/actions/general.actions.ts"
    click Utils "https://github.com/tharanitharan-m/prepwise/blob/main/lib/utils.ts"
    click VapiSDK "https://github.com/tharanitharan-m/prepwise/blob/main/lib/vapi.sdk.ts"
    click FirebaseAdmin "https://github.com/tharanitharan-m/prepwise/blob/main/firebase/admin.ts"
    click FirebaseClient "https://github.com/tharanitharan-m/prepwise/blob/main/firebase/client.ts"
    click Types "https://github.com/tharanitharan-m/prepwise/blob/main/types/index.d.ts"
    click Types "https://github.com/tharanitharan-m/prepwise/blob/main/types/vapi.d.ts"
    click Constants "https://github.com/tharanitharan-m/prepwise/blob/main/constants/index.ts"
    click GlobalsCSS "https://github.com/tharanitharan-m/prepwise/blob/main/app/globals.css"
    click NextConfig "https://github.com/tharanitharan-m/prepwise/blob/main/next.config.ts"
    click TSConfig "https://github.com/tharanitharan-m/prepwise/blob/main/tsconfig.json"
    click PostCSS "https://github.com/tharanitharan-m/prepwise/blob/main/postcss.config.mjs"
    click ESLint "https://github.com/tharanitharan-m/prepwise/blob/main/eslint.config.mjs"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000
    classDef backend fill:#d4edda,stroke:#28a745,color:#000
    classDef external fill:#fff3cd,stroke:#ffc107,color:#000
    classDef db fill:#e2e3e5,stroke:#6c757d,color:#000
    classDef config fill:#f8d7da,stroke:#dc3545,color:#000
```
