# yuyuanweb/ai-ppt-generator architecture

> Architecture diagram of the GitHub repository yuyuanweb/ai-ppt-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yuyuanweb/ai-ppt-generator
- Repository: https://github.com/yuyuanweb/ai-ppt-generator

## Overview

#### Purpose and Deployable Surfaces
AI PPT is a document-to-editable-slide-deck system: users provide a topic, text, or uploaded document; refine an AI-generated outline; generate and edit slides; then export validated native PPTX. The primary implementation is a React SPA plus FastAPI API/worker stack. A parallel Java/Spring implementation mirrors much of the backend domain and service surface. Entrypoints: `frontend/src/main.tsx`, `backend/app/main.py`, `backend/app/worker/tasks.py`, and `java_backend/src/main/java/com/aippt/Application.java`.

#### Client Application
The React/TypeScript SPA owns project navigation, outline confirmation, generation-progress display, and the slide-editor experience. It calls REST endpoints and consumes SSE for long-running workflow progress. The editor renders structured slide content—not exported images—and supports direct text, layout, theme, image, and AI edits. Key surfaces: `frontend/src/App.tsx`, `frontend/src/features/outline/OutlineWorkspace.tsx`, `frontend/src/features/deck/EditorWorkspace.tsx`.

#### API, Identity, and Persistence Boundary
FastAPI versioned endpoints expose authentication, projects/sources, outlines, deck generation/editing/pages/layout, media, design, and export. Dependency/security code establishes authenticated request context; SQLAlchemy models and Alembic migrations persist users, projects, source documents, outlines, and slides. Relevant paths: `backend/app/api/v1/auth.py`, `backend/app/api/v1/deck/generation.py`, `backend/app/models/project.py`, `backend/alembic/versions/11425e70d184_create_slides.py`.

#### Input-to-Outline Workflow
Project sources enter as topic/text or uploads, are parsed by type-specific ingest adapters, and become normalized source sections. The outline workflow uses LLM structured output to produce a persisted, editable intermediate outline rather than directly generating pages. Input signatures/progress services support recomputation and status reporting. Paths: `backend/app/ingest/registry.py`, `backend/app/workflows/outline.py`, `backend/app/services/outline_inputs.py`.

#### Asynchronous Deck Generation and Events
After outline confirmation, deck/page generation is decomposed into background jobs. ARQ worker tasks execute workflows, apply retry behavior, and publish Redis-backed progress events; the API exposes these through SSE so completed pages become available incrementally and failures can be retried/cancelled per page. Paths: `backend/app/worker/deck_tasks.py`, `backend/app/core/queue.py`, `backend/app/services/events.py`, `backend/app/api/sse.py`.

#### Slide Model, AI Editing, and Layout Engine
Slides separate semantic content, theme, and layout. LLM slide and edit workflows produce constrained structured drafts/patches; domain validation and quality logic gate invalid results. The flex-layout tree/solver supports editable containers, resize/move operations, normalization, presets, and switching layout modes. Frontend equivalents preserve preview/edit parity. Paths: `backend/app/workflows/slide.py`, `backend/app/domain/flex_solve.py`, `backend/app/domain/slide_patch.py`, `frontend/src/features/deck/FlexEditLayer.tsx`.

#### Shared Rendering and Export
Shared JSON catalogs define themes, traditional layouts, and flex presets consumed across runtimes. Browser rendering uses these inputs for previews; server export validates content/geometry/text constraints, constructs native PPTX objects, then verifies the output. Images are acquired/validated through generated, Unsplash, and Bailian providers and stored locally or in COS-compatible storage. Paths: `shared/themes/midnight.json`, `shared/flex-presets/title-bullets.json`, `backend/app/render/pptx.py`, `backend/app/images/pipeline.py`, `backend/app/storage/cos.py`.

#### Runtime Infrastructure
The Python deployment consists of API and worker processes, PostgreSQL-style migration-backed persistence, Redis for queue/pub-sub, configurable LLM clients, object/local storage, and Nginx/container orchestration. The Java backend supplies Spring Boot, MyBatis, Redis queue/event, JWT, storage, and worker counterparts. Paths: `docker-compose.yml`, `backend/Dockerfile`, `java_backend/src/main/java/com/aippt/shared/redis/JobQueue.java`, `nginx.conf`.

Main entry points: [`frontend/src/features/deck/EditorWorkspace.tsx`](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/deck/EditorWorkspace.tsx) (Deck editor), [`backend/app/main.py`](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/main.py) (FastAPI API), [`backend/app/worker/deck_tasks.py`](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/worker/deck_tasks.py) (Deck worker tasks), [`frontend/src/App.tsx`](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/App.tsx) (React SPA)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_spa["React SPA<br/>client app<br/>[App.tsx]"]
  node_outline_ui["Outline workspace<br/>client feature"]
  node_editor_ui["Deck editor<br/>client feature"]
  node_flex_editor["Flex edit layer<br/>client layout<br/>[FlexEditLayer.tsx]"]
end

subgraph group_python["Python backend"]
  node_api["FastAPI API<br/>REST and SSE API<br/>[main.py]"]
  node_deck_api["Deck generation API<br/>API surface<br/>[generation.py]"]
  node_outline_workflow["Outline workflow<br/>LLM workflow<br/>[outline.py]"]
  node_ingest["Source ingest<br/>ingest adapters<br/>[registry.py]"]
  node_worker["Deck worker tasks<br/>ARQ worker<br/>[deck_tasks.py]"]
  node_slide_workflow["Slide and AI edit workflow<br/>LLM workflow<br/>[slide.py]"]
  node_layout_engine["Flex layout engine<br/>domain solver<br/>[flex_solve.py]"]
  node_exporter["PPTX export<br/>renderer<br/>[pptx.py]"]
  node_image_pipeline["Image pipeline<br/>media service<br/>[pipeline.py]"]
end

subgraph group_data["Data and shared assets"]
  node_projects_db[("Projects and slides<br/>SQLAlchemy persistence<br/>[project.py]")]
  node_shared_catalogs["Theme and layout catalogs<br/>shared JSON assets<br/>[midnight.json]"]
  node_object_storage[("Object storage<br/>COS-compatible storage<br/>[cos.py]")]
end

subgraph group_java["Java mirror backend"]
  node_java_app["Spring Boot backend<br/>parallel API runtime<br/>[Application.java]"]
  node_java_queue["Java job queue<br/>Redis worker queue<br/>[JobQueue.java]"]
end

subgraph group_runtime["Runtime infrastructure"]
  node_redis["Redis<br/>queue and pub-sub<br/>[queue.py]"]
  node_deployment{{"Container deployment<br/>orchestration<br/>[docker-compose.yml]"}}
end

node_spa -->|"REST + SSE"| node_api
node_spa -->|"hosts"| node_outline_ui
node_spa -->|"hosts"| node_editor_ui
node_editor_ui -->|"uses"| node_flex_editor
node_outline_ui -->|"confirm outline"| node_deck_api
node_editor_ui -->|"generate and edit"| node_deck_api
node_api -->|"accepts sources"| node_ingest
node_ingest -->|"normalized sections"| node_outline_workflow
node_outline_workflow -->|"persists outline"| node_projects_db
node_deck_api -->|"enqueues jobs"| node_worker
node_worker -->|"runs"| node_slide_workflow
node_slide_workflow -->|"validates layout"| node_layout_engine
node_slide_workflow -->|"persists pages"| node_projects_db
node_worker -->|"jobs and progress"| node_redis
node_api -->|"streams progress"| node_redis
node_editor_ui -->|"renders with"| node_shared_catalogs
node_layout_engine -->|"uses presets"| node_shared_catalogs
node_exporter -->|"reads deck"| node_projects_db
node_exporter -->|"applies themes"| node_shared_catalogs
node_image_pipeline -->|"stores media"| node_object_storage
node_java_app -->|"enqueues jobs"| node_java_queue
node_java_queue -->|"uses"| node_redis
node_deployment -->|"runs"| node_api
node_deployment -->|"runs"| node_worker

click node_spa "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/App.tsx"
click node_outline_ui "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/outline/OutlineWorkspace.tsx"
click node_editor_ui "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/deck/EditorWorkspace.tsx"
click node_flex_editor "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/deck/FlexEditLayer.tsx"
click node_api "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/main.py"
click node_deck_api "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/api/v1/deck/generation.py"
click node_outline_workflow "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/workflows/outline.py"
click node_ingest "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/ingest/registry.py"
click node_worker "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/worker/deck_tasks.py"
click node_slide_workflow "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/workflows/slide.py"
click node_layout_engine "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/domain/flex_solve.py"
click node_exporter "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/render/pptx.py"
click node_image_pipeline "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/images/pipeline.py"
click node_projects_db "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/models/project.py"
click node_shared_catalogs "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/shared/themes/midnight.json"
click node_object_storage "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/storage/cos.py"
click node_java_app "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/java_backend/src/main/java/com/aippt/Application.java"
click node_java_queue "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/java_backend/src/main/java/com/aippt/shared/redis/JobQueue.java"
click node_redis "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/core/queue.py"
click node_deployment "https://github.com/yuyuanweb/ai-ppt-generator/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_spa,node_outline_ui,node_editor_ui,node_flex_editor toneBlue
class node_api,node_deck_api,node_outline_workflow,node_ingest,node_worker,node_slide_workflow,node_layout_engine,node_exporter,node_image_pipeline toneAmber
class node_projects_db,node_shared_catalogs,node_object_storage toneMint
class node_java_app,node_java_queue toneRose
class node_redis,node_deployment toneIndigo
```

## Components

### React client

- [React SPA](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/App.tsx): client app · Project, outline, generation, and editor UI. · `frontend/src/App.tsx`
- [Outline workspace](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/outline/OutlineWorkspace.tsx): client feature · `frontend/src/features/outline/OutlineWorkspace.tsx`
- [Deck editor](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/deck/EditorWorkspace.tsx): client feature · Edits structured slides and previews layouts. · `frontend/src/features/deck/EditorWorkspace.tsx`
- [Flex edit layer](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/frontend/src/features/deck/FlexEditLayer.tsx): client layout · `frontend/src/features/deck/FlexEditLayer.tsx`

### Python backend

- [FastAPI API](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/main.py): REST and SSE API · Authenticated versioned application endpoints. · `backend/app/main.py`
- [Deck generation API](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/api/v1/deck/generation.py): API surface · `backend/app/api/v1/deck/generation.py`
- [Outline workflow](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/workflows/outline.py): LLM workflow · Produces editable persisted outlines. · `backend/app/workflows/outline.py`
- [Source ingest](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/ingest/registry.py): ingest adapters · Parses uploads and normalizes source sections. · `backend/app/ingest/registry.py`
- [Deck worker tasks](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/worker/deck_tasks.py): ARQ worker · Runs generation jobs with retries. · `backend/app/worker/deck_tasks.py`
- [Slide and AI edit workflow](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/workflows/slide.py): LLM workflow · Generates constrained slide drafts and patches. · `backend/app/workflows/slide.py`
- [Flex layout engine](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/domain/flex_solve.py): domain solver · Normalizes editable layout trees and operations. · `backend/app/domain/flex_solve.py`
- [PPTX export](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/render/pptx.py): renderer · Validates and verifies native PPTX output. · `backend/app/render/pptx.py`
- [Image pipeline](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/images/pipeline.py): media service · Acquires and validates provider images. · `backend/app/images/pipeline.py`

### Data and shared assets

- [Projects and slides](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/models/project.py): SQLAlchemy persistence · Projects, sources, outlines, and slides. · `backend/app/models/project.py`
- [Theme and layout catalogs](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/shared/themes/midnight.json): shared JSON assets · Consumed by browser and server rendering. · `shared/themes/midnight.json`
- [Object storage](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/storage/cos.py): COS-compatible storage · `backend/app/storage/cos.py`

### Java mirror backend

Parallel Spring implementation.

- [Spring Boot backend](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/java_backend/src/main/java/com/aippt/Application.java): parallel API runtime · Mirrors backend domain and service surface. · `java_backend/src/main/java/com/aippt/Application.java`
- [Java job queue](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/java_backend/src/main/java/com/aippt/shared/redis/JobQueue.java): Redis worker queue · `java_backend/src/main/java/com/aippt/shared/redis/JobQueue.java`

### Runtime infrastructure

- [Redis](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/backend/app/core/queue.py): queue and pub-sub · Carries jobs and progress events. · `backend/app/core/queue.py`
- [Container deployment](https://github.com/yuyuanweb/ai-ppt-generator/blob/main/docker-compose.yml): orchestration · Runs API, worker, data services, and proxy. · `docker-compose.yml`

## Connections

- React SPA → FastAPI API: REST + SSE
- React SPA → Outline workspace: hosts
- React SPA → Deck editor: hosts
- Deck editor → Flex edit layer: uses
- Outline workspace → Deck generation API: confirm outline
- Deck editor → Deck generation API: generate and edit
- FastAPI API → Source ingest: accepts sources
- Source ingest → Outline workflow: normalized sections
- Outline workflow → Projects and slides: persists outline
- Deck generation API → Deck worker tasks: enqueues jobs
- Deck worker tasks → Slide and AI edit workflow: runs
- Slide and AI edit workflow → Flex layout engine: validates layout
- Slide and AI edit workflow → Projects and slides: persists pages
- Deck worker tasks → Redis: jobs and progress
- FastAPI API → Redis: streams progress
- Deck editor → Theme and layout catalogs: renders with
- Flex layout engine → Theme and layout catalogs: uses presets
- PPTX export → Projects and slides: reads deck
- PPTX export → Theme and layout catalogs: applies themes
- Image pipeline → Object storage: stores media
- Spring Boot backend → Java job queue: enqueues jobs
- Java job queue → Redis: uses
- Container deployment → FastAPI API: runs
- Container deployment → Deck worker tasks: runs
