# arpitpatelsitapur/prepsmart architecture

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

- Interactive diagram: https://gitdiagram.com/arpitpatelsitapur/prepsmart
- Repository: https://github.com/arpitpatelsitapur/prepsmart

## Overview

##### Project Type & Purpose
- This is a Streamlit-based web application designed for technical interview preparation.
- It provides two primary modes: a “Topic to Quiz” mode (for generating customized, multiple-choice quizzes powered by Deepseek R1) and a “Voice-to-Voice AI Interview” mode (leveraging Deepgram for speech-to-text and text-to-speech, and Groq LLM for interview-style interactions).
- The application uses multithreading to handle parallel tasks such as transcription, LLM response generation, and TTS playback.

##### Analyzing the File Structure
- Top-level files include:
- app.py: The primary entry point for the Streamlit app which orchestrates the UI and backend logic.
- requirements.txt and runtime.txt: Define dependencies and runtime configuration.
- .env (as referenced in the README): Holds environment variables like API keys.
- The utils directory contains supporting modules:
- topic_page.py: Likely handles the UI components and logic specific to the quiz interface.
- topic_to_quiz.py: Contains the quiz generation logic using Deepseek R1.
- There may be additional assets, like images (app_logo.png) that are referenced within the README.

##### Key Components
- UI Layer (Frontend):
- Represented by Streamlit components in app.py.
- Includes interactive elements like sidebar options for “Topic to Quiz” and “Voice-to-Voice AI Interview.”
- Business Logic and Utility Modules:
- The quiz generation logic in topic_to_quiz.py.
- The UI logic specifically for the topic page in topic_page.py.
- The use of multithreading for handling parallel processes.
- External Services & APIs:
- Deepseek R1 LLM: Used to generate personalized quiz questions.
- Deepgram API: Handles both Speech-to-Text (STT) and Text-to-Speech (TTS) services.
- Groq LLM: Generates interview-style responses.
- Supporting Configuration:
- Environment Variables (.env file) for API keys.
- Dependency management via requirements.txt and runtime.txt, ensuring deployment consistency.

##### Relationships & Interactions
- The UI (app.py via Streamlit) serves as the hub:
- It calls functions from the utility modules (topic_page.py and topic_to_quiz.py) based on user actions.
- For “Topic to Quiz,” the UI sends user input (chosen topics) to the quiz generation logic, which in turn communicates with the Deepseek R1 API to generate questions.
- For “Voice-to-Voice AI Interview,” the UI triggers a cycle where the user’s speech is captured, then:
- Deepgram API is called for real-time transcription (STT).
- Groq LLM is used to generate responses.
- Deepgram’s TTS is used to convert responses back to speech.
- Multithreading is employed to manage these concurrent tasks without blocking the UI.
- Directional flows should be highlighted:

##### Architectural Patterns & Technologies
- Although this isn’t a multi-tier traditional backend and frontend architecture, a layered approach is evident:
- The presentation layer (Streamlit UI).
- The application logic layer (utility scripts handling the quiz and interview processes).
- The integration layer (communication with external AI services and APIs).
- Emphasis on parallel processing through Python’s multithreading shows the application’s design for responsiveness in real-time interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    A["Streamlit UI (app.py)"]:::ui

    subgraph "Quiz Mode"
        B["Topic Page UI Logic (utils/topic_page.py)"]:::logic
        C["Quiz Generation Logic (utils/topic_to_quiz.py)"]:::logic
        D["Deepseek R1 API"]:::api
    end

    %% Voice-to-Voice Mode Subgraph
    subgraph "Voice-to-Voice Mode"
        F["Multithreading Manager"]:::multiThread
        G["Deepgram API (STT & TTS)"]:::api
        H["Groq LLM API"]:::api
    end

    %% Configuration Subgraph
    subgraph "Configuration"
        K[".env"]:::config
        L["requirements.txt"]:::config
        M["runtime.txt"]:::config
    end

    %% Connections from UI to Quiz Mode
    A -->|"triggers"| B
    B -->|"managesActions"| C
    C -->|"callsQuizAPI"| D

    %% Connections from UI to Voice-to-Voice Mode
    A -->|"initiatesVoiceMode"| F
    F -->|"callsSTT"| G
    F -->|"invokesLLM"| H
    H -->|"requestsTTS"| G

    %% Configuration provides settings to the UI
    L -->|"configures"| A

    %% Click Events
    click A "https://github.com/arpitpatelsitapur/prepsmart/blob/main/app.py"
    click B "https://github.com/arpitpatelsitapur/prepsmart/blob/main/utils/topic_page.py"
    click C "https://github.com/arpitpatelsitapur/prepsmart/blob/main/utils/topic_to_quiz.py"
    click K "https://github.com/arpitpatelsitapur/prepsmart/blob/main/.env"
    click L "https://github.com/arpitpatelsitapur/prepsmart/blob/main/requirements.txt"
    click M "https://github.com/arpitpatelsitapur/prepsmart/blob/main/runtime.txt"

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef logic fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef api fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef config fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
    classDef multiThread fill:#D1C4E9,stroke:#4A148C,stroke-width:2px;
```
