How yuyuanweb/ai-ppt-generator works
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: EditorWorkspace.tsx Deck editor · main.py FastAPI API · deck_tasks.py Deck worker tasks · App.tsx React SPA
Components 20
React client
- React SPA · Project, outline, generation, and editor UI.
frontend/src/App.tsx - Outline workspace
frontend/src/features/outline/OutlineWorkspace.tsx - Deck editor · Edits structured slides and previews layouts.
frontend/src/features/deck/EditorWorkspace.tsx - Flex edit layer
frontend/src/features/deck/FlexEditLayer.tsx
Python backend
- FastAPI API · Authenticated versioned application endpoints.
backend/app/main.py - Deck generation API
backend/app/api/v1/deck/generation.py - Outline workflow · Produces editable persisted outlines.
backend/app/workflows/outline.py - Source ingest · Parses uploads and normalizes source sections.
backend/app/ingest/registry.py - Deck worker tasks · Runs generation jobs with retries.
backend/app/worker/deck_tasks.py - Slide and AI edit workflow · Generates constrained slide drafts and patches.
backend/app/workflows/slide.py - Flex layout engine · Normalizes editable layout trees and operations.
backend/app/domain/flex_solve.py - PPTX export · Validates and verifies native PPTX output.
backend/app/render/pptx.py - Image pipeline · Acquires and validates provider images.
backend/app/images/pipeline.py
Data and shared assets
- Projects and slides · Projects, sources, outlines, and slides.
backend/app/models/project.py - Theme and layout catalogs · Consumed by browser and server rendering.
shared/themes/midnight.json - Object storage
backend/app/storage/cos.py
Java mirror backend
Parallel Spring implementation.
- Spring Boot backend · Mirrors backend domain and service surface.
java_backend/src/main/java/com/aippt/Application.java - Java job queue
java_backend/src/main/java/com/aippt/shared/redis/JobQueue.java
Runtime infrastructure
- Redis · Carries jobs and progress events.
backend/app/core/queue.py - Container deployment · Runs API, worker, data services, and proxy.
docker-compose.yml
Connections 24
- 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