SkillAgentSearch skills...

Prism

Prism is a next-generation document processing SDK built in Rust, designed to view, convert, and extract content from 600+ file formats. It's the modern, developer-friendly alternative to Oracle Outside In.

Install / Use

/learn @abahjat/Prism
About this skill

Quality Score

0/100

Category

Design

Supported Platforms

Universal

README

Prism - Modern Document Processing SDK

"Any document, any platform, in milliseconds."

Prism is a next-generation document processing SDK built in Rust, designed to view, convert, and extract content from 600+ file formats. It's the modern, developer-friendly alternative to Oracle Outside In.

🖼️ Visuals

<p align="center"> <img src="assets/screenshots/viewer_home.png" width="800" alt="Prism Home"> </p> <p align="center"> <img src="assets/screenshots/viewer_mht.png" width="400" alt="MHT Viewing"> <img src="assets/screenshots/viewer_image.png" width="400" alt="Image Viewing"> </p>

🚀 Features

  • Comprehensive Format Support: 68+ document formats currently implemented

    • Documents: PDF, RTF, XPS, EPUB
    • Microsoft Office: DOCX, XLSX, PPTX, DOC, XLS, PPT, ONE, VSDX, MPP
    • OpenDocument: ODT, ODS, ODP, ODG
    • Images: PNG, JPEG, JPEG 2000, TIFF, GIF, WebP, BMP, ICO, CUR, TGA, PSD, PCX, WBMP
    • Vector: SVG, SVGZ, EPS, EMF, EMZ, WMF, AI
    • Email & Calendar: EML, MSG, MBOX, VCF, ICS, MHT
    • Archives: ZIP, TAR, GZIP, 7z, Bzip2, UNIX Compress (.z)
    • Database: SQLite, DBF
    • Code: Rust, Python, JavaScript, TypeScript, C, C++, CSS (syntax highlighting)
    • CAD: DXF
    • Text: TXT, HTML, JSON, XML, CSV, Markdown, LOG
  • Modern Architecture: Built with Rust for memory safety, performance, and reliability

  • Cloud-Native: Designed for containerization, horizontal scaling, and serverless deployment

  • Secure by Default: WebAssembly sandboxing for parser isolation

  • Developer-Friendly: Clean APIs with SDKs for 10+ languages

  • High Performance: Parallel processing, streaming support, and optimized rendering

📦 Components

Core Components

| Component | Description | Status | |-----------|-------------|--------| | prism-core | Core engine, Unified Document Model (UDM), parser/renderer traits | ✅ Foundation complete | | prism-parsers | Format parser implementations | 🚧 In development | | prism-render | Rendering engine (HTML, PDF, Image output) | 🚧 Basic HTML renderer | | prism-sandbox | WebAssembly sandboxing for secure parser execution | 🚧 Framework ready | | prism-server | REST API server (Axum-based) | 🚧 Basic endpoints | | prism-cli | Command-line interface | 🚧 Structure ready |

🛠️ Installation

Prerequisites

  • Rust 1.85 or later (Edition 2024)
  • Cargo (comes with Rust)

Building from Source

# Clone the repository
git clone https://github.com/abahjat/prism.git
cd prism

# Build all crates
cargo build --release

# Run tests
cargo test

# Build optimized binaries
cargo build --release

Binaries

After building, you'll find the binaries in target/release/:

  • prism - CLI tool
  • prism-server - REST API server

🚀 Quick Start

Using the CLI

# Detect document format
prism detect document.pdf

# Convert a document
prism convert input.docx --output output.pdf

# Extract text
prism extract-text document.pdf --output text.txt

# Extract metadata
prism metadata document.pdf

Using the REST API Server

# Start the server (default: 127.0.0.1:8080)
cargo run --bin prism-server

# Custom host and port
cargo run --bin prism-server -- --host 0.0.0.0 --port 3000

# Or use environment variables
PRISM_HOST=0.0.0.0 PRISM_PORT=3000 cargo run --bin prism-server

# Health check
curl http://localhost:8080/api/health

# Version information
curl http://localhost:8080/api/version

CORS Configuration

By default, the server allows requests from:

  • documain.ai and all subdomains
  • localhost and 127.0.0.1 (any port) for local development

Development Mode (Allow All Origins)

# Using CLI flag
cargo run --bin prism-server -- --cors-origins "*"

# Using environment variable
PRISM_CORS_ORIGINS="*" cargo run --bin prism-server

Production Deployment

When deploying to a different domain, specify your allowed origins:

# Single origin
cargo run --bin prism-server -- --cors-origins "https://yourdomain.com"

# Multiple origins (comma-separated)
cargo run --bin prism-server -- --cors-origins "https://app.example.com,https://admin.example.com"

# Using environment variable
PRISM_CORS_ORIGINS="https://yourdomain.com" cargo run --bin prism-server

Docker/Kubernetes

# Docker Compose
environment:
  - PRISM_CORS_ORIGINS=https://yourdomain.com

# Kubernetes
env:
  - name: PRISM_CORS_ORIGINS
    value: "https://yourdomain.com"

Using the Rust Library

Add Prism to your Cargo.toml:

[dependencies]
prism-core = "0.5.0"
prism-parsers = "0.5.0"
prism-render = "0.5.0"

Example usage:

use prism_core::format::detect_format;
use prism_core::Document;

#[tokio::main]
async fn main() -> prism_core::Result<()> {
    // Initialize Prism
    prism_core::init();

    // Read a document
    let data = std::fs::read("document.pdf")?;

    // Detect the format
    let format_result = detect_format(&data, Some("document.pdf"))
        .ok_or_else(|| prism_core::Error::DetectionFailed("Unknown format".to_string()))?;

    println!("Detected format: {}", format_result.format.name);
    println!("MIME type: {}", format_result.format.mime_type);
    println!("Confidence: {:.2}%", format_result.confidence * 100.0);

    Ok(())
}

Format Detection

use prism_core::format::detect_format;

// Detect from bytes
let data = std::fs::read("document.pdf")?;
let result = detect_format(&data, Some("document.pdf"));

if let Some(detection) = result {
    println!("Format: {}", detection.format.name);
    println!("MIME: {}", detection.format.mime_type);
    println!("Confidence: {:.2}%", detection.confidence * 100.0);
}

Document Rendering

use prism_core::Document;
use prism_render::html::HtmlRenderer;
use prism_core::render::{Renderer, RenderContext};

async fn render_to_html(document: &Document) -> prism_core::Result<String> {
    let renderer = HtmlRenderer::new();

    let context = RenderContext {
        options: Default::default(),
        filename: Some("output.html".to_string()),
    };

    let html_bytes = renderer.render(document, context).await?;
    Ok(String::from_utf8(html_bytes.to_vec())?)
}

.NET Integration (Windows)

Prism can be integrated into .NET applications (Windows Forms, WPF, MAUI) via the prism-bindings crate, which exposes a standard C API.

  1. Build the DLL:

    cargo build -p prism-bindings --release
    

    This produces target/release/prism_bindings.dll.

  2. Add to C# Project:

    • Copy the DLL to your project output directory.
    • Use [DllImport] to call the functions.

    See examples/dotnet/ for a complete working example.

🏗️ Architecture

Unified Document Model (UDM)

All document formats are parsed into a common intermediate representation:

Document
├── Metadata (title, author, dates, custom properties)
├── Pages[]
│   ├── Dimensions
│   ├── Content Blocks[]
│   │   ├── Text (runs, styles, positions)
│   │   ├── Images (embedded, linked)
│   │   ├── Tables (rows, cols, cells)
│   │   └── Vectors (paths, shapes)
│   └── Annotations
├── Styles (fonts, colors, paragraph styles)
├── Resources (fonts, images, embeddings)
└── Structure (headings, TOC, bookmarks)

Parser Architecture

Each format parser implements the Parser trait:

#[async_trait]
pub trait Parser: Send + Sync {
    fn format(&self) -> Format;
    fn can_parse(&self, data: &[u8]) -> bool;
    async fn parse(&self, data: Bytes, context: ParseContext) -> Result<Document>;
}

Renderer Architecture

Renderers implement the Renderer trait to produce output in various formats:

#[async_trait]
pub trait Renderer: Send + Sync {
    fn output_format(&self) -> Format;
    async fn render(&self, document: &Document, context: RenderContext) -> Result<Bytes>;
}

🔧 Development

Project Structure

prism/
├── Cargo.toml              # Workspace root
├── crates/
│   ├── prism-core/        # Core engine, UDM, traits
│   ├── prism-parsers/     # Format parser implementations
│   ├── prism-render/      # Rendering engine
│   ├── prism-sandbox/     # WASM sandboxing
│   ├── prism-server/      # REST API server
│   └── prism-cli/         # Command-line interface
├── tests/                 # Integration tests
└── docs/                  # Documentation

Running Tests

# Run all tests
cargo test

# Run tests for a specific crate
cargo test --package prism-core

# Run tests with output
cargo test -- --nocapture

# Run only unit tests
cargo test --lib

# Run only documentation tests
cargo test --doc

Code Quality

# Check code without building
cargo check

# Run Clippy linter
cargo clippy --all-targets --all-features

# Format code
cargo fmt

# Check formatting
cargo fmt -- --check

Watching for Changes

Install cargo-watch:

cargo install cargo-watch

# Watch and run checks
cargo watch -x check

# Watch and run tests
cargo watch -x test

🌐 REST API

Endpoints

| Endpoint | Method | Description | |----------|--------|-------------| | /health | GET | Health check | | /version | GET | Version information | | /detect | POST | Detect document format | | /convert | POST | Convert document to another format | | /extract/text | POST | Extract text from document | | /extract/metadata | POST | Extract metadata from document | | /render | POST | Render document to output format |

Example API Usage

# Health check
curl http://localhost:8080/health

# Get version information
curl http://localhost:8080/version

# Detect format (planned)
curl -X POST http://localhost:8080/detect \
  -F "file=@document.pdf"

# Convert document (planned)
curl -X POST http://localhost:8080/convert \
  -F "file=@document.docx" \
  -F "output_format=pdf" \
  -o output.pdf

🐳 Docker Deployment

Building Docker Image

Related Skills

View on GitHub
GitHub Stars14
CategoryDesign
Updated2mo ago
Forks1

Languages

Rust

Security Score

80/100

Audited on Jan 19, 2026

No findings