Project Architecture
Overview
Scriptoria separates a Python UI shell from reusable core services:
studio_ui/renders the FastHTML and HTMX interface.universal_iiif_core/owns provider resolution, storage, download orchestration, export logic, OCR services, and runtime policy.universal_iiif_cli/exposes the CLI entrypoint on top of the same core services.
The UI depends on the core layer. The core layer does not depend on UI modules.
Current UI Structure
The Studio-facing UI is now organized as focused packages rather than large single-file modules.
Routes And Workspace Helpers
studio_ui/routes/studio.pyregisters the Studio routes.studio_ui/routes/studio_handlers.pyacts as the public handler surface and orchestration entrypoint.studio_ui/routes/_studio/contains focused helpers for:- workspace context;
- manifest and read-source selection;
- thumbnail/export fragments;
- page-level job preferences;
- UI utility glue.
This keeps the route surface stable while moving implementation detail into narrower modules.
Settings UI
studio_ui/components/settings/panes/contains domain-specific settings panes.- The package is organized by responsibility such as general, images, network, PDF, system, viewer, and discovery settings.
Studio Output UI
studio_ui/components/studio/export/owns the Output tab assembly.- The package is split into:
- PDF inventory rendering;
- page actions;
- thumbnail rendering;
- output tab assembly;
- client-side tab script generation.
Core Services
Discovery
Discovery uses a shared provider registry and typed orchestration in universal_iiif_core.discovery.
Responsibilities:
- classify user input;
- resolve direct provider inputs;
- route free-text search to provider search adapters;
- normalize results into the shared search contract;
- support provider-specific filters and pagination where available.
Downloading
Download orchestration is handled by core services and a job manager backed by local state.
Runtime behavior includes:
- native PDF-first strategy when configured;
- IIIF image fallback;
- staged page validation before promotion;
- resume and retry safety across partial runs.
Storage
VaultManager and related storage modules keep track of:
- manuscripts and metadata;
- download and export jobs;
- UI preferences and local working state;
- snippet and OCR-related local records.
Export
Export services manage:
- PDF inventory discovery;
- profile-driven export jobs;
- local and temporary remote high-resolution image sourcing;
- cleanup and retention policies.
OCR
OCR services abstract local and remote engines behind a common workflow, while the UI handles asynchronous job feedback.
Networking
The centralized HTTP client is the primary transport layer for runtime network operations.
Responsibilities:
- retry and backoff policy;
- per-library network customization;
- concurrency and rate limiting;
- metrics and request hygiene around hostile or fragile upstream services.
End-To-End Flow
1. Discovery To Library
- The user submits a URL, identifier, shelfmark, or query.
- Discovery resolves or searches through the provider registry.
- Results are normalized into the shared search contract.
Add itemwrites local metadata without forcing a full download.
2. Download To Local Working State
- A download job starts through the job manager.
- The runtime prefers native PDF when available and configured.
- Otherwise it downloads IIIF images and validates them in staging.
- Validated output is promoted into local scans when the promotion policy allows it.
3. Library To Studio
- The user opens a local item from Library.
- Studio builds a workspace context from local records and manifest state.
- The viewer chooses remote or local mode based on completeness and policy.
- The user works across transcription, history, metadata, image actions, and output.
4. Output And Export
- The Output tab reads current PDF inventory.
- The user selects an export profile or uses a page-level refresh action.
- Export jobs run through the storage-backed job system.
- Output artifacts are persisted under runtime-managed paths.
Design Rules
docs/is the documentation source of truth; wiki pages are derived publish targets.- Runtime paths are resolved through
ConfigManager, not hardcoded strings. scans/is the operational image source for local study workflows.- Staging and retry behavior must remain safe for partial and resumed downloads.
- UI package structure should reflect responsibility boundaries, not just file size limits.
Current Hotspots For Contributors
- Discovery orchestration and provider search behavior.
- Studio workspace and read-source selection.
- Output tab assembly and thumbnail/page-action rendering.
- Settings panes for network, PDF, viewer, and system behavior.
- Config reference and runtime validation alignment.