# chaitanyabiswas/pdf-splitter architecture

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

- Interactive diagram: https://gitdiagram.com/chaitanyabiswas/pdf-splitter
- Repository: https://github.com/chaitanyabiswas/pdf-splitter

## Overview

PDF Splitter is a small Python library with a CLI for dividing PDFs into page-count chunks, optionally skipping initial pages. The main workflow validates and reads the source PDF, calculates original-page ranges, resolves output filenames and collisions, then writes chunks while preserving metadata where supported. The README documents both CLI and Python API entry points; the source excerpts show the CLI call path and the splitter’s utility calls. External PDF-library interactions are visible in the splitter excerpt.

Main entry points: [`pdf_splitter/splitter.py`](https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/splitter.py) (Split and validate), [`pdf_splitter/cli.py`](https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/cli.py) (Command-line interface), [`pdf_splitter/utils.py`](https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/utils.py) (Filename and path handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["Command-line interface<br/>[cli.py]"]
end

subgraph group_processing["PDF processing"]
  node_splitter["Split and validate<br/>[splitter.py]"]
  node_pdf_library["pypdf reader/writer"]
end

subgraph group_files["File handling"]
  node_path_utils["Filename and path handling<br/>[utils.py]"]
  node_source_pdf["Source PDF"]
  node_output_pdfs["Chunk PDFs"]
end

node_cli_user(("CLI user"))
node_api_caller(("Python caller"))

node_cli_user -->|"runs"| node_cli
node_api_caller -->|"calls API"| node_splitter
node_cli -->|"calls"| node_splitter
node_splitter -->|"reads and writes"| node_pdf_library
node_splitter -->|"resolves paths"| node_path_utils
node_splitter -->|"reads"| node_source_pdf
node_splitter -->|"writes chunks"| node_output_pdfs

click node_cli "https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/cli.py"
click node_splitter "https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/splitter.py"
click node_path_utils "https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/utils.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_cli,node_cli_user toneBlue
class node_splitter,node_pdf_library toneAmber
class node_path_utils,node_source_pdf,node_output_pdfs toneMint
class node_api_caller toneIndigo
```

## Components

### Entry points

- [Command-line interface](https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/cli.py): `pdf_splitter/cli.py`

### PDF processing

- [Split and validate](https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/splitter.py): `pdf_splitter/splitter.py`
- **pypdf reader/writer**

### File handling

- [Filename and path handling](https://github.com/chaitanyabiswas/pdf-splitter/blob/master/pdf_splitter/utils.py): `pdf_splitter/utils.py`
- **Source PDF**
- **Chunk PDFs**

### Other components

- **CLI user**
- **Python caller**

## Connections

- CLI user → Command-line interface: runs (evidence: `README.md`)
- Python caller → Split and validate: calls API (evidence: `README.md`)
- Command-line interface → Split and validate: calls (evidence: `pdf_splitter/cli.py`)
- Split and validate → pypdf reader/writer: reads and writes (evidence: `pdf_splitter/splitter.py`)
- Split and validate → Filename and path handling: resolves paths (evidence: `pdf_splitter/splitter.py`)
- Split and validate → Source PDF: reads (evidence: `pdf_splitter/splitter.py`)
- Split and validate → Chunk PDFs: writes chunks (evidence: `pdf_splitter/splitter.py`)
