> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/lumina-ai-inc/chunkr/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Understanding Chunkr document processing concepts and architecture

Chunkr is a document intelligence API that transforms unstructured documents into structured, searchable data. It uses a multi-stage pipeline to extract, analyze, and organize document content.

## Core Concepts

Chunkr processes documents through several key stages:

<CardGroup cols={2}>
  <Card title="Segmentation" icon="grid" href="/concepts/segmentation">
    Detect and classify layout elements like tables, images, and text blocks
  </Card>

  <Card title="OCR" icon="eye" href="/concepts/ocr">
    Extract text from images and documents with optical character recognition
  </Card>

  <Card title="Pipelines" icon="diagram-project" href="/concepts/pipelines">
    Orchestrate processing steps from document upload to final output
  </Card>

  <Card title="Chunking" icon="scissors" href="/concepts/chunking">
    Combine segments into semantically meaningful chunks for embedding
  </Card>
</CardGroup>

## Document Processing Flow

The typical document processing flow in Chunkr follows these steps:

```mermaid theme={null}
graph LR
    A[Upload Document] --> B[Convert to PDF]
    B --> C[Convert to Images]
    C --> D[OCR Extraction]
    D --> E[Layout Analysis]
    E --> F[Segment Processing]
    F --> G[Chunking]
    G --> H[Output]
```

### 1. Document Upload

Documents can be uploaded in various formats including PDF, images (JPEG, PNG), and office documents. All non-PDF formats are automatically converted to PDF for processing.

### 2. Page Conversion

PDF pages are converted to high-quality images for OCR and segmentation. The resolution can be controlled with the `high_resolution` parameter:

* **Standard resolution**: Faster processing
* **High resolution**: Better accuracy for complex layouts (\~7 seconds latency per page)

### 3. Text Extraction

Text is extracted using OCR (Optical Character Recognition). Chunkr supports multiple OCR strategies:

* `All`: Process all pages with OCR (\~0.5 seconds per page)
* `Auto`: Use existing text layer when available, apply OCR only when needed

### 4. Layout Analysis

The segmentation engine detects and classifies layout elements:

<CodeGroup>
  ```json Segment Types theme={null}
  {
    "segment_type": "Table",
    "other_types": [
      "Title",
      "SectionHeader",
      "Text",
      "ListItem",
      "Picture",
      "Caption",
      "Formula",
      "Footnote",
      "PageHeader",
      "PageFooter",
      "Page"
    ]
  }
  ```
</CodeGroup>

Each segment contains:

* **Bounding box**: Position and dimensions on the page
* **OCR results**: Extracted text with confidence scores
* **Type classification**: Element type (table, image, text, etc.)
* **Content**: Processed HTML, Markdown, or LLM-generated output

### 5. Segment Processing

Segments are post-processed to generate structured content:

* **Auto generation**: Heuristic-based HTML/Markdown conversion
* **LLM generation**: Fine-tuned models for tables, formulas, and complex elements
* **Image cropping**: Extract segment images for visual elements

### 6. Chunking

Segments are combined into chunks based on semantic boundaries and target length. The chunking algorithm:

* Respects document hierarchy (titles, sections)
* Keeps related elements together (captions with images)
* Honors target token/word count limits
* Optionally ignores headers and footers

### 7. Output Generation

The final output includes:

```json theme={null}
{
  "chunks": [
    {
      "chunk_id": "uuid",
      "chunk_length": 245,
      "segments": [...],
      "embed": "Combined text for embedding"
    }
  ],
  "page_count": 10,
  "pdf_url": "https://..."
}
```

## Data Model

### Segment

A segment represents a single layout element:

```typescript theme={null}
interface Segment {
  segment_id: string;
  segment_type: SegmentType;
  bbox: BoundingBox;
  confidence?: number;
  
  // Text content
  text: string;          // OCR-extracted text
  content: string;       // Formatted content (HTML or Markdown)
  html: string;          // HTML representation
  markdown: string;      // Markdown representation
  llm?: string;          // LLM-generated content
  
  // Metadata
  page_number: number;
  page_width: number;
  page_height: number;
  image?: string;        // URL to cropped segment image
  ocr?: OCRResult[];     // Detailed OCR results
}
```

### Chunk

A chunk contains one or more segments:

```typescript theme={null}
interface Chunk {
  chunk_id: string;
  chunk_length: number;     // Token/word count
  segments: Segment[];
  embed?: string;           // Combined content for embedding
}
```

### Bounding Box

All spatial information uses normalized coordinates:

```typescript theme={null}
interface BoundingBox {
  left: number;    // X coordinate
  top: number;     // Y coordinate  
  width: number;   // Box width
  height: number;  // Box height
}
```

## Configuration

Chunkr's behavior is controlled through the `Configuration` object:

```json theme={null}
{
  "segmentation_strategy": "LayoutAnalysis",
  "ocr_strategy": "Auto",
  "high_resolution": true,
  "chunk_processing": {
    "target_length": 512,
    "tokenizer": "Word",
    "ignore_headers_and_footers": true
  },
  "segment_processing": {
    "Table": {
      "strategy": "LLM",
      "format": "Html"
    }
  }
}
```

See [Pipelines](/concepts/pipelines) for detailed configuration options.

## Next Steps

<CardGroup cols={2}>
  <Card title="Learn about Pipelines" icon="diagram-project" href="/concepts/pipelines">
    Understand the processing pipeline and configuration
  </Card>

  <Card title="Explore Segmentation" icon="grid" href="/concepts/segmentation">
    Deep dive into layout analysis strategies
  </Card>

  <Card title="OCR Strategies" icon="eye" href="/concepts/ocr">
    Learn about text extraction methods
  </Card>

  <Card title="Chunking Algorithm" icon="scissors" href="/concepts/chunking">
    Understand how segments are combined into chunks
  </Card>
</CardGroup>
