# allweonedev/presentation-ai architecture

> Architecture diagram of the GitHub repository allweonedev/presentation-ai, 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/allweonedev/presentation-ai
- Repository: https://github.com/allweonedev/presentation-ai

## Overview

Based on our analysis of the file tree and the README, this project is an open-source, full-stack AI-powered presentation generator built with Next.js and React. Its key purpose is to generate, edit, and present slides using AI technologies, integrating multiple services such as OpenAI for content generation, Together AI for image generation, and NextAuth for authentication. The project is structured as a modern full-stack web application with clearly separated concerns.

##### Main Components
- Frontend Application: Built using Next.js and React. It includes pages (under src/app) for dashboard, authentication, presentation creation, editing, and viewing. There is an extensive folder structure devoted to components for presentation editing (custom elements, outline, theme, text editor using Plate Editor), drag-and-drop functionality, and various UI parts (in src/components/ui).
- Backend/API: The application leverages Next.js API routes (in src/app/api) for authentication (NextAuth routes), presentation generation (including outline and slide generation), image generation (UploadThing), and file handling.
- Server-side Logic: Under src/server, code handles authentication, database connectivity, and other server-related utilities. There is also integration with Next.js middleware (src/middleware.ts).
- Database Layer: Managed by Prisma (prisma/schema.prisma) which integrates with a PostgreSQL database.
- External Services:
- AI Content Generation via the OpenAI API.
- Image Generation via the Together AI API.
- Authentication integrations with Google (via NextAuth).
- File Uploads handled by UploadThing.
- State and Context Management: The project employs multiple React hooks (in src/hooks) and state management (in src/states) along with several context providers (in src/provider) that wrap the application to supply configuration and theme data.

##### Out the Relationships and Interactions
- Client (Browser) interacts with the Frontend Application to request pages and functionality.
- Frontend components, including specialized editors and UI elements, communicate with API routes (for tasks like generating outlines or presentations) through HTTP requests and via Next.js server-side functions.
- API endpoints serve as the bridge between the frontend and backend server logic. They coordinate authentication (using NextAuth), initiate AI-content generation, manage file uploads, and interact with the PostgreSQL database through Prisma.
- The server-side code (in src/server) handles business logic tasks, server configuration, and interacts with external APIs.
- External services (OpenAI, Together AI, Google OAuth, UploadThing) are directly integrated within the API logic and during client-side interactions (e.g., triggering image generation or handling sign-in flows).

##### Architectural Patterns and Important Technologies
- Framework/Library Choices: Next.js for server-side rendering and routing, React for UI, and TypeScript for static typing.
- Component-based Architecture: The frontend is modularized into many reusable components (e.g., presentation editor, theme selectors, drag-and-drop elements, text editors) that demonstrate separation of concerns.
- API and Server Abstraction: Use of Next.js API routes to encapsulate backend logic and separate presentation layers from service/API integrations.
- External Service Integration: Distinct services are used for content and image generation, authentication, and file uploads.
- Drag-and-Drop and Rich Text Editing: Specialized components and hooks (under src/components/presentation/editor and src/components/text-editor) indicate advanced front–end interactions using libraries like DND Kit and Plate Editor.

- From Frontend to API (HTTP requests for generating presentations, authentication, etc.).
- From API to External Services (for AI and image generation).
- From API to Database (via Prisma).
- UI Components (e.g., rectangles for pages and components).
- Data Storage (e.g., database symbols for PostgreSQL).
- Clearly label providers like NextAuth, Tanstack, and integration points for UploadThing.

- Out the comprehensive directory structure to capture specialized areas – such as the presentation and text editing functionalities – to ensure that every core function (AI generation, customization, real-time editing, authentication) is clearly represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client / Frontend Layer
    subgraph "Client (Frontend)"
        FE1["Pages (Next.js & React)"]:::frontend
        FE2["UI Components (Components & Presentation)"]:::frontend
        FE3["Presentation Editor & Slide Controls"]:::frontend
        FE4["Dashboard & Outline Management"]:::frontend
        FE5["State & Context Management"]:::frontend
    end

    %% API / Backend Layer
    subgraph "API/Backend"
        BE1["API Routes"]:::backend
        BE2["Server Logic & Middleware"]:::backend
    end

    %% Database Layer
    subgraph "Database"
        DB1["Prisma Schema (PostgreSQL)"]:::database
    end

    %% External Services
    subgraph "External Services"
        EX1["OpenAI API"]:::external
        EX2["Together AI API"]:::external
        EX3["Google OAuth"]:::external
        EX4["UploadThing Service"]:::external
    end

    %% Connections for Client Layer
    FE1 -->|"renders"| FE2
    FE2 -->|"invokes"| FE3
    FE3 -->|"triggers"| FE4
    FE5 -->|"provides state to"| FE1
    FE5 --> FE2

    %% Connections between Frontend and API/Backend
    FE1 -->|"HTTP calls"| BE1
    FE2 -->|"HTTP calls"| BE1
    FE3 -->|"HTTP calls"| BE1
    FE4 -->|"HTTP calls"| BE1

    %% API/Backend interactions
    BE1 -->|"authenticates via"| EX3
    BE1 -->|"calls for content"| EX1
    BE1 -->|"calls for images"| EX2
    BE1 -->|"file upload"| EX4
    BE1 -->|"database operations"| DB1
    BE2 -->|"supports API logic"| BE1

    %% Click Events - Frontend
    click FE1 "https://github.com/allweonedev/presentation-ai/tree/main/src/app"
    click FE2 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/ui"
    click FE2 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/presentation"
    click FE2 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/text-editor"
    click FE2 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/prose-mirror"
    click FE3 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/presentation/editor"
    click FE3 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/presentation/presentation-page"
    click FE4 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/presentation/dashboard"
    click FE4 "https://github.com/allweonedev/presentation-ai/tree/main/src/components/presentation/outline"
    click FE5 "https://github.com/allweonedev/presentation-ai/tree/main/src/hooks"
    click FE5 "https://github.com/allweonedev/presentation-ai/blob/main/src/states/presentation-state.ts"
    click FE5 "https://github.com/allweonedev/presentation-ai/tree/main/src/provider"

    %% Click Events - API/Backend
    click BE1 "https://github.com/allweonedev/presentation-ai/tree/main/src/app/api"
    click BE1 "https://github.com/allweonedev/presentation-ai/blob/main/src/app/api/auth/[...nextauth]"
    click BE1 "https://github.com/allweonedev/presentation-ai/tree/main/src/app/api/presentation/generate"
    click BE1 "https://github.com/allweonedev/presentation-ai/tree/main/src/app/api/presentation/outline"
    click BE1 "https://github.com/allweonedev/presentation-ai/tree/main/src/app/api/uploadthing"
    click BE2 "https://github.com/allweonedev/presentation-ai/tree/main/src/server"
    click BE2 "https://github.com/allweonedev/presentation-ai/blob/main/src/middleware.ts"

    %% Click Events - Database
    click DB1 "https://github.com/allweonedev/presentation-ai/blob/main/prisma/schema.prisma"

    %% Click Events - External Actions (for file image generation actions)
    click EX4 "https://github.com/allweonedev/presentation-ai/tree/main/src/app/api/uploadthing"
    click EX2 "https://github.com/allweonedev/presentation-ai/blob/main/src/app/_actions/image/generate.ts"
    
    %% Styling
    classDef frontend fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef database fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef external fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
```
