File size: 25,535 Bytes
09c76b7
4ab4326
 
607dadc
 
6f5e5d8
607dadc
 
f837931
a2e03fe
f837931
a2e03fe
6f5e5d8
607dadc
f837931
6f5e5d8
a2e03fe
f837931
a2e03fe
 
 
f837931
 
a2e03fe
6f5e5d8
607dadc
f837931
 
a2e03fe
f837931
 
a2e03fe
0d3ae46
a2e03fe
f837931
d7d485c
 
 
 
 
 
 
 
 
 
f837931
 
a2e03fe
 
f837931
0d3ae46
f837931
a2e03fe
f837931
 
a2e03fe
 
 
 
 
f837931
 
a2e03fe
f837931
 
 
 
a2e03fe
f837931
0d3ae46
f837931
 
a2e03fe
0d3ae46
a2e03fe
f837931
 
a2e03fe
 
 
 
f837931
 
 
a2e03fe
 
 
f837931
 
 
a2e03fe
 
0d3ae46
f837931
 
 
6f5e5d8
a2e03fe
 
607dadc
f837931
a2e03fe
607dadc
f837931
 
 
 
a2e03fe
607dadc
f837931
a2e03fe
 
6f5e5d8
a2e03fe
 
607dadc
f837931
 
a2e03fe
 
f837931
607dadc
f837931
6f5e5d8
a2e03fe
 
607dadc
6f5e5d8
82af292
 
a2e03fe
 
 
 
0d3ae46
f837931
 
82af292
6f5e5d8
 
82af292
6f5e5d8
 
f837931
 
82af292
f837931
6f5e5d8
 
 
a2e03fe
 
f837931
6f5e5d8
f837931
a2e03fe
6f5e5d8
 
 
a2e03fe
f837931
6f5e5d8
a2e03fe
 
 
 
f837931
6f5e5d8
 
 
 
 
 
f837931
 
82af292
f837931
a2e03fe
 
f837931
 
a2e03fe
f837931
 
 
82af292
f837931
a2e03fe
 
 
 
 
6f5e5d8
a2e03fe
 
 
 
 
 
f837931
 
9c0af8f
0d3ae46
 
 
 
 
010234d
0d3ae46
 
 
 
 
 
 
 
 
 
 
 
010234d
 
 
 
 
9c0af8f
 
 
 
 
 
 
 
 
 
 
 
 
 
010234d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c0af8f
d7d485c
 
 
 
9c0af8f
 
d7d485c
9c0af8f
 
d7d485c
010234d
 
d7d485c
9c0af8f
 
 
 
 
 
 
 
d7d485c
9c0af8f
 
 
 
 
 
 
 
 
 
 
 
d7d485c
 
 
 
 
 
 
 
 
 
 
 
010234d
607dadc
09c76b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2c0d40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0086807
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
import re
import gradio as gr

CUSTOM_CSS = """
body {
    background: linear-gradient(180deg, #f4f6f8 0%, #edf1f5 100%);
}
.gradio-container {
    max-width: 1280px !important;
    padding-top: 20px !important;
    padding-bottom: 36px !important;
    font-family: "Aptos", "Segoe UI", "Helvetica Neue", sans-serif !important;
    color: #1c2733;
}
.hero-shell {
    background: linear-gradient(135deg, #11283f 0%, #1a3d5f 100%);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(18, 36, 53, 0.16);
    margin-bottom: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.hero-inner {
    padding: 30px 34px;
    color: #ffffff;
}
.eyebrow {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ffffff !important;
    margin-bottom: 12px;
}
.hero-title {
    margin: 0 0 12px 0;
    font-size: 2.5rem;
    line-height: 1.08;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff !important;
    opacity: 1 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.hero-subtitle {
    max-width: 860px;
    margin: 0;
    font-size: 1.02rem;
    line-height: 1.75;
    color: #ffffff !important;
}
.hero-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-top: 22px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    overflow: hidden;
}
.hero-stat {
    background: rgba(255, 255, 255, 0.08);
    padding: 14px 16px;
}
.hero-stat strong {
    display: block;
    font-size: 0.92rem;
    margin-bottom: 4px;
    color: #ffffff !important;
}
.hero-stat span {
    font-size: 0.84rem;
    color: #ffffff !important;
    line-height: 1.45;
}
.panel {
    background: #ffffff;
    border: 1px solid #d7dde5;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(31, 47, 61, 0.06);
    overflow: hidden;
}
.panel-head {
    padding: 20px 22px 14px 22px;
    border-bottom: 1px solid #e3e8ee;
    background: linear-gradient(180deg, #fbfcfd 0%, #f5f8fb 100%);
}
.panel-title {
    margin: 0 0 6px 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: #17324a;
}
.panel-copy {
    margin: 0;
    color: #56697a;
    font-size: 0.95rem;
    line-height: 1.6;
}
.panel-body {
    padding: 20px 22px 22px 22px;
}
.metric-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.metric-card {
    background: #f8fafc;
    border: 1px solid #dfe5eb;
    border-left: 4px solid #244e73;
    border-radius: 8px;
    padding: 14px 14px 12px 14px;
}
.metric-card strong {
    display: block;
    color: #173954;
    font-size: 1rem;
    margin-bottom: 4px;
}
.metric-card span {
    color: #607180;
    font-size: 0.88rem;
    line-height: 1.45;
}

/* Base Textbox & Textarea styling */
textarea, [data-testid="textbox"] textarea {
    background: #ffffff !important;
    border: 1px solid #ccd5de !important;
    border-radius: 8px !important;
    font-size: 0.98rem !important;
    color: #27272A !important;
    box-shadow: none !important;
}
textarea::placeholder, [data-testid="textbox"] textarea::placeholder {
    color: #7a8896 !important;
}
textarea:focus, [data-testid="textbox"] textarea:focus {
    border: 1px solid #244e73 !important;
    box-shadow: 0 0 0 3px rgba(36, 78, 115, 0.12) !important;
}

/* Button styling */
button.primary {
    background: #173a59 !important;
    color: #ffffff !important;
    border: 1px solid #173a59 !important;
    border-radius: 8px !important;
    min-height: 46px !important;
    font-weight: 700 !important;
    transition: all 0.2s ease !important;
}
button.primary:hover {
    background: #214d75 !important;
    border-color: #214d75 !important;
    color: #ffffff !important;
}
button.secondary {
    background: #ffffff !important;
    color: #173954 !important;
    border: 1px solid #ccd5de !important;
    border-radius: 8px !important;
    min-height: 46px !important;
    font-weight: 700 !important;
    transition: all 0.2s ease !important;
}
button.secondary:hover {
    background: #eef4f8 !important;
    color: #16324a !important;
    border-color: #b8c7d4 !important;
}

/* Output Prose styling */
.prose, .prose * {
    color: #1e2f3d !important;
    line-height: 1.72 !important;
}
.prose h1, .prose h2, .prose h3 {
    color: #16324a !important;
    font-weight: 800 !important;
}

/* Footer Banner */
.footer-banner {
    margin-top: 16px;
    background: #ffffff;
    border: 1px solid #d8dfe6;
    border-radius: 10px;
    padding: 16px 20px;
    color: #4d6272;
    font-size: 0.94rem;
    line-height: 1.65;
    box-shadow: 0 8px 18px rgba(31, 47, 61, 0.05);
}
.footer-banner strong {
    color: #16324a;
}

/* Keep hero stats white no matter what */
.hero-shell *,
.hero-inner *,
.hero-subtitle,
.eyebrow,
.hero-stat strong,
.hero-stat span {
    color: #ffffff !important;
}

@media (max-width: 900px) {
    .hero-title {
        font-size: 2rem;
    }
    .hero-bar,
    .metric-strip {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   SLEDGEHAMMER OVERRIDES FOR GRADIO BUGS
   ========================================= */

/* 1. HERO TITLE FIX (Bypasses Gradio's internal h1 color reset) */
.gradio-container .hero-shell h1.hero-title,
.gradio-container .hero-shell h1,
.hero-shell .hero-title {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important; /* Forces white even if webkit overrides it */
    opacity: 1 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18) !important;
    margin: 0 0 12px 0 !important;
    font-size: 2.5rem !important;
    font-weight: 800 !important;
}

/* 2. TABS VISIBILITY FIX */
div.tab-nav {
    gap: 8px !important;
    padding: 14px 22px 0 22px !important;
    background: #ffffff !important;
}
button[role="tab"] {
    color: #41586b !important; /* Forces unselected text to be dark grey */
    border-radius: 999px !important;
    border: 1px solid #d5dce4 !important;
    background: #f7f9fb !important;
    font-weight: 700 !important;
    transition: all 0.2s ease !important;
}
button[role="tab"]:hover {
    background: #edf3f8 !important;
    color: #173954 !important;
    border-color: #bfd0dd !important;
}
button[role="tab"].selected {
    background: #173a59 !important; /* Force background on active */
    color: #ffffff !important;      /* Force white text on active */
    border-color: #173a59 !important;
}

/* 3. EXAMPLES LABEL ("Sample Business Scenarios") FIX */
.examples > div:first-child,
.examples > div:first-child *,
.examples .label-wrap,
.examples .label-wrap *,
div.examples label,
div.examples p,
div.examples span {
    color: #000000 !important;
    font-weight: 700 !important;
    opacity: 1 !important;
}

/* 4. EXAMPLES BUTTONS & HOVER STATE FIX */
.examples button,
.examples [role="button"],
.examples .gallery-item {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #ccd5de !important;
}

/* Force text inside the un-hovered buttons to stay black */
.examples button *,
.examples [role="button"] *,
.examples .gallery-item * {
    color: #000000 !important;
}

/* Hover and Selected states for Examples */
.examples button:hover,
.examples [role="button"]:hover,
.examples .gallery-item:hover,
.examples button.selected,
.examples [aria-selected="true"] {
    background-color: #173a59 !important; /* Dark blue background so white text pops */
    color: #ffffff !important;            /* White text */
    border-color: #173a59 !important;
}

/* Force text inside the hovered/selected buttons to turn white */
.examples button:hover *,
.examples [role="button"]:hover *,
.examples .gallery-item:hover *,
.examples button.selected *,
.examples [aria-selected="true"] * {
    color: #ffffff !important;
}
"""

def guess_title(notes):
    text = notes.lower()
    if "checkout" in text or "cart" in text or "payment" in text:
        return "Checkout Experience Improvement"
    if "hospital" in text or "patient" in text or "reception" in text:
        return "Patient Registration Process Improvement"
    if "login" in text or "signup" in text or "authentication" in text:
        return "Login and Access Experience Improvement"
    if "dashboard" in text:
        return "Operational Dashboard Enhancement"
    return "Business Process Improvement Initiative"

def extract_payment_methods(text):
    methods = []
    options = ["upi", "cards", "wallets", "net banking", "cod", "cash on delivery"]
    lowered = text.lower()
    for item in options:
        if item in lowered:
            methods.append(item.upper() if item == "upi" else item.title())
    return methods

def build_objectives(text):
    objectives = []
    lowered = text.lower()

    if "cart" in lowered or "checkout" in lowered:
        objectives.append("Reduce checkout drop-off and improve completion rate")
    if "mobile" in lowered:
        objectives.append("Improve the experience for mobile users")
    if "support" in lowered:
        objectives.append("Reduce support tickets related to the process")
    if "faster" in lowered or "slow" in lowered:
        objectives.append("Reduce time required to complete the process")
    if "payment" in lowered:
        objectives.append("Make payment completion simpler and more flexible")
    if "dashboard" in lowered:
        objectives.append("Provide clearer visibility for business users")

    if not objectives:
        objectives = [
            "Improve process efficiency",
            "Increase consistency in user experience",
            "Reduce manual effort"
        ]

    return objectives[:4]

def build_scope(text):
    scope = []
    lowered = text.lower()

    if "checkout" in lowered or "cart" in lowered:
        scope.append("Covers the end-to-end checkout journey")
    if "payment" in lowered:
        scope.append("Includes payment option selection and payment completion flow")
    if "guest checkout" in lowered or "guest" in lowered:
        scope.append("Includes guest user purchase flow")
    if "mobile" in lowered or "tablet" in lowered:
        scope.append("Includes responsive experience on mobile and tablet devices")
    if "dashboard" in lowered:
        scope.append("Includes dashboard access for internal users")

    if not scope:
        scope = [
            "Covers the target business process described in the stakeholder notes",
            "Includes the main user interactions and supporting business workflow"
        ]

    return scope

def build_functional_requirements(text):
    reqs = []
    lowered = text.lower()
    payments = extract_payment_methods(text)

    if "guest checkout" in lowered or "guest" in lowered:
        reqs.append("The system should allow users to continue without mandatory account login")

    if payments:
        reqs.append(f"The system should support the following payment methods: {', '.join(payments)}")

    if "mobile" in lowered:
        reqs.append("The system should provide a mobile-friendly experience")
    if "tablet" in lowered:
        reqs.append("The system should work effectively on tablet devices")
    if "otp" in lowered:
        reqs.append("The system should support OTP-based verification")
    if "dashboard" in lowered:
        reqs.append("The system should provide a dashboard for business users")
    if "login" in lowered and "optional" in lowered:
        reqs.append("The system should make login optional where appropriate")
    if "faster" in lowered or "slow" in lowered:
        reqs.append("The system should reduce unnecessary user steps in the process")

    if not reqs:
        reqs = [
            "The system should support the core business process described by stakeholders",
            "The system should simplify the current user journey",
            "The system should improve consistency across the workflow"
        ]

    return reqs[:6]

def build_non_functional_requirements(text):
    reqs = [
        "The solution should be easy to use for target users",
        "The solution should be reliable during normal business usage"
    ]

    lowered = text.lower()
    if "mobile" in lowered or "tablet" in lowered:
        reqs.append("The interface should be responsive across supported screen sizes")
    if "payment" in lowered or "otp" in lowered or "login" in lowered:
        reqs.append("The solution should protect user and transaction data")
    if "faster" in lowered or "slow" in lowered:
        reqs.append("The process should complete within an acceptable response time")

    return reqs[:4]

def build_assumptions(text):
    assumptions = [
        "Stakeholder notes represent the primary business need for the first version",
        "Existing systems can be updated without a full platform replacement"
    ]

    lowered = text.lower()
    if "launch" in lowered or "month" in lowered:
        assumptions.append("Delivery timeline expectations are realistic and approved by stakeholders")
    if "payment" in lowered:
        assumptions.append("Payment integrations can be configured within the current technical landscape")

    return assumptions[:4]

def build_risks(text):
    risks = [
        "Incomplete stakeholder input may lead to missing requirements",
        "Tight delivery timelines may reduce testing time"
    ]

    lowered = text.lower()
    if "payment" in lowered:
        risks.append("Payment integration complexity may delay release")
    if "guest" in lowered:
        risks.append("Guest user journeys may create reporting or tracking challenges")
    if "mobile" in lowered or "tablet" in lowered:
        risks.append("Cross-device usability issues may affect adoption")

    return risks[:4]

def build_success_metrics(text):
    metrics = [
        "Reduced time spent preparing business documentation",
        "Improved consistency of requirement outputs"
    ]

    lowered = text.lower()
    if "cart" in lowered or "checkout" in lowered:
        metrics.append("Higher checkout completion rate")
    if "support" in lowered:
        metrics.append("Lower support ticket volume")
    if "mobile" in lowered:
        metrics.append("Improved mobile task completion rate")

    return metrics[:4]

def build_user_stories(text):
    lowered = text.lower()
    stories = []

    if "guest checkout" in lowered or "guest" in lowered:
        stories.append({
            "role": "customer",
            "goal": "complete checkout without creating an account",
            "benefit": "I can purchase faster",
            "given": "I have items in my cart",
            "when": "I proceed to checkout",
            "then": "I should be able to continue as a guest"
        })

    if "payment" in lowered or extract_payment_methods(text):
        methods = extract_payment_methods(text)
        method_text = ", ".join(methods) if methods else "multiple payment options"
        stories.append({
            "role": "customer",
            "goal": f"choose from {method_text}",
            "benefit": "I can use my preferred payment method",
            "given": "I am on the payment step",
            "when": "I review the payment options",
            "then": f"I should see {method_text}"
        })

    if "mobile" in lowered or "tablet" in lowered:
        device = "mobile device" if "mobile" in lowered else "tablet"
        stories.append({
            "role": "user",
            "goal": f"complete the journey smoothly on my {device}",
            "benefit": "I can finish the task without frustration",
            "given": f"I am using a {device}",
            "when": "I open the process flow",
            "then": "the experience should be clear and easy to use"
        })

    if "dashboard" in lowered:
        stories.append({
            "role": "business user",
            "goal": "view information in a dashboard",
            "benefit": "I can manage work more efficiently",
            "given": "I log into the dashboard",
            "when": "I review current records or updates",
            "then": "I should be able to access the information I need clearly"
        })

    if not stories:
        stories.append({
            "role": "end user",
            "goal": "complete the main process with fewer steps",
            "benefit": "I can save time and effort",
            "given": "I start the process",
            "when": "I move through the required steps",
            "then": "the journey should feel simple and efficient"
        })
        stories.append({
            "role": "business stakeholder",
            "goal": "receive clearer requirement documentation",
            "benefit": "delivery can be more consistent",
            "given": "stakeholder notes are captured",
            "when": "documentation is generated",
            "then": "the output should be structured and easy to review"
        })

    return stories[:5]

def format_brd(notes):
    title = guess_title(notes)
    objectives = build_objectives(notes)
    scope = build_scope(notes)
    functional = build_functional_requirements(notes)
    non_functional = build_non_functional_requirements(notes)
    assumptions = build_assumptions(notes)
    risks = build_risks(notes)
    metrics = build_success_metrics(notes)

    brd = f"""# Business Requirements Document
## Project Title
{title}
## Executive Summary
This document translates unstructured stakeholder notes into a cleaner, review-ready business requirements format. It is designed to help Business Analysts move faster from conversation capture to formal documentation.
## Business Problem
Stakeholder feedback suggests that the current process contains friction, inconsistency, or avoidable manual effort. A more structured solution is needed to improve user outcomes and business performance.
## Objectives
""" + "\n".join([f"- {item}" for item in objectives]) + """
## Scope
""" + "\n".join([f"- {item}" for item in scope]) + """
## Functional Requirements
""" + "\n".join([f"- {item}" for item in functional]) + """
## Non-Functional Requirements
""" + "\n".join([f"- {item}" for item in non_functional]) + """
## Assumptions
""" + "\n".join([f"- {item}" for item in assumptions]) + """
## Risks
""" + "\n".join([f"- {item}" for item in risks]) + """
## Success Metrics
""" + "\n".join([f"- {item}" for item in metrics])

    return brd

def format_stories(notes):
    stories = build_user_stories(notes)
    sections = ["# BDD-Style User Stories"]

    for index, story in enumerate(stories, start=1):
        sections.append(
            f"""
## User Story {index}
As a {story['role']},  
I want to {story['goal']},  
So that {story['benefit']}.
### Acceptance Criteria
- Given {story['given']}
- When {story['when']}
- Then {story['then']}
""".strip()
        )

    return "\n\n".join(sections)

def format_before_after(notes):
    cleaned = notes.strip()
    bullet_lines = [line.strip(" -•\t") for line in cleaned.splitlines() if line.strip()]
    if not bullet_lines:
        bullet_lines = [part.strip() for part in re.split(r"[.;]\s*", cleaned) if part.strip()]

    before = "\n".join([f"- {line}" for line in bullet_lines[:8]])

    return f"""# Before vs After
## Before: Raw Stakeholder Notes
{before}
## After: Business-Ready Output
- Raw notes were grouped into a formal BRD structure
- Requirements were separated into functional and non-functional areas
- User needs were rewritten as BDD-style stories
- The output is now easier to review, share, and present
## Portfolio Value
This demonstrates BA lifecycle thinking, requirement structuring, and workflow automation in a recruiter-friendly format.
"""

def generate_documents(notes):
    notes = notes.strip()

    if not notes:
        msg = "Please paste stakeholder notes first."
        return msg, msg, msg

    brd = format_brd(notes)
    stories = format_stories(notes)
    before_after = format_before_after(notes)

    return brd, stories, before_after

with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Base()) as demo:
    gr.HTML("""
    <div class="hero-shell">
        <div class="hero-inner">
            <div class="eyebrow">Strategy • Requirements • Workflow Automation</div>
            <h1 class="hero-title">Agentic BA</h1>
            <p class="hero-subtitle">
                A Business Analyst portfolio solution that converts unstructured stakeholder notes into
                structured BRDs, BDD-style user stories, and a clear before-versus-after documentation view.
            </p>
            <div class="hero-bar">
                <div class="hero-stat">
                    <strong>Structured Documentation</strong>
                    <span>Converts rough notes into formal requirement outputs.</span>
                </div>
                <div class="hero-stat">
                    <strong>Public Portfolio Demo</strong>
                    <span>Built to share with recruiters and hiring teams.</span>
                </div>
                <div class="hero-stat">
                    <strong>100% Free Stack</strong>
                    <span>No paid APIs, subscriptions, or hidden usage costs.</span>
                </div>
                <div class="hero-stat">
                    <strong>BA Lifecycle Focus</strong>
                    <span>Highlights analysis, structuring, and requirement thinking.</span>
                </div>
            </div>
        </div>
    </div>
    """)

    with gr.Row(equal_height=True):
        with gr.Column(scale=5):
            gr.HTML("""
            <div class="panel">
                <div class="panel-head">
                    <h2 class="panel-title">Input Workspace</h2>
                    <p class="panel-copy">
                        Provide stakeholder notes, workshop summaries, or interview observations.
                        The application reorganizes them into clearer business deliverables.
                    </p>
                </div>
                <div class="panel-body">
                    <div class="metric-strip">
                        <div class="metric-card">
                            <strong>BRD Output</strong>
                            <span>Formal business requirement structure</span>
                        </div>
                        <div class="metric-card">
                            <strong>BDD Stories</strong>
                            <span>User-centered requirement framing</span>
                        </div>
                        <div class="metric-card">
                            <strong>Showcase View</strong>
                            <span>Before-and-after transformation for interviews</span>
                        </div>
                    </div>
            """)

            notes_input = gr.Textbox(
                lines=16,
                label="Raw Stakeholder Notes",
                placeholder="Example: Customers are abandoning carts before payment. Stakeholders want easier checkout, UPI, cards, wallets, guest checkout, mobile-friendly flow, and fewer support issues."
            )

            with gr.Row():
                generate_btn = gr.Button("Generate Deliverables", variant="primary")
                clear_btn = gr.Button("Clear Input", variant="secondary")

            gr.Examples(
                examples=[
                    ["Customers are abandoning carts before payment. They want easier checkout, UPI, cards, wallets, mobile-friendly pages, guest checkout, and fewer support issues."],
                    ["Hospital reception staff say patient registration is slow. They want OTP verification, fewer manual steps, tablet support, and a simple dashboard for receptionists."],
                    ["Users find login confusing. Stakeholders want optional sign-in where possible, a simpler user flow, faster completion, and fewer helpdesk calls."]
                ],
                inputs=notes_input,
                label="Sample Business Scenarios"
            )

            gr.HTML("</div></div>")

        with gr.Column(scale=7):
            gr.HTML("""
            <div class="panel">
                <div class="panel-head">
                    <h2 class="panel-title">Output Review</h2>
                    <p class="panel-copy">
                        Review the generated documentation in a format designed for portfolio presentation
                        and rapid recruiter understanding.
                    </p>
                </div>
            """)

            with gr.Tabs():
                with gr.Tab("BRD"):
                    brd_output = gr.Markdown()
                with gr.Tab("BDD User Stories"):
                    stories_output = gr.Markdown()
                with gr.Tab("Before vs After"):
                    before_after_output = gr.Markdown()

            gr.HTML("</div>")

    gr.HTML("""
    <div class="footer-banner">
        <strong>Recruiter takeaway:</strong> This project demonstrates how a Business Analyst can apply
        structured automation thinking to convert unclear stakeholder input into clearer, more consistent,
        and more presentation-ready requirement documentation.
    </div>
    """)

    generate_btn.click(
        fn=generate_documents,
        inputs=notes_input,
        outputs=[brd_output, stories_output, before_after_output]
    )

    clear_btn.click(
        fn=lambda: ("", "", "", ""),
        inputs=[],
        outputs=[notes_input, brd_output, stories_output, before_after_output]
    )

demo.launch()