-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadAI-Overview.html
More file actions
1060 lines (933 loc) · 29.8 KB
/
ThreadAI-Overview.html
File metadata and controls
1060 lines (933 loc) · 29.8 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ThreadAI — App Overview</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');
:root {
--accent: #5A70FF;
--accent-soft: #EEF1FF;
--accent-mid: #8B9DFF;
--bg: #FFFFFF;
--surface: #F8F9FC;
--border: #E8EBF4;
--text: #111827;
--text-secondary: #6B7280;
--text-muted: #9CA3AF;
--success: #10B981;
--claude: #D97757;
--openai: #10A37F;
--gradient-start: #5A70FF;
--gradient-end: #9B6BFF;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Inter', -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
font-size: 13px;
line-height: 1.6;
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
/* ── Cover Page ── */
.cover {
min-height: 100vh;
background: linear-gradient(145deg, #0F0F1A 0%, #1A1040 50%, #0D1A3A 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 60px 40px;
page-break-after: always;
position: relative;
overflow: hidden;
}
.cover::before {
content: '';
position: absolute;
width: 600px; height: 600px;
background: radial-gradient(circle, rgba(90,112,255,0.25) 0%, transparent 70%);
top: -100px; left: 50%;
transform: translateX(-50%);
pointer-events: none;
}
.cover::after {
content: '';
position: absolute;
width: 400px; height: 400px;
background: radial-gradient(circle, rgba(155,107,255,0.15) 0%, transparent 70%);
bottom: -50px; right: -50px;
pointer-events: none;
}
.cover-logo {
width: 96px; height: 96px;
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
border-radius: 28px;
margin-bottom: 32px;
display: flex;
align-items: center;
justify-content: center;
font-size: 44px;
box-shadow: 0 24px 64px rgba(90,112,255,0.5);
position: relative;
z-index: 1;
}
.cover h1 {
font-size: 64px;
font-weight: 800;
color: #FFFFFF;
letter-spacing: -2px;
line-height: 1;
margin-bottom: 16px;
position: relative; z-index: 1;
}
.cover-tagline {
font-size: 20px;
font-weight: 400;
color: rgba(255,255,255,0.65);
max-width: 480px;
line-height: 1.5;
margin-bottom: 48px;
position: relative; z-index: 1;
}
.cover-badges {
display: flex;
gap: 12px;
flex-wrap: wrap;
justify-content: center;
position: relative; z-index: 1;
}
.badge {
background: rgba(255,255,255,0.08);
border: 1px solid rgba(255,255,255,0.12);
color: rgba(255,255,255,0.80);
padding: 8px 18px;
border-radius: 100px;
font-size: 12px;
font-weight: 500;
letter-spacing: 0.3px;
}
.cover-meta {
position: absolute;
bottom: 40px;
left: 0; right: 0;
text-align: center;
color: rgba(255,255,255,0.3);
font-size: 11px;
letter-spacing: 1px;
text-transform: uppercase;
}
/* ── Layout ── */
.page {
max-width: 900px;
margin: 0 auto;
padding: 60px 48px;
}
.page-break { page-break-before: always; }
/* ── Section Headings ── */
.section-label {
font-size: 10px;
font-weight: 700;
letter-spacing: 2px;
text-transform: uppercase;
color: var(--accent);
margin-bottom: 8px;
}
h2 {
font-size: 28px;
font-weight: 700;
letter-spacing: -0.5px;
color: var(--text);
margin-bottom: 24px;
}
h3 {
font-size: 16px;
font-weight: 600;
color: var(--text);
margin-bottom: 12px;
}
.divider {
height: 1px;
background: var(--border);
margin: 48px 0;
}
/* ── Intro Block ── */
.intro-block {
background: var(--accent-soft);
border-left: 4px solid var(--accent);
border-radius: 0 12px 12px 0;
padding: 24px 28px;
margin-bottom: 48px;
font-size: 15px;
color: #374151;
line-height: 1.7;
}
.intro-block strong { color: var(--accent); }
/* ── Feature Cards ── */
.feature-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 40px;
}
.feature-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 16px;
padding: 24px;
transition: all 0.2s;
}
.feature-card.full-width {
grid-column: 1 / -1;
}
.feature-icon {
width: 44px; height: 44px;
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
margin-bottom: 16px;
}
.feature-card h3 {
font-size: 15px;
font-weight: 600;
margin-bottom: 8px;
}
.feature-card p {
font-size: 12.5px;
color: var(--text-secondary);
line-height: 1.65;
}
.feature-list {
margin-top: 10px;
padding-left: 0;
list-style: none;
}
.feature-list li {
font-size: 12px;
color: var(--text-secondary);
padding: 3px 0;
padding-left: 16px;
position: relative;
}
.feature-list li::before {
content: '→';
position: absolute;
left: 0;
color: var(--accent);
font-size: 10px;
top: 4px;
}
/* ── Provider Cards ── */
.provider-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 40px;
}
.provider-card {
border-radius: 16px;
padding: 28px;
position: relative;
overflow: hidden;
}
.provider-card.anthropic {
background: linear-gradient(135deg, #FFF7F4 0%, #FFF0EA 100%);
border: 1px solid #F5C9B5;
}
.provider-card.openai {
background: linear-gradient(135deg, #F0FBF7 0%, #E8F8F3 100%);
border: 1px solid #A7DFC9;
}
.provider-name {
font-size: 18px;
font-weight: 700;
margin-bottom: 4px;
}
.provider-card.anthropic .provider-name { color: #C4541E; }
.provider-card.openai .provider-name { color: #0D7A5F; }
.provider-sub {
font-size: 11px;
font-weight: 500;
letter-spacing: 0.5px;
text-transform: uppercase;
margin-bottom: 20px;
}
.provider-card.anthropic .provider-sub { color: #E07A50; }
.provider-card.openai .provider-sub { color: #10A37F; }
.model-pill {
display: inline-block;
padding: 5px 12px;
border-radius: 100px;
font-size: 11px;
font-weight: 500;
margin: 3px 4px 3px 0;
}
.provider-card.anthropic .model-pill {
background: rgba(196,84,30,0.10);
color: #C4541E;
}
.provider-card.openai .model-pill {
background: rgba(16,163,127,0.10);
color: #0D7A5F;
}
.provider-stat {
margin-top: 16px;
font-size: 11px;
color: var(--text-muted);
}
.provider-stat strong {
color: var(--text-secondary);
font-weight: 600;
}
/* ── Architecture Diagram ── */
.arch-diagram {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 16px;
padding: 32px;
margin-bottom: 32px;
}
.arch-layers {
display: flex;
flex-direction: column;
gap: 4px;
margin-bottom: 24px;
}
.arch-layer {
display: flex;
align-items: stretch;
gap: 4px;
}
.arch-layer-label {
width: 130px;
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-muted);
display: flex;
align-items: center;
padding-right: 12px;
flex-shrink: 0;
}
.arch-boxes {
display: flex;
gap: 4px;
flex: 1;
}
.arch-box {
flex: 1;
padding: 10px 14px;
border-radius: 8px;
font-size: 11px;
font-weight: 500;
text-align: center;
}
.arch-box.presentation { background: #EEF1FF; color: var(--accent); }
.arch-box.domain { background: #F0FBF7; color: #0D7A5F; }
.arch-box.data { background: #FFF7F0; color: #C4541E; }
.arch-box.harness { background: #F5F0FF; color: #7C3AED; }
.arch-arrow {
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: var(--text-muted);
padding: 0 4px;
}
/* ── Use Case Table ── */
.usecase-table {
width: 100%;
border-collapse: collapse;
font-size: 12.5px;
margin-bottom: 32px;
}
.usecase-table th {
text-align: left;
padding: 10px 16px;
background: var(--accent);
color: white;
font-weight: 600;
font-size: 11px;
letter-spacing: 0.3px;
}
.usecase-table th:first-child { border-radius: 8px 0 0 0; }
.usecase-table th:last-child { border-radius: 0 8px 0 0; }
.usecase-table td {
padding: 10px 16px;
border-bottom: 1px solid var(--border);
vertical-align: top;
}
.usecase-table tr:last-child td { border-bottom: none; }
.usecase-table tr:nth-child(even) td { background: var(--surface); }
.usecase-table td:first-child {
font-family: 'JetBrains Mono', monospace;
font-size: 11px;
color: var(--accent);
white-space: nowrap;
}
/* ── Tech Stack ── */
.tech-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
margin-bottom: 40px;
}
.tech-item {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 14px 16px;
}
.tech-item-label {
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-muted);
margin-bottom: 4px;
}
.tech-item-value {
font-size: 13px;
font-weight: 600;
color: var(--text);
}
/* ── Code Quality ── */
.quality-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 40px;
}
.quality-item {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 14px 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
}
.quality-icon {
width: 28px; height: 28px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
flex-shrink: 0;
background: var(--accent-soft);
}
.quality-text {
font-size: 12px;
color: var(--text-secondary);
line-height: 1.5;
}
.quality-text strong {
color: var(--text);
display: block;
font-size: 12.5px;
margin-bottom: 2px;
}
/* ── Getting Started ── */
.steps {
display: flex;
flex-direction: column;
gap: 16px;
margin-bottom: 40px;
}
.step {
display: flex;
align-items: flex-start;
gap: 16px;
}
.step-number {
width: 32px; height: 32px;
border-radius: 50%;
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
color: white;
font-size: 14px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.step-content {
flex: 1;
padding-top: 4px;
}
.step-content h4 {
font-size: 14px;
font-weight: 600;
margin-bottom: 4px;
}
.step-content p {
font-size: 12.5px;
color: var(--text-secondary);
line-height: 1.6;
}
.code-inline {
font-family: 'JetBrains Mono', monospace;
font-size: 11px;
background: #F1F3F9;
color: var(--accent);
padding: 2px 6px;
border-radius: 4px;
}
/* ── Footer ── */
.footer {
background: linear-gradient(135deg, #0F0F1A 0%, #1A1040 100%);
padding: 48px;
text-align: center;
color: rgba(255,255,255,0.5);
margin-top: 60px;
}
.footer-title {
font-size: 28px;
font-weight: 700;
color: white;
margin-bottom: 8px;
}
.footer-sub {
font-size: 14px;
color: rgba(255,255,255,0.4);
margin-bottom: 24px;
}
.footer-link {
display: inline-block;
background: var(--accent);
color: white;
padding: 12px 28px;
border-radius: 100px;
font-size: 13px;
font-weight: 600;
text-decoration: none;
margin: 0 6px;
}
@media print {
.cover { min-height: auto; padding: 80px 60px 60px; }
.page { padding: 40px 48px; }
.footer { margin-top: 40px; }
body { font-size: 12px; }
}
</style>
</head>
<body>
<!-- ═══════════════════════════════════════ COVER ═══════════════════════════════════════ -->
<div class="cover">
<div class="cover-logo">🧵</div>
<h1>ThreadAI</h1>
<p class="cover-tagline">
A production-quality iOS AI chat app with branching sub-thread conversations.<br/>
Powered by OpenAI · Your keys · Beautiful SwiftUI.
</p>
<div class="cover-badges">
<span class="badge">iOS 17+</span>
<span class="badge">Swift 5.9+</span>
<span class="badge">SwiftUI</span>
<span class="badge">OpenAI API</span>
<span class="badge">No Dependencies</span>
</div>
<div class="cover-meta">App Overview · 2025</div>
</div>
<!-- ═══════════════════════════════════════ PAGE 1: FEATURES ═══════════════════════════════════════ -->
<div class="page">
<div class="section-label">What is ThreadAI</div>
<h2>AI chat that thinks in branches</h2>
<div class="intro-block">
Most AI chat apps are <strong>linear</strong> — one conversation, one direction. ThreadAI introduces
<strong>sub-threads</strong>: fork any message into a new branch, where the parent conversation is
automatically carried as context. Explore multiple directions, compare approaches, or dive deep on
one idea — all without losing the original thread.
</div>
<div class="section-label">Core Features</div>
<h2>Everything you need, nothing you don't</h2>
<div class="feature-grid">
<div class="feature-card full-width">
<div class="feature-icon">🧵</div>
<h3>Thread-Based Conversations</h3>
<p>The defining feature. Fork any message into a sub-thread — the parent conversation context is carried forward automatically. Sub-threads appear as inline cards inside the parent chat. Nesting is unlimited and context builds recursively.</p>
<ul class="feature-list">
<li>Fork via long-press context menu on any message</li>
<li>Parent messages up to the fork point are included as AI context</li>
<li>Sub-threads listed inline and in the thread list sheet</li>
<li>Arbitrary nesting — sub-threads of sub-threads work perfectly</li>
<li>Optional custom system prompt per sub-thread</li>
</ul>
</div>
<div class="feature-card">
<div class="feature-icon">⚡</div>
<h3>Real-Time Streaming</h3>
<p>Responses stream token-by-token with a live blinking cursor. Stop generation at any time — the partial response is preserved.</p>
<ul class="feature-list">
<li>JSON-line streaming over URLSession</li>
<li>Typing indicator before first token</li>
<li>Buffered rendering to avoid UI thrash</li>
<li>Stop button with immediate cancellation</li>
</ul>
</div>
<div class="feature-card">
<div class="feature-icon">📝</div>
<h3>Full Markdown Rendering</h3>
<p>AI responses render with complete markdown support, including syntax-highlighted code blocks.</p>
<ul class="feature-list">
<li>Headers, bold, italic, inline code</li>
<li>Bullet lists and ordered lists</li>
<li>Block quotes with accent left bar</li>
<li>Code blocks with language label + copy button</li>
<li>Text selection on all content</li>
</ul>
</div>
<div class="feature-card">
<div class="feature-icon">🔖</div>
<h3>Bookmarks</h3>
<p>Save any AI message with a long-press. Each bookmark gets a short auto-generated title for easy identification.</p>
<ul class="feature-list">
<li>Dedicated Bookmarks tab across all conversations</li>
<li>Tap to navigate directly to the source message</li>
<li>Swipe to remove bookmarks</li>
<li>Sorted by recency</li>
</ul>
</div>
<div class="feature-card">
<div class="feature-icon">🗂️</div>
<h3>Conversation Management</h3>
<p>Keep your conversations organised with search, pinning, and inline sub-thread previews.</p>
<ul class="feature-list">
<li>Pin conversations to top of list</li>
<li>Search by conversation title</li>
<li>Swipe to delete conversations</li>
<li>Sub-thread previews inline (up to 3 + "+N more")</li>
<li>Custom system prompt per conversation</li>
</ul>
</div>
<div class="feature-card">
<div class="feature-icon">🔐</div>
<h3>Secure API Key Management</h3>
<p>Your API keys are stored in the iOS Keychain and never leave your device except to reach the AI provider directly.</p>
<ul class="feature-list">
<li>Keychain storage only — never UserDefaults or logs</li>
<li>Live validation via 1-token test request</li>
<li>Status: Not Set / Validating / Valid / Invalid</li>
<li>Keychain-scoped per provider</li>
</ul>
</div>
</div>
<div class="divider"></div>
<!-- ── AI Providers ── -->
<div class="section-label">AI Support</div>
<h2>OpenAI — two models</h2>
<div class="provider-grid" style="grid-template-columns: 1fr;">
<div class="provider-card openai">
<div class="provider-name">OpenAI</div>
<div class="provider-sub">openai api · json-line streaming</div>
<span class="model-pill">GPT-4o</span>
<span class="model-pill">GPT-4o mini</span>
<div class="provider-stat"><strong>Context window:</strong> 128,000 tokens</div>
</div>
</div>
<p style="font-size: 12.5px; color: var(--text-secondary); margin-bottom: 8px;">
Switch model mid-conversation from the chat toolbar. Adding a new provider requires only a single file that conforms to the <span class="code-inline">AIProvider</span> protocol — nothing else changes.
</p>
</div>
<!-- ═══════════════════════════════════════ PAGE 2: ARCHITECTURE ═══════════════════════════════════════ -->
<div class="page page-break">
<div class="section-label">Architecture</div>
<h2>MVVM + Clean Architecture</h2>
<div class="arch-diagram">
<div class="arch-layers">
<div class="arch-layer">
<div class="arch-layer-label">Presentation</div>
<div class="arch-boxes">
<div class="arch-box presentation">SwiftUI Views</div>
<div class="arch-box presentation">@Observable ViewModels</div>
</div>
</div>
<div class="arch-layer" style="padding: 2px 0;">
<div class="arch-layer-label"></div>
<div class="arch-boxes" style="justify-content: center;">
<div style="font-size: 18px; color: #9CA3AF;">↕</div>
</div>
</div>
<div class="arch-layer">
<div class="arch-layer-label">Domain</div>
<div class="arch-boxes">
<div class="arch-box domain">Entities</div>
<div class="arch-box domain">Use Cases</div>
<div class="arch-box domain">Repo Protocols</div>
</div>
</div>
<div class="arch-layer" style="padding: 2px 0;">
<div class="arch-layer-label"></div>
<div class="arch-boxes" style="justify-content: center;">
<div style="font-size: 18px; color: #9CA3AF;">↕</div>
</div>
</div>
<div class="arch-layer">
<div class="arch-layer-label">Data</div>
<div class="arch-boxes">
<div class="arch-box data">CoreData</div>
<div class="arch-box data">Repo Impls</div>
<div class="arch-box data">Keychain</div>
</div>
</div>
<div class="arch-layer" style="padding: 2px 0;">
<div class="arch-layer-label"></div>
<div class="arch-boxes" style="justify-content: center;">
<div style="font-size: 18px; color: #9CA3AF;">↕</div>
</div>
</div>
<div class="arch-layer">
<div class="arch-layer-label">AI Harness</div>
<div class="arch-boxes">
<div class="arch-box harness">AIProvider Protocol</div>
<div class="arch-box harness">OpenAIProvider</div>
<div class="arch-box harness">OpenAIProvider</div>
</div>
</div>
</div>
<p style="font-size: 11.5px; color: var(--text-muted); text-align: center;">
Strict one-way dependency flow · Domain has zero framework imports · Providers are plug-and-play
</p>
</div>
<div class="section-label">Use Cases</div>
<h2>Business logic is explicit and isolated</h2>
<table class="usecase-table">
<thead>
<tr>
<th>Use Case</th>
<th>What it does</th>
</tr>
</thead>
<tbody>
<tr>
<td>SendMessageUseCase</td>
<td>Sends a user message and handles the streaming AI response. Saves both messages to CoreData via the repository.</td>
</tr>
<tr>
<td>BuildContextChainUseCase</td>
<td>Recursively walks the thread ancestry to assemble the full message context for the AI request. Handles arbitrary nesting depth and excludes messages after the fork point in parent threads.</td>
</tr>
<tr>
<td>CreateSubThreadUseCase</td>
<td>Forks a sub-thread from a specific message, linking it to the parent conversation with the fork message ID. Creates the new CDConversation record.</td>
</tr>
<tr>
<td>BookmarkMessageUseCase</td>
<td>Toggles a bookmark on a message. Auto-generates a short title from the message content. Persists via MessageRepository.</td>
</tr>
</tbody>
</table>
<div class="divider"></div>
<div class="section-label">Tech Stack</div>
<h2>Modern Swift, zero third-party dependencies</h2>
<div class="tech-grid">
<div class="tech-item">
<div class="tech-item-label">Language</div>
<div class="tech-item-value">Swift 5.9+</div>
</div>
<div class="tech-item">
<div class="tech-item-label">UI Framework</div>
<div class="tech-item-value">SwiftUI only</div>
</div>
<div class="tech-item">
<div class="tech-item-label">iOS Target</div>
<div class="tech-item-value">iOS 17+</div>
</div>
<div class="tech-item">
<div class="tech-item-label">State Management</div>
<div class="tech-item-value">@Observable macro</div>
</div>
<div class="tech-item">
<div class="tech-item-label">Persistence</div>
<div class="tech-item-value">CoreData</div>
</div>
<div class="tech-item">
<div class="tech-item-label">Concurrency</div>
<div class="tech-item-value">Async/Await + AsyncThrowingStream</div>
</div>
<div class="tech-item">
<div class="tech-item-label">Security</div>
<div class="tech-item-value">Keychain Services</div>
</div>
<div class="tech-item">
<div class="tech-item-label">Networking</div>
<div class="tech-item-value">URLSession + SSE</div>
</div>
<div class="tech-item">
<div class="tech-item-label">Dependencies</div>
<div class="tech-item-value">None</div>
</div>
</div>
<div class="divider"></div>
<div class="section-label">Code Quality</div>
<h2>Production-grade standards</h2>
<div class="quality-grid">
<div class="quality-item">
<div class="quality-icon">🚫</div>
<div class="quality-text">
<strong>No force unwraps</strong>
Zero <code style="font-size:11px">!</code> operators in production code. All optionals are handled explicitly.
</div>
</div>
<div class="quality-item">
<div class="quality-icon">🪵</div>
<div class="quality-text">
<strong>OSLog only</strong>
No <code style="font-size:11px">print()</code> in production. Structured logging via Apple's Logger API.
</div>
</div>
<div class="quality-item">
<div class="quality-icon">🔑</div>
<div class="quality-text">
<strong>Keychain-only key storage</strong>
API keys never touch UserDefaults, logs, or plain files. Keychain with device lock protection.
</div>
</div>
<div class="quality-item">
<div class="quality-icon">⚠️</div>
<div class="quality-text">
<strong>No silent errors</strong>
All async functions surface errors. No silent <code style="font-size:11px">try?</code> swallowing.
</div>
</div>
<div class="quality-item">
<div class="quality-icon">📏</div>
<div class="quality-text">
<strong>400-line view cap</strong>
No SwiftUI view file exceeds 400 lines. Components are extracted into their own files.
</div>
</div>
<div class="quality-item">
<div class="quality-icon">🌐</div>
<div class="quality-text">
<strong>Localisation-ready</strong>
No hardcoded UI strings. All text uses <code style="font-size:11px">LocalizedStringKey</code>.
</div>
</div>
</div>
</div>
<!-- ═══════════════════════════════════════ PAGE 3: GETTING STARTED ═══════════════════════════════════════ -->
<div class="page page-break">
<div class="section-label">Getting Started</div>
<h2>Up and running in under 5 minutes</h2>
<div class="steps">
<div class="step">
<div class="step-number">1</div>
<div class="step-content">
<h4>Clone the repository</h4>
<p>
<span class="code-inline">git clone git@github.com:dsngeu/ThreadAI.git</span><br/>
<span class="code-inline">open ThreadAI.xcodeproj</span>
</p>
</div>
</div>
<div class="step">
<div class="step-number">2</div>
<div class="step-content">
<h4>Build and run</h4>
<p>Select a simulator or device in Xcode and press Run. No package manager, no <span class="code-inline">pod install</span>, no <span class="code-inline">swift package resolve</span> — zero third-party dependencies.</p>
</div>
</div>
<div class="step">
<div class="step-number">3</div>
<div class="step-content">
<h4>Add your API keys</h4>
<p>Open the <strong>Settings</strong> tab in the app. Tap <strong>OpenAI API Key</strong>, paste your key, and tap <strong>Validate & Save</strong>. The app makes a live 1-token test before storing the key in Keychain.</p>
</div>
</div>
<div class="step">
<div class="step-number">4</div>
<div class="step-content">
<h4>Start your first conversation</h4>
<p>Tap the compose button, choose a model, and start chatting. Long-press any AI message to fork a sub-thread or bookmark it.</p>
</div>
</div>
</div>
<div class="divider"></div>
<div class="section-label">Requirements</div>
<h2>What you need</h2>
<div class="tech-grid" style="grid-template-columns: 1fr 1fr 1fr;">
<div class="tech-item">
<div class="tech-item-label">Xcode</div>
<div class="tech-item-value">15.0 or later</div>
</div>
<div class="tech-item">
<div class="tech-item-label">Target device</div>
<div class="tech-item-value">iOS 17+ (device or sim)</div>
</div>
<div class="tech-item">
<div class="tech-item-label">API Key</div>
<div class="tech-item-value">OpenAI</div>
</div>
</div>
<div class="divider"></div>
<div class="section-label">Project Structure</div>
<h2>Where to find things</h2>
<table class="usecase-table">
<thead>