How dhruv2541/ai-ppt-template-designer works
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: app.py App Entry · export.py Export API · api.js API Client · index.html Editor UI
Components 24
Frontend
Browser-based editor, gallery, and client logic
- Editor UI · Main browser experience for editing templates and browsing the gallery
frontend/index.html - API Client · Frontend request layer for backend operations
frontend/js/api.js - Editor State · Client-side template and selection state
frontend/js/editorState.js - Event Flow · Editor event wiring and user interaction handling
frontend/js/editorEvents.js - Timeline · Animation and resize interactions in the editor
frontend/js/timelineResize.js - Template Gallery · Browse and select prebuilt templates
frontend/js/templateGallery.js
HTTP API
Flask route modules for product capabilities
- Templates API · Template operations and editor state endpoints
backend/routes/templates.py - Catalog API · Curated prebuilt template listing endpoints
backend/routes/prebuilt_templates.py - AI API · AI-assisted template and content operations
backend/routes/ai.py - Export API · PowerPoint export entry point
backend/routes/export.py - Usage API · Usage accounting and telemetry endpoints
backend/routes/usage.py
Services
Core business logic and integrations
- Template Engine · Template composition and rendering logic
backend/services/template_engine.py - AI Service · External AI interaction and response shaping
backend/services/ai_service.py - PPTX Service · PowerPoint file generation pipeline
backend/services/pptx_service.py - Animation XML · PowerPoint animation XML handling
backend/services/animation_xml.py - Asset Storage · Image and asset persistence layer
backend/services/storage_service.py - Usage Service · API usage tracking and counters
backend/services/usage_service.py
Persistence
Database models, migrations, and seed data
- Data Model · Relational models for templates, usage, and catalog data
backend/models.py - Migrations · Alembic database migration history
backend/migrations - Template Seeds · Initial curated prebuilt template records
backend/seeds/seed_prebuilt_templates.py
Runtime
Application wiring, auth, config, and deployment
- App Entry · Application startup and route registration
backend/app.py - Auth Core · Authentication and authorization helpers
backend/auth.py - Config · Environment-driven application settings
backend/config.py - Extensions · Shared Flask extension initialization
backend/extensions.py
Connections 37
- 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