Skip to content

MomenMushtaha/MessageAI

Repository files navigation

MessageAI

AI-Powered Messaging Platform for Remote Teams

A production-ready iOS messaging application built with SwiftUI and Supabase, featuring integrated AI assistants to help remote professionals manage communication overload, track decisions, and maintain team alignment across time zones.

🎯 Overview

MessageAI combines enterprise-grade messaging infrastructure with intelligent AI assistants designed specifically for distributed teams. Built on a modern SwiftUI + Supabase architecture, it delivers WhatsApp-quality real-time messaging enhanced with contextual AI features that surface insights without leaving your conversations.

Target Users: Engineering managers, product leads, and remote team coordinators managing high-volume async communication across time zones.

Core Value: Transforms message overload into actionable intelligence through embedded AI agents.

✨ Key Features

πŸ€– AI Assistants

MoChain - Remote Team Assistant

Your intelligent work companion that lives inside your conversations:

  • πŸ“Š Thread Summarization - Digest 50+ message threads in seconds
  • 🎯 Action Item Extraction - Auto-detect commitments and owners ("I'll do X")
  • βœ… Decision Tracking - Surface agreed-upon decisions from discussions
  • 🚨 Priority Detection - Flag urgent messages automatically
  • πŸ” Smart Semantic Search - Find information by meaning, not keywords
  • πŸ’¬ Direct Chat - Ask MoChain questions about your team coordination
  • 🧠 Multi-Step Workflows - Execute complex tasks autonomously

MushLifts - Personal Wellness Assistant

Dedicated fitness and wellness AI for busy remote professionals:

  • πŸ’ͺ Workout Planning - Personalized training programs
  • πŸ₯— Nutrition Guidance - Meal planning and dietary advice
  • πŸƒ Fitness Tracking - Progress monitoring and motivation
  • βš–οΈ Work-Life Balance - Wellness tips for remote workers

πŸ’¬ Core Messaging

Real-Time Communication

  • Instant message delivery via Supabase Realtime
  • WhatsApp-style message status (sent βœ“, delivered βœ“βœ“, read πŸ”΅)
  • Typing indicators and presence system
  • Group chats with participant management
  • Direct one-on-one conversations

Rich Media Support

  • πŸ“Έ Image sharing via S3/CloudFront CDN
  • πŸŽ₯ Video messages with playback controls
  • πŸŽ™οΈ Voice messages with waveform visualization
  • πŸ–ΌοΈ Group avatars and profile pictures

Smart Features

  • πŸ“ Message pinning for important updates
  • πŸ—‘οΈ Delete for Me vs Delete for Everyone
  • 🧹 Clear chat history (personal view only)
  • 🎯 Lazy conversation creation (DB created on first message)
  • πŸ’Ύ Offline support with auto-sync
  • ⚑ Optimistic UI for instant feedback

🎨 User Experience

Beautiful Interface

  • WhatsApp-inspired gradients and animations
  • Custom message bubble shapes with tail pointers
  • Glass morphism effects on AI action toolbar
  • Smooth spring-based transitions (60fps)
  • Professional design token system (Colors, Typography, Shadows, Spacing)

Smart Notifications

  • In-app banner notifications (no developer account needed)
  • APNs push notification support
  • Conversation-aware notification routing

Helpful Guidance

  • Character counter (4096 limit)
  • Empty states with onboarding hints
  • User-friendly error messages
  • AI configuration banner for setup

⚑ Performance & Architecture

Dual-Database Design

  • Global DB for shared conversations and messages
  • Per-user privacy layer for personal deletions
  • Server-side message filtering for optimal privacy
  • ISO8601 timestamp standardization

Optimization

  • NSCache reduces Supabase reads by ~70%
  • Lazy loading with pagination (100 messages at a time)
  • Smart UI updates (only re-render on actual changes)
  • 15MB cache limit with auto-cleanup
  • Optimized queries with delta polling
  • <200ms latency with optimistic UI

Observability

  • Performance monitoring dashboard
  • Sync service monitoring
  • Database operation tracing
  • State inspector for debugging
  • Test data seeding for development

πŸ›  Technology Stack

Frontend

  • SwiftUI - Declarative UI framework
  • SwiftData - Modern local persistence
  • iOS 17+ - Latest platform features
  • CoreML - On-device AI inference
  • AVFoundation - Audio/video playback

Backend

  • Supabase Postgres - Realtime JSON document store with JSONB
  • Supabase Auth - Email/password authentication
  • Supabase Edge Functions - Serverless API endpoints (Deno runtime)
  • AWS S3 + CloudFront - Media storage and CDN
  • OpenAI GPT-4 - AI assistant capabilities

AI Infrastructure

  • On-device Apple Intelligence for translations
  • Server-side inference via Edge Functions
  • Multiple inference provider support (CoreML, Foundation Models, Server)

πŸ“‹ Requirements

  • iOS: 17.0 or later
  • Xcode: 16.0 or later
  • Swift: 5.9+
  • Supabase: Project with Postgres database
  • Optional: AWS S3 bucket for media, OpenAI API key for AI features

πŸš€ Quick Start

Local Development Setup

For simulator and local testing, use the automated setup script:

# Clone the repository
git clone https://github.com/MomenMushtaha/MessageAI.git
cd message-ai

# Run Supabase setup (installs CLI, starts local instance, creates schema)
./scripts/setup-supabase.sh

# Start AI agent backend (optional - for MoChain/MushLifts)
./scripts/start-backend.sh

The setup script automatically:

  • Installs Supabase CLI (if needed)
  • Initializes local Supabase at http://127.0.0.1:54321
  • Creates realtime_documents table with RLS policies
  • Sets up authentication system

Physical Device Testing

To test on a physical iOS device connected to your local Supabase:

  1. Find your Mac's local IP address:

    ifconfig | grep "inet " | grep -v 127.0.0.1
  2. Update Info.plist with your local IP:

    <key>SUPABASE_URL</key>
    <string>http://192.168.x.x:54321</string>
  3. Enable Local Network permission:

    • iOS Settings β†’ Privacy & Security β†’ Local Network β†’ MessageAI βœ“

Production Deployment

1. Supabase Cloud Setup

Create a production Supabase project:

# Create project at https://supabase.com/dashboard
# Then configure your project:

# Create realtime documents table
psql $SUPABASE_DB_URL -c "
CREATE TABLE IF NOT EXISTS realtime_documents (
  path TEXT PRIMARY KEY,
  data JSONB
);

-- Enable RLS
ALTER TABLE realtime_documents ENABLE ROW LEVEL SECURITY;

-- Allow authenticated users full access
CREATE POLICY \"Allow authenticated access\"
  ON realtime_documents
  FOR ALL
  USING (auth.role() = 'authenticated')
  WITH CHECK (auth.role() = 'authenticated');
"

2. Configure App Credentials

Copy the example config and fill in your credentials:

cp Config.example.xcconfig Config.xcconfig

Edit Config.xcconfig:

SUPABASE_URL = https://your-project.supabase.co
SUPABASE_ANON_KEY = your-anon-key-here
SUPABASE_FUNCTIONS_URL = https://your-project.functions.supabase.co
S3_UPLOAD_ENDPOINT = $(SUPABASE_FUNCTIONS_URL)/generate-upload-url
MOCHAIN_CHAT_ENDPOINT = $(SUPABASE_FUNCTIONS_URL)/mochain
MUSHLIFTS_CHAT_ENDPOINT = $(SUPABASE_FUNCTIONS_URL)/mushlifts

3. Deploy Edge Functions

Deploy the AI and media handling functions:

cd supabase/functions

# Deploy all functions
supabase functions deploy mochain
supabase functions deploy mushlifts
supabase functions deploy generate-upload-url
supabase functions deploy send-notification
supabase functions deploy aiSummarize
supabase functions deploy summarizeText

# Set environment variables
supabase secrets set OPENAI_API_KEY=sk-your-key-here
supabase secrets set AWS_BUCKET=your-bucket-name
supabase secrets set AWS_REGION=us-east-1
supabase secrets set CLOUDFRONT_DOMAIN=d123.cloudfront.net

4. AWS S3 + CloudFront Setup

For media storage:

  1. Create S3 Bucket

    • Enable private ACLs and block public access
    • Note the bucket name and region
  2. Create CloudFront Distribution (optional but recommended)

    • Point to your S3 bucket
    • Note the distribution domain (e.g., d123.cloudfront.net)
  3. Configure IAM Credentials

    • Create IAM user with S3 write permissions
    • Generate access keys
    • Store in Edge Function environment variables
  4. Update Edge Function Config

    supabase secrets set AWS_ACCESS_KEY_ID=your-access-key
    supabase secrets set AWS_SECRET_ACCESS_KEY=your-secret-key

5. APNs Push Notifications

For production push notifications:

  1. Generate APNs key in Apple Developer Console
  2. Upload key to Supabase (or configure in Edge Function)
  3. Device tokens automatically register via app's built-in flow
  4. Stored at users/{userId}/pushTokens/{token} in realtime_documents

πŸ“ Project Structure

message-ai/
β”œβ”€β”€ MessageAI/                          # Main iOS app directory
β”‚   β”œβ”€β”€ MessageAIApp.swift              # App entry point, Supabase + SwiftData init
β”‚   β”œβ”€β”€ MainAppView.swift               # Root view with auth state management
β”‚   β”‚
β”‚   β”œβ”€β”€ Models/                         # Data models
β”‚   β”‚   β”œβ”€β”€ User.swift                  # User model with online presence
β”‚   β”‚   β”œβ”€β”€ Conversation.swift          # Conversation (direct/group)
β”‚   β”‚   β”œβ”€β”€ LocalMessage.swift          # SwiftData message persistence
β”‚   β”‚   β”œβ”€β”€ LocalConversation.swift     # SwiftData conversation cache
β”‚   β”‚   └── TypingStatus.swift          # Typing indicator state
β”‚   β”‚
β”‚   β”œβ”€β”€ Views/                          # SwiftUI screens
β”‚   β”‚   β”œβ”€β”€ Auth/                       # Authentication screens
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginView.swift         # Email/password login
β”‚   β”‚   β”‚   └── SignUpView.swift        # User registration
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Chat/                       # AI Assistant interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ MoChainChatView.swift   # MoChain AI chat
β”‚   β”‚   β”‚   └── MushLiftsChatView.swift # MushLifts wellness chat
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ ChatList/                   # Conversation list screens
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatListView.swift      # Main conversations list
β”‚   β”‚   β”‚   β”œβ”€β”€ ConversationRow.swift   # Conversation cell UI
β”‚   β”‚   β”‚   β”œβ”€β”€ NewChatView.swift       # Start direct chat
β”‚   β”‚   β”‚   β”œβ”€β”€ NewGroupView.swift      # Create group chat
β”‚   β”‚   β”‚   β”œβ”€β”€ MoChainCard.swift       # MoChain entry point card
β”‚   β”‚   β”‚   β”œβ”€β”€ MushLiftsCard.swift     # MushLifts entry point card
β”‚   β”‚   β”‚   └── AIConfigBanner.swift    # AI setup prompt
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Conversation/               # Message detail screens
β”‚   β”‚   β”‚   β”œβ”€β”€ ConversationDetailView.swift  # Message thread view
β”‚   β”‚   β”‚   β”œβ”€β”€ GroupDetailsView.swift        # Group settings
β”‚   β”‚   β”‚   β”œβ”€β”€ GroupInfoView.swift           # Group info sheet
β”‚   β”‚   β”‚   └── OpenAISettingsView.swift      # Configure AI API keys
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Profile/                    # User profile screens
β”‚   β”‚   β”‚   β”œβ”€β”€ UserProfileView.swift   # View user profile
β”‚   β”‚   β”‚   └── EditProfileView.swift   # Edit own profile
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Settings/                   # App settings
β”‚   β”‚   β”‚   └── InferenceSettingsView.swift   # AI inference config
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Debug/                      # Development tools
β”‚   β”‚   β”‚   β”œβ”€β”€ ConversationDebugView.swift   # Message debugging
β”‚   β”‚   β”‚   β”œβ”€β”€ UserDiagnosticView.swift      # User data inspection
β”‚   β”‚   β”‚   β”œβ”€β”€ StateInspectorView.swift      # App state viewer
β”‚   β”‚   β”‚   β”œβ”€β”€ DatabaseExplorerView.swift    # DB browser
β”‚   β”‚   β”‚   └── TestDataDebugView.swift       # Test data management
β”‚   β”‚   β”‚
β”‚   β”‚   └── Components/                 # Reusable view components
β”‚   β”‚       β”œβ”€β”€ AIInsightsView.swift    # AI results display
β”‚   β”‚       β”œβ”€β”€ MessageActionsSheet.swift     # Message context menu
β”‚   β”‚       β”œβ”€β”€ TypingIndicatorView.swift     # Typing animation
β”‚   β”‚       β”œβ”€β”€ ForwardMessageView.swift      # Message forwarding
β”‚   β”‚       └── ReactionPickerView.swift      # Message reactions
β”‚   β”‚
β”‚   β”œβ”€β”€ Components/                     # Standalone UI components
β”‚   β”‚   β”œβ”€β”€ AIBottomBar.swift           # AI actions toolbar
β”‚   β”‚   β”œβ”€β”€ MessageBubbleShape.swift    # Custom bubble shape
β”‚   β”‚   β”œβ”€β”€ AIResultCard.swift          # AI insight card
β”‚   β”‚   β”œβ”€β”€ InAppNotificationBanner.swift     # Notification banner
β”‚   β”‚   β”œβ”€β”€ OfflineBanner.swift         # Offline indicator
β”‚   β”‚   β”œβ”€β”€ AudioMessageView.swift      # Voice message player
β”‚   β”‚   β”œβ”€β”€ VideoMessageView.swift      # Video player
β”‚   β”‚   β”œβ”€β”€ ImageMessageView.swift      # Image viewer
β”‚   β”‚   β”œβ”€β”€ VoiceRecordingView.swift    # Voice recorder UI
β”‚   β”‚   β”œβ”€β”€ PinnedMessagesView.swift    # Pinned messages sheet
β”‚   β”‚   β”œβ”€β”€ AnimatedTypingIndicator.swift     # Typing dots
β”‚   β”‚   β”œβ”€β”€ SelectableMessageText.swift       # Text selection
β”‚   β”‚   └── SkeletonView.swift          # Loading placeholders
β”‚   β”‚
β”‚   β”œβ”€β”€ Services/                       # Business logic layer
β”‚   β”‚   β”œβ”€β”€ AuthService.swift           # Authentication
β”‚   β”‚   β”œβ”€β”€ AuthService+ServiceProtocol.swift
β”‚   β”‚   β”œβ”€β”€ ChatService.swift           # Core messaging orchestration
β”‚   β”‚   β”œβ”€β”€ ChatService+Conversations.swift   # Conversation CRUD
β”‚   β”‚   β”œβ”€β”€ ChatService+Messages.swift        # Message CRUD
β”‚   β”‚   β”œβ”€β”€ ChatService+Sending.swift         # Message sending logic
β”‚   β”‚   β”œβ”€β”€ ChatService+MessageActions.swift  # Delete, pin, etc.
β”‚   β”‚   β”œβ”€β”€ ChatService+Groups.swift          # Group management
β”‚   β”‚   β”œβ”€β”€ ChatService+Users.swift           # User lookups
β”‚   β”‚   β”œβ”€β”€ ChatService+Media.swift           # Media handling
β”‚   β”‚   β”œβ”€β”€ ChatService+Notifications.swift   # In-app notifications
β”‚   β”‚   β”œβ”€β”€ ChatService+ServiceProtocol.swift
β”‚   β”‚   β”œβ”€β”€ PresenceService.swift       # Online status + typing
β”‚   β”‚   β”œβ”€β”€ PresenceService+ServiceProtocol.swift
β”‚   β”‚   β”œβ”€β”€ SyncService.swift           # Offline sync coordination
β”‚   β”‚   β”œβ”€β”€ SyncService+ServiceProtocol.swift
β”‚   β”‚   β”œβ”€β”€ SyncMonitor.swift           # Sync health monitoring
β”‚   β”‚   β”œβ”€β”€ LocalStorageService.swift   # SwiftData persistence
β”‚   β”‚   β”œβ”€β”€ LocalStorageService+ServiceProtocol.swift
β”‚   β”‚   β”œβ”€β”€ MediaService.swift          # S3 media uploads
β”‚   β”‚   β”œβ”€β”€ AIService.swift             # AI features coordinator
β”‚   β”‚   β”œβ”€β”€ InferenceManager.swift      # Multi-provider AI inference
β”‚   β”‚   β”œβ”€β”€ CoreMLInferenceProvider.swift     # On-device inference
β”‚   β”‚   β”œβ”€β”€ FoundationModelsInferenceProvider.swift  # Apple Intelligence
β”‚   β”‚   β”œβ”€β”€ ServerInferenceProvider.swift     # Edge Function calls
β”‚   β”‚   β”œβ”€β”€ NotificationService.swift   # In-app notification manager
β”‚   β”‚   β”œβ”€β”€ PushNotificationService.swift     # APNs registration
β”‚   β”‚   β”œβ”€β”€ NetworkMonitor.swift        # Connectivity monitoring
β”‚   β”‚   β”œβ”€β”€ NetworkMonitor+ServiceProtocol.swift
β”‚   β”‚   β”œβ”€β”€ CacheManager.swift          # NSCache for users/convos
β”‚   β”‚   β”œβ”€β”€ RateLimiter.swift           # API rate limiting
β”‚   β”‚   β”œβ”€β”€ HealthCheckService.swift    # Service health monitoring
β”‚   β”‚   β”œβ”€β”€ ErrorRecoveryService.swift  # Auto-recovery logic
β”‚   β”‚   β”œβ”€β”€ PerformanceMonitor.swift    # Performance tracking
β”‚   β”‚   β”œβ”€β”€ LoggingService.swift        # Centralized logging
β”‚   β”‚   β”œβ”€β”€ DatabaseOperationTracer.swift     # DB query tracing
β”‚   β”‚   β”œβ”€β”€ AudioService.swift          # Audio recording/playback
β”‚   β”‚   β”œβ”€β”€ AppConfig.swift             # App configuration
β”‚   β”‚   β”œβ”€β”€ ServiceProtocol.swift       # Service lifecycle protocol
β”‚   β”‚   β”‚
β”‚   β”‚   └── Supabase/                   # Supabase integration
β”‚   β”‚       β”œβ”€β”€ SupabaseAuthClient.swift      # Auth REST wrapper
β”‚   β”‚       β”œβ”€β”€ SupabaseRealtimeDatabase.swift # Realtime DB w/ polling
β”‚   β”‚       └── SupabaseConfiguration.swift   # Config validation
β”‚   β”‚
β”‚   β”œβ”€β”€ Theme/                          # Design system tokens
β”‚   β”‚   β”œβ”€β”€ Colors.swift                # Color palette
β”‚   β”‚   β”œβ”€β”€ Typography.swift            # Font styles
β”‚   β”‚   β”œβ”€β”€ Shadows.swift               # Shadow presets
β”‚   β”‚   └── Spacing.swift               # Spacing constants
β”‚   β”‚
β”‚   β”œβ”€β”€ Utilities/                      # Helper utilities
β”‚   β”‚   β”œβ”€β”€ ValidationUtility.swift     # Input validation
β”‚   β”‚   └── TestDataSeeder.swift        # Test data generation
β”‚   β”‚
β”‚   └── AppDelegate.swift               # AppDelegate for APNs
β”‚
β”œβ”€β”€ supabase/                           # Backend infrastructure
β”‚   └── functions/                      # Edge Functions (Deno)
β”‚       β”œβ”€β”€ mochain/                    # MoChain AI agent
β”‚       β”‚   └── index.ts                # GPT-4 streaming chat
β”‚       β”œβ”€β”€ mushlifts/                  # MushLifts AI agent
β”‚       β”‚   └── index.ts                # Fitness/wellness AI
β”‚       β”œβ”€β”€ generate-upload-url/        # Media upload handler
β”‚       β”‚   └── index.ts                # S3 presigned URL generation
β”‚       β”œβ”€β”€ send-notification/          # Push notifications
β”‚       β”‚   β”œβ”€β”€ index.ts                # APNs dispatcher
β”‚       β”‚   └── apns.ts                 # APNs client
β”‚       β”œβ”€β”€ aiSummarize/                # Thread summarization
β”‚       β”‚   └── index.ts                # Conversation summarizer
β”‚       └── summarizeText/              # Generic text summary
β”‚           └── index.ts                # Text summarization
β”‚
β”œβ”€β”€ scripts/                            # Development scripts
β”‚   β”œβ”€β”€ setup-supabase.sh               # Automated Supabase local setup
β”‚   β”œβ”€β”€ start-backend.sh                # Start all edge functions locally
β”‚   β”œβ”€β”€ start-ai-agents.sh              # Start AI agent servers
β”‚   β”œβ”€β”€ stop-agents.sh                  # Stop AI agent servers
β”‚   └── .env-setup.sh                   # Environment configuration
β”‚
β”œβ”€β”€ MessageAI.xcodeproj/                # Xcode project
β”œβ”€β”€ Config.xcconfig                     # App configuration (git-ignored)
β”œβ”€β”€ Config.example.xcconfig             # Configuration template
β”œβ”€β”€ Info.plist                          # App info and permissions
β”œβ”€β”€ Info.plist.example                  # Info.plist template
β”œβ”€β”€ MessageAI.entitlements              # App capabilities
└── README.md                           # This file

πŸ—„ Database Architecture

MessageAI uses a dual-database architecture for privacy and performance:

Global Database (Shared)

Stores all conversations and messages accessible to participants:

realtime_documents.data:
{
  "conversations": {
    "{conversationId}": {
      "type": "direct" | "group",
      "name": "Group Name",  // only for groups
      "avatarUrl": "https://...",  // optional group avatar
      "participantIds": ["user1", "user2", ...],
      "participantMap": { "user1": true, "user2": true },
      "createdAt": "2024-01-01T00:00:00Z",
      "lastMessageAt": "2024-01-01T12:34:56Z",
      "messages": {
        "{messageId}": {
          "senderId": "user1",
          "text": "Hello world",
          "createdAt": "2024-01-01T12:34:56Z",
          "type": "text" | "image" | "video" | "audio",
          "mediaUrl": "https://...",  // for media messages
          "deliveredTo": ["user2"],
          "readBy": ["user2"],
          "deletedForEveryone": true,  // if sender deleted for all
          "isPinned": true  // optional
        }
      }
    }
  },
  "users": {
    "{userId}": {
      "profile": {
        "displayName": "John Doe",
        "email": "john@example.com",
        "avatarUrl": "https://...",
        "createdAt": "2024-01-01T00:00:00Z"
      },
      "presence": {
        "isOnline": true,
        "lastSeen": "2024-01-01T12:34:56Z"
      },
      "typing": {
        "{conversationId}": {
          "isTyping": true,
          "timestamp": "2024-01-01T12:34:56Z"
        }
      }
    }
  }
}

Per-User Database (Private)

Personal deletions and preferences invisible to other users:

realtime_documents.data:
{
  "users": {
    "{userId}": {
      "deletedMessages": {
        "{conversationId}": {
          "{messageId}": true  // marked as deleted for this user
        }
      },
      "pushTokens": {
        "{token}": {
          "createdAt": "2024-01-01T00:00:00Z",
          "deviceName": "iPhone 15 Pro"
        }
      }
    }
  }
}

Key Design Patterns

  • Lazy Creation: Conversations created in DB only when first message is sent
  • Delete for Me: Adds messageId to users/{userId}/deletedMessages (private)
  • Delete for Everyone: Sets deletedForEveryone: true on message (global)
  • Clear Chat: Bulk adds all message IDs to user's deletedMessages
  • Server-Side Filtering: Messages filtered during fetch based on deletion lists
  • ISO8601 Timestamps: All dates use ISO8601 strings for consistency
  • Participant Map: Enables efficient WHERE participantMap ? :userId queries

πŸ§ͺ Development Tools

Debug Views

Access via ChatListView menu:

  • State Inspector - View app-wide state in real-time
  • Database Explorer - Browse Supabase documents
  • Conversation Debug - Inspect message metadata
  • User Diagnostic - View user data and presence
  • Test Data Debug - Seed conversations for testing
  • Performance Monitor - Track app performance metrics

Test Data Seeding

Use TestDataSeeder to generate realistic test data:

// In TestDataDebugView
let seeder = TestDataSeeder(userId: currentUserId)
await seeder.seedConversations(count: 10)
await seeder.seedMessages(conversationId: id, count: 50)

Scripts

# Start local Supabase
./scripts/setup-supabase.sh

# Start edge functions locally (requires Deno)
./scripts/start-backend.sh

# Start AI agents
./scripts/start-ai-agents.sh

# Stop AI agents
./scripts/stop-agents.sh

πŸ”§ Configuration Files

Config.xcconfig

Main app configuration (copy from Config.example.xcconfig):

SUPABASE_URL = https://your-project.supabase.co
SUPABASE_ANON_KEY = your-anon-key
SUPABASE_FUNCTIONS_URL = https://your-project.functions.supabase.co
S3_UPLOAD_ENDPOINT = $(SUPABASE_FUNCTIONS_URL)/generate-upload-url
MOCHAIN_CHAT_ENDPOINT = $(SUPABASE_FUNCTIONS_URL)/mochain
MUSHLIFTS_CHAT_ENDPOINT = $(SUPABASE_FUNCTIONS_URL)/mushlifts

Info.plist

Runtime configuration (copy from Info.plist.example):

<key>SUPABASE_URL</key>
<string>http://127.0.0.1:54321</string>  <!-- Local dev -->

<key>SUPABASE_ANON_KEY</key>
<string>your-local-anon-key</string>

<!-- AI Endpoints -->
<key>MOCHAIN_CHAT_ENDPOINT</key>
<string>http://127.0.0.1:54321/functions/v1/mochain</string>

<key>MUSHLIFTS_CHAT_ENDPOINT</key>
<string>http://127.0.0.1:54321/functions/v1/mushlifts</string>

<!-- Media -->
<key>S3_UPLOAD_ENDPOINT</key>
<string>http://127.0.0.1:54321/functions/v1/generate-upload-url</string>

πŸ“± Features Deep Dive

AI Bottom Bar

Glassmorphic toolbar with 5 AI actions available in conversations:

  1. Summarize ✨ - Generate thread summary
  2. Actions βœ… - Extract action items with owners
  3. Decisions πŸ† - Find agreed-upon decisions
  4. Search πŸ” - Semantic search within conversation
  5. Translate 🌐 - On-device message translation

Implemented in AIBottomBar.swift

Message Status System

WhatsApp-style delivery receipts:

  • βœ“ (Gray) - Sent to server
  • βœ“βœ“ (Gray) - Delivered to recipient device
  • πŸ”΅βœ“βœ“ (Blue) - Read by recipient

Managed by ChatService+Messages.swift with real-time updates via observers.

Presence System

Real-time online/offline status:

  • Heartbeat: 60-second intervals update users/{userId}/presence/isOnline
  • Last Seen: Displays "last seen X ago" when offline
  • Typing Indicators: Real-time typing status per conversation
  • Auto-Cleanup: Observer pattern ensures presence updates stop when view dismissed

Implemented in PresenceService.swift

Offline Support

Comprehensive offline-first architecture:

  1. SwiftData Persistence - All messages/conversations cached locally
  2. Optimistic UI - Messages appear instantly, sync in background
  3. Network Monitor - Detects connectivity changes, shows offline banner
  4. SyncService - Queues operations, auto-syncs when online
  5. Conflict Resolution - Server timestamp wins on conflicts

See SyncService.swift and NetworkMonitor.swift

🎨 Theme System

Centralized design tokens in MessageAI/Theme/:

// Colors.swift - Semantic color system
Color.brandBlue
Color.aiActionPurple
Color.textPrimary
Color.backgroundPrimary

// Typography.swift - Text styles
Font.headline
Font.bodyText
Font.caption

// Shadows.swift - Shadow presets
View().shadow(.card)
View().shadow(.elevated)

// Spacing.swift - Consistent spacing
Spacing.xs   // 4pt
Spacing.sm   // 8pt
Spacing.md   // 16pt
Spacing.lg   // 24pt

🚒 Deployment Checklist

Pre-Launch

  • Update Config.xcconfig with production Supabase credentials
  • Update Info.plist with production endpoints
  • Deploy all Edge Functions to Supabase
  • Set up AWS S3 bucket and CloudFront distribution
  • Configure APNs certificates and upload to Supabase
  • Set OPENAI_API_KEY secret in Supabase
  • Test AI features with production API keys
  • Enable Supabase RLS policies on all tables
  • Test on physical device with production backend
  • Remove debug views from production builds
  • Update app version and build number

Post-Launch

  • Monitor Supabase usage and costs
  • Monitor OpenAI API usage
  • Monitor S3/CloudFront bandwidth
  • Set up error tracking (Sentry, etc.)
  • Monitor APNs delivery rates
  • Review performance metrics
  • Gather user feedback on AI accuracy

🀝 Contributing

This is a reference implementation showcasing modern iOS + Supabase architecture with AI integration. Feel free to:

  • Fork and customize for your use case
  • Report issues or suggest improvements
  • Use as learning material for SwiftUI + Supabase
  • Extend with additional AI features

πŸ“„ License

See LICENSE file for details.

πŸ™ Acknowledgments


MessageAI - Intelligent messaging for distributed teams. Built with ❀️ using SwiftUI and Supabase.

About

ReviewLens AI is a secure, web-based platform designed to help businesses extract actionable insights from large volumes of customer reviews. The system ingests publicly available reviews from platforms such as Amazon or Google Maps and enables users to interact with the data through a guardrailed AI-powered Q&A interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors