# ksaurabhsingh/ai_interview architecture

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

- Interactive diagram: https://gitdiagram.com/ksaurabhsingh/ai_interview
- Repository: https://github.com/ksaurabhsingh/ai_interview

## Overview

##### Project Type and Purpose
- This is a full-stack, Python-based web application designed to automate voice interviews.
- It provides resume upload, AI-driven question generation, text-to-speech for asking questions, speech-to-text for capturing answers, NLP-based summarization and evaluation, and finally outputs a scored Excel report.

##### Main Architectural Components
a. Frontend Layer
- Streamlit UI – main user interface for uploading resumes, starting interviews, viewing progress, and downloading reports.
- Flask API – serves as an internal HTTP layer (if used directly by Streamlit or external clients).
b. Backend Pipeline
- Resume Parser & RAG Module – ingests PDF/DOCX, extracts key info via Retrieval-Augmented Generation.
- Question Generator – leverages LangChain + Llama 3.2 to craft tailored interview questions.
- TTS Engine – Coqui TTS for converting text questions to audio.
- Audio I/O Module – PyAudio to play questions and record candidate responses.
- STT Engine – Silero (or equivalent) to transcribe recorded audio into text.
- Summarization & Evaluation Module – uses NLP models (Llama via Ollama) to summarize answers, score them, and generate remarks/attributes.
c. Data & Storage
- Excel Report Generator – writes candidate responses, scores, and attributes to an XLSX file.
- Logging – local file-based logging for debugging and audit trails.
d. External Services & Libraries
- LangChain & Ollama – orchestration of LLM calls.
- Coqui TTS & Silero – speech synthesis/recognition.
- Python Ecosystem – virtual environment, pip dependencies.

##### Component Interactions and Data Flow
- The user interacts with Streamlit UI → Streamlit sends REST/gRPC calls to Flask endpoints or invokes pipeline functions directly.
- Resume upload flows into the Resume Parser → Extracted data moves into the Question Generator.
- Generated questions are passed to the TTS Engine → Audio is played via PyAudio.
- Candidate speaks back → PyAudio records input → STT Engine transcribes audio → Text goes to Summarization & Evaluation.
- Evaluation outputs (scores, remarks) feed into the Excel Report Generator → Downloadable .xlsx.
- Throughout, each module logs activity to the Logging component.

##### Architectural Patterns & Principles
- Layered Architecture – clear separation between UI, API, business logic, model integration, and data persistence.
- Orchestrator/Coordinator – a central controller (Flask or a pipeline manager) sequences resume parsing, question generation, TTS/STT, and evaluation.
- Modular Design – each major function (parsing, question gen, TTS, STT, evaluation) is encapsulated in its own module or service for easy testing and replacement.

## Diagram (Mermaid)

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

    %% Frontend Layer
    subgraph "Frontend Layer"
        Streamlit["Streamlit UI"]:::ui
        FlaskAPI["Flask API"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic" 
        Parser["Resume Parser & RAG Module"]:::logic
        QGen["Question Generator\nLangChain + Llama 3.2"]:::logic
        Orchestrator["Pipeline Orchestrator\n(Flask/Pipeline Manager)"]:::logic
    end

    %% AI Services Layer
    subgraph "AI & Speech Services"
        LangChain["LangChain & Ollama"]:::service
        TTS["TTS Engine\nCoqui TTS"]:::service
        AudioIO["Audio I/O Module\nPyAudio"]:::service
        STT["STT Engine\nSilero STT"]:::service
        Eval["Summarization & Evaluation\nLlama via Ollama"]:::service
    end

    %% Data & Storage Layer
    subgraph "Data & Storage"
        Excel["Excel Report Generator"]:::storage
        Logging["Logging Module\nFile-based"]:::storage
        Docs["Project Documentation\nREADME.md"]:::storage
    end

    %% Flow Connections
    User -->|interacts with| Streamlit
    Streamlit -->|calls| FlaskAPI
    FlaskAPI -->|invoke| Orchestrator
    Orchestrator -->|upload resume| Parser
    Parser -->|parsed data| QGen
    QGen -->|questions| TTS
    TTS -->|audio output| AudioIO
    AudioIO -->|plays question| User
    User -->|speaks answer| AudioIO
    AudioIO -->|recorded audio| STT
    STT -->|transcript text| Eval
    Eval -->|evaluation results| Excel
    Orchestrator -->|logs events| Logging
    Parser -->|calls LLM| LangChain
    QGen -->|calls LLM| LangChain
    Eval -->|calls LLM| LangChain

    %% Click Events
    click Docs "https://github.com/ksaurabhsingh/ai_interview/blob/main/README.md"

    %% Styles
    classDef external fill:#FFFFFF,stroke:#000000,stroke-width:1px;
    classDef ui fill:#E0F7FA,stroke:#00796B,stroke-width:2px;
    classDef api fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;
    classDef logic fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef service fill:#FFF3E0,stroke:#F57C00,stroke-width:2px;
    classDef storage fill:#E0E0E0,stroke:#616161,stroke-width:2px;
```
