How renset/macai works
macai is a native macOS AI chat client. Users configure an API service and persona, compose a message (optionally with attachments), send it through the chat workflow to an AI provider, and view the response in the conversation. Chats and settings are persisted locally, with optional iCloud sync; preferences also expose service, persona, backup/restore, and general settings. The source index supports the central UI, message, persistence, and attachment relationships below; some capability links are documented in the README, while unsampled implementation details are left unconnected.
Main entry points: macaiApp.swift App shell · ChatLogicHandler.swift Chat actions · ChatStore.swift Chat persistence · PreferencesView.swift Preferences
Components 24
Chat workflow
- App shell
macai/macaiApp.swift - Main content
macai/UI/ContentView.swift - Chat interface
macai/UI/Chat/ChatView.swift - Chat actions
macai/UI/Chat/ChatLogicHandler.swift - Chat view model
macai/UI/Chat/ChatViewModel.swift - Message handling
macai/Utilities/MessageManager.swift - Message content
macai/Models/MessageContent.swift - Attachment parsing
macai/Utilities/AttachmentParser.swift - Chat list
macai/UI/ChatList/ChatListView.swift
AI services
- AI providers
macai/Utilities/APIHandlers - Provider factory
macai/Utilities/APIHandlers/APIServiceFactory.swift
Data and sync
- Chat persistence
macai/Store/ChatStore.swift - Database patching
macai/Utilities/DatabasePatcher.swift - Legacy migration
macai/Store/V1ToV3Migration.swift - iCloud sync
macai/Utilities/CloudSyncManager.swift - Attachment models
macai/Models/DocumentAttachment.swift
Preferences
- Preferences
macai/UI/Preferences/PreferencesView.swift - API service settings
macai/UI/Preferences/TabAPIServicesView.swift - AI personas
macai/UI/Preferences/TabAIPersonasView.swift - Backup and restore
macai/UI/Preferences/TabBackupRestoreView.swift - Token storage
macai/Utilities/TokenManager.swift
Other components
- Mac user
- AI service
- CloudKit
Connections 26
- Mac user → App shell: launches
macai/macaiApp.swift - App shell → Main content: presents
macai/macaiApp.swift - Main content → Chat interface: shows
macai/UI/ContentView.swift - Main content → Chat list: shows
macai/UI/ContentView.swift - Chat interface → Chat actions: delegates
- Chat actions → Chat view model: uses
macai/UI/Chat/ChatLogicHandler.swift - Chat view model → Message handling: uses
macai/UI/Chat/ChatViewModel.swift - Chat view model → Provider factory: creates via
macai/UI/Chat/ChatViewModel.swift - Provider factory → AI providers: selects
- AI providers → AI service: requests
- Message handling → AI service: sends messages
- Message content → Attachment parsing: parses with
macai/Models/MessageContent.swift - Message content → Attachment models: uses
macai/Models/MessageContent.swift - Chat actions → Attachment models: handles
macai/UI/Chat/ChatLogicHandler.swift - Chat actions → Chat persistence: uses
macai/UI/Chat/ChatLogicHandler.swift - Preferences → API service settings: shows
macai/UI/Preferences/PreferencesView.swift - Preferences → AI personas: shows
macai/UI/Preferences/PreferencesView.swift - Preferences → Chat persistence: uses
macai/UI/Preferences/PreferencesView.swift - API service settings → Token storage: uses
macai/UI/Preferences/TabAPIServicesView.swift - API service settings → AI providers: configures
- Backup and restore → Chat persistence: backs up
- App shell → iCloud sync: initializes
macai/macaiApp.swift - iCloud sync → CloudKit: syncs with
macai/Utilities/CloudSyncManager.swift - App shell → Database patching: initializes
macai/macaiApp.swift - Chat persistence → Token storage: deletes tokens
macai/Store/ChatStore.swift - Mac user → Backup and restore: imports or exports