# mohammed-iqramul/ai-mock-interviewer architecture

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

- Interactive diagram: https://gitdiagram.com/mohammed-iqramul/ai-mock-interviewer
- Repository: https://github.com/mohammed-iqramul/ai-mock-interviewer

## Overview

##### Project Type and Purpose
- This is a single-page, front-end React application (built with Vite) that serves as an AI-powered mock interview platform. It directly interacts with external services (Perplexity Sonar API for Q&A and feedback, and the browser’s Web Speech API for STT/TTS) and uses static JSON data for its resources and practice sheets. There is no in-repo backend service—API calls originate from the browser.

##### File Structure Overview
- Top-level “frontend” folder contains all source code.
- src/pages – route-based React components (Home, Practice, Interview, Resources, etc.)
- src/data – static JSON/JS data (resourcesData, sheets, etc.)
- App.jsx & main.jsx – root component and ReactDOM bootstrap
- vite.config.js, package.json – build & dependency configs
- zDocument folder holds architectural documentation (Backend.md, WebSocket.md, etc.) but no runnable backend code lives here.

##### Key Architecture Insights from README
- UI is built in React + Tailwind CSS, uses Framer Motion for animation.
- State is handled with React hooks and persisted in browser Local Storage.
- Core flows:
a. Mock Interview Session – capture microphone audio → Web Speech API (STT) → send text to Perplexity Sonar API → receive AI response → SpeechSynthesis (TTS) → render Q&A & summary.
b. Practice & Resources – load static JSON from src/data to render lists, sheets, and cards.

##### Components
A. Browser-side (Client)
1. UI Layer
- React Components (pages & shared components)
- TailwindCSS + Framer Motion
2. State & Data Layer
- React useState/useEffect hooks
- Local Storage for progress tracking
- Static JSON data loader (src/data)
3. API Layer
- Perplexity Sonar REST endpoints
- Web Speech API interfaces (SpeechRecognition, SpeechSynthesis)
B. External Services
- Perplexity Sonar API (AI interview engine)
- Web Speech API (built-in browser STT/TTS)

##### Relationships & Data Flow
- User interacts with UI → UI invokes Web Speech API (STT) → recognized text sent over HTTPS to Sonar API → Sonar API responds with Q/A or feedback → UI renders response and triggers Web Speech API (TTS) for audio playback → updates Local Storage if needed.
- Practice/Resources pages read JSON files at build time or runtime → rendered as static content; no external calls.

##### Architectural Patterns & Principles
- Component-based UI (React) with route-based code splitting.
- Unidirectional data flow with hooks.
- Separation of concerns:
- Presentation (JSX + CSS)
- State management (hooks + storage)
- Service layer (API wrappers for Sonar & Speech)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interaction
    User["User"]:::external

    subgraph "Browser Client"
        direction TB

        subgraph "UI Layer"
            direction TB
            Home["Home Page"]:::frontend
            Practice["Practice Overview"]:::frontend
            Interviews["Interview Overview"]:::frontend
            Dashboard["Dashboard/Landing"]:::frontend
            Resources["Resources Overview"]:::frontend
            NotFound["404 Fallback"]:::frontend
            InterviewSession["Mock Interview Session"]:::frontend
            SheetDetails["Practice Sheet Details"]:::frontend
            ResourceWrapper["Resource Page Wrapper"]:::frontend
            ResourceCard["Individual Resource Card"]:::frontend
            CoreRes["Core Resources"]:::frontend
            DSARes["DSA Resources"]:::frontend
            HRRes["HR Resources"]:::frontend
            NonTechRes["Non-Technical Resources"]:::frontend
            ProjectsRes["Projects Resources"]:::frontend
            ResumeRes["Resume Guides"]:::frontend
            WebdevRes["Web Development Resources"]:::frontend
            SheetsRes["Practice Sheets Listing"]:::frontend
            Styling["Tailwind CSS & Framer Motion"]:::frontend
        end

        subgraph "State & Data Layer"
            direction TB
            HooksStorage["React Hooks & LocalStorage"]:::frontend
            StaticLoader["Static JSON Data Loader"]:::frontend
            ResourcesData["resourcesData.js"]:::frontend
            SheetsTopics["sheetsTopics.json"]:::frontend
            SheetsData["sheets.json"]:::frontend
        end

        subgraph "API Layer & Browser APIs"
            direction TB
            SpeechRecognition["SpeechRecognition (STT)"]:::builtins
            SpeechSynthesis["SpeechSynthesis (TTS)"]:::builtins
        end
    end

    subgraph "External Services"
        direction TB
        SonarAPI["Perplexity Sonar API"]:::external
    end

    %% Data flow arrows
    User -->|"interacts with"| Home
    User -->|"interacts with"| Practice
    User -->|"interacts with"| Interviews
    User -->|"interacts with"| Dashboard
    User -->|"interacts with"| Resources
    User -->|"interacts with"| NotFound
    User -->|"starts session"| InterviewSession

    InterviewSession -->|"capture audio"| SpeechRecognition
    SpeechRecognition -->|"transcribed text"| SonarAPI
    SonarAPI -->|"JSON response"| InterviewSession
    InterviewSession -->|"play response"| SpeechSynthesis
    SpeechSynthesis -->|"audio output"| User

    Home -->|"loads static content"| StaticLoader
    Practice -->|"loads static content"| StaticLoader
    Resources -->|"loads static content"| StaticLoader
    StaticLoader --> ResourcesData
    StaticLoader --> SheetsTopics
    StaticLoader --> SheetsData
    StaticLoader -->|"data"| Home
    StaticLoader -->|"data"| Practice
    StaticLoader -->|"data"| Resources

    InterviewSession -->|"update progress"| HooksStorage
    Home -->|"update state"| HooksStorage
    Practice -->|"update state"| HooksStorage
    Resources -->|"update state"| HooksStorage

    Styling -->|"styles & animations"| Home
    Styling -->|"styles & animations"| Practice
    Styling -->|"styles & animations"| Interviews
    Styling -->|"styles & animations"| Dashboard
    Styling -->|"styles & animations"| Resources
    Styling -->|"styles & animations"| InterviewSession

    %% Click events
    click Home "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/Home.jsx"
    click Practice "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/Practice.jsx"
    click Interviews "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/Interviews.jsx"
    click Dashboard "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/Dashboard.jsx"
    click Resources "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/Resources.jsx"
    click NotFound "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/NotFound.jsx"
    click InterviewSession "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/interview/InterviewSession.jsx"
    click SheetDetails "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/practive/SheetDetails.jsx"
    click ResourceWrapper "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/ResourcePageWrapper.jsx"
    click ResourceCard "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/ResourceCard.jsx"
    click CoreRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/Core.jsx"
    click DSARes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/DSA.jsx"
    click HRRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/HR.jsx"
    click NonTechRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/NonTech.jsx"
    click ProjectsRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/Projects.jsx"
    click ResumeRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/Resume.jsx"
    click WebdevRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/Webdev.jsx"
    click SheetsRes "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/pages/resources/Sheets.jsx"
    click ResourcesData "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/data/resourcesData.js"
    click SheetsTopics "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/data/sheetsTopics.json"
    click SheetsData "https://github.com/mohammed-iqramul/ai-mock-interviewer/blob/main/frontend/src/data/sheets.json"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:1px
    classDef builtins fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef external fill:#ffe0b2,stroke:#ef6c00,stroke-width:1px
```
