- Add hand-written wiki (index, overview, how-to, extending, dev) with MkDocs config following the platform anatomy - Complete the library nav by registering the csv and xlsx groups in docforge.nav.yml and docs/mkdocs.lib.yml - Regenerate lib/MCP outputs with the rebuilt nav
3.1 KiB
3.1 KiB
🧱 Overview
OmniRead is designed as a decoupled content engine with three distinct layers. Understanding them is the key to using and extending the library.
🏗️ Architecture
┌─────────────────────────────┐
│ Source (URL, file, storage) │
└────────────┬────────────────┘
│
┌─────────▼──────────┐
│ Scraper / Client │ fetches raw bytes
└─────────┬──────────┘
│ returns
┌─────────▼──────────┐
│ Content │ raw + source + type
└─────────┬──────────┘
│
┌─────────▼──────────┐
│ Parser │ parse() → structured T
└────────────────────┘
- Scraper (
BaseScraper) — fetches raw bytes from a source (HTTP URL, filesystem path, object storage). Returns aContentinstance. Scrapers never interpret content. - Content (
Content) — the canonical exchange model: raw bytes, source identifier, and optionalContentTypeenum. - Parser (
BaseParser[T]) — receives aContentand returns a structured result of typeTviaparse().
📦 The Content model
Defined in omniread.core.content:
from dataclasses import dataclass
from omniread import Content, ContentType
@dataclass(slots=True)
class Content:
raw: bytes
source: str
content_type: ContentType | None = None
raw— the raw bytes exactly as retrieved.source— URL, file path, or logical name identifying the origin.content_type— optionalContentTypeenum value.
🎭 The ContentType enum
| Value | MIME | Used by |
|---|---|---|
HTML |
text/html |
HTMLScraper |
PDF |
application/pdf |
PDFScraper |
XLSX |
application/vnd.openxmlformats-... |
XlsxScraper |
CSV |
text/csv |
CsvScraper |
JSON |
application/json |
— |
XML |
application/xml |
— |
🧩 Format modules at a glance
| Module | Scraper | Parser | Client | Notes |
|---|---|---|---|---|
omniread.html |
HTMLScraper |
HTMLParser |
— | httpx + BeautifulSoup |
omniread.pdf |
PDFScraper |
PDFParser |
FileSystemPDFClient |
explicit client layer |
omniread.csv |
CsvScraper |
CsvParser |
FileSystemCsvClient |
stdlib csv module |
omniread.xlsx |
XlsxScraper |
XlsxParser |
FileSystemXlsxClient |
openpyxl-backed |
📚 Read Next
- How to Use — working examples per format.
- Extending OmniRead — subclassing scrapers and parsers.