# aryan-r-patel/audiofy architecture

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

- Interactive diagram: https://gitdiagram.com/aryan-r-patel/audiofy
- Repository: https://github.com/aryan-r-patel/audiofy

## Overview

##### Project type and purpose
- Audiofy is a full-stack web application built with Flask (Python) on the backend and HTML/CSS/Bootstrap templates on the frontend.
- Its primary purpose is to accept a PDF upload (or pasted text), extract the text via PyPDF2, generate an AI‐based summary using the Gemini API, convert the text (or summary) to speech via gTTS, and serve the resulting MP3 back to the user.

##### File structure
- Top-level files:
- app.py – main Flask application and HTTP route definitions
- database.py – SQLite connection setup and ORM or helper methods
- requirements.txt – Python dependencies (Flask, gTTS, PyPDF2, Gemini client)
- .gitignore
- Directories:
- static/ – contains images and (potentially) CSS/JS assets
- templates/ – Flask Jinja2 templates: index.html, upload.html, result.html, error.html, layout.html
- test/ – sample PDF(s) for automated/manual testing
- Environment configuration: a .env file holds GEMINI_API_KEY and PROMPT variables.

##### README for additional insights
- Tech stack confirms Flask backend, Bootstrap frontend, SQLite database.
- Workflow details: file upload → text extraction → AI summary → TTS conversion → MP3 delivery.
- Future scope hints at additional file-type support, styling improvements, and more robust PDF parsing.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    subgraph "Frontend/UI"
        direction TB
        Browser["Web Browser"]:::external
        subgraph "Templates" 
            direction TB
            Index["index.html"]:::frontend
            Upload["upload.html"]:::frontend
            Result["result.html"]:::frontend
            ErrorPage["error.html"]:::frontend
            Layout["layout.html"]:::frontend
        end
        subgraph "Static Assets"
            direction TB
            StaticAssets["static/"]:::storage
        end
    end

    %% Backend
    subgraph "Backend Service"
        direction TB
        FlaskApp["Flask App"]:::internal
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Database["SQLite DB"]:::datastore
        FileStorage["Local File Storage"]:::storage
        TestFiles["Sample Test Files"]:::storage
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Gemini["Gemini API"]:::external
        gTTS["Google TTS API"]:::external
    end

    %% Flows
    Browser -->|"HTTP POST /upload"| FlaskApp
    FlaskApp -->|"renders"| Index
    FlaskApp -->|"renders"| Upload
    FlaskApp -->|"renders"| Result
    FlaskApp -->|"renders"| ErrorPage
    FlaskApp -->|"serves static assets"| StaticAssets
    FlaskApp -->|"save PDF/MP3"| FileStorage
    FlaskApp -->|"SQL INSERT/SELECT"| Database
    FlaskApp -->|"uses sample PDFs"| TestFiles
    FlaskApp -->|"POST text→summary"| Gemini
    Gemini -->|"summary"| FlaskApp
    FlaskApp -->|"POST text→MP3"| gTTS
    gTTS -->|"MP3 file"| FlaskApp
    FlaskApp -->|"HTTP Response (MP3/summary)"| Browser
    FlaskApp -->|"on error"| ErrorPage

    %% Click Events
    click FlaskApp "https://github.com/aryan-r-patel/audiofy/blob/main/app.py"
    click Database "https://github.com/aryan-r-patel/audiofy/blob/main/database.py"
    click Index "https://github.com/aryan-r-patel/audiofy/blob/main/templates/index.html"
    click Upload "https://github.com/aryan-r-patel/audiofy/blob/main/templates/upload.html"
    click Result "https://github.com/aryan-r-patel/audiofy/blob/main/templates/result.html"
    click ErrorPage "https://github.com/aryan-r-patel/audiofy/blob/main/templates/error.html"
    click Layout "https://github.com/aryan-r-patel/audiofy/blob/main/templates/layout.html"
    click StaticAssets "https://github.com/aryan-r-patel/audiofy/tree/main/static/"
    click TestFiles "https://github.com/aryan-r-patel/audiofy/blob/main/test/sample1.pdf"

    %% Styles
    classDef internal fill:#D6EAF8,stroke:#3498DB,color:#1B4F72;
    classDef frontend fill:#D5F5E3,stroke:#27AE60,color:#196F3D;
    classDef datastore fill:#FAD7A0,stroke:#E67E22,color:#87431D;
    classDef external fill:#FCF3CF,stroke:#F1C40F,color:#7D6608;
    classDef storage fill:#F5EEF8,stroke:#8E44AD,color:#4A235A;
```
