# MEDIA MANAGER SYSTEM — FULL BLUEPRINT
Build a complete Media Manager (digital asset management) system. This specification covers 4 entities, 1 main page, 12 components, and 2 backend functions.
---
## 1. ENTITY SCHEMAS
### 1.1 MediaAsset
```json
{
"name": "MediaAsset",
"type": "object",
"properties": {
"asset_name": {
"type": "string",
"description": "File name or title"
},
"asset_type": {
"type": "string",
"enum": [
"image",
"video",
"audio",
"document",
"3d_model"
],
"description": "Type of media"
},
"original_url": {
"type": "string",
"description": "URL of original upload"
},
"public_url": {
"type": "string",
"description": "URL of blurred/approved version (if applicable)"
},
"thumbnail_url": {
"type": "string",
"description": "Thumbnail image URL (auto-generated from first frame for videos)"
},
"collection_id": {
"type": "string",
"description": "ID of the collection this asset belongs to"
},
"display_order": {
"type": "number",
"default": 0,
"description": "Order for display within a collection or folder"
},
"contains_students": {
"type": "boolean",
"default": false,
"description": "CRITICAL: If true, requires safeguarding approval"
},
"blur_applied": {
"type": "boolean",
"default": false,
"description": "Has face blurring been applied"
},
"blur_regions": {
"type": "array",
"items": {
"type": "object"
},
"description": "Coordinates of blurred regions"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Searchable tags"
},
"sector": {
"type": "string",
"enum": [
"Technology",
"Healthcare",
"Engineering",
"Creative & Media",
"Finance",
"Education",
"Retail",
"Hospitality",
"Construction",
"Legal",
"Manufacturing",
"Public Sector",
"Social Enterprise",
"Other",
"N/A"
]
},
"school_id": {
"type": "string",
"description": "Associated school if applicable"
},
"event_id": {
"type": "string",
"description": "Associated event if applicable"
},
"story_id": {
"type": "string",
"description": "Associated story if applicable"
},
"usage_references": {
"type": "array",
"items": {
"type": "string"
},
"description": "Where this asset is used"
},
"approval_status": {
"type": "string",
"enum": [
"pending",
"approved",
"rejected"
],
"default": "pending",
"description": "Safeguarding approval state"
},
"approved_by": {
"type": "string",
"description": "User email who approved"
},
"approved_date": {
"type": "string",
"format": "date"
},
"uploaded_by_email": {
"type": "string",
"description": "Uploader email for audit"
},
"qr_code_url": {
"type": "string",
"description": "Generated QR code image URL"
}
},
"required": [
"asset_name",
"asset_type",
"original_url"
]
}
```
### 1.2 Collection
```json
{
"name": "Collection",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Collection name"
},
"description": {
"type": "string",
"description": "Brief description"
},
"sector": {
"type": "string",
"enum": [
"Technology",
"Healthcare",
"Engineering",
"Creative & Media",
"Finance",
"Education",
"Retail",
"Hospitality",
"Construction",
"Legal",
"Manufacturing",
"Public Sector",
"Social Enterprise",
"Land Based",
"Multi-Sector",
"Other"
]
},
"collection_type": {
"type": "string",
"enum": [
"images",
"videos",
"mixed",
"3d_models",
"audio",
"documents"
],
"default": "images"
},
"asset_ids": {
"type": "array",
"items": {
"type": "string"
},
"description": "Ordered array of MediaAsset IDs"
},
"thumbnail_url": {
"type": "string"
},
"hero_image_url": {
"type": "string",
"description": "Hero image shown as watermark on collection card"
},
"favourite_asset_ids": {
"type": "array",
"items": {
"type": "string"
},
"description": "Up to 12 favourite asset IDs for rotator/scheduling"
},
"status": {
"type": "string",
"enum": [
"draft",
"published"
],
"default": "draft"
},
"featured": {
"type": "boolean",
"default": false
}
},
"required": [
"name"
]
}
```
### 1.3 Folder
```json
{
"name": "Folder",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Folder name"
},
"parent_folder_id": {
"type": "string",
"description": "Parent folder ID for nested folders"
},
"asset_ids": {
"type": "array",
"items": {
"type": "string"
},
"description": "IDs of assets in this folder"
},
"color": {
"type": "string",
"description": "Folder color for visual organization"
}
},
"required": [
"name"
]
}
```
### 1.4 Gallery
```json
{
"name": "Gallery",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"asset_ids": {
"type": "array",
"items": {
"type": "string"
},
"description": "IDs of assets in this gallery"
},
"is_public": {
"type": "boolean",
"default": false
},
"share_token": {
"type": "string",
"description": "Unique token for sharing gallery"
},
"cover_image_url": {
"type": "string"
}
},
"required": [
"title"
]
}
```
---
## 2. PAGES
### 2.1 MediaManager (main page)
- **Tabs**: All | Images | Videos | Documents | Collections | Folders | Galleries
- **Header**: Title "Media Manager" + Upload button (violet to pink gradient)
- **Search bar**: Full-text search across asset names and tags
- **Sort**: Oldest first, Newest first, Name A-Z, Name Z-A
- **Tag filter**: Quick filter chips from all existing tags
- **Full-page drag-and-drop**: Dragging files anywhere onto the page shows a fullscreen drop overlay with bouncing upload icon, then opens the upload dialog with files pre-loaded
- **Pick mode**: Supports ?pickMode=true&pickTarget=banner&returnTo=URL - when active, clicking an image returns its URL to the calling page
- Uses TanStack Query for all data fetching (queryKey: 'media-assets', 'collections', 'folders', 'galleries')
---
## 3. COMPONENTS
### 3.1 MediaUpload (components/media/MediaUpload)
- Dialog-based multi-file uploader
- Drag-and-drop zone + file browser
- File preview grid (thumbnail previews for images)
- **Auto-naming**: Toggle to auto-name files with base name + incrementing number, auto-detects next number from existing assets
- **Auto-transcribe**: Toggle for audio/video files - triggers transcription after upload
- **Video thumbnail extraction**: For video files, automatically captures a non-blank frame (tries 0.167s, 0.5s, 1s, 2s) and uploads as thumbnail
- Per-file + overall progress bars with percentage
- Tags input (comma-separated, applied to all files)
- Upload flow: Uses UploadFile integration first, falls back to S3 backend function
- Collection assignment: When uploading from a collection view, batch-updates the collection's asset_ids array after all uploads complete
- File type detection: image, video, audio, document, 3d_model (glb, gltf, obj, fbx, stl)
### 3.2 MediaGrid (components/media/MediaGrid)
- Responsive grid with 4 adjustable thumbnail sizes: XS (10-col), S (8-col), M (4-col), L (3-col)
- Size control: +/- buttons persisted to localStorage
- Lazy loading with pagination (60 per page, "Load more" button)
- Asset cards show: image preview, video thumbnail with play overlay, 3D model badge, document icon
- **Selection mode**: Click checkbox on any card to select. Multi-select up to 50 assets
- Inline rename: Click asset name to edit in-place
- Right-click/kebab menu: View Details, Move to Collection, Duplicate, Delete
- Hover overlay: View + Download buttons
- Compact name overlay at small sizes, full info panel at M/L sizes
- Tags displayed as badges (max 3 visible + overflow count)
- Drag-and-drop zone for uploading when empty
- Integrates with useSignedUrls hook for S3 private URLs
### 3.3 CollectionManager (components/media/CollectionManager)
- Square card grid of collections with hero image watermarks
- Virtual "Latest" collection always appears first - shows all assets sorted by newest
- **Create collection**: Dialog with name, description, type (images/videos/mixed/3d_models/audio/documents)
- **Collection detail view**: Click into a collection to see its assets
- **Drag-and-drop reordering**: Assets can be dragged to reorder within a collection using @hello-pangea/dnd. Order persists to Collection.asset_ids array
- **Hero image picker**: Click "Select from gallery" to enter pick mode, then click any asset to set it as the collection's hero image. Shows as watermark on card with gradient overlay
- **Favourites**: Toggle star on assets (max 12). Progress bar shows favourite count. Only enabled when collection has 13+ assets
- **Selection toolbar**: Bulk favourite, unfavourite, rename, remove from collection, delete
- **Delete collection**: Confirmation dialog with option to also delete all contained assets
- **Rename collection**: Inline rename dialog
- **Copy link**: Copy deep link to collection
- forwardRef with imperative handle: getSelectedCollectionId(), resetSelection()
- Uses useSignedUrls for all S3 URLs
### 3.4 FolderManager (components/media/FolderManager)
- Grid of colour-coded folders with item count
- Create folder dialog with name + colour picker (6 preset colours)
- Empty state with "Create Folder" CTA
### 3.5 GalleryManager (components/media/GalleryManager)
- Card grid of galleries with public/private badge
- Create gallery: title, description, is_public toggle
- Auto-generates share_token on creation
- Copy share link button with copied feedback
### 3.6 MediaDetailDialog (components/media/MediaDetailDialog)
- Full-screen expandable dialog (toggle between max-w-3xl and 95vw)
- **Prev/Next navigation**: Arrow buttons + counter badge when viewing within a list
- **Preview**: Image (object-contain), Video (with VideoPlayer component + "Set Thumbnail" button), 3D Model (with ModelViewer), Document fallback
- **Inline rename**: Click title to edit name in-place
- **URL display**: Read-only input + copy button with check feedback
- **Details grid**: Type, Created date, Uploaded By, Approval Status
- **Tag management**: View existing tags as removable badges, add new tags via input + Add button
- Download + Close action buttons
### 3.7 VideoPlayer (components/media/VideoPlayer)
- Custom HTML5 video player with frame-accurate timeline
- Transport controls: Go to start, back 1 frame (at 30fps), play/pause, forward 1 frame, go to end
- **In/Out points**: Set in and out markers on the timeline. Displays coloured range highlight. Shows timecodes for each point + computed duration between them
- Timeline: Click to seek, progress fill, playhead indicator
- Time display: MM:SS.mmm format (millisecond precision)
- Calls onInOutChange callback when markers are set
### 3.8 ThumbnailPicker (components/media/ThumbnailPicker)
- Embedded video player for thumbnail selection
- Scrub to desired frame, click "Set as Thumbnail"
- Captures frame to canvas, converts to JPEG blob, uploads to S3, updates MediaAsset.thumbnail_url
- Timeline with playhead and progress
### 3.9 ModelViewer (components/media/ModelViewer)
- Three.js-based 3D model viewer
- Supports GLB, GLTF, OBJ, FBX, STL formats via Three.js addon loaders
- Auto-rotate, drag to rotate, scroll to zoom
- Grid floor, ambient + directional + hemisphere lighting
- Auto-center and scale model to fit viewport
- Loading spinner + error state
- interactive prop: when false, disables mouse/touch interaction
### 3.10 MediaSelectionToolbar (components/media/MediaSelectionToolbar)
- Sticky toolbar (violet background) when assets are selected in the main grid
- Shows selection count + max cap indicator (50)
- Actions: Select/Deselect All, Rename All (sequential naming dialog), Move to Collection (picker dialog), Delete (requires typing "DELETE" to confirm)
- Processing states with loaders
### 3.11 CollectionSelectionToolbar (components/media/CollectionSelectionToolbar)
- Same sticky toolbar style but for within-collection selections
- Additional actions: Bulk Favourite (up to 12), Bulk Unfavourite, Rename, Remove from Collection (unlinks without deleting), Delete
- Same "type DELETE" confirmation for destructive actions
### 3.12 useSignedUrls (components/media/useSignedUrls)
- Custom React hook for batched S3 signed URL resolution
- Detects S3 URLs by hostname, passes non-S3 URLs through unchanged
- In-memory cache with 50-minute TTL (signed URLs expire at 60 min)
- Batches requests in groups of 100 via getSignedS3Url backend function
- Returns { [rawUrl]: signedUrl } map
- Helper function: getSignedUrl(urlMap, url) - returns signed URL or fallback
---
## 4. BACKEND FUNCTIONS
### 4.1 uploadToS3 (functions/uploadToS3)
- **Secrets required**: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET_NAME, AWS_REGION
- Authenticates user via Base44 SDK
- Accepts two upload methods:
1. JSON body with base64-encoded file_data, file_name, content_type, folder
2. multipart/form-data with file field + folder field
- S3 key format: {folder}/{timestamp}-{filename}
- Uploads with ACL: 'public-read'
- Returns: { success, file_url, file_name, content_type }
- Uses @aws-sdk/client-s3 PutObjectCommand
### 4.2 getSignedS3Url (functions/getSignedS3Url)
- **Secrets required**: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET_NAME, AWS_REGION
- Authenticates user via Base44 SDK
- Accepts: { urls: string[] } (max 100)
- For each URL: extracts S3 key from URL, generates pre-signed GetObject URL (1 hour expiry)
- Non-S3 URLs are returned as-is
- Uses @aws-sdk/s3-request-presigner getSignedUrl
- Returns: { signed_urls: { [originalUrl]: signedUrl } }
---
## 5. UTILITY: uploadToS3 (frontend helper)
### components/utils/uploadToS3
- Converts File to base64 (in 8KB chunks to avoid stack overflow)
- Calls uploadToS3 backend function via base44.functions.invoke
- Returns { file_url, file_name, content_type }
- Used as fallback when base44.integrations.Core.UploadFile fails
---
## 6. DESIGN SYSTEM
- **Theme**: Dark background (black/slate-900), glass-morphism cards with backdrop-blur
- **Accent colours**: Violet to Pink gradients for primary actions, teal to cyan for secondary
- **Font**: Nunito for headings
- **Cards**: Rounded-2xl, border-white/10, hover:shadow-lg
- **Badges**: Small rounded badges for tags and status
- **Toolbars**: Sticky violet-600/95 backdrop-blur with white text
- **Empty states**: Centered icon + description + CTA button
- **Loading**: Shimmer cards or spinner animations
- **Dialogs**: DialogContent with max-w-3xl or max-w-5xl, max-h-90vh overflow-y-auto
---
## 7. IMPLEMENTATION ORDER
1. Create all 4 entities (MediaAsset, Collection, Folder, Gallery)
2. Set up AWS secrets and create both backend functions (uploadToS3, getSignedS3Url)
3. Create the useSignedUrls hook and uploadToS3 utility
4. Create MediaUpload, MediaGrid, MediaDetailDialog, VideoPlayer, ThumbnailPicker, ModelViewer
5. Create MediaSelectionToolbar and CollectionSelectionToolbar
6. Create CollectionManager, FolderManager, GalleryManager
7. Create the MediaManager page wiring all tabs together