# hassan-farid/urecipy architecture

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

- Interactive diagram: https://gitdiagram.com/hassan-farid/urecipy
- Repository: https://github.com/hassan-farid/urecipy

## Overview

##### Main Components

a) Frontend Layer:
- Templates directory with two HTML files (home.html and recipe.html)

b) Application Layer:
- Center the main Flask application (app.py) as the core controller
- Utility modules (utils.py and db_ops.py) as supporting components

c) Storage Layer:
- SQLite database (data.db)
- Audio storage directory (audios/)

d) External Services:
- gTTS (Google Text-to-Speech) API integration

##### Component Relationships

- User → Frontend (HTTP requests)
- Frontend → Application Layer (Flask routes)
- Application Layer → Database Layer (CRUD operations)
- Application Layer → Audio Storage (File I/O)
- Application Layer → gTTS API (Text-to-speech conversion)

##### Specific Design Elements

Use these visual elements:
- Blue rectangles for frontend components
- Green rectangles for application layer components
- Purple rectangle for audio storage
- Orange rectangle for external gTTS API

**[User/Browser]**
- ↓
**[Frontend Layer (Templates)]**
- ↓
**[Application Layer]**
- ↙     ↓     ↘
**[DB] [Audio] [gTTS API]**

##### Important Details

a) Data Flow Annotations:
- HTTP/HTTPS requests between layers
- File I/O operations for audio handling
- Database queries
- API calls to gTTS

b) Key Components:
- Flask application server
- Template rendering engine
- Database operations module
- Audio processing utilities
- Text-to-speech conversion service

##### Technical Specifications

- Technology stack: Flask, SQLite, gTTS
- File formats: HTML, MP4 (for audio)
- Database schema reference
- API endpoints

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Legend"
        L1[Frontend Component]:::frontend
        L2[Application Component]:::application
        L3[(Database)]:::database
        L4[Storage Component]:::storage
        L5[External Service]:::external
    end

    subgraph "Frontend Layer"
        Browser["Web Browser"]:::frontend
        Templates["Templates"]:::frontend
        HomeTemplate["home.html"]:::frontend
        RecipeTemplate["recipe.html"]:::frontend
    end

    subgraph "Application Layer"
        Flask["Flask App"]:::application
        DBOps["Database Operations"]:::application
        Utils["Utility Functions"]:::application
    end

    subgraph "Storage Layer"
        DB[(SQLite Database)]:::database
        AudioStorage["Audio Storage"]:::storage
    end

    subgraph "External Services"
        gTTS["Google TTS API"]:::external
    end

    Browser --> Templates
    Templates --> HomeTemplate
    Templates --> RecipeTemplate
    HomeTemplate --> Flask
    RecipeTemplate --> Flask
    Flask --> DBOps
    Flask --> Utils
    DBOps --> DB
    Utils --> AudioStorage
    Utils --> gTTS
    gTTS --> AudioStorage

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef application fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white

    click Templates "https://github.com/Hassan-Farid/Urecipy/tree/master/templates"
    click HomeTemplate "https://github.com/Hassan-Farid/Urecipy/blob/master/templates/home.html"
    click RecipeTemplate "https://github.com/Hassan-Farid/Urecipy/blob/master/templates/recipe.html"
    click Flask "https://github.com/Hassan-Farid/Urecipy/blob/master/app.py"
    click DBOps "https://github.com/Hassan-Farid/Urecipy/blob/master/db_ops.py"
    click Utils "https://github.com/Hassan-Farid/Urecipy/blob/master/utils.py"
    click DB "https://github.com/Hassan-Farid/Urecipy/blob/master/data.db"
    click AudioStorage "https://github.com/Hassan-Farid/Urecipy/tree/master/audios"
```
