malepati/custom_template_working
0
1# Custom Template Workflow Analysis2 3## 1. Overview4The "Custom Template" feature allows users to upload a PowerPoint (`.pptx`) file, which is then processed, converted into code (React/TSX), and saved in the database for future generation tasks.5 6## 2. Detailed Workflow7 8### **Step 1: Upload & Extraction**9- **Endpoint**: `POST /api/v1/ppt/pptx-slides/process`10- **Input**: `.pptx` file.11- **Process**:12 1. Validates file type and size (<100MB).13 2. Extracts **OXML** (Open XML) content from each slide.14 3. Converts slides to **PDF** (via LibreOffice) and then to **Images** (Screenshots).15 4. Analyzes fonts used in the slides.16 5. Saves screenshots to `/app_data/images/{uuid}/`.17- **Output**: Returns a JSON list of slides, each containing:18 - `xml_content`: The raw OXML structure.19 - `screenshot_url`: Path to the generated image.20 - `normalized_fonts`: List of detected fonts.21 22### **Step 2: Processing (The "Black Box")**23*Note: This specific logic is orchestrated by the Frontend, as the backend provides the building blocks.*24- The Frontend likely takes the **OXML** and **Screenshots** from Step 1.25- It calls `POST /api/v1/ppt/slide-to-html` to convert the visual/XML representation into **HTML**.26- It then calls `POST /api/v1/ppt/html-to-react` to use an LLM (OpenAI GPT-5) to convert that HTML into **React/TSX components**.27- These components represent the "Layout" of the slide.28 29### **Step 3: Storage**30Once the React code is generated, it is saved to the database.31 32#### **A. Saving Layouts (The Body)**33- **Endpoint**: `POST /api/v1/ppt/template-management/save-templates`34- **Table**: `presentation_layout_codes`35- **Data Stored**:36 - `presentation` (UUID): Links to the Template ID.37 - `layout_id`: Unique string ID for the specific slide layout.38 - `layout_name`: Human-readable name (e.g., "Title Slide").39 - `layout_code`: **The actual React/TSX code string.**40 - `fonts`: List of fonts required.41 42#### **B. Saving Metadata (The Header)**43- **Endpoint**: `POST /api/v1/ppt/template-management/templates`44- **Table**: `templates`45- **Data Stored**:46 - `id`: UUID (Matches the `presentation` ID above).47 - `name`: Template Name.48 - `description`: Optional description.49 - `created_at`: Timestamp.50 51### **Step 4: Retrieval and Display**52- **Endpoint**: `GET /api/v1/ppt/template-management/get-templates/{presentation_id}`53- **Process**:54 1. Fetches metadata from `templates` table.55 2. Fetches all associated layouts from `presentation_layout_codes` table.56- **Format to User**:57 - The frontend receives the list of layouts (with their React code).58 - It renders these React components dynamically to show the user what the template looks like.59 - When generating a new presentation, the system selects one of these layouts (`layout_code`) and injects the new content into it.60 61## 3. Database Format Summary62- **Format**: The core "Template" is not saved as a `.pptx` file. It is saved as **Functionally Equivalent React Code**.63- **Location**: PostgreSQL (or SQLite).64- **Schema**:65 - `TemplateModel`: Metadata.66 - `PresentationLayoutCodeModel`: The "Body" of the template (one row per slide layout).67 