# wizardgeeky/ai-mock-interview-platform architecture

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

- Interactive diagram: https://gitdiagram.com/wizardgeeky/ai-mock-interview-platform
- Repository: https://github.com/wizardgeeky/ai-mock-interview-platform

## Overview

##### Main Components
a. User Interface (Frontend)
- Represented by the pages and components in the "app" directory (e.g., interview, portal, profile, reset pages).
b. API / Backend Services
- Directory "app/api" includes versioned endpoints for authentication (login, reset links, password changes, user details, and mock test endpoints).
c. Data Models & Configuration
- Models (Interview, ResetLink, UserModel) and configuration files (database-config, ai-config, email-config) reside under "app/models" and "app/config".
d. External Services & Integrations
- Judge0 Compiler: For real-time code execution.
- Gemini AI: For AI-powered code review and interview simulation.
e. Database & Security
- MongoDB plays the primary storage role for users, interview history, and other persistent data.
- Security aspects (JWT tokens, AES encryption) can be annotated as part of the data flow within the Authentication & Session Management module.

##### Detail the Relationships & Data Flow
- How the Frontend interacts with the Backend:
- From the UI, users submit code through interactive pages (Interview, Portal, etc.), which trigger API calls.
- Flow from Backend to External Services:
- API endpoints for coding challenges send requests to Gemini AI and Judge0 to generate problems, execute code, and fetch AI feedback.
- API endpoints with the Database:
- Internal utility flows:
- Modules like token generation (app/utils/token.ts) and encryption logic (app/utils/cipher.ts) as supporting functions within the Backend layer.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clearly separate UI (React pages/components) from API logic (Next.js API routes and controllers).
- Versioning in APIs: Note how the API routes are versioned (v.0.0 under "app/api/auth"), which allows for future scalability.
- Security: Emphasize JWT-based authentication and the AES encryption strategy (with cipher utilities and config files).
- Integration Points: Mark external service integration points for Judge0 and Gemini AI, as these are key to the project’s AI capabilities.

##### Summary of Essential Elements
- Components:
- Frontend (Next.js pages, Tailwind CSS)
- Backend/API Endpoints (Authentication, Mock Interview modules)
- Data Models & Configurations (UserModel, Interview, ResetLink, AI/Email/Database Config)
- External Services (Judge0, Gemini AI)
- Database (MongoDB)
- Connections:
- API calls between Frontend and API
- API communication with External Services and Database
- Security flows through authentication modules
- Design Focus:
- Detailed representation of data flow and interactions.
- Emphasis on security, modular API design, and external integrations for AI and code execution.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Frontend Layer
    subgraph "Frontend Layer"
        F1["Interview Page"] 
        F2["Portal Page"]
        F3["Profile Page"]
        F4["Reset Password Page"]
        F5["Root Page"]
        F6["Layout"]
    end

    %% API Endpoints / Backend
    subgraph "API Endpoints / Backend (v.0.0)"
        B1["Login Endpoint"]
        B2["Mock Test Endpoint"]
        B3["Reset Link Endpoint"]
        B4["Reset Password Endpoint"]
        B5["User Endpoint"]
        B6["User Mock Tests Endpoint"]
    end

    %% Security & Utilities
    subgraph "Security & Utilities"
        S1["AES Encryption Utility"]
        S2["JWT Token Utility"]
        S3["Reset Link Utility"]
    end

    %% Data Models & Config
    subgraph "Data Models & Config"
        M["Data Models"]
        C["Configuration Files"]
    end

    %% External Services
    E1["Judge0 Compiler Service"]
    E2["Gemini AI Service"]

    %% Database
    D["Database (MongoDB)"]

    %% Connections
    %% Frontend to API
    F5 -->|"HTTP_request"| B1

    %% API to Data Models & Config
    B5 -->|"uses"| M

    %% API to Database
    B6 -->|"stores_session"| D

    %% API to External Services
    B2 -->|"executes_code"| E1
    B2 -->|"AI_feedback"| E2

    %% API to Security & Utilities
    B1 -->|"JWT_auth"| S2
    B3 -->|"generate_reset"| S3
    B4 -->|"encrypt_data"| S1

    %% Configures External Service via config
    C -->|"configures"| E2

    %% Styling classes
    classDef frontend fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef backend fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef security fill:#E0CEFF,stroke:#333,stroke-width:2px;
    classDef models fill:#CCCCFF,stroke:#333,stroke-width:2px;
    classDef database fill:#FFF2CC,stroke:#333,stroke-width:2px;
    classDef external fill:#FCE4D6,stroke:#333,stroke-width:2px;

    class F1,F2,F3,F4,F5,F6 frontend;
    class B1,B2,B3,B4,B5,B6 backend;
    class S1,S2,S3 security;
    class M,C models;
    class D database;
    class E1,E2 external;

    %% Click Events for Frontend Components
    click F1 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/components/interview/page.tsx"
    click F2 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/components/portal/page.tsx"
    click F3 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/components/profile/page.tsx"
    click F4 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/components/reset/password/page.tsx"
    click F5 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/page.tsx"
    click F6 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/layout.tsx"

    %% Click Events for API Endpoints
    click B1 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/api/auth/v.0.0/login/route.ts"
    click B2 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/api/auth/v.0.0/mocktest/route.ts"
    click B3 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/api/auth/v.0.0/resetlink/route.ts"
    click B4 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/api/auth/v.0.0/resetpwd/route.ts"
    click B5 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/api/auth/v.0.0/user/route.ts"
    click B6 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/api/auth/v.0.0/user/mocktests/route.ts"

    %% Click Events for Data Models & Config
    click M "https://github.com/wizardgeeky/ai-mock-interview-platform/tree/main/app/models"
    click C "https://github.com/wizardgeeky/ai-mock-interview-platform/tree/main/app/config"

    %% Click Events for External Services
    click E1 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/utils/judge0.ts"
    click E2 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/config/ai-config.ts"

    %% Click Events for Security & Utility Modules
    click S1 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/utils/cipher.ts"
    click S2 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/utils/token.ts"
    click S3 "https://github.com/wizardgeeky/ai-mock-interview-platform/blob/main/app/utils/resetlink.ts"
```
