# vighnesh2304/prepwise architecture

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

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

## Overview

##### Main Components
- Frontend (User Interface):
- Inside this, show separate segments for:
◦ Auth Pages – located under app/(auth) with sign-in and sign-up pages (using Firebase for auth).
◦ Main Interview Pages – found in app/(root), including the interview dashboard, individual interview routes (dynamic [id] pages), and feedback display.
◦ Shared Layout – global and layout files (app/layout.tsx, etc.) that provide consistent navigation and styling.

- API Layer:
- “API Endpoints” that the Next.js server exposes. Notably:
◦ The /app/api route with subroutes like /vapi/generate that calls a server-side function to generate interview questions.

- Business Logic & Service Layer:
◦ Actions (auth.action.ts, general.action.ts) that encapsulate core functionalities like authentication and interview feedback generation.
◦ Utility functions (lib/utils.ts) that support various tasks like fetching tech logos or interview covers.

- External Integrations:
- Distinct components for:

- Styling & UI Libraries:

##### Relationships and Data Flow
◦ User interactions on the frontend trigger API calls (for interview generation, submission, and feedback retrieval).
◦ API endpoints in the Next.js server then communicate with external AI services (Vapi, Gemini) to generate questions or to process interview transcripts.
◦ Business logic interacts with the Firebase backend for authentication and storage of interview sessions and feedback results.
◦ Utility functions (like getTechLogos) are called by UI components and server actions to enhance UI presentation.
- That the project’s routing is modular – with a clear separation between authentication flows (/app/(auth)) and main application areas (/app/(root)).

##### Architectural Patterns and Design Principles
- The separation of concerns is visible: UI components, API routes, business logic, and external integration are clearly delineated.
- The use of Next.js’ file-based routing (with dynamic paths and route segments) suggests an MVC-like separation where pages serve as controllers, components as views, and business logic in the lib folder as the model layer, even if not traditional MVC.
- That the project uses modern server-side functions (e.g., in app/api/vapi/generate/route.ts) to process requests, aligning with serverless/Microservice patterns.

##### Final Composition Elements
- Clear, legible labels for each component and subcomponent.
- And annotate how authentication, interview generation, and feedback are handled in the application’s flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U("User / Client"):::user
    CA("Next.js Frontend"):::frontend
    subgraph "Frontend Modules"
        A("Authentication Pages"):::frontend
        I("Main Interview Pages"):::frontend
        L("Shared Layout"):::frontend
        R("Reusable UI Components"):::frontend
    end
    API("API Endpoints"):::api
    BL("Business Logic & Service Layer"):::logic
    FB("Firebase"):::external
    AI("AI Services (Vapi AI & Google Gemini)"):::external
    S("Styling (Tailwind CSS & shadcn/ui)"):::styling

    U -->|"Uses"| CA
    CA -->|"Includes"| A
    CA -->|"Includes"| I
    CA -->|"Includes"| L
    CA -->|"Includes"| R
    CA -->|"APIRequest"| API
    API -->|"Process"| BL
    API -->|"VoiceGeneration"| AI
    BL ---|"AuthCall/DataStorage"| FB
    R -->|"CallsUtils"| BL
    A -->|"AuthAction"| BL
    S -->|"StyleApplied"| CA

    classDef user fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef api fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef logic fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef styling fill:#fff3cd,stroke:#856404,stroke-width:2px;

    click CA "https://github.com/vighnesh2304/prepwise/tree/main/app"
    click A "https://github.com/vighnesh2304/prepwise/tree/main/app/(auth)"
    click A "https://github.com/vighnesh2304/prepwise/blob/main/app/(auth)/sign-in/page.tsx"
    click A "https://github.com/vighnesh2304/prepwise/blob/main/app/(auth)/sign-up/page.tsx"
    click A "https://github.com/vighnesh2304/prepwise/blob/main/app/(auth)/layout.tsx"
    click I "https://github.com/vighnesh2304/prepwise/tree/main/app/(root)/interview"
    click I "https://github.com/vighnesh2304/prepwise/blob/main/app/(root)/interview/[id]/feedback/page.tsx"
    click I "https://github.com/vighnesh2304/prepwise/blob/main/app/(root)/page.tsx"
    click L "https://github.com/vighnesh2304/prepwise/blob/main/app/layout.tsx"
    click L "https://github.com/vighnesh2304/prepwise/blob/main/app/(root)/layout.tsx"
    click R "https://github.com/vighnesh2304/prepwise/blob/main/components/InterviewCard.tsx"
    click R "https://github.com/vighnesh2304/prepwise/blob/main/components/AuthForm.tsx"
    click R "https://github.com/vighnesh2304/prepwise/blob/main/components/ui/button.tsx"
    click R "https://github.com/vighnesh2304/prepwise/blob/main/components/ui/form.tsx"
    click R "https://github.com/vighnesh2304/prepwise/blob/main/components/ui/input.tsx"
    click R "https://github.com/vighnesh2304/prepwise/blob/main/components/ui/label.tsx"
    click API "https://github.com/vighnesh2304/prepwise/blob/main/app/api/vapi/generate/route.ts"
    click BL "https://github.com/vighnesh2304/prepwise/blob/main/lib/actions/auth.action.ts"
    click BL "https://github.com/vighnesh2304/prepwise/blob/main/lib/actions/general.action.ts"
    click BL "https://github.com/vighnesh2304/prepwise/blob/main/lib/utils.ts"
    click BL "https://github.com/vighnesh2304/prepwise/blob/main/lib/vapi.sdk.ts"
    click FB "https://github.com/vighnesh2304/prepwise/blob/main/firebase/admin.ts"
    click FB "https://github.com/vighnesh2304/prepwise/blob/main/firebase/client.ts"
    click S "https://github.com/vighnesh2304/prepwise/blob/main/app/globals.css"
    click S "https://github.com/vighnesh2304/prepwise/tree/main/components/ui"
    click AI "https://github.com/vighnesh2304/prepwise/blob/main/lib/vapi.sdk.ts"
```
