# rxz33/ai-interview-generator architecture

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

- Interactive diagram: https://gitdiagram.com/rxz33/ai-interview-generator
- Repository: https://github.com/rxz33/ai-interview-generator

## Overview

##### Project type + purpose (what you’re diagramming)
This is a **full-stack web application**: **InterQ** (AI Interview Question Generator). Users interact with a **React + Tailwind** frontend, which calls a **Node.js/Express** backend. The backend generates interview questions and sample answers by calling **Groq AI**, and persists data in **MongoDB**.

Given the file tree:
- `client/` → frontend (React app)
- `server.js` → backend entrypoint (Express server)
- `package.json` / `package-lock.json` → likely root Node project (possibly serving API + building client)

##### Frontend (`client/`)
- **UI Pages / Views**
- Role selection, difficulty selection, skill level, company type, etc.
- **API Client Layer**
- A thin module responsible for calling backend endpoints (fetch/axios)
- **State Management**
- Local state / context / query cache (don’t assume Redux; label generically)
- **Styling**
- Tailwind CSS (call out as a frontend dependency)

##### Backend (`server.js`)
Treat `server.js` as the entrypoint that wires:
- **Express App / Router layer**
- **Interview Generation Controller / Service**
- Builds prompts, selects difficulty, formats output
- **Groq AI Client**
- Outbound API calls (LLM inference)
- **MongoDB Data Access Layer**
- **Config / Secrets**

##### Deployment (`render.yaml`)
An infra boundary that shows:
- **Render Web Service** hosting Node/Express
- **MongoDB** (likely MongoDB Atlas) as an external managed service
- **Groq API** as an external SaaS dependency

##### User Browser
→ loads **React SPA** (from CDN/static hosting or from Express static serving)
##### React SPA
→ calls **Express REST API** (HTTPS)
##### Express API
→ reads/writes **MongoDB** (TCP connection via driver/ODM)
##### Express API
→ calls **Groq AI API** (HTTPS)
##### Express API
→ returns structured JSON to **React SPA**
##### React SPA
→ renders question set + sample answers + follow-ups

- Does Express **serve the React build** or is React deployed separately?
- Actual API routes (e.g., `/api/generate`, `/api/questions`, `/api/history`)
- Mongo usage: which entities are stored (history, users, templates)
- render.yaml: single service vs multiple services (web + static)

This will be the most accurate representation of this repo’s purpose and structure while still being detailed and componentized.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =======================
    %% Users / Client Device
    %% =======================
    subgraph "Client Device"
        U["User (Candidate)"]:::external
        B["Web Browser"]:::external
        U -->|"uses"| B
    end

    %% =======================
    %% Hosting / Deployment
    %% =======================
    subgraph "Internet / Hosting"
        subgraph "Render Cloud"
            RD["Render Web Service Runtime"]:::infra
            ENV["Environment Variables\n(GROQ_API_KEY, MONGODB_URI)"]:::config
            RD -->|"injects"| ENV
        end

        subgraph "First-party App"
            subgraph "Frontend: React + Tailwind (SPA)"
                FE["React SPA (client/)"]:::frontend
                FE_UI["UI Pages / Views\n(role,difficulty,skill,company type)"]:::frontend
                FE_API["API Client Layer\n(fetch/axios)"]:::frontend
                FE_STATE["State Management\n(local/context/cache)"]:::frontend
                FE_STYLE["Tailwind CSS Styling"]:::frontend

                FE -->|"renders"| FE_UI
                FE_UI -->|"updates"| FE_STATE
                FE_UI -->|"triggers calls"| FE_API
                FE_STYLE -->|"styles"| FE_UI
            end

            subgraph "Backend: Node.js + Express API"
                BE["Express Server (server.js)"]:::backend
                BE_ROUTER["Express App / Router Layer"]:::backend
                BE_GEN["Interview Generation Controller / Service\n(normalize→prompt→parse/format)"]:::backend
                BE_GROQ["Groq AI Client\n(LLM request wrapper)"]:::backend
                BE_MONGO["MongoDB Data Access Layer\n(history/generated sets)"]:::backend

                BE -->|"routes"| BE_ROUTER
                BE_ROUTER -->|"calls"| BE_GEN
                BE_GEN -->|"uses"| BE_GROQ
                BE_GEN -->|"persists/reads"| BE_MONGO
                ENV -->|"configures"| BE
                ENV -->|"configures"| BE_GROQ
                ENV -->|"configures"| BE_MONGO
            end
        end

        subgraph "External Managed Services"
            GROQ["Groq AI API\n(External SaaS)"]:::external
            MDB[("MongoDB\n(Managed / Atlas)")]:::datastore
        end
    end

    %% =======================
    %% Primary Runtime Flow
    %% =======================
    B -->|"HTTPS GET static assets"| FE
    FE_API -->|"HTTPS JSON (REST)"| BE_ROUTER
    BE_GROQ -->|"HTTPS prompt/inference"| GROQ
    BE_MONGO -->|"CRUD (questions,answers,history)"| MDB
    BE_ROUTER -->|"JSON response\n(question set + sample answers)"| FE_API
    FE_UI -->|"renders results"| B

    %% =======================
    %% Notes / Failure modes (lightweight)
    %% =======================
    GROQ -.->|"rate limits/timeouts\n→ backend error mapping"| BE_GROQ:::note

    %% =======================
    %% Click Events (from component mapping)
    %% =======================
    click FE "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click FE_UI "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click FE_API "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click FE_STATE "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click FE_STYLE "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click BE "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click BE_ROUTER "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click BE_GEN "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click BE_GROQ "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click BE_MONGO "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click ENV "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click RD "https://github.com/rxz33/ai-interview-generator/blob/main/render.yaml"
    click ENV "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click RD "https://github.com/rxz33/ai-interview-generator/blob/main/render.yaml"
    click BE "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click FE "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click RD "https://github.com/rxz33/ai-interview-generator/blob/main/render.yaml"
    click FE "https://github.com/rxz33/ai-interview-generator/tree/main/client/"
    click BE "https://github.com/rxz33/ai-interview-generator/blob/main/server.js"
    click RD "https://github.com/rxz33/ai-interview-generator/blob/main/render.yaml"
    click U "https://github.com/rxz33/ai-interview-generator/blob/main/package.json"
    click B "https://github.com/rxz33/ai-interview-generator/blob/main/package-lock.json"

    %% =======================
    %% Styles
    %% =======================
    classDef frontend fill:#1f77b4,stroke:#0b3d66,color:#ffffff,stroke-width:1px
    classDef backend fill:#0b5fa5,stroke:#083a63,color:#ffffff,stroke-width:1px
    classDef datastore fill:#2e7d32,stroke:#1b5e20,color:#ffffff,stroke-width:1px
    classDef external fill:#6b7280,stroke:#374151,color:#ffffff,stroke-width:1px
    classDef infra fill:#7c3aed,stroke:#4c1d95,color:#ffffff,stroke-width:1px
    classDef config fill:#f59e0b,stroke:#92400e,color:#111827,stroke-width:1px
    classDef note fill:#94a3b8,stroke:#475569,color:#0f172a,stroke-dasharray:4 3
```
