Skip to content
/ Prism Public

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.

License

Notifications You must be signed in to change notification settings

abahjat/Prism

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

Prism Home

MHT Viewing Image Viewing

πŸš€ Features

  • Comprehensive Format Support: Support for 600+ document formats (200+ in Phase 1)

    • Office: DOCX, XLSX, PPTX, DOC, XLS, PPT, RTF, ONE, VSDX, MPP, XPS, EPUB
    • PDF: PDF 1.x-2.0, PDF/A
    • Email: MSG, EML, PST, MHT
    • Images: JPEG, PNG, TIFF, GIF, BMP, WebP, HEIC
    • Archives: ZIP, RAR, 7z, TAR, GZIP
    • CAD: DWG, DXF
    • And many more...
  • 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.75 or later
  • 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

Using the Rust Library

Add Prism to your Cargo.toml:

[dependencies]
prism-core = "0.1.0"
prism-parsers = "0.1.0"
prism-render = "0.1.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

FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release --bin prism-server

FROM debian:bookworm-slim
COPY --from=builder /app/target/release/prism-server /usr/local/bin/
EXPOSE 8080
CMD ["prism-server", "--host", "0.0.0.0"]

Build and run:

# Build image
docker build -t prism-server .

# Run container
docker run -p 8080:8080 prism-server

# Custom port
docker run -p 3000:3000 -e PRISM_PORT=3000 prism-server

Docker Compose

version: '3.8'
services:
  prism:
    image: prism/server:latest
    ports:
      - "8080:8080"
    environment:
      - PRISM_HOST=0.0.0.0
      - PRISM_PORT=8080
    volumes:
      - ./data:/data
      - ./cache:/cache

☸️ Kubernetes Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: prism-server
spec:
  replicas: 3
  selector:
    matchLabels:
      app: prism
  template:
    metadata:
      labels:
        app: prism
    spec:
      containers:
      - name: prism
        image: prism/server:latest
        ports:
        - containerPort: 8080
        env:
        - name: PRISM_HOST
          value: "0.0.0.0"
        - name: PRISM_PORT
          value: "8080"
        resources:
          requests:
            memory: "2Gi"
            cpu: "1000m"
          limits:
            memory: "4Gi"
            cpu: "2000m"

πŸ“Š Performance

Current performance targets:

Operation Target (p95) Status
Format Detection <10ms βœ… Achieved
Simple Conversion (10 pages) <500ms 🚧 In progress
Text Extraction <100ms 🚧 In progress
Thumbnail Generation <200ms 🚧 In progress

πŸ”’ Security

  • Parser Sandboxing: All parsers run in WebAssembly sandboxes with strict memory/CPU limits
  • No Code Execution: Documents cannot execute code; macros are parsed but not run
  • Memory Limits: Configurable memory limits per parser instance
  • Timeout Protection: Execution time limits prevent infinite loops
  • No I/O Access: Sandboxed parsers cannot access filesystem or network

πŸ—ΊοΈ Roadmap

Phase 1 (Current - Year 1): Foundation

  • βœ… Core architecture and UDM
  • βœ… Basic format detection
  • βœ… HTML renderer
  • 🚧 200 format support
  • 🚧 REST API
  • 🚧 CLI tool

Phase 2 (Year 2): Expansion

  • 400 format support
  • AI-powered features (classification, summarization)
  • SOC 2 Type II compliance
  • Enterprise features

Phase 3 (Year 3): Parity

  • 600+ format support
  • FedRAMP certification
  • Format parity with Oracle Outside In

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Development Guidelines

  1. Follow Rust best practices and idioms
  2. Write tests for new functionality
  3. Document public APIs with rustdoc comments
  4. Run cargo clippy before submitting
  5. Ensure cargo test passes
  6. Update documentation as needed

πŸ“ License

Prism is dual-licensed under:

  • AGPL-3.0: For open source projects and internal use where source availability is acceptable (LICENSE).
  • Commercial: For proprietary/closed-source applications (LICENSE_COMMERCIAL).

See DUAL_LICENSING.md for a detailed guide on which license you need.

πŸ™ Acknowledgments

Prism is inspired by and aims to be a modern alternative to:

  • Oracle Outside In
  • Apache POI
  • LibreOffice
  • Various document processing libraries

πŸ“ž Support

🌟 Status

Current Status: Early Development (v0.1.0)

  • βœ… Core architecture complete
  • βœ… Format detection working
  • βœ… Basic HTML renderer
  • 🚧 Parser implementations in progress
  • 🚧 Additional renderers in development
  • 🚧 REST API under construction

Built with ❀️ in Rust

About

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.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published