Skip to content
scriptsnsenses-sysPublic

About

A powerful tool for making PPTs from python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

THE PPT MAKERS

AI-powered presentation generator. Enter a creative brief, get a polished, editable .pptx — a Flask backend renders real PowerPoint files with python-pptx, driven by a configurable LLM (or a dependency-free local fallback when no AI provider is configured).

developed by DG


Table of contents

  1. Local installation
  2. Virtual environment setup
  3. Installing dependencies
  4. Running locally
  5. Environment variables
  6. Render deployment
  7. API usage
  8. JSON schema example
  9. Example curl request
  10. Project architecture
  11. Adding a new slide layout

1. Local installation

git clone <your-fork-url> the-ppt-makers
cd the-ppt-makers

2. Virtual environment setup

python3 -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate

3. Installing dependencies

pip install -r requirements.txt

4. Running locally

# Dev server (auto-reload with FLASK_DEBUG=1)
python app.py

# or, closer to production:
gunicorn app:app --bind 0.0.0.0:5000

Visit http://localhost:5000. Without any AI_* environment variables set, the app runs on its local fallback generator — fully functional, no external calls, no API key required. This is intentional: the app should never be broken out of the box.

5. Environment variables

Variable Required Description
PORT On Render (auto-set) Port the Flask app binds to. Defaults to 5000 locally.
AI_BASE_URL No Base URL of an OpenAI-compatible chat-completions API, e.g. https://api.openai.com/v1. If unset, the local fallback generator is used.
AI_API_KEY No API key for the configured provider. Never hardcode this — set it as an environment variable only.
AI_MODEL No Model name to request, e.g. gpt-4o-mini, claude-sonnet-4-6 (via an OpenAI-compatible gateway), or any model your provider exposes.
MAX_CONTENT_LENGTH_BYTES No Max request body size in bytes. Defaults to 2097152 (2 MB).
FLASK_DEBUG No Set to 1 for Flask's dev auto-reload. Never enable in production.

The app never sends API keys to the frontend — all AI calls happen server-side in prompts.py.

Provider flexibility: call_llm() in prompts.py targets a standard {AI_BASE_URL}/chat/completions endpoint with an OpenAI-compatible request/response shape. This works directly with OpenAI, OpenRouter, most self-hosted OpenAI-compatible gateways (vLLM, LiteLLM, Ollama's OpenAI shim), and Anthropic via an OpenAI-compatible proxy. Swapping providers is a config change, not a code change.

6. Render deployment

This repo includes render.yaml for one-click infrastructure-as-code deployment.

  1. Push this repo to GitHub.
  2. In the Render dashboard: New → Blueprint, point it at your repo. Render will read render.yaml automatically.
  3. Set AI_BASE_URL, AI_API_KEY, and AI_MODEL as environment variables in the Render dashboard (they're marked sync: false in render.yaml so they're never committed to source control).
  4. Deploy. Render builds with pip install -r requirements.txt and starts with:
    gunicorn app:app --bind 0.0.0.0:$PORT --workers 2 --timeout 120
    

The app binds to 0.0.0.0 and reads PORT from the environment, as required by Render Web Services.

Manual (non-blueprint) setup

If you'd rather configure the service by hand in the Render dashboard:

  • Runtime: Python 3.12
  • Build command: pip install -r requirements.txt
  • Start command: gunicorn app:app --bind 0.0.0.0:$PORT

7. API usage

GET /api/health

Returns service status and whether an AI provider is currently configured.

{ "status": "ok", "service": "the-ppt-makers", "version": "1.0.0", "ai_configured": true }

POST /api/plan

Generates just the structured JSON presentation plan (no file rendering). Used by the frontend to drive the live preview before the user downloads.

Request:

{ "config": { "title": "...", "audience": "...", "goal": "...", "slide_count": 10, "brief": "..." } }

Response: { "spec": { ...full presentation JSON, see schema below... } }

POST /api/generate

Generates and returns a downloadable .pptx file. Accepts two modes:

Mode "brief" — full pipeline: AI (or fallback) generates the plan, then it's rendered.

{ "mode": "brief", "config": { "title": "...", "brief": "...", "slide_count": 10 } }

Mode "spec" — render a presentation spec you already have (e.g. one edited client-side after /api/plan, or hand-written).

{ "mode": "spec", "spec": { "title": "...", "slides": [ ... ] } }

On success: binary .pptx response with Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation and a Content-Disposition download header. On failure: JSON { "error": "...", "details": [...] } with an appropriate 4xx/5xx status. No internal file paths or stack traces are ever included in responses.

8. JSON schema example

This is the presentation spec produced by the AI architect (prompts.py) and consumed by the renderer (ppt_generator.py + layouts.py):

{
  "title": "Series A Pitch — Aurora Energy",
  "subtitle": "Accelerating the distributed solar transition",
  "audience": "Seed investors",
  "goal": "Secure Series A funding",
  "theme": { "mood": "confident", "primary": "#6C5CE7", "secondary": "#00D9C0" },
  "slides": [
    {
      "type": "hero",
      "eyebrow": "Overview",
      "title": "Aurora Energy",
      "subtitle": "Helping utilities integrate distributed solar at scale."
    },
    {
      "type": "metrics",
      "title": "Traction",
      "items": [
        { "value": "3", "label": "Pilot utilities signed" },
        { "value": "80%", "label": "Battery cost drop since 2015" }
      ]
    },
    {
      "type": "closing",
      "title": "Thank you",
      "subtitle": "Questions & discussion"
    }
  ]
}

Valid slide type values: hero, statement, cards, process, timeline, comparison, quote, metrics, image, closing. See prompts.py's SLIDE_TYPE_GUIDE for what each expects in items.

9. Example curl request

curl -X POST http://localhost:5000/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "brief",
    "config": {
      "title": "Q3 Growth Strategy",
      "audience": "Leadership team",
      "goal": "Align on Q3 priorities",
      "slide_count": 8,
      "style": "modern",
      "tone": "confident",
      "brief": "Revenue grew 22% QoQ. Churn dropped to 3.1%. Doubling down on enterprise sales. Hiring 4 new AEs next quarter. Key risk is onboarding capacity."
    }
  }' \
  --output presentation.pptx

10. Project architecture

the-ppt-makers/
├── app.py              Flask routes: /, /api/health, /api/plan, /api/generate
├── ppt_generator.py     Validation + render pipeline (spec JSON -> .pptx)
├── layouts.py            Visual design system: add_* components, render_* slide types
├── prompts.py             AI architect: system prompt, provider call, schema validation, local fallback
├── requirements.txt
├── render.yaml
├── templates/
│   └── index.html         Frontend shell (sidebar, config form, preview panel)
└── static/
    ├── style.css           Design tokens + full responsive layout
    └── app.js               Form handling, generation flow, live preview rendering

Pipeline:

Frontend config
     │
     ▼
POST /api/generate  (or /api/plan for preview-only)
     │
     ▼
prompts.generate_presentation_plan()
     │  if AI configured → call_llm() → parse_and_validate_llm_output()
     │  else / on failure → local_fallback_plan()
     ▼
validated presentation spec (JSON)
     │
     ▼
ppt_generator.build_presentation()
     │  for each slide: layouts.RENDERERS[type](...)
     ▼
python-pptx Presentation object
     │
     ▼
.pptx bytes → send_file() → browser download

The LLM never outputs Python or raw slide coordinates — only structured JSON describing semantic slide content (type, title, items, etc). All visual decisions (spacing, color, typography, shapes) live in layouts.py, so the design system stays consistent regardless of what the model generates, and can be restyled globally without touching the AI prompt.

11. Adding a new slide layout

  1. Design it in layouts.py: write a render_my_type(prs, spec, theme, idx, total) function using the existing add_* helpers (add_card, add_title, add_metric, etc.) or new ones if needed. Follow the pattern of existing renderers — background, header/eyebrow, content, footer, slide number.
  2. Register it: add "my_type": render_my_type to the RENDERERS dict at the bottom of layouts.py.
  3. Document it for the AI: add a line to SLIDE_TYPE_GUIDE in prompts.py describing when to use it and what fields it expects in items.
  4. Add a preview mapping (optional but recommended): extend miniSlideMarkup() in static/app.js with a case for "my_type" so the live preview shows something reasonable before download.
  5. Test: validate a spec containing your new type against validate_presentation_spec(), then render it with build_presentation() and confirm the .pptx opens correctly.

No other files need to change — ppt_generator.py's VALID_SLIDE_TYPES is derived automatically from RENDERERS.keys().


Security notes

  • No API keys are ever exposed to frontend JavaScript — all AI calls happen server-side.
  • Generated files are streamed from memory (io.BytesIO); no user-controlled filesystem paths are ever accepted or exposed.
  • Request bodies are size-limited (MAX_CONTENT_LENGTH_BYTES) and slide counts are server-side clamped regardless of client input.
  • No user-provided Python or arbitrary code is ever executed.
  • Malformed JSON, LLM failures, and rendering failures all return clean JSON errors — never stack traces.

About

A powerful tool for making PPTs from python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages