Tone Packs Feature
Overview
Tone packs are collections of images mapped to emotional tones that appear on journal entry cards in the stream view. This allows users to visually identify the emotional tone of entries at a glance without reading the content.
Features
- Create Tone Packs: Users can create custom tone packs with a name, description, and theme (e.g., origami, animals, nature, abstract)
- AI Image Generation: Generate images for tones using OpenAI DALL-E 3 based on the pack's theme
- Visual Display: Tone pack images appear as small icons on note cards in the stream view when an entry has a matching mood
- Sharing: Users can share their tone packs with other users by email or user ID
- Public Packs: Users can make their tone packs public for others to discover and use
Database Schema
Tables
tone_packs: Stores tone pack metadata (name, description, theme, owner, public status)tone_pack_images: Maps tones to images within a packtone_pack_shares: Tracks which users have access to shared packs
User Preferences
The active tone pack ID is stored in profiles.preferences.active_tone_pack_id.
API Endpoints
Tone Packs
GET /api/tone-packs- Get all tone packs available to user (own, shared, public)GET /api/tone-packs/:id- Get single tone packPOST /api/tone-packs- Create new tone packPUT /api/tone-packs/:id- Update tone packDELETE /api/tone-packs/:id- Delete tone packPOST /api/tone-packs/:id/generate-images- Generate images for tones using AIPOST /api/tone-packs/:id/share- Share tone pack with userDELETE /api/tone-packs/:id/share/:userId- Unshare tone packPOST /api/tone-packs/:id/activate- Set tone pack as active for user
Setup
1. Database Migration
Run the migration to create the necessary tables:
# Apply migration
supabase migration up
Or manually run supabase/migrations/015_add_tone_packs.sql
2. Storage Bucket
Create a Supabase storage bucket named tone-packs:
Option 1: Run the migration (Recommended)
# Apply migration 018
supabase migration up
Or manually run supabase/migrations/018_create_tone_packs_bucket.sql in the Supabase SQL Editor.
Option 2: Via Supabase Dashboard
- Go to Storage
- Create new bucket
- Name:
tone-packs - Public: Yes
- File size limit: 5MB
- Allowed MIME types:
image/png,image/jpeg,image/jpg,image/webp
Option 3: Manual SQL
-- In Supabase dashboard or via SQL
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
VALUES (
'tone-packs',
'tone-packs',
true,
5242880, -- 5MB
ARRAY['image/png', 'image/jpeg', 'image/jpg', 'image/webp']
);
Note: The migration also sets up RLS policies for secure access control.
3. Environment Variables
Ensure OPENAI_API_KEY is set in your backend environment for AI image generation.
Usage
Creating a Tone Pack
- Go to Settings → Tone Packs
- Click "Create New Pack"
- Enter name, description, and select a theme
- Optionally make it public
- Click "Create & Generate Images"
- Select tones to generate images for
- Images are generated using AI based on the theme
Activating a Tone Pack
- In Settings → Tone Packs, find your pack
- Click "Activate"
- The pack will now be used in the stream view
Sharing a Tone Pack
- Click "Share" on your tone pack
- Enter the user's email or user ID
- The pack will appear in their "Shared With Me" section
Viewing Tone Images
- In the stream view (
/dashboard/stream), entries with a mood will display the corresponding tone pack image - Images appear as small icons in the top-right corner of note cards
- Only the active tone pack's images are displayed
Supported Tones
Common tones that can be detected/generated:
- Positive: joyful, grateful, excited, hopeful, content, peaceful, optimistic
- Negative: sad, anxious, frustrated, angry, worried, disappointed, melancholic, pessimistic
- Neutral: calm, contemplative, neutral, tired, energetic
Themes
Available themes for tone packs:
- origami
- animals
- nature
- abstract
- geometric
- minimalist
- watercolor
- line-art
- icons
- emojis
- shapes
- patterns
Technical Details
Image Generation
- Uses OpenAI DALL-E 3 model
- Images are 1024x1024px (square for icons)
- Uploaded to Supabase storage bucket
tone-packs - Stored at path:
{userId}/{packId}/{tone}-{timestamp}.png
Stream View Integration
- Active tone pack is loaded when user profile is fetched
- Entry mood is matched to tone pack images (case-insensitive)
- Images are displayed as 16px icons (scaled with note size)
- Positioned in top-right corner of note cards
Future Enhancements
- Browse public tone packs
- Rate/review tone packs
- Import/export tone packs
- Custom tone definitions
- Batch image generation
- Image editing/regeneration