# dhruv2541/ai-ppt-template-designer architecture

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

- Interactive diagram: https://gitdiagram.com/dhruv2541/ai-ppt-template-designer
- Repository: https://github.com/dhruv2541/ai-ppt-template-designer

## Overview

1. **Overall shape**
   This repo is a split frontend/backend application for designing PowerPoint templates with AI assistance. The browser hosts the editor and gallery UI, while the Python backend exposes API endpoints for template operations, AI features, export, and usage tracking.

2. **Frontend boundary**
   `frontend/index.html` and the `frontend/js/` modules implement a vanilla-JS client, not a heavyweight SPA framework. The main client-side concerns are editor state, event handling, timeline/animation interactions, API calls, and template gallery browsing. `frontend/Videos/` contains local media assets likely used as sample or preview content in the editor/gallery experience.

3. **Backend API layer**
   The backend is organized around Flask-style route modules in `backend/routes/`: `ai.py`, `templates.py`, `prebuilt_templates.py`, `export.py`, and `usage.py`. This is the primary HTTP boundary. Each route module corresponds to a major product capability rather than a generic CRUD-only API.

4. **Core service layer**
   Business logic is separated into `backend/services/`. The important service boundaries are:
   - `template_engine.py` for template composition/rendering logic
   - `pptx_service.py` for generating PowerPoint files
   - `ai_service.py` for AI-driven content or template assistance
   - `animation_xml.py` for PPT animation XML handling
   - `image_service.py` and `storage_service.py` for asset/image persistence concerns
   - `validation.py` for input and consistency checks
   - `usage_service.py` for API usage accounting
   This service layer is where most non-HTTP logic lives.

5. **Persistence model**
   `backend/models.py` plus Alembic migrations define the database schema. The repo includes migrations for the initial schema, API usage tracking, and prebuilt templates, including a later addition of `category` to prebuilt templates. This indicates a relational database is central to the system, with schema evolution managed explicitly.

6. **Prebuilt template subsystem**
   Prebuilt templates are a first-class feature, not an afterthought. The repository contains `backend/seeds/seed_prebuilt_templates.py`, `backend/PREBUILT_TEMPLATES.md`, and a dedicated route. This suggests a curated template catalog stored in the database and surfaced in the UI as a gallery, with categories used for browsing and filtering.

7. **Export pipeline**
   The export path is its own subsystem: the client requests an export, the backend assembles template state and assets, and `pptx_service.py` produces the downloadable presentation. `backend/routes/export.py` is the entry point, while animation XML and image/storage services likely feed the final PPTX assembly. This is the main “produce artifact” path in the architecture.

8. **AI-assisted generation path**
   `backend/routes/ai.py` and `ai_service.py` isolate external AI interactions from the rest of the app. The frontend likely sends prompt/template context to the backend, which then calls the AI service and returns structured results for the editor. This keeps any model/provider coupling behind a service boundary.

9. **Auth and usage control**
   Authentication and authorization are handled separately in `backend/auth.py` and `services/auth_service.py`, implying protected endpoints or API access checks. `usage.py` and `usage_service.py` add accounting/telemetry around API consumption, backed by a dedicated database table. That makes usage tracking part of the system design, not just logging.

10. **Runtime and deployment**
   `backend/Procfile`, `.env.example`, `requirements.txt`, and Alembic indicate a Python web service intended for environment-based deployment. The backend is likely run as a standalone app process, with configuration coming from environment variables and database migrations applied separately.

11. **Testing strategy**
   The repository has both backend unit/integration tests and end-to-end coverage. `backend/tests/` includes tests for AI, auth, export, templates, animations, and database consistency, while top-level `tests/` includes endpoint checks, prebuilt template tests, and HTML reports. `test_e2e_playwright.py` shows the browser UI is exercised as a real user flow.

12. **Useful diagram boundaries**
   For an architecture diagram, the clearest boundaries are:
   - Browser editor/UI
   - HTTP API layer
   - Service layer for template/AI/export logic
   - Relational database for templates, usage, and app metadata
   - External AI/model provider behind `ai_service`
   - File/artifact generation path for PPTX export
   - Seed/migration pipeline for initial and evolving data

Main entry points: [`backend/app.py`](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/app.py) (App Entry), [`backend/routes/export.py`](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/export.py) (Export API), [`frontend/js/api.js`](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/api.js) (API Client), [`frontend/index.html`](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/index.html) (Editor UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_ui["Editor UI<br/>vanilla-js client<br/>[index.html]"]
  node_frontend_api["API Client<br/>browser module<br/>[api.js]"]
  node_frontend_state["Editor State<br/>state module<br/>[editorState.js]"]
  node_frontend_events["Event Flow<br/>interaction module<br/>[editorEvents.js]"]
  node_frontend_timeline["Timeline<br/>ui module<br/>[timelineResize.js]"]
  node_frontend_gallery["Template Gallery<br/>browser module<br/>[templateGallery.js]"]
end

subgraph group_api["HTTP API"]
  node_routes_templates["Templates API<br/>flask route<br/>[templates.py]"]
  node_routes_prebuilt["Catalog API<br/>flask route"]
  node_routes_ai["AI API<br/>flask route<br/>[ai.py]"]
  node_routes_export["Export API<br/>flask route<br/>[export.py]"]
  node_routes_usage["Usage API<br/>flask route<br/>[usage.py]"]
end

subgraph group_services["Services"]
  node_svc_template["Template Engine<br/>core service<br/>[template_engine.py]"]
  node_svc_ai["AI Service<br/>integration service<br/>[ai_service.py]"]
  node_svc_pptx["PPTX Service<br/>artifact service<br/>[pptx_service.py]"]
  node_svc_animation["Animation XML<br/>format service<br/>[animation_xml.py]"]
  node_svc_storage[("Asset Storage<br/>storage service<br/>[storage_service.py]")]
  node_svc_usage["Usage Service<br/>accounting service<br/>[usage_service.py]"]
end

subgraph group_persistence["Persistence"]
  node_models_db[("Data Model<br/>database schema<br/>[models.py]")]
  node_migrations["Migrations<br/>schema evolution"]
  node_seed_templates["Template Seeds<br/>seed data"]
end

subgraph group_runtime["Runtime"]
  node_app_runtime["App Entry<br/>flask app<br/>[app.py]"]
  node_auth_core["Auth Core<br/>auth boundary<br/>[auth.py]"]
  node_app_config["Config<br/>[config.py]"]
  node_extensions["Extensions<br/>app wiring<br/>[extensions.py]"]
end

node_frontend_ui -->|"calls"| node_frontend_api
node_frontend_ui -->|"uses"| node_frontend_state
node_frontend_ui -->|"binds"| node_frontend_events
node_frontend_ui -->|"drives"| node_frontend_timeline
node_frontend_ui -->|"shows"| node_frontend_gallery
node_frontend_api -->|"requests"| node_routes_templates
node_frontend_api -->|"requests"| node_routes_ai
node_frontend_api -->|"requests"| node_routes_export
node_frontend_api -->|"requests"| node_routes_prebuilt
node_frontend_api -->|"requests"| node_routes_usage
node_routes_templates -->|"delegates"| node_svc_template
node_routes_templates -->|"reads/writes"| node_models_db
node_routes_prebuilt -->|"serves"| node_seed_templates
node_routes_prebuilt -->|"queries"| node_models_db
node_routes_ai -->|"delegates"| node_svc_ai
node_routes_ai -.->|"tracks"| node_svc_usage
node_routes_export -->|"delegates"| node_svc_pptx
node_routes_export -->|"uses"| node_svc_animation
node_routes_export -->|"uses"| node_svc_storage
node_routes_export -->|"uses"| node_svc_template
node_routes_usage -->|"delegates"| node_svc_usage
node_svc_template -->|"persists"| node_models_db
node_svc_template -->|"loads assets"| node_svc_storage
node_svc_ai -->|"accounts"| node_svc_usage
node_svc_pptx -->|"packages assets"| node_svc_storage
node_svc_usage -->|"updates"| node_models_db
node_app_runtime -->|"reads"| node_app_config
node_app_runtime -->|"initializes"| node_extensions
node_app_runtime -->|"registers"| node_routes_ai
node_app_runtime -->|"registers"| node_routes_templates
node_app_runtime -->|"registers"| node_routes_prebuilt
node_app_runtime -->|"registers"| node_routes_export
node_app_runtime -->|"registers"| node_routes_usage
node_auth_core -.->|"protects"| node_routes_templates
node_auth_core -.->|"protects"| node_routes_export
node_auth_core -.->|"guards"| node_svc_ai
node_migrations -->|"evolves"| node_models_db

click node_frontend_ui "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/index.html"
click node_frontend_api "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/api.js"
click node_frontend_state "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/editorState.js"
click node_frontend_events "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/editorEvents.js"
click node_frontend_timeline "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/timelineResize.js"
click node_frontend_gallery "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/templateGallery.js"
click node_routes_templates "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/templates.py"
click node_routes_prebuilt "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/prebuilt_templates.py"
click node_routes_ai "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/ai.py"
click node_routes_export "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/export.py"
click node_routes_usage "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/usage.py"
click node_svc_template "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/template_engine.py"
click node_svc_ai "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/ai_service.py"
click node_svc_pptx "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/pptx_service.py"
click node_svc_animation "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/animation_xml.py"
click node_svc_storage "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/storage_service.py"
click node_svc_usage "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/usage_service.py"
click node_models_db "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/models.py"
click node_migrations "https://github.com/dhruv2541/ai-ppt-template-designer/tree/main/backend/migrations"
click node_seed_templates "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/seeds/seed_prebuilt_templates.py"
click node_app_runtime "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/app.py"
click node_auth_core "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/auth.py"
click node_app_config "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/config.py"
click node_extensions "https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/extensions.py"

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_frontend_ui,node_frontend_api,node_frontend_state,node_frontend_events,node_frontend_timeline,node_frontend_gallery toneBlue
class node_routes_templates,node_routes_prebuilt,node_routes_ai,node_routes_export,node_routes_usage toneAmber
class node_svc_template,node_svc_ai,node_svc_pptx,node_svc_animation,node_svc_storage,node_svc_usage toneMint
class node_models_db,node_migrations,node_seed_templates toneRose
class node_app_runtime,node_auth_core,node_app_config,node_extensions toneIndigo
```

## Components

### Frontend

Browser-based editor, gallery, and client logic

- [Editor UI](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/index.html): vanilla-js client · Main browser experience for editing templates and browsing the gallery · `frontend/index.html`
- [API Client](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/api.js): browser module · Frontend request layer for backend operations · `frontend/js/api.js`
- [Editor State](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/editorState.js): state module · Client-side template and selection state · `frontend/js/editorState.js`
- [Event Flow](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/editorEvents.js): interaction module · Editor event wiring and user interaction handling · `frontend/js/editorEvents.js`
- [Timeline](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/timelineResize.js): ui module · Animation and resize interactions in the editor · `frontend/js/timelineResize.js`
- [Template Gallery](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/frontend/js/templateGallery.js): browser module · Browse and select prebuilt templates · `frontend/js/templateGallery.js`

### HTTP API

Flask route modules for product capabilities

- [Templates API](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/templates.py): flask route · Template operations and editor state endpoints · `backend/routes/templates.py`
- [Catalog API](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/prebuilt_templates.py): flask route · Curated prebuilt template listing endpoints · `backend/routes/prebuilt_templates.py`
- [AI API](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/ai.py): flask route · AI-assisted template and content operations · `backend/routes/ai.py`
- [Export API](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/export.py): flask route · PowerPoint export entry point · `backend/routes/export.py`
- [Usage API](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/routes/usage.py): flask route · Usage accounting and telemetry endpoints · `backend/routes/usage.py`

### Services

Core business logic and integrations

- [Template Engine](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/template_engine.py): core service · Template composition and rendering logic · `backend/services/template_engine.py`
- [AI Service](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/ai_service.py): integration service · External AI interaction and response shaping · `backend/services/ai_service.py`
- [PPTX Service](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/pptx_service.py): artifact service · PowerPoint file generation pipeline · `backend/services/pptx_service.py`
- [Animation XML](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/animation_xml.py): format service · PowerPoint animation XML handling · `backend/services/animation_xml.py`
- [Asset Storage](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/storage_service.py): storage service · Image and asset persistence layer · `backend/services/storage_service.py`
- [Usage Service](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/services/usage_service.py): accounting service · API usage tracking and counters · `backend/services/usage_service.py`

### Persistence

Database models, migrations, and seed data

- [Data Model](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/models.py): database schema · Relational models for templates, usage, and catalog data · `backend/models.py`
- [Migrations](https://github.com/dhruv2541/ai-ppt-template-designer/tree/main/backend/migrations): schema evolution · Alembic database migration history · `backend/migrations`
- [Template Seeds](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/seeds/seed_prebuilt_templates.py): seed data · Initial curated prebuilt template records · `backend/seeds/seed_prebuilt_templates.py`

### Runtime

Application wiring, auth, config, and deployment

- [App Entry](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/app.py): flask app · Application startup and route registration · `backend/app.py`
- [Auth Core](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/auth.py): auth boundary · Authentication and authorization helpers · `backend/auth.py`
- [Config](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/config.py): runtime config · Environment-driven application settings · `backend/config.py`
- [Extensions](https://github.com/dhruv2541/ai-ppt-template-designer/blob/main/backend/extensions.py): app wiring · Shared Flask extension initialization · `backend/extensions.py`

## Connections

- Editor UI → API Client: calls · Browser UI issues backend requests
- Editor UI → Editor State: uses · UI reads and updates editor state
- Editor UI → Event Flow: binds · User interactions are wired through event handlers
- Editor UI → Timeline: drives · Timeline controls affect the editor experience
- Editor UI → Template Gallery: shows · UI includes browsing for prebuilt templates
- API Client → Templates API: requests · Client talks to template endpoints
- API Client → AI API: requests · Client sends AI assistance requests
- API Client → Export API: requests · Client triggers export generation
- API Client → Catalog API: requests · Client loads curated template catalog data
- API Client → Usage API: requests · Client reports or reads usage state
- Templates API → Template Engine: delegates · Template endpoint defers to template engine
- Templates API → Data Model: reads/writes · Template state is persisted in the database
- Catalog API → Template Seeds: serves · Prebuilt catalog is backed by seeded records
- Catalog API → Data Model: queries · Catalog data is stored in the database
- AI API → AI Service: delegates · AI endpoint isolates provider interaction
- AI API → Usage Service: tracks · AI requests contribute to usage accounting
- Export API → PPTX Service: delegates · Export endpoint builds downloadable PPTX files
- Export API → Animation XML: uses · Export pipeline includes animation XML handling
- Export API → Asset Storage: uses · Export pipeline resolves stored assets
- Export API → Template Engine: uses · Export assembles the current template definition
- Usage API → Usage Service: delegates · Usage endpoint updates accounting data
- Template Engine → Data Model: persists · Template composition relies on stored records
- Template Engine → Asset Storage: loads assets · Template engine needs media and image assets
- AI Service → Usage Service: accounts · AI consumption is measured for usage control
- PPTX Service → Asset Storage: packages assets · PPTX generation includes stored media
- Usage Service → Data Model: updates · Usage metrics are stored in relational tables
- App Entry → Config: reads · App startup uses environment-based config
- App Entry → Extensions: initializes · Application startup wires shared extensions
- App Entry → AI API: registers · App mounts the AI route module
- App Entry → Templates API: registers · App mounts the template route module
- App Entry → Catalog API: registers · App mounts the catalog route module
- App Entry → Export API: registers · App mounts the export route module
- App Entry → Usage API: registers · App mounts the usage route module
- Auth Core → Templates API: protects · Auth boundary secures protected endpoints
- Auth Core → Export API: protects · Auth boundary secures protected endpoints
- Auth Core → AI Service: guards · Auth logic may gate AI features
- Migrations → Data Model: evolves · Schema migrations track model changes
