-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShared-Document.txt
More file actions
295 lines (210 loc) · 9.11 KB
/
Copy pathShared-Document.txt
File metadata and controls
295 lines (210 loc) · 9.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
Shared Document: Ruby App Development
1. Modules Overview
Module List
1. UserDataStorageModule
• Purpose: Handles all user data operations, including storing, retrieving, and updating user profiles, conversation histories, and preferences.
• Note: For data categorization details, refer to the Data Categorization Document if needed.
2. ChatInterfaceModule
• Purpose: Provides the user interface for the chat functionality, including displaying messages and handling user input.
3. AIIntegrationModule
• Purpose: Manages communication with the GPT-4o API, including sending prompts and receiving responses.
• Note: This module may require data categorization details from the Data Categorization Document.
4. NotificationModule
• Purpose: Handles scheduling and sending of proactive messages and notifications to the user.
• Note: Refer to the Data Categorization Document if this module needs to process data categories for notifications.
5. ModuleMarketplaceModule
• Purpose: Implements the marketplace where users can browse, purchase, and manage expert modules.
6. UserContentIntegrationModule
• Purpose: Allows users to upload personal content (e.g., images, text) to enhance Ruby’s knowledge base.
7. AuthenticationModule
• Purpose: Manages user authentication, registration, and security features.
8. SettingsAndPreferencesModule
• Purpose: Enables users to manage their settings, preferences, and purchased modules.
2. Data Models and Structures
2.1. Data Entities
A. UserProfile
• Description: Stores user-specific information and preferences.
• Attributes:
• userId: String
• name: String
• email: String
• preferences: [String]
• modulesPurchased: [ModulePurchase]
• importantPeople: [Person]
• upcomingEvents: [Event]
B. ConversationHistory
• Description: Stores the conversation between the user and Ruby.
• Attributes:
• userId: String
• messages: [Message]
C. Message
• Description: Represents a single message in a conversation.
• Attributes:
• sender: String (e.g., “user” or “Ruby”)
• timestamp: Date
• content: String
• messageId: String
• Note: For data categorization attributes, refer to the Data Categorization Document if required.
D. ModulePurchase
• Description: Represents a module purchased by the user.
• Attributes:
• moduleId: String
• purchaseDate: Date
• isActive: Bool
E. Module
• Description: Represents an expert module available in the marketplace.
• Attributes:
• moduleId: String
• title: String
• description: String
• price: Decimal
• content: String
• author: String
• version: String
F. Person
• Description: Represents a person important to the user.
• Attributes:
• name: String
• relationship: String (e.g., “friend”, “sister”)
• notes: String (optional)
G. Event
• Description: Represents an event relevant to the user.
• Attributes:
• name: String
• date: Date
• time: Date (if applicable)
• location: String (optional)
• notes: String (optional)
3. APIs and Interfaces
3.1. UserDataStorageModule
• Functions:
• func saveUserProfile(profile: UserProfile)
• func getUserProfile(userId: String) -> UserProfile?
• func updateUserProfile(profile: UserProfile)
• func deleteUserProfile(userId: String)
• Conversation History:
• func saveConversation(history: ConversationHistory)
• func getConversation(userId: String) -> ConversationHistory?
• func appendMessage(userId: String, message: Message)
• Note: For handling data categories in messages, refer to the Data Categorization Document.
3.2. ChatInterfaceModule
• Functions:
• func displayMessage(message: Message)
• func sendMessage(content: String)
• delegate func onMessageSent(message: Message)
3.3. AIIntegrationModule
• Functions:
• func sendPrompt(prompt: String, context: [Message], completion: @escaping (String) -> Void)
• func handleResponse(response: String)
• Dependencies:
• Network manager for API calls.
• Authentication tokens for GPT-4o API.
• Note: If integrating data categories into prompts, see the Data Categorization Document.
3.4. NotificationModule
• Functions:
• func scheduleNotification(notification: NotificationItem)
• func cancelNotification(notificationId: String)
• func handleNotificationAction(action: NotificationAction)
3.5. ModuleMarketplaceModule
• Functions:
• func fetchAvailableModules() -> [Module]
• func purchaseModule(moduleId: String, completion: @escaping (Bool) -> Void)
• func getPurchasedModules(userId: String) -> [Module]
3.6. UserContentIntegrationModule
• Functions:
• func uploadUserContent(content: UserContent)
• func getUserContent(userId: String) -> [UserContent]
3.7. AuthenticationModule
• Functions:
• func registerUser(email: String, password: String, completion: @escaping (Bool, Error?) -> Void)
• func loginUser(email: String, password: String, completion: @escaping (Bool, Error?) -> Void)
• func logoutUser()
3.8. SettingsAndPreferencesModule
• Functions:
• func updatePreferences(userId: String, preferences: [String])
• func getPreferences(userId: String) -> [String]
4. Naming Conventions
4.1. Files and Classes
• Use UpperCamelCase for class names and structs.
• Example: UserProfile, ConversationHistory
• File names should match the class or struct they contain.
• Example: UserProfile.swift, AIIntegrationModule.swift
4.2. Functions and Methods
• Use lowerCamelCase for function and method names.
• Example: saveUserProfile(), sendMessage()
4.3. Variables and Constants
• Use lowerCamelCase for variable and constant names.
• Example: userId, messageContent
• Constants should be prefixed with k if desired.
• Example: let kMaxMessageLength = 500
4.4. Protocols and Delegates
• Protocol names should end with Delegate or Protocol.
• Example: ChatInterfaceDelegate
4.5. Comments and Documentation
• Use /// for documentation comments.
• Provide clear and concise explanations for functions and classes.
5. Dependencies and Libraries
5.1. iOS Development
• Language: Swift
• Minimum iOS Version: iOS 14.0
5.2. Storage
• Local Storage: Core Data for persistent local storage.
5.3. Networking
• Library: URLSession for network calls.
• Alternative: Alamofire for simplified networking (optional).
5.4. User Interface
• Frameworks:
• UIKit (or SwiftUI if preferred)
• Chat UI: MessageKit library for chat interfaces.
5.5. Notifications
• Framework: UserNotifications for handling local and push notifications.
5.6. Authentication
• Service: Firebase Authentication (optional)
• Alternative: Custom authentication backend.
5.7. Image Processing (for User Content Integration)
• Library: Vision framework for OCR (if needed).
• Alternative: Tesseract OCR library.
5.8. AI Integration
• API: OpenAI GPT-4o API.
• Requirements:
• Secure API key management.
• Compliance with OpenAI’s usage policies.
6. Data Flow and Integration Points
6.1. User Registration and Authentication
• Flow:
1. User registers or logs in via the AuthenticationModule.
2. Upon successful authentication, the UserDataStorageModule retrieves the user’s profile and preferences.
6.2. Chat Functionality
• Flow:
1. User inputs a message via the ChatInterfaceModule.
2. Message is saved using the UserDataStorageModule.
3. AIIntegrationModule sends the message and relevant context to the GPT-4o API.
4. The response is received and displayed using the ChatInterfaceModule.
5. ConversationHistory is updated accordingly.
• Note: If data categorization is required, refer to the Data Categorization Document.
6.3. Proactive Messaging and Notifications
• Flow:
1. Based on user data and scheduled events, the NotificationModule schedules notifications.
2. Notifications trigger the app to send proactive messages via the ChatInterfaceModule.
• Note: For data-driven notifications, see the Data Categorization Document.
6.4. Module Marketplace
• Flow:
1. User browses modules using the ModuleMarketplaceModule.
2. Purchases are processed, and the UserDataStorageModule updates the user’s purchased modules.
3. Purchased modules influence AI responses via the AIIntegrationModule.
7. Additional Considerations
7.1. API Key Management
• Security: API keys for services like OpenAI should be stored securely and not hard-coded into the app.
• Best Practice: Use a secure backend server to manage API requests if possible.
7.2. Error Handling
• Implement comprehensive error handling and user feedback mechanisms across all modules.
7.3. Accessibility
• Ensure that the app complies with accessibility standards for all users.
7.4. Internationalization
• Plan for supporting multiple languages if targeting a global audience.
8. How to Use This Document
• For Modules Not Requiring Data Categorization:
• Use this document as is for development.
• For Modules Requiring Data Categorization:
• Refer to the separate Data Categorization Document for detailed data structures, APIs, and implementation guidelines.
End of Updated Shared Document