# davirizzo/slide-generation-app architecture

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

- Interactive diagram: https://gitdiagram.com/davirizzo/slide-generation-app
- Repository: https://github.com/davirizzo/slide-generation-app

## Overview

##### Main components
- Client/Frontend: Represent components in the app directory (pages such as page.tsx, editor/page.tsx, preview/page.tsx, sign-in, sign-up, etc.) along with the reusable UI components in the components/ directory (including a rich set of UI elements under components/ui).
- API Layer: Break out the API endpoints found under app/api. Create separate subdivisions for handling presentations, templates, and themes. Note that some endpoints have dynamic routing (e.g., [id] folders indicating parameterized routes) which means data is fetched or manipulated per resource.
- Business Logic / Integration Layer: Group the code in the lib folder (lib/google, lib/openai, lib/supabase) which handles external integrations and business logic. This is where your application communicates with external services.
- Database: Represent the Supabase setup. The supabase/migrations directory shows SQL scripts to create and verify presentations, meaning a relational database is at the core.
- Static Assets & Styling: Visual assets (logos, fonts, global CSS in app/globals.css, Tailwind config) that are used by the frontend; these are supporting resources rather than core logic.
- Middleware/Configuration: Include important files like next.config.js(.mjs), tsconfig.json, and middleware.ts that dictate project behavior and routing.

##### Relationships and interactions
- Optionally, denote any common dependency where the UI components might also import utilities, hooks, or shared types (from files in hooks, types, and lib/utils).

##### Architectural patterns and design principles
- Full-stack separation: Emphasize the clear division between UI (client-side) and the server/API layer.
- RESTful API design: Illustrate the structured API endpoints with dynamic routing (see the [id] routes) which follow REST paradigms.
- Modularization: Point out that the project is broken down into reusable components (under components/) and segregated business logic (under lib/).
- Integration with external services: Represent how the application leverages external APIs provided by Google, OpenAI, and Supabase to extend functionality.

##### Relevant technologies and libraries
- Next.js Dynamic Routing and API Routes: The core frameworks utilized for building both client pages and server endpoints.
- Tailwind CSS: For styling and responsive design (see tailwind.config.ts).
- Supabase: As the backend-as-a-service solution for database interactions, suggested by migration scripts and the lib/supabase directory.
- External APIs: Google Fonts/other Google services and OpenAI integrations via the libraries in lib/google and lib/openai.
- UI Component Libraries: A comprehensive set of UI elements (buttons, dialogs, modals, etc.) organized under components/ui.

- A distinct block for the Client (driven by Next.js pages like the editor, sign-in/up, presentations, etc.).
- A block for the API routes segregated into different endpoints (e.g., presentations, templates, themes with both generic and [id] routes).
- A block for the integration layer that shows external API clients (Google, OpenAI) and the Supabase client.
- A block depicting the Supabase database where the migrations apply.
- Auxiliary blocks to show configuration, middleware, and assets where relevant.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client/UI (Next.js Pages)
    subgraph "Client/UI (Next.js Pages)"
        home["Home (app/page.tsx)"]:::frontend
        editor["Editor (app/editor/page.tsx)"]:::frontend
        preview["Preview (app/preview/page.tsx)"]:::frontend
        signin["Sign-In (app/sign-in/[[...sign-in]]/page.tsx)"]:::frontend
        signup["Sign-Up (app/sign-up/[[...sign-up]]/page.tsx)"]:::frontend
        presentationsPage["Presentations (app/presentations/page.tsx)"]:::frontend
        templatesPage["Templates (app/templates/page.tsx)"]:::frontend
        reusableUI["Reusable UI Components (components/ & components/ui)"]:::frontend
    end

    %% API Layer (Server Endpoints)
    subgraph "API Layer (Server Endpoints)"
        presAPI["Presentations API (app/api/presentations/route.ts)"]:::api
        presDynAPI["Presentations Dynamic API (app/api/presentations/[id]/route.ts)"]:::api
        tempAPI["Templates API (app/api/templates/route.ts)"]:::api
        tempDynAPI["Templates Dynamic API (app/api/templates/[id]/route.ts)"]:::api
        themesAPI["Themes API (app/api/themes/route.ts)"]:::api
    end

    %% Business Logic / Integration
    subgraph "Business Logic / Integration"
        google["Google Integration (lib/google/client.ts)"]:::integration
        openai["OpenAI Integration (lib/openai/client.ts)"]:::integration
        supabaseInt["Supabase Integration (lib/supabase/client.ts)"]:::integration
        utils["Utilities & Types (lib/utils.ts & lib/types.ts)"]:::integration
    end

    %% Database
    subgraph "Database"
        supabaseDB["Supabase Database"]:::database
        migCreate["Migration: create_presentations (supabase/migrations/20250128_create_presentations.sql)"]:::database
        migVerify["Migration: verify_presentations (supabase/migrations/20250128_verify_presentations.sql)"]:::database
    end

    %% Static Assets & Styling
    subgraph "Static Assets & Styling"
        globalStyles["Global Styles (app/globals.css)"]:::assets
        tailwindCfg["Tailwind Config (tailwind.config.ts)"]:::assets
        assets["Assets (app/assets/ & app/assets/logos)"]:::assets
        fonts["Fonts (app/fonts)"]:::assets
        publicLogos["Public Logos (public/logos)"]:::assets
    end

    %% Middleware/Configuration
    subgraph "Middleware/Configuration"
        nextConfig["Next Config (next.config.js)"]:::config
        nextConfigMJS["Next Config MJS (next.config.mjs)"]:::config
        tsconfig["TS Config (tsconfig.json)"]:::config
        middleware["Middleware (middleware.ts)"]:::config
    end

    %% Client to API connections
    presentationsPage -->|"HTTP"| presAPI
    presentationsPage -->|"HTTP"| presDynAPI
    templatesPage -->|"HTTP"| tempAPI
    templatesPage -->|"HTTP"| tempDynAPI
    editor -->|"HTTP"| themesAPI

    %% API to Integration connections
    presAPI -->|"calls"| google
    presAPI -->|"calls"| openai
    presAPI -->|"calls"| supabaseInt

    presDynAPI -->|"calls"| google
    presDynAPI -->|"calls"| openai
    presDynAPI -->|"calls"| supabaseInt

    tempAPI -->|"calls"| supabaseInt
    tempDynAPI -->|"calls"| supabaseInt

    themesAPI -->|"calls"| supabaseInt

    %% Integration to Database connection
    supabaseInt -->|"queries"| supabaseDB

    %% Reusable UI to Utilities connection
    reusableUI -->|"imports"| utils

    %% Middleware/Configuration influence
    nextConfig -->|"configures"| home
    nextConfig -->|"configures"| presAPI
    nextConfigMJS -->|"configures"| home
    middleware -->|"handles"| presAPI

    %% Migrations linking to Database
    migCreate --> supabaseDB
    migVerify --> supabaseDB

    %% Static Assets contributions to Client/UI
    assets -->|"provides"| home
    globalStyles -->|"styles"| home
    fonts -->|"provides"| home
    publicLogos -->|"provides"| home

    %% Click Events for Client/Frontend
    click home "https://github.com/davirizzo/slide-generation-app/blob/main/app/page.tsx"
    click editor "https://github.com/davirizzo/slide-generation-app/blob/main/app/editor/page.tsx"
    click preview "https://github.com/davirizzo/slide-generation-app/blob/main/app/preview/page.tsx"
    click signin "https://github.com/davirizzo/slide-generation-app/blob/main/app/sign-in/[[...sign-in]]/page.tsx"
    click signup "https://github.com/davirizzo/slide-generation-app/blob/main/app/sign-up/[[...sign-up]]/page.tsx"
    click presentationsPage "https://github.com/davirizzo/slide-generation-app/blob/main/app/presentations/page.tsx"
    click templatesPage "https://github.com/davirizzo/slide-generation-app/blob/main/app/templates/page.tsx"
    click reusableUI "https://github.com/davirizzo/slide-generation-app/tree/main/components/"

    %% Click Events for API Layer
    click presAPI "https://github.com/davirizzo/slide-generation-app/blob/main/app/api/presentations/route.ts"
    click presDynAPI "https://github.com/davirizzo/slide-generation-app/blob/main/app/api/presentations/[id]/route.ts"
    click tempAPI "https://github.com/davirizzo/slide-generation-app/blob/main/app/api/templates/route.ts"
    click tempDynAPI "https://github.com/davirizzo/slide-generation-app/blob/main/app/api/templates/[id]/route.ts"
    click themesAPI "https://github.com/davirizzo/slide-generation-app/blob/main/app/api/themes/route.ts"

    %% Click Events for Business Logic / Integration
    click google "https://github.com/davirizzo/slide-generation-app/blob/main/lib/google/client.ts"
    click openai "https://github.com/davirizzo/slide-generation-app/blob/main/lib/openai/client.ts"
    click supabaseInt "https://github.com/davirizzo/slide-generation-app/blob/main/lib/supabase/client.ts"
    click utils "https://github.com/davirizzo/slide-generation-app/blob/main/lib/utils.ts"

    %% Click Events for Database
    click migCreate "https://github.com/davirizzo/slide-generation-app/blob/main/supabase/migrations/20250128_create_presentations.sql"
    click migVerify "https://github.com/davirizzo/slide-generation-app/blob/main/supabase/migrations/20250128_verify_presentations.sql"

    %% Click Events for Static Assets & Styling
    click globalStyles "https://github.com/davirizzo/slide-generation-app/blob/main/app/globals.css"
    click tailwindCfg "https://github.com/davirizzo/slide-generation-app/blob/main/tailwind.config.ts"
    click assets "https://github.com/davirizzo/slide-generation-app/tree/main/app/assets/"
    click fonts "https://github.com/davirizzo/slide-generation-app/tree/main/app/fonts"
    click publicLogos "https://github.com/davirizzo/slide-generation-app/tree/main/public/logos"

    %% Click Events for Middleware/Configuration
    click nextConfig "https://github.com/davirizzo/slide-generation-app/blob/main/next.config.js"
    click nextConfigMJS "https://github.com/davirizzo/slide-generation-app/blob/main/next.config.mjs"
    click tsconfig "https://github.com/davirizzo/slide-generation-app/blob/main/tsconfig.json"
    click middleware "https://github.com/davirizzo/slide-generation-app/blob/main/middleware.ts"

    %% Styles
    classDef frontend fill:#A8DADC,stroke:#457B9D,stroke-width:2px;
    classDef api fill:#FAD4A5,stroke:#E76F51,stroke-width:2px;
    classDef integration fill:#C9F0FF,stroke:#1B4F72,stroke-width:2px;
    classDef database fill:#C3E88D,stroke:#43A047,stroke-width:2px;
    classDef assets fill:#FFCB77,stroke:#D9480F,stroke-width:2px;
    classDef config fill:#F4A261,stroke:#E76F51,stroke-width:2px;
```
