# ajith-bondili/ai-interviewer architecture

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

- Interactive diagram: https://gitdiagram.com/ajith-bondili/ai-interviewer
- Repository: https://github.com/ajith-bondili/ai-interviewer

## Overview

##### Project Type and Purpose
- This is a full-stack AI-powered web application (“PrepPal”) for mock interviews.
- Frontend: React + Tailwind CSS (Vite) in `frontend/`.
- Backend: Flask + SQLAlchemy with SQLite (and placeholder for MySQL/MongoDB) in `backend/`.
- AI services: OpenAI, Cohere, GCP APIs.

##### File Structure Analysis
- Top level:
- `frontend/` – React app with components, assets, Tailwind config, Vite config.
- `backend/` – Flask app: `app.py`, DB schema (`SQLite.sql`), models, config, API wrappers (`cohere_api.py`), audio transcription, upload folder, Dockerfile, start scripts.
- `requirements.txt`, top-level `package.json` for root scripts, `uploads/` for persisted resumes.
- Patterns:
- MVC-style: `models.py` (data), `app.py` (controllers/routes), templates/interfaces via JSON.
- External integrations: `cohere_api.py`, `audio_transcription.py` connect to AI services.
- Persistence: SQLAlchemy ORM backed by SQLite (but README suggests MySQL/MongoDB optionally).

##### README Insights
- Features: mock interviews, AI feedback, progress tracking, file uploads (resumes, audio).
- Tech Stack: React.js, Tailwind, Flask, Python, OpenAI, GCP, Cohere, OpenCV, Recharts.
- Deployment hints: Dockerfile in backend, env vars for API keys.

a. Main Components
- Client (Web Browser with React UI)
- Frontend Static Server (Vite dev server or CDN)
- Backend API Server (Flask app in Docker)
- Database (SQLite/MySQL via SQLAlchemy)
- File Storage (local `uploads/` directory or external storage)
- AI Services (OpenAI, Cohere, GCP Speech-to-Text)
- Optional Analytics Service (Recharts uses data returned by backend)
b. Relationships & Data Flows
1. User interacts with React UI → submits answers / uploads resume/audio.
2. React calls REST endpoints on Flask (`/api/interview`, `/api/upload`).
3. Backend persists metadata + files to DB + storage.
4. Backend dispatches API calls to OpenAI/Cohere for question generation and feedback.
5. For audio answers, `audio_transcription.py` calls GCP Speech-to-Text, returns transcript.
6. Feedback & analytics data returned to frontend → rendered by Recharts.
c. Architectural Patterns & Principles
- Separation of concerns: Presentation (React), Business Logic (Flask), Data Layer (SQLAlchemy).
- Micro-services style integration points for AI APIs.
- Single-page Application for frontend.
- Containerization: backend Dockerfile + start.sh script.
d. Key Technologies & Libraries
- Frontend: React, Vite, Tailwind, Recharts, OpenCV (for webcam capture)
- Backend: Flask, SQLAlchemy, SQLite/MySQL, Python scripts for AI integration
- External: OpenAI API, Cohere API, GCP Speech-to-Text

##### Detailing & Component Separation
- API Layer: `app.py` routes
- Business Layer: `cohere_api.py`, `audio_transcription.py`, `config.py`
- Data Layer: `models.py`, `init_db.py`
- For frontend, group by feature: Authentication, Interview Flow, Feedback/Analytics.
- Use of Docker and environment variables for dev/prod.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React UI)"
        direction TB
        MainEntry["main.jsx"]:::frontend
        HTMLTemplate["index.html"]:::frontend
        ViteConfig["vite.config.js"]:::frontend
        TailwindConfig["tailwind.config.js"]:::frontend
        GlobalCSS["index.css"]:::frontend
        PublicAssets["public"]:::frontend
        Login["Login.jsx"]:::frontend
        Dashboard["Dashboard.jsx"]:::frontend
        Practice["Practice.jsx"]:::frontend
        Feedback["Feedback.jsx"]:::frontend
        GetStarted["GetStarted.jsx"]:::frontend
        About["About.jsx"]:::frontend
        AboutPage["AboutPage.jsx"]:::frontend
        Navbar["Navbar.jsx"]:::frontend
        LoadingSpinner["LoadingSpinner.jsx"]:::frontend
        BackgroundPolygons["BackgroundPolygons.jsx"]:::frontend
        PackageJSON["package.json"]:::frontend
        LockFile["package-lock.json"]:::frontend
        ESLint["eslint.config.js"]:::frontend
        PostCSS["postcss.config.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Flask API)"
        direction TB
        App["app.py"]:::backend
        Config["config.py"]:::backend
        InitDB["init_db.py"]:::backend
        Models["models.py"]:::backend
        SQLiteScript["SQLite.sql"]:::backend
        DBFile["ai_interview_bot.db"]:::backend
        CohereAPI["cohere_api.py"]:::backend
        AudioTranscription["audio_transcription.py"]:::backend
        StartScript["start.sh"]:::backend
        Dockerfile["Dockerfile"]:::backend
    end

    %% External & Infrastructure
    Browser["User Browser"]:::external
    DB["SQLite DB"]:::db
    Storage["Uploads Folder"]:::storage
    TopStorage["uploads/"]:::storage
    AICloud1["OpenAI"]:::external
    AICloud2["Cohere"]:::external
    AICloud3["GCP STT"]:::external

    %% Relationships
    Browser -->|"interacts with"| MainEntry
    MainEntry -->|"loads UI components"| Login
    MainEntry --> Dashboard
    MainEntry --> Practice
    MainEntry --> Feedback
    MainEntry --> GetStarted
    MainEntry --> About
    MainEntry --> Navbar
    MainEntry --> LoadingSpinner
    MainEntry --> BackgroundPolygons

    MainEntry -->|builds| ViteConfig
    MainEntry -->|styles| TailwindConfig
    MainEntry -->|imports| GlobalCSS
    MainEntry -->|serves assets| PublicAssets

    Browser -->|"calls REST API"| App
    App -->|"reads/writes"| DB
    DB -->|"read/write"| App
    App -->|"stores files"| Storage
    Storage -->|"persists to"| TopStorage

    App -.->|"async call"| CohereAPI
    App -.->|"async call"| AudioTranscription
    App -.->|"async call"| AICloud1
    CohereAPI -.-> AICloud2
    AudioTranscription -.-> AICloud3

    %% Click Events
    click MainEntry "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/main.jsx"
    click HTMLTemplate "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/index.html"
    click ViteConfig "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/vite.config.js"
    click TailwindConfig "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/tailwind.config.js"
    click GlobalCSS "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/index.css"
    click PublicAssets "https://github.com/ajith-bondili/ai-interviewer/tree/main/frontend/public"
    click Login "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/Login.jsx"
    click Dashboard "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/Dashboard.jsx"
    click Practice "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/Practice.jsx"
    click Feedback "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/Feedback.jsx"
    click GetStarted "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/GetStarted.jsx"
    click About "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/About.jsx"
    click AboutPage "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/AboutPage.jsx"
    click Navbar "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/Navbar.jsx"
    click LoadingSpinner "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/LoadingSpinner.jsx"
    click BackgroundPolygons "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/src/components/BackgroundPolygons.jsx"
    click PackageJSON "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/package.json"
    click LockFile "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/package-lock.json"
    click ESLint "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/eslint.config.js"
    click PostCSS "https://github.com/ajith-bondili/ai-interviewer/blob/main/frontend/postcss.config.js"

    click App "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/app.py"
    click Config "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/config.py"
    click InitDB "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/init_db.py"
    click Models "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/models.py"
    click SQLiteScript "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/SQLite.sql"
    click DBFile "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/ai_interview_bot.db"
    click CohereAPI "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/cohere_api.py"
    click AudioTranscription "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/audio_transcription.py"
    click StartScript "https://github.com/ajith-bondili/ai-interviewer/blob/main/backend/start.sh"
    click Dockerfile "https://github.com/ajith-bondili/ai-interviewer/tree/main/backend/Dockerfile"
    click Storage "https://github.com/ajith-bondili/ai-interviewer/tree/main/backend/uploads/"
    click TopStorage "https://github.com/ajith-bondili/ai-interviewer/tree/main/uploads/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#89CFF0,stroke:#000,stroke-width:1px
    classDef db fill:#90EE90,stroke:#000,stroke-width:1px
    classDef storage fill:#F4A460,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
