Skip to content

voxire/glyph

Repository files navigation

@voxire/glyph

Production-grade OCR and document intelligence platform.

Glyph is a fully composable, TypeScript-first SDK for document scanning, OCR, structured field extraction, and validation. It is designed for long-term extensibility with a Rust-powered preprocessing layer and ONNX runtime support.


Architecture

npm package (TypeScript API)
        ↓
Rust native preprocessing
        ↓
ONNX runtime
        ↓
OCR providers (RapidOCR, Tesseract, Textract, Cloud Vision)
        ↓
Document parsers (passport, invoice, receipt, custom)
        ↓
Validation layer (MRZ, IBAN, totals, custom)
        ↓
Normalized structured JSON

Monorepo structure

packages/
├── core        — Interfaces, types, pipeline builder
├── node        — @voxire/glyph main entry point
├── native      — Rust napi-rs bindings wrapper
├── providers   — OCR provider implementations
├── parsers     — Document parsers
├── validators  — Field + document validators
├── outputs     — Output formatters (JSON, CSV, text)
├── models      — ONNX model registry + downloader
├── examples    — Usage examples
└── playground  — Interactive playground

crates/
├── preprocess  — Image preprocessing pipeline
├── inference   — ONNX runtime abstraction
├── image       — Low-level image utilities
├── bindings    — napi-rs Node.js bindings
├── pdf         — PDF rasterization (Phase 3)
└── pipeline    — Rust-side orchestration

Quick start

pnpm add @voxire/glyph

Zero-config scan

import { scanDocument } from '@voxire/glyph';

const result = await scanDocument('/path/to/document.jpg');
console.log(result.documentType);   // 'generic'
console.log(result.confidence);     // 0.98
console.log(result.fields);         // extracted key-value fields

Full pipeline control

import {
  createPipeline,
  RapidOcrProvider,
  JsonFormatter,
} from '@voxire/glyph';
import { PassportParser } from '@voxire/parsers';
import { MrzValidator } from '@voxire/validators';

const pipeline = createPipeline()
  .useOCR(new RapidOcrProvider({ numThreads: 4 }))
  .useParser(new PassportParser())
  .useValidator(new MrzValidator())
  .useOutput(new JsonFormatter())
  .build();

const json = await pipeline.run('/path/to/passport.jpg');
console.log(json);
// {
//   "documentType": "passport",
//   "confidence": 0.98,
//   "fields": { "firstName": { "value": "Mohamad", "confidence": 0.98 }, ... },
//   "blocks": [...],
//   "warnings": [],
//   "metadata": { "provider": "rapidocr", "processingMs": 123 }
// }

await pipeline.dispose();

Hooks & plugins

const pipeline = createPipeline()
  .useOCR(provider)
  .useParser(parser)
  // Inline hook
  .on('afterOcr', (ctx) => {
    console.log(`OCR confidence: ${ctx.data.result.confidence}`);
  })
  // Plugin
  .usePlugin(new MyAuditPlugin())
  .build();

OCR Providers

Provider Execution Network Languages
RapidOcrProvider Local (ONNX) No en, zh, ja, ko, + more
TesseractProvider Local (WASM) No 100+
MockOcrProvider In-process No — (testing)
TextractProvider Cloud (AWS) Yes en, fr, de, es, + more
CloudVisionProvider Cloud (GCP) Yes 50+

Parsers

Parser Document Type Fields
PassportParser passport firstName, lastName, documentNumber, MRZ validation
InvoiceParser invoice invoiceNumber, total, IBAN, dates
ReceiptParser receipt merchantName, total, items
GenericParser generic Configurable regex patterns

Validators

Validator Applies To
MrzValidator passport
IbanValidator invoice
InvoiceTotalValidator invoice

Development

# Install dependencies
pnpm install

# Build TypeScript packages
pnpm build:ts

# Build Rust crates
pnpm rust:build

# Build native Node.js bindings
pnpm build:native

# Run tests
pnpm test

# Type check
pnpm typecheck

# Lint Rust
pnpm rust:clippy

Phases

Phase Status
1 — Monorepo, TypeScript SDK, Rust bindings, preprocessing, OCR provider
2 — Parser architecture, passport, invoice, validation layer
3 — PDF support, layout analysis, table extraction Planned
4 — Fraud detection, GPU, cloud/local hybrid, enterprise Planned

License

MIT © Voxire

About

Production-grade OCR and document intelligence platform — TypeScript SDK with Rust preprocessing, ONNX runtime, pluggable providers, parsers, and validators

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors