The BackSpace application is the web platform component of CraftSpace, built with SvelteKit. It serves as both the host for the Unity WebGL client and the data processing pipeline for Internet Archive collections.
BackSpace handles several key responsibilities:
- Content Pipeline: Processes Internet Archive collections, generates metadata, and creates texture atlases
- Web Interface: Hosts the Unity WebGL build and provides UI elements
- API Server: Provides endpoints for dynamic queries and data retrieval
- Deployment: Manages static and dynamic content delivery
- Authentication: User management and access control
SvelteKit/BackSpace/
├── scripts/ # Collection processing scripts
│ ├── download-items.js # Fetch items from Internet Archive
│ ├── generate-atlases.js # Create texture atlases
│ ├── pipeline-*.js # Data pipeline workflows
│ └── ...
├── src/ # SvelteKit application source
│ ├── routes/ # Application routes
│ │ ├── api/ # API endpoints
│ │ ├── collections/ # Collection browsing views
│ │ ├── explore/ # Exploration interface
│ │ └── settings/ # User settings and administration
│ ├── lib/ # Shared components and utilities
│ │ ├── components/ # Reusable UI components
│ │ ├── stores/ # Svelte stores for state management
│ │ ├── utils/ # Utility functions
│ │ └── api/ # API client libraries
│ └── ...
├── static/ # Static assets
│ ├── data/ # Collection data
│ ├── unity/ # Unity WebGL build
│ ├── js/unity-extensions/ # JavaScript extensions for Unity
│ └── ...
└── build/ # Production build output
BackSpace uses a multi-tiered caching and deployment strategy for Internet Archive collections data.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Internet │ │ Data │ │ Deployment │
│ Archive API │ ──────► │ Processing │ ──────► │ Destinations │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
│
▼
Generate Metadata
with Color Icons
│
│
┌─────────┴──────────┐
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ Unity │ │ SvelteKit │
│ Resources Dir │ │ Static Dir │
└─────────────────┘ └─────────────────┘
(Selected Sets) (All Collections)
-
Collection Registration:
- User registers a collection from Internet Archive
- System stores collection metadata locally
-
Collection Processing:
- Backend scripts download and process collection items
- Metadata is enhanced with extracted content features
- Texture atlases are generated for efficient visualization
-
Unity Data Delivery:
- Unity client requests collection data via API
- BackSpace delivers optimized data for visualization
- Real-time updates maintain synchronization
BackSpace processes book covers at multiple resolutions to support efficient visualization in 3D space. The system generates and manages various representations, from single-pixel color summaries to full-resolution covers.
For detailed information about the visualization techniques, including ultra-low resolution techniques, texture atlas generation, and multi-resolution display approaches, see the Visualization Techniques documentation.
BackSpace implements a multi-level caching strategy:
The system handles two types of collections:
-
Static Collections:
- Defined in the master configuration with specific queries
- Downloaded and processed during build time
- Permanently stored in the static data directory or CDN
- Example:
"prefix": "sf", "dynamic": false
(default)
-
Dynamic Queries:
- Generated on-demand based on user searches or filters
- Processed at runtime and cached temporarily
- Stored in a separate directory structure from static collections
- Example:
"prefix": "dyn_a7f3b2", "dynamic": true
-
Unity Client-Side Cache:
- Selected high-priority collections are bundled directly with the Unity WebGL build
- Stored in
Unity/CraftSpace/Assets/Resources/Collections/{prefix}
- These collections are available immediately without network requests
- The Unity build's
index.json
only includes these pre-bundled collections - Flag during download:
--include-in-unity=true
-
SvelteKit Static Directory:
- Static collections are placed in
SvelteKit/BackSpace/static/data/collections/{prefix}
- Provides a server-side cache for collections not bundled with Unity
- Can be offloaded to a CDN for improved performance
- Static collections are placed in
-
Dynamic Content Directory:
- Dynamic queries are stored in
SvelteKit/BackSpace/static/data/dynamic/{hash}
- Managed by the SvelteKit app with automatic cleanup for old/unused queries
- Not typically deployed to CDN due to their temporary nature
- TTL (Time To Live) configuration controls how long dynamic content is kept
- Dynamic queries are stored in
-
Progressive Loading:
- Collections bundled with Unity load instantly
- Additional collections load from the server as needed
- Low-resolution icons load first for immediate visualization
- Higher resolution assets load progressively
For each collection item, the system provides multiple resolution levels with specific caching strategies. See the Visualization Techniques documentation for details on the resolution hierarchy and encoding approaches.
{
"collections": [
{
"prefix": "sf",
"query": "subject:\"Science fiction\" AND mediatype:texts",
"name": "Science Fiction",
"description": "Classic science fiction literature",
"includeInUnity": true,
"maxItems": 100,
"sortBy": "downloads",
"sortDirection": "desc",
"resolutions": {
"1x1": { "generate": true, "cacheLevel": "metadata" },
"2x3": { "generate": true, "cacheLevel": "metadata" },
"16x24": { "generate": true, "cacheLevel": "server" },
"64x96": { "generate": true, "cacheLevel": "server" },
"tile": { "generate": true, "cacheLevel": "server" },
"full": { "generate": false, "cacheLevel": "server" }
}
},
{
"prefix": "poetry",
"query": "subject:Poetry AND mediatype:texts",
"name": "Poetry Collection",
"description": "Famous poetry works",
"includeInUnity": false,
"maxItems": 50
},
{
"prefix": "dyn_a7f3b2",
"query": "creator:\"Asimov, Isaac\" AND mediatype:texts",
"name": "Dynamic Query - Asimov",
"description": "Dynamically generated collection for Isaac Asimov",
"includeInUnity": false,
"maxItems": 30,
"dynamic": true
}
]
}
The system supports cache invalidation through query parameters:
?clearcache=true
- Instructs Unity to clear its persistent browser storage?reload=collections
- Forces a refresh of the collection index from the server?version={hash}
- Used for cache-busting when new collections are deployed
These parameters are recognized by the SvelteKit app and passed to Unity.
The BackSpace application hosts and communicates with the Unity WebGL client:
<!-- Unity Container Component -->
<div class="unity-container">
<!-- Unity WebGL will be loaded here -->
{#if unityStatus === 'loading'}
<div class="loading-overlay">Loading Unity WebGL...</div>
{/if}
</div>
BackSpace includes several reusable UI components:
- Collection Browser: Grid and list views for browsing collections
- Item Viewer: Detail view for individual items with metadata
- Search Interface: Advanced search with filters and sorting
- Unity Container: Responsive container for the Unity WebGL client
- Administration Tools: Collection management interface
User authentication and authorization are handled through SvelteKit hooks:
// Authentication functionality is implemented in src/hooks.server.js
// to protect routes and manage user sessions
The BackSpace application provides several API endpoints:
GET /api/collections
: List all available collectionsGET /api/collections/:prefix
: Get details for a specific collectionGET /api/collections/:prefix/items
: Get items in a collectionPOST /api/collections
: Register a new collection (admin only)DELETE /api/collections/:prefix
: Remove a collection (admin only)
GET /api/items/:id
: Get details for a specific itemGET /api/items/:id/content
: Get content for a specific itemGET /api/items/:id/similar
: Find similar items
GET /api/search?q=query
: Search across collectionsGET /api/collections/:prefix/search?q=query
: Search within a collection
All API endpoints return JSON responses and support standard HTTP status codes for error handling.
-
Install Dependencies:
cd SvelteKit/BackSpace npm install
-
Configure Collections: Edit the
collections.json
file at the project root -
Run Development Server:
# Starts server on http://localhost:5173 npm run dev
-
Process Collections:
# Build TypeScript scripts npm run build:scripts # Run full pipeline npm run pipeline-full # Or run incremental updates npm run pipeline-incremental
# Build scripts
npm run build:scripts
# Process collections
npm run pipeline-full
# Build SvelteKit app
npm run build
The build output will be in SvelteKit/BackSpace/build/
.
To add a new collection:
- Edit the
collections.json
file - Add a new entry with query parameters
- Run the pipeline to process the collection
- Update the Unity project if including in client
BackSpace implements several performance optimizations:
- Incremental Static Regeneration: Pre-render pages but update dynamically
- API Response Caching: Cache API responses to reduce load
- Lazy Loading: Load components and data only when needed
- Asset Optimization: Compress and optimize static assets
- Unity WebGL Streaming: Progressive loading of Unity content
BackSpace can be deployed to various environments:
- Static Hosting: Export as static site with serverless functions
- Container-based: Deploy using Docker to cloud platforms
- Node.js Server: Run as a standalone Node.js application
The recommended deployment approach uses Digital Ocean App Platform for both static hosting and containerized backend services.
The BackSpace pipeline generates texture atlases for book covers at multiple resolutions. These atlases pack multiple book covers into single texture files for efficient rendering in Unity. For details on atlas generation techniques and optimization strategies, see the Texture Atlas System section in the Visualization documentation.
For Unity-specific details on texture atlases, gutters, and optimization techniques used in the CraftSpace renderer, see the Unity Rendering Implementation section in the Visualization documentation.
Common issues and solutions:
-
Unity Loading Fails:
- Check browser console for errors
- Verify Unity build files are correctly placed in
static/unity
- Ensure browser supports WebGL 2.0
-
API Errors:
- Check server logs for detailed error information
- Verify Internet Archive API credentials
- Check network connectivity and CORS configuration
-
Slow Collection Processing:
- Adjust concurrency settings in configuration
- Verify disk space and memory availability
- Consider using batch processing for large collections
Planned enhancements for BackSpace include:
- Progressive Web App: Full PWA support for offline capabilities
- Collaborative Features: Real-time collaboration between users
- Advanced Analytics: Usage tracking and visualization patterns
- Personalization: User-specific collections and preferences
- Internationalization: Multi-language support