Overview
The CAFH Platform uses a localStorage-based storage system that simulates a 200MB persistent database. All data is stored in the browser’s localStorage with versioned keys for easy data migration.Initialization
db.init
Initializes all storage keys with default data. This method is called automatically when the app mounts.Storage Keys
All data is stored using versioned keys for maintainability:Core Data
cafh_user_session_v1- Current user sessioncafh_user_prefs_v1- User preferences (theme, notifications)cafh_user_history_v1- User activity history
Content Management
cafh_blog_v1- Blog postscafh_blog_config_v1- Blog section configurationcafh_events_v1- Calendar events and meetingscafh_content_v1- General content itemscafh_custom_pages_v1- CMS custom pagescafh_home_config_v1- Home page configurationcafh_hero_config_v1- Hero section configurationcafh_menu_v1- Mega menu structure
Media & Assets
cafh_media_v1- Media library assets
CRM & Communications
cafh_contacts_v1- Contact databasecafh_crm_lists_v1- Contact listscafh_email_logs_v1- Email delivery logscafh_email_metrics_v1- Email campaign metricscafh_campaigns_v1- Email campaignscafh_automations_v1- Automation rulescafh_automation_executions_v1- Automation execution logscafh_smtp_config_v1- SMTP configuration
Analytics
cafh_content_interactions_v1- Content consumption trackingcafh_changelog_v1- CMS change log
Module 1: Virtual Meeting Room
cafh_feedback_q_v1- Feedback questionscafh_feedback_r_v1- Feedback responsescafh_badges_v1- Member badges (gamification)cafh_participation_v1- Participation recordscafh_zoom_widget_v1- Zoom widget configuration
Module 2: Activity Calendar
cafh_activity_events_v1- Activity eventscafh_activity_cats_v1- Activity categories
Helper Functions
initStorage
Internal helper function that initializes a storage key with default data if it doesn’t exist.Storage Patterns
Reading Data
All data retrieval methods follow a consistent pattern:Writing Data
All data persistence follows this pattern:Error Handling
All storage operations include try-catch blocks:Data Limits
Array Size Limits
Certain collections have size limits to prevent localStorage overflow:- Content Interactions: Max 5,000 items
- Change Logs: Max 100 items
- Automation Executions: Max 500 items
- CRM Contacts: Warning at 5,000 items
Storage Size
The system is designed to simulate 200MB of persistent storage:Best Practices
1. Always Check for Null
2. Use Versioned Keys
All keys include version suffixes (_v1) for future migration support.
3. Parse Safely
4. Validate Data Structure
Migration Strategy
When data structures change, increment version numbers:db.init():