# venkatjogi/ai-workshop architecture

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

- Interactive diagram: https://gitdiagram.com/venkatjogi/ai-workshop
- Repository: https://github.com/venkatjogi/ai-workshop

## Overview

##### Project type and purpose
- This is a full-stack AI study assistant (“AI-Workshop”) built with React on the frontend and Flask on the backend.
- It lets users type or speak questions, upload PDFs, calls GPT-4 to generate answers, optionally reads them aloud, and can email results.

##### File structure
- Top-level:
- backend/ – Flask server, exposes REST endpoints (/ask, /send-email), holds config (.env) and dependencies (requirements.txt).
- frontend/ – React single-page app with public/ (index.html) and src/ (React components, CSS).
- Components:
- ChatBox.js handles UI, speech-to-text, PDF parsing (pdfjs-dist), fetch calls to backend, and text-to-speech.
- app.py implements two POST routes: /ask (GPT-4 via OpenAI SDK) and /send-email (SMTP via smtplib).
- Build/config: package.json, requirements.txt, .env, CORS enabled for cross-origin calls.

##### README for additional insights
- The README details the code flow (index.html → index.js → App.js → ChatBox.js → backend endpoints → GPT-4/SMTP).
- It lists environment variables (OPENAI_API_KEY, SMTP_SENDER, SMTP_PASSWORD).
- It describes how frontend features (speech recognition, PDF upload) augment the ChatBox.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User & Browser
    subgraph "User & Browser"
        direction TB
        User["User"]:::ui
    end

    %% Frontend Layer
    subgraph "Frontend (React)" 
        direction TB
        SPA["React SPA"]:::ui
        Public["public/index.html"]:::ui
        Entry["src/index.js"]:::ui
        App["App.js"]:::ui
        ChatBox["ChatBox.js"]:::ui
        Package["package.json"]:::ui
    end

    %% Backend Layer
    subgraph "Backend (Flask)"
        direction TB
        FlaskApp["app.py"]:::backend
        Env[".env"]:::backend
        Req["requirements.txt"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OpenAI["OpenAI GPT-4 API"]:::external
        SMTP["SMTP Server"]:::external
    end

    %% Flows
    User -->|"visits"| SPA
    SPA -->|"loads"| Public
    Public -->|"runs"| Entry
    Entry -->|"renders"| App
    App -->|"mounts"| ChatBox

    ChatBox -->|"POST { prompt }|/ask"| FlaskApp
    FlaskApp -->|"calls API"| OpenAI
    OpenAI -->|"returns JSON"| FlaskApp
    FlaskApp -->|"returns JSON response"| ChatBox
    ChatBox -->|"text-to-speech audio"| User

    ChatBox -->|"POST {prompt,response}|/send-email"| FlaskApp
    FlaskApp -->|"sends email via"| SMTP

    Env -->|"config for"| FlaskApp
    Req -->|"deps for"| FlaskApp

    %% Click events
    click SPA "https://github.com/venkatjogi/ai-workshop/tree/main/frontend/"
    click Public "https://github.com/venkatjogi/ai-workshop/blob/main/frontend/public/index.html"
    click Entry "https://github.com/venkatjogi/ai-workshop/blob/main/frontend/src/index.js"
    click App "https://github.com/venkatjogi/ai-workshop/blob/main/frontend/src/App.js"
    click ChatBox "https://github.com/venkatjogi/ai-workshop/blob/main/frontend/src/components/ChatBox.js"
    click Package "https://github.com/venkatjogi/ai-workshop/blob/main/frontend/package.json"
    click FlaskApp "https://github.com/venkatjogi/ai-workshop/blob/main/backend/app.py"
    click Env "https://github.com/venkatjogi/ai-workshop/blob/main/backend/.env"
    click Req "https://github.com/venkatjogi/ai-workshop/blob/main/backend/requirements.txt"

    %% Styles
    classDef ui fill:#D0E4FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
