# scanny/python-pptx architecture

> Architecture diagram of the GitHub repository scanny/python-pptx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/scanny/python-pptx
- Repository: https://github.com/scanny/python-pptx

## Overview

python-pptx is a Python library for creating, reading, updating, and analyzing PowerPoint presentations without requiring PowerPoint itself. A typical workflow starts with application data and the public Presentation API, then edits presentation and slide content—shapes, text, charts, and images—and saves or reads a .pptx package. The graph also shows the XML object model and OPC packaging layer that support those features. Edges reflect README statements or dependencies visible in the supplied excerpts and SOURCE INDEX; unsampled internals are not treated as inspected call flows.

Main entry points: [`src/pptx/shapes/shapetree.py`](https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py) (Shape collections), [`src/pptx/parts/slide.py`](https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py) (Slide parts), [`src/pptx/opc/package.py`](https://github.com/scanny/python-pptx/blob/master/src/pptx/opc/package.py) (OPC package I/O), [`src/pptx/presentation.py`](https://github.com/scanny/python-pptx/blob/master/src/pptx/presentation.py) (Presentation model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_pptx_api["Presentation API<br/>[api.py]"]
  node_presentation["Presentation model<br/>[presentation.py]"]
end

subgraph group_content["Presentation Content"]
  node_slide_model["Slide model<br/>[slide.py]"]
  node_shape_tree["Shape collections<br/>[shapetree.py]"]
  node_shape_types["Shape objects<br/>[autoshape.py]"]
  node_text["Text and fonts<br/>[text.py]"]
  node_chart_data["Chart data<br/>[data.py]"]
  node_chart_model["Chart model<br/>[chart.py]"]
  node_chart_xml["Chart XML writer<br/>[xmlwriter.py]"]
  node_image_parts["Image parts<br/>[image.py]"]
  node_media["Media handling<br/>[media.py]"]
  node_color["Color and fills<br/>[color.py]"]
end

subgraph group_format["Document Format"]
  node_package["OPC package I/O<br/>[package.py]"]
  node_slide_parts["Slide parts<br/>[slide.py]"]
  node_oxml["XML element model<br/>[xmlchemy.py]"]
  node_oxml_text["Text XML<br/>[text.py]"]
  node_oxml_slide["Slide XML<br/>[slide.py]"]
  node_xml_namespaces["XML namespaces<br/>[ns.py]"]
  node_simple_types["XML simple types<br/>[simpletypes.py]"]
end

subgraph group_support["Shared Support"]
  node_chart_enums["Chart enums<br/>[chart.py]"]
  node_dml_enums["Drawing enums<br/>[dml.py]"]
  node_shape_enums["Shape enums<br/>[shapes.py]"]
  node_shared["Shared utilities<br/>[shared.py]"]
end

node_content_source(("Application data"))
node_output_file["PPTX file"]
node_analysis_user(("Presentation analyst"))

node_content_source -->|"provides content"| node_pptx_api
node_pptx_api -->|"creates or opens"| node_presentation
node_presentation -->|"loads and saves"| node_package
node_package -->|"resolves parts"| node_slide_parts
node_slide_parts -->|"provides slide part"| node_slide_model
node_slide_model -->|"exposes shapes"| node_shape_tree
node_shape_tree -->|"constructs shapes"| node_shape_types
node_shape_types -->|"exposes text"| node_text
node_shape_tree -->|"accepts chart data"| node_chart_data
node_chart_model -->|"uses chart data"| node_chart_data
node_chart_data -->|"composes chart XML"| node_chart_xml
node_shape_tree -->|"adds pictures"| node_image_parts
node_image_parts -->|"uses package parts"| node_package
node_slide_model -->|"uses slide parts"| node_slide_parts
node_shape_tree -->|"uses shape types"| node_shape_enums
node_chart_xml -->|"uses chart types"| node_chart_enums
node_text -->|"edits text XML"| node_oxml_text
node_oxml_text -->|"uses XML types"| node_simple_types
node_oxml -->|"uses namespaces"| node_xml_namespaces
node_chart_xml -->|"uses namespaces"| node_xml_namespaces
node_slide_parts -->|"uses slide XML"| node_oxml_slide
node_color -->|"uses drawing enums"| node_dml_enums
node_chart_model -->|"uses shared helpers"| node_shared
node_media -->|"uses package constants"| node_package
node_presentation -->|"saves presentation"| node_output_file
node_output_file -->|"supports analysis"| node_analysis_user

click node_pptx_api "https://github.com/scanny/python-pptx/blob/master/src/pptx/api.py"
click node_presentation "https://github.com/scanny/python-pptx/blob/master/src/pptx/presentation.py"
click node_package "https://github.com/scanny/python-pptx/blob/master/src/pptx/opc/package.py"
click node_slide_parts "https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py"
click node_slide_model "https://github.com/scanny/python-pptx/blob/master/src/pptx/slide.py"
click node_shape_tree "https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py"
click node_shape_types "https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py"
click node_text "https://github.com/scanny/python-pptx/blob/master/src/pptx/text/text.py"
click node_chart_data "https://github.com/scanny/python-pptx/blob/master/src/pptx/chart/data.py"
click node_chart_model "https://github.com/scanny/python-pptx/blob/master/src/pptx/chart/chart.py"
click node_chart_xml "https://github.com/scanny/python-pptx/blob/master/src/pptx/chart/xmlwriter.py"
click node_image_parts "https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py"
click node_media "https://github.com/scanny/python-pptx/blob/master/src/pptx/media.py"
click node_oxml "https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py"
click node_oxml_text "https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/text.py"
click node_oxml_slide "https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/slide.py"
click node_xml_namespaces "https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/ns.py"
click node_color "https://github.com/scanny/python-pptx/blob/master/src/pptx/dml/color.py"
click node_chart_enums "https://github.com/scanny/python-pptx/blob/master/src/pptx/enum/chart.py"
click node_dml_enums "https://github.com/scanny/python-pptx/blob/master/src/pptx/enum/dml.py"
click node_shape_enums "https://github.com/scanny/python-pptx/blob/master/src/pptx/enum/shapes.py"
click node_simple_types "https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/simpletypes.py"
click node_shared "https://github.com/scanny/python-pptx/blob/master/src/pptx/shared.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_pptx_api,node_presentation toneBlue
class node_slide_model,node_shape_tree,node_shape_types,node_text,node_chart_data,node_chart_model,node_chart_xml,node_image_parts,node_media,node_color toneAmber
class node_package,node_slide_parts,node_oxml,node_oxml_text,node_oxml_slide,node_xml_namespaces,node_simple_types toneMint
class node_chart_enums,node_dml_enums,node_shape_enums,node_shared toneRose
class node_content_source,node_output_file,node_analysis_user toneIndigo
```

## Components

### Public API

- [Presentation API](https://github.com/scanny/python-pptx/blob/master/src/pptx/api.py): `src/pptx/api.py`
- [Presentation model](https://github.com/scanny/python-pptx/blob/master/src/pptx/presentation.py): `src/pptx/presentation.py`

### Presentation Content

- [Slide model](https://github.com/scanny/python-pptx/blob/master/src/pptx/slide.py): `src/pptx/slide.py`
- [Shape collections](https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py): `src/pptx/shapes/shapetree.py`
- [Shape objects](https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py): `src/pptx/shapes/autoshape.py`
- [Text and fonts](https://github.com/scanny/python-pptx/blob/master/src/pptx/text/text.py): `src/pptx/text/text.py`
- [Chart data](https://github.com/scanny/python-pptx/blob/master/src/pptx/chart/data.py): `src/pptx/chart/data.py`
- [Chart model](https://github.com/scanny/python-pptx/blob/master/src/pptx/chart/chart.py): `src/pptx/chart/chart.py`
- [Chart XML writer](https://github.com/scanny/python-pptx/blob/master/src/pptx/chart/xmlwriter.py): `src/pptx/chart/xmlwriter.py`
- [Image parts](https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py): `src/pptx/parts/image.py`
- [Media handling](https://github.com/scanny/python-pptx/blob/master/src/pptx/media.py): `src/pptx/media.py`
- [Color and fills](https://github.com/scanny/python-pptx/blob/master/src/pptx/dml/color.py): `src/pptx/dml/color.py`

### Document Format

- [OPC package I/O](https://github.com/scanny/python-pptx/blob/master/src/pptx/opc/package.py): `src/pptx/opc/package.py`
- [Slide parts](https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py): `src/pptx/parts/slide.py`
- [XML element model](https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py): `src/pptx/oxml/xmlchemy.py`
- [Text XML](https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/text.py): `src/pptx/oxml/text.py`
- [Slide XML](https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/slide.py): `src/pptx/oxml/slide.py`
- [XML namespaces](https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/ns.py): `src/pptx/oxml/ns.py`
- [XML simple types](https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/simpletypes.py): `src/pptx/oxml/simpletypes.py`

### Shared Support

- [Chart enums](https://github.com/scanny/python-pptx/blob/master/src/pptx/enum/chart.py): `src/pptx/enum/chart.py`
- [Drawing enums](https://github.com/scanny/python-pptx/blob/master/src/pptx/enum/dml.py): `src/pptx/enum/dml.py`
- [Shape enums](https://github.com/scanny/python-pptx/blob/master/src/pptx/enum/shapes.py): `src/pptx/enum/shapes.py`
- [Shared utilities](https://github.com/scanny/python-pptx/blob/master/src/pptx/shared.py): `src/pptx/shared.py`

### Other components

- **Application data**
- **PPTX file**
- **Presentation analyst**

## Connections

- Application data → Presentation API: provides content
- Presentation API → Presentation model: creates or opens
- Presentation model → OPC package I/O: loads and saves (evidence: `src/pptx/opc/package.py`)
- OPC package I/O → Slide parts: resolves parts (evidence: `src/pptx/opc/package.py`)
- Slide parts → Slide model: provides slide part (evidence: `src/pptx/parts/slide.py`)
- Slide model → Shape collections: exposes shapes (evidence: `src/pptx/slide.py`)
- Shape collections → Shape objects: constructs shapes (evidence: `src/pptx/shapes/shapetree.py`)
- Shape objects → Text and fonts: exposes text (evidence: `src/pptx/text/text.py`)
- Shape collections → Chart data: accepts chart data (evidence: `src/pptx/shapes/shapetree.py`)
- Chart model → Chart data: uses chart data (evidence: `src/pptx/chart/chart.py`)
- Chart data → Chart XML writer: composes chart XML (evidence: `src/pptx/chart/data.py`)
- Shape collections → Image parts: adds pictures (evidence: `src/pptx/shapes/shapetree.py`)
- Image parts → OPC package I/O: uses package parts (evidence: `src/pptx/parts/image.py`)
- Slide model → Slide parts: uses slide parts (evidence: `src/pptx/slide.py`)
- Shape collections → Shape enums: uses shape types (evidence: `src/pptx/shapes/shapetree.py`)
- Chart XML writer → Chart enums: uses chart types (evidence: `src/pptx/chart/xmlwriter.py`)
- Text and fonts → Text XML: edits text XML (evidence: `src/pptx/text/text.py`)
- Text XML → XML simple types: uses XML types (evidence: `src/pptx/oxml/text.py`)
- XML element model → XML namespaces: uses namespaces (evidence: `src/pptx/oxml/xmlchemy.py`)
- Chart XML writer → XML namespaces: uses namespaces (evidence: `src/pptx/chart/xmlwriter.py`)
- Slide parts → Slide XML: uses slide XML (evidence: `src/pptx/parts/slide.py`)
- Color and fills → Drawing enums: uses drawing enums (evidence: `src/pptx/dml/color.py`)
- Chart model → Shared utilities: uses shared helpers (evidence: `src/pptx/chart/chart.py`)
- Media handling → OPC package I/O: uses package constants (evidence: `src/pptx/media.py`)
- Presentation model → PPTX file: saves presentation
- PPTX file → Presentation analyst: supports analysis
