ai-flow-dev 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +408 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +791 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/fs-utils.d.ts +2 -0
  8. package/dist/fs-utils.d.ts.map +1 -0
  9. package/dist/fs-utils.js +46 -0
  10. package/dist/fs-utils.js.map +1 -0
  11. package/package.json +71 -0
  12. package/prompts/backend/flow-dev-feature.md +1318 -0
  13. package/prompts/backend/flow-dev-fix.md +903 -0
  14. package/prompts/backend/flow-dev-refactor.md +715 -0
  15. package/prompts/backend/flow-dev-review.md +401 -0
  16. package/prompts/backend/flow-dev-work.md +1129 -0
  17. package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
  18. package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
  19. package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
  20. package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
  21. package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
  22. package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
  23. package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
  24. package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
  25. package/prompts/backend/flow-docs-gen.md +820 -0
  26. package/prompts/backend/flow-docs-sync.md +526 -0
  27. package/prompts/backend/flow-project-init.md +248 -0
  28. package/prompts/backend/flow-project-roadmap.md +1159 -0
  29. package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
  30. package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
  31. package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
  32. package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
  33. package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
  34. package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
  35. package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
  36. package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
  37. package/prompts/frontend/flow-docs-gen.md +413 -0
  38. package/prompts/frontend/flow-docs-sync.md +561 -0
  39. package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
  40. package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
  41. package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
  42. package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
  43. package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
  44. package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
  45. package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
  46. package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
  47. package/prompts/mobile/flow-docs-gen.md +430 -0
  48. package/prompts/mobile/flow-docs-sync.md +634 -0
  49. package/templates/backend/.clauderules.template +111 -0
  50. package/templates/backend/.cursorrules.template +102 -0
  51. package/templates/backend/.env.example.template +122 -0
  52. package/templates/backend/README.template.md +200 -0
  53. package/templates/backend/ai-instructions.template.md +354 -0
  54. package/templates/backend/copilot-instructions.template.md +160 -0
  55. package/templates/backend/docs/api.template.md +251 -0
  56. package/templates/backend/docs/architecture.template.md +612 -0
  57. package/templates/backend/docs/business-flows.template.md +109 -0
  58. package/templates/backend/docs/code-standards.template.md +828 -0
  59. package/templates/backend/docs/contributing.template.md +163 -0
  60. package/templates/backend/docs/data-model.template.md +416 -0
  61. package/templates/backend/docs/operations.template.md +591 -0
  62. package/templates/backend/docs/testing.template.md +762 -0
  63. package/templates/backend/project-brief.template.md +176 -0
  64. package/templates/backend/specs/configuration.template.md +133 -0
  65. package/templates/backend/specs/security.template.md +422 -0
  66. package/templates/frontend/README.template.md +121 -0
  67. package/templates/frontend/ai-instructions.template.md +368 -0
  68. package/templates/frontend/docs/api-integration.template.md +390 -0
  69. package/templates/frontend/docs/components.template.md +567 -0
  70. package/templates/frontend/docs/error-handling.template.md +385 -0
  71. package/templates/frontend/docs/operations.template.md +123 -0
  72. package/templates/frontend/docs/performance.template.md +140 -0
  73. package/templates/frontend/docs/pwa.template.md +135 -0
  74. package/templates/frontend/docs/state-management.template.md +394 -0
  75. package/templates/frontend/docs/styling.template.md +779 -0
  76. package/templates/frontend/docs/testing.template.md +736 -0
  77. package/templates/frontend/project-brief.template.md +55 -0
  78. package/templates/frontend/specs/accessibility.template.md +111 -0
  79. package/templates/frontend/specs/configuration.template.md +520 -0
  80. package/templates/frontend/specs/security.template.md +197 -0
  81. package/templates/fullstack/README.template.md +282 -0
  82. package/templates/fullstack/ai-instructions.template.md +487 -0
  83. package/templates/fullstack/project-brief.template.md +197 -0
  84. package/templates/fullstack/specs/configuration.template.md +380 -0
  85. package/templates/mobile/AGENT.template.md +251 -0
  86. package/templates/mobile/README.template.md +195 -0
  87. package/templates/mobile/ai-instructions.template.md +221 -0
  88. package/templates/mobile/docs/app-store.template.md +163 -0
  89. package/templates/mobile/docs/architecture.template.md +100 -0
  90. package/templates/mobile/docs/native-features.template.md +137 -0
  91. package/templates/mobile/docs/navigation.template.md +81 -0
  92. package/templates/mobile/docs/offline-strategy.template.md +90 -0
  93. package/templates/mobile/docs/permissions.template.md +70 -0
  94. package/templates/mobile/docs/state-management.template.md +116 -0
  95. package/templates/mobile/docs/testing.template.md +146 -0
  96. package/templates/mobile/project-brief.template.md +97 -0
  97. package/templates/mobile/specs/build-configuration.template.md +116 -0
  98. package/templates/mobile/specs/deployment.template.md +114 -0
  99. package/templates/shared/AGENT.template.md +252 -0
@@ -0,0 +1,659 @@
1
+ # Phase 3: State & Data Management
2
+
3
+ **Duration:** 20-25 minutes
4
+ **Questions:** ~13 questions
5
+ **Output:** docs/state-management.md, docs/offline-strategy.md, parts of ai-instructions.md
6
+
7
+ ---
8
+
9
+ ## 🎯 Objective
10
+
11
+ Define how your mobile app will manage state and handle data:
12
+
13
+ 1. How will you manage app state?
14
+ 2. How will you fetch server data?
15
+ 3. What offline strategy will you use?
16
+ 4. How will you synchronize data?
17
+
18
+ ---
19
+
20
+ ## 📋 Questions
21
+
22
+ ### Question 3.1: App State Management
23
+
24
+ **How will you manage global app state?**
25
+
26
+ **If React Native:**
27
+ - A) ⭐ **Redux Toolkit** (Recommended)
28
+ - Predictable state management
29
+ - DevTools support
30
+ - Best for: Complex apps, large teams
31
+
32
+ - B) 🔥 **Zustand**
33
+ - Minimal boilerplate
34
+ - Simple API
35
+ - Best for: Small to medium apps
36
+
37
+ - C) **MobX**
38
+ - Observable-based
39
+ - Less boilerplate than Redux
40
+ - Best for: Rapid development
41
+
42
+ - D) **Context API + useReducer**
43
+ - Built-in React
44
+ - No dependencies
45
+ - Best for: Simple apps, MVPs
46
+
47
+ - E) **Jotai / Recoil**
48
+ - Atomic state management
49
+ - Best for: Fine-grained reactivity
50
+
51
+ **If Flutter:**
52
+ - A) ⭐ **Provider** (Recommended)
53
+ - Simple, official recommendation
54
+ - Best for: Most apps
55
+
56
+ - B) 🔥 **Riverpod**
57
+ - Type-safe, compile-time errors
58
+ - Best for: Type-safe apps
59
+
60
+ - C) **Bloc**
61
+ - Event-driven architecture
62
+ - Best for: Complex state logic
63
+
64
+ - D) **GetX**
65
+ - All-in-one solution
66
+ - Best for: Rapid development
67
+
68
+ **If Native:**
69
+ - **MVVM Pattern** with ViewModels
70
+ - **Observable Pattern** (RxSwift/RxJava)
71
+
72
+ **Your answer:**
73
+
74
+ ---
75
+
76
+ ### Question 3.2: HTTP Client Library
77
+
78
+ **What HTTP client library will you use to fetch data from your backend?**
79
+
80
+ **If React Native:**
81
+ - A) ⭐ **Axios** (Recommended)
82
+ - Promise-based HTTP client
83
+ - Interceptors, automatic JSON parsing
84
+ - Best for: Most React Native apps
85
+
86
+ - B) **Fetch API**
87
+ - Built-in browser API
88
+ - No dependencies
89
+ - Best for: Simple apps
90
+
91
+ - C) **React Query / TanStack Query**
92
+ - Data fetching with caching
93
+ - Automatic refetching
94
+ - Best for: Complex data needs
95
+
96
+ **If Flutter:**
97
+ - A) ⭐ **Dio** (Recommended)
98
+ - Powerful HTTP client
99
+ - Interceptors, form data
100
+ - Best for: Most Flutter apps
101
+
102
+ - B) **http package**
103
+ - Simple HTTP client
104
+ - Built-in Flutter package
105
+ - Best for: Simple apps
106
+
107
+ **If Native iOS:**
108
+ - A) ⭐ **URLSession** (Built-in)
109
+ - B) **Alamofire**
110
+ - Popular third-party library
111
+
112
+ **If Native Android:**
113
+ - A) ⭐ **OkHttp** (Recommended)
114
+ - B) **Retrofit**
115
+ - Type-safe HTTP client
116
+
117
+ **Your answer:**
118
+
119
+ **If using REST API, ask:**
120
+ - What API base URL structure?
121
+ - Single base URL
122
+ - Multiple endpoints
123
+ - Environment-based URLs (dev/staging/prod)
124
+
125
+ **If using GraphQL, ask:**
126
+ - What GraphQL client?
127
+ - React Native: Apollo Client, urql
128
+ - Flutter: graphql_flutter, ferry
129
+ - What GraphQL endpoint URL?
130
+
131
+ ---
132
+
133
+ ### Question 3.3: Offline Strategy
134
+
135
+ **How will your app work offline?**
136
+
137
+ A) ⭐ **Read-Only Offline** (Recommended)
138
+ - Cache data for reading
139
+ - Show cached data when offline
140
+ - Queue writes for when online
141
+ - Best for: Most apps
142
+
143
+ B) **Full Offline Support**
144
+ - Complete CRUD offline
145
+ - Sync when online
146
+ - Best for: Productivity apps, note-taking
147
+
148
+ C) **No Offline Support**
149
+ - Require internet connection
150
+ - Show error when offline
151
+ - Best for: Real-time apps, streaming
152
+
153
+ **Your answer:**
154
+
155
+ ---
156
+
157
+ ### Question 3.4: Local Storage Solution
158
+
159
+ **What will you use for local data storage?**
160
+
161
+ **If React Native:**
162
+ - A) ⭐ **AsyncStorage** (Recommended)
163
+ - Simple key-value storage
164
+ - Best for: Small data, settings
165
+
166
+ - B) **MMKV**
167
+ - Faster than AsyncStorage
168
+ - Best for: Performance-critical storage
169
+
170
+ - C) **WatermelonDB**
171
+ - SQLite-based, reactive
172
+ - Best for: Complex relational data
173
+
174
+ - D) **Realm**
175
+ - Object database
176
+ - Best for: Complex data models
177
+
178
+ **If Flutter:**
179
+ - A) ⭐ **SharedPreferences** (Simple data)
180
+ - B) **Hive** (Fast, NoSQL)
181
+ - C) **Isar** (Fast, NoSQL)
182
+ - D) **SQLite (sqflite)** (Relational data)
183
+
184
+ **If Native iOS:**
185
+ - A) **UserDefaults** (Simple data)
186
+ - B) **Core Data** (Complex relational data)
187
+ - C) **Realm** (Object database)
188
+
189
+ **If Native Android:**
190
+ - A) **SharedPreferences** (Simple data)
191
+ - B) **Room** (SQLite abstraction)
192
+ - C) **DataStore** (Modern, type-safe)
193
+
194
+ **Your answer:**
195
+
196
+ ---
197
+
198
+ ### Question 3.5: Data Synchronization
199
+
200
+ **How will you sync data between local and server?**
201
+
202
+ A) ⭐ **Optimistic Updates + Background Sync** (Recommended)
203
+ - Update UI immediately
204
+ - Sync in background
205
+ - Handle conflicts gracefully
206
+ - Best for: Most apps
207
+
208
+ B) **Pessimistic Updates**
209
+ - Wait for server confirmation
210
+ - Show loading states
211
+ - Best for: Critical data (payments, etc.)
212
+
213
+ C) **Manual Sync**
214
+ - User-triggered sync
215
+ - Pull-to-refresh pattern
216
+ - Best for: Simple apps
217
+
218
+ D) **Real-time Sync**
219
+ - WebSockets or Server-Sent Events
220
+ - Instant updates
221
+ - Best for: Collaborative apps, chat
222
+
223
+ **Your answer:**
224
+
225
+ ---
226
+
227
+ ### Question 3.6: Conflict Resolution
228
+
229
+ **How will you handle data conflicts when syncing?**
230
+
231
+ A) ⭐ **Last Write Wins** (Recommended)
232
+ - Simple, most recent update wins
233
+ - Best for: Most apps
234
+
235
+ B) **Server Wins**
236
+ - Always use server version
237
+ - Best for: Authoritative server data
238
+
239
+ C) **Merge Strategy**
240
+ - Intelligent merging
241
+ - Best for: Collaborative editing
242
+
243
+ D) **User Resolution**
244
+ - Ask user to choose
245
+ - Best for: Critical conflicts
246
+
247
+ **Your answer:**
248
+
249
+ ---
250
+
251
+ ### Question 3.7: Caching Strategy
252
+
253
+ **How will you cache API responses?**
254
+
255
+ A) ⭐ **Time-based Cache** (Recommended)
256
+ - Cache for X minutes/hours
257
+ - Refresh after expiry
258
+ - Best for: Most data
259
+
260
+ B) **Stale-While-Revalidate**
261
+ - Show cached data immediately
262
+ - Fetch fresh data in background
263
+ - Best for: Good UX
264
+
265
+ C) **Cache Forever**
266
+ - Cache until app update
267
+ - Best for: Static data
268
+
269
+ D) **No Caching**
270
+ - Always fetch fresh
271
+ - Best for: Real-time data
272
+
273
+ **Your answer:**
274
+
275
+ ---
276
+
277
+ ### Question 3.8: Form State Management
278
+
279
+ **How will you handle form state?**
280
+
281
+ **If React Native:**
282
+ - A) ⭐ **React Hook Form** (Recommended)
283
+ - Minimal re-renders
284
+ - Good performance
285
+
286
+ - B) **Formik**
287
+ - Popular, well-documented
288
+
289
+ **If Flutter:**
290
+ - A) ⭐ **FormBuilder** (Recommended)
291
+ - B) **Built-in Form widgets**
292
+
293
+ **Your answer:**
294
+
295
+ ---
296
+
297
+ ### Question 3.9: Error Handling Strategy
298
+
299
+ **How will you handle API errors?**
300
+
301
+ A) ⭐ **Centralized Error Handler** (Recommended)
302
+ - Global error handling
303
+ - Consistent error messages
304
+ - Best for: Most apps
305
+
306
+ B) **Per-Request Handling**
307
+ - Handle errors in components
308
+ - More granular control
309
+ - Best for: Complex error scenarios
310
+
311
+ C) **Error Boundary Pattern**
312
+ - Catch errors at component level
313
+ - Show fallback UI
314
+ - Best for: React Native
315
+
316
+ **Your answer:**
317
+
318
+ ---
319
+
320
+ ### Question 3.10: Network Error Handling (Mobile-Specific)
321
+
322
+ **How will you handle mobile-specific network errors?**
323
+
324
+ **Select all that apply:**
325
+
326
+ - [ ] **No Internet Connection**
327
+ - Show offline message
328
+ - Display cached data when available
329
+ - Best for: All apps
330
+
331
+ - [ ] **Slow Network (2G/3G)**
332
+ - Show loading indicators
333
+ - Implement request timeouts
334
+ - Best for: Apps with heavy data
335
+
336
+ - [ ] **Request Timeout**
337
+ - Retry failed requests
338
+ - Show timeout error message
339
+ - Best for: All apps
340
+
341
+ - [ ] **Network Switching (WiFi ↔ Mobile Data)**
342
+ - Handle connection changes gracefully
343
+ - Retry failed requests on reconnect
344
+ - Best for: Apps with background sync
345
+
346
+ - [ ] **Certificate Errors**
347
+ - Handle SSL pinning failures
348
+ - Show security warnings
349
+ - Best for: Apps with certificate pinning
350
+
351
+ **Your answer:**
352
+
353
+ **If retry logic selected, ask:**
354
+ - What retry strategy?
355
+ - Exponential backoff
356
+ - Fixed interval
357
+ - User-triggered retry
358
+
359
+ ---
360
+
361
+ ### Question 3.11: Loading States
362
+
363
+ **How will you handle loading states?**
364
+
365
+ A) ⭐ **Skeleton Screens** (Recommended)
366
+ - Show content structure while loading
367
+ - Better UX than spinners
368
+ - Best for: Most screens
369
+
370
+ B) **Loading Spinners**
371
+ - Simple, universal
372
+ - Best for: Quick loads
373
+
374
+ C) **Progressive Loading**
375
+ - Load critical data first
376
+ - Load secondary data after
377
+ - Best for: Complex screens
378
+
379
+ **Your answer:**
380
+
381
+ ---
382
+
383
+ ### Question 3.12: Data Validation
384
+
385
+ **How will you validate data?**
386
+
387
+ A) ⭐ **Client-side Validation** (Required)
388
+ - Validate before sending to server
389
+ - Better UX, less server load
390
+
391
+ B) **Schema Validation**
392
+ - Use Zod, Yup, or similar
393
+ - Type-safe validation
394
+
395
+ C) **Server Validation Only**
396
+ - Validate on server
397
+ - Show errors after submission
398
+ - Not recommended (poor UX)
399
+
400
+ **Your answer:**
401
+
402
+ ---
403
+
404
+ ### Question 3.13: Background Data Refresh
405
+
406
+ **How will you refresh data in the background?**
407
+
408
+ A) ⭐ **Background Fetch** (Recommended)
409
+ - Refresh when app is backgrounded
410
+ - iOS: Background App Refresh
411
+ - Android: WorkManager
412
+ - Best for: Most apps
413
+
414
+ B) **Push Notifications**
415
+ - Server pushes updates
416
+ - App refreshes on notification
417
+ - Best for: Real-time updates
418
+
419
+ C) **No Background Refresh**
420
+ - Refresh only when app opens
421
+ - Best for: Simple apps
422
+
423
+ **Your answer:**
424
+
425
+ ---
426
+
427
+ #### 🎨 MERMAID STATE MANAGEMENT DIAGRAM FORMATS - CRITICAL
428
+
429
+ **Use these exact formats** for mobile state management diagrams:
430
+
431
+ ---
432
+
433
+ ##### 1️⃣ Mobile State Architecture (Server + Client + Local)
434
+
435
+ Use `graph LR` to show different state types:
436
+
437
+ ```mermaid
438
+ graph LR
439
+ subgraph "State Types"
440
+ SERVER[Server State<br/>Redux Toolkit Query<br/>TanStack Query]
441
+ CLIENT[Client State<br/>Redux/Zustand]
442
+ LOCAL[Local Storage<br/>AsyncStorage<br/>MMKV]
443
+ CACHE[Cache<br/>WatermelonDB<br/>Realm]
444
+ end
445
+
446
+ subgraph "Mobile App Components"
447
+ S1[Home Screen]
448
+ S2[Profile Screen]
449
+ S3[Product List]
450
+ S4[Cart Screen]
451
+ end
452
+
453
+ SERVER -.->|products, users| S3
454
+ SERVER -.->|user profile| S2
455
+ CLIENT -.->|cart items, theme| S1
456
+ CLIENT -.->|auth token| S2
457
+ LOCAL -.->|user preferences| S1
458
+ CACHE -.->|offline data| S3
459
+ CACHE -.->|synced items| S4
460
+
461
+ style SERVER fill:#e1f5ff
462
+ style CLIENT fill:#fff4e6
463
+ style LOCAL fill:#e8f5e9
464
+ style CACHE fill:#f3e5f5
465
+ ```
466
+
467
+ **Use for:** Mobile apps with offline-first strategy
468
+
469
+ ---
470
+
471
+ ##### 2️⃣ Data Flow with Offline Support
472
+
473
+ Use `sequenceDiagram` to show complete data sync cycle:
474
+
475
+ ```mermaid
476
+ sequenceDiagram
477
+ participant U as User
478
+ participant UI as Screen
479
+ participant Store as State Manager
480
+ participant Cache as Local Cache
481
+ participant API as API Service
482
+ participant BE as Backend
483
+
484
+ U->>UI: Open Product List
485
+ UI->>Store: Request products
486
+ Store->>Cache: Check local cache
487
+
488
+ alt Cache Hit (Offline Mode)
489
+ Cache-->>Store: Return cached data
490
+ Store-->>UI: Display cached products
491
+ UI-->>U: Show products (stale)
492
+ end
493
+
494
+ alt Online Mode
495
+ Store->>API: Fetch fresh products
496
+ API->>BE: GET /api/products
497
+ BE-->>API: 200 OK + data
498
+ API-->>Store: Return products
499
+ Store->>Cache: Update cache
500
+ Store-->>UI: Display fresh products
501
+ UI-->>U: Show products (fresh)
502
+ end
503
+
504
+ Note over Cache: Cache valid for 5min
505
+
506
+ U->>UI: Add to cart (Offline)
507
+ UI->>Store: Add item to cart
508
+ Store->>Cache: Save to pending queue
509
+ Store-->>UI: Optimistic update
510
+ UI-->>U: Show cart updated
511
+
512
+ Note over Store,API: When online detected
513
+ Store->>API: Sync pending items
514
+ API->>BE: POST /api/cart/add
515
+ BE-->>API: 201 Created
516
+ API-->>Store: Confirm sync
517
+ Store->>Cache: Clear pending queue
518
+ ```
519
+
520
+ **Use for:** Apps with offline support and data synchronization
521
+
522
+ ---
523
+
524
+ ##### 3️⃣ State Decision Tree (Mobile-Specific)
525
+
526
+ Use `graph TD` to help developers choose state strategy:
527
+
528
+ ```mermaid
529
+ graph TD
530
+ A[New State Needed] --> B{From Backend?}
531
+ B -->|Yes| C{Needs Offline?}
532
+ C -->|Yes| D[Use Cache + Server State<br/>WatermelonDB + RTK Query]
533
+ C -->|No| E[Use Server State Only<br/>TanStack Query]
534
+
535
+ B -->|No| F{Persist Across<br/>App Restarts?}
536
+ F -->|Yes| G[Use AsyncStorage<br/>or MMKV<br/>+ Client State]
537
+ F -->|No| H{Shared Across<br/>Screens?}
538
+
539
+ H -->|Yes| I[Use Global State<br/>Redux/Zustand]
540
+ H -->|No| J{Complex Logic?}
541
+
542
+ J -->|Yes| K[Use useReducer<br/>Local State]
543
+ J -->|No| L[Use useState<br/>Simple Local State]
544
+
545
+ style D fill:#e1f5ff
546
+ style E fill:#e1f5ff
547
+ style G fill:#e8f5e9
548
+ style I fill:#fff4e6
549
+ style K fill:#fce4ec
550
+ style L fill:#fce4ec
551
+ ```
552
+
553
+ **Use for:** Decision-making guide for mobile state strategy
554
+
555
+ ---
556
+
557
+ ##### 4️⃣ Redux Architecture (Mobile Pattern)
558
+
559
+ Use `graph TB` to show Redux structure for mobile:
560
+
561
+ ```mermaid
562
+ graph TB
563
+ subgraph "Mobile App"
564
+ SCREEN[Screen Components]
565
+ end
566
+
567
+ subgraph "Redux Store"
568
+ SLICE1[Auth Slice<br/>user, token]
569
+ SLICE2[Cart Slice<br/>items, total]
570
+ SLICE3[Settings Slice<br/>theme, language]
571
+ RTK[RTK Query<br/>API endpoints]
572
+ end
573
+
574
+ subgraph "Side Effects"
575
+ MIDDLEWARE[Redux Middleware]
576
+ PERSIST[Redux Persist<br/>AsyncStorage]
577
+ end
578
+
579
+ subgraph "Backend"
580
+ API[REST API]
581
+ end
582
+
583
+ SCREEN -->|dispatch| SLICE1
584
+ SCREEN -->|dispatch| SLICE2
585
+ SCREEN -->|useSelector| SLICE3
586
+ SCREEN -->|useQuery| RTK
587
+
588
+ RTK -->|fetch| API
589
+
590
+ SLICE1 --> MIDDLEWARE
591
+ SLICE2 --> MIDDLEWARE
592
+ MIDDLEWARE --> PERSIST
593
+
594
+ PERSIST -.->|save| LOCAL[(AsyncStorage)]
595
+
596
+ style SCREEN fill:#e3f2fd
597
+ style RTK fill:#e1f5ff
598
+ style PERSIST fill:#e8f5e9
599
+ style LOCAL fill:#f3e5f5
600
+ ```
601
+
602
+ **Use for:** Redux-based mobile apps with persistence
603
+
604
+ ---
605
+
606
+ **Diagram Guidelines:**
607
+ - Show offline/online paths clearly
608
+ - Include cache layers (AsyncStorage, MMKV, WatermelonDB)
609
+ - Use sequence diagrams for sync flows
610
+ - Color code: Server=blue, Client=orange, Local=green, Cache=purple
611
+ - Include mobile-specific considerations (slow networks, offline-first)
612
+
613
+ ---
614
+
615
+ ## ✅ Phase 3 Completion
616
+
617
+ After answering all questions, summarize:
618
+
619
+ ```
620
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
621
+ ✅ Phase 3 Complete: State & Data Management
622
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
623
+
624
+ Selected Stack:
625
+ - State Management: Redux Toolkit
626
+ - HTTP Client: Axios
627
+ - Offline Strategy: Read-Only Offline
628
+ - Local Storage: AsyncStorage + WatermelonDB
629
+ - Sync Strategy: Optimistic Updates + Background Sync
630
+ - Conflict Resolution: Last Write Wins
631
+ - Caching: Stale-While-Revalidate
632
+ - Network Error Handling: Centralized with retry logic
633
+
634
+ Proceed to Phase 4 (Permissions & Native Features)? (Y/n)
635
+ ```
636
+
637
+ ---
638
+
639
+ ## 📝 Generated Documents
640
+
641
+ After Phase 3, generate/update:
642
+
643
+ - `docs/state-management.md` - State management patterns and setup
644
+ - `docs/offline-strategy.md` - Offline and sync strategy
645
+ - `ai-instructions.md` - Add state management rules
646
+
647
+ ---
648
+
649
+ **Next Phase:** Phase 4 - Permissions & Native Features
650
+
651
+ Read: `.ai-flow/prompts/mobile/flow-docs-gen-phase-4-permissions.md`
652
+
653
+ ---
654
+
655
+ **Last Updated:** 2025-01-XX
656
+
657
+ **Version:** 1.4.0
658
+
659
+