MrInvincible96 commited on
Commit
010234d
·
verified ·
1 Parent(s): ebcf662

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -377
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import re
2
  import gradio as gr
3
 
4
-
5
  CUSTOM_CSS = """
6
  body {
7
  background: linear-gradient(180deg, #f4f6f8 0%, #edf1f5 100%);
@@ -126,9 +125,6 @@ body {
126
  font-size: 0.88rem;
127
  line-height: 1.45;
128
  }
129
- label, span, p, li, div {
130
- color: #1f2f3d;
131
- }
132
 
133
  /* Base Textbox & Textarea styling */
134
  textarea, [data-testid="textbox"] textarea {
@@ -177,36 +173,6 @@ button.secondary:hover {
177
  border-color: #b8c7d4 !important;
178
  }
179
 
180
- /* Tab styling & Fix for invisible unselected tabs */
181
- .tab-nav {
182
- gap: 8px !important;
183
- padding: 14px 22px 0 22px !important;
184
- background: #ffffff !important;
185
- }
186
- .tab-nav button {
187
- border-radius: 999px !important;
188
- border: 1px solid #d5dce4 !important;
189
- background: #f7f9fb !important;
190
- color: #41586b !important;
191
- font-weight: 700 !important;
192
- transition: all 0.2s ease !important;
193
- }
194
- .tab-nav button span {
195
- color: #41586b !important; /* Force text color on inner span */
196
- }
197
- .tab-nav button:hover,
198
- .tab-nav button:hover span {
199
- background: #edf3f8 !important;
200
- color: #173954 !important;
201
- border-color: #bfd0dd !important;
202
- }
203
- .tab-nav button.selected,
204
- .tab-nav button.selected span {
205
- background: #173a59 !important;
206
- color: #ffffff !important;
207
- border-color: #173a59 !important;
208
- }
209
-
210
  /* Output Prose styling */
211
  .prose, .prose * {
212
  color: #1e2f3d !important;
@@ -233,40 +199,6 @@ button.secondary:hover {
233
  color: #16324a;
234
  }
235
 
236
- /* Examples Visibility Fixes */
237
- .examples label,
238
- .examples label span,
239
- .examples .label-wrap,
240
- .examples .label-wrap span {
241
- color: #000000 !important; /* Force Sample Business Scenarios label to be black */
242
- font-weight: 700 !important;
243
- opacity: 1 !important;
244
- }
245
-
246
- .examples button,
247
- .examples [role="button"],
248
- .examples .gallery-item {
249
- color: #000000 !important;
250
- }
251
-
252
- /* Fix for dark hover states */
253
- .examples button:hover,
254
- .examples [role="button"]:hover,
255
- .examples .gallery-item:hover,
256
- .examples [aria-selected="true"],
257
- .examples .selected {
258
- background: #eef4f8 !important;
259
- color: #000000 !important;
260
- border-color: #b8c7d4 !important;
261
- }
262
-
263
- .examples button:hover *,
264
- .examples [role="button"]:hover *,
265
- .examples .gallery-item:hover *,
266
- .examples [aria-selected="true"] * {
267
- color: #000000 !important; /* Ensure text remains black on hover */
268
- }
269
-
270
  /* Keep hero text white no matter what */
271
  .hero-shell *,
272
  .hero-inner *,
@@ -274,12 +206,7 @@ button.secondary:hover {
274
  .hero-subtitle,
275
  .eyebrow,
276
  .hero-stat strong,
277
- .hero-stat span,
278
- .hero-shell h1,
279
- .hero-shell h2,
280
- .hero-shell h3,
281
- .hero-shell p,
282
- .hero-shell div {
283
  color: #ffffff !important;
284
  }
285
 
@@ -292,6 +219,63 @@ button.secondary:hover {
292
  grid-template-columns: 1fr;
293
  }
294
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  """
296
 
297
  def guess_title(notes):
@@ -435,306 +419,4 @@ def build_risks(text):
435
 
436
  lowered = text.lower()
437
  if "payment" in lowered:
438
- risks.append("Payment integration complexity may delay release")
439
- if "guest" in lowered:
440
- risks.append("Guest user journeys may create reporting or tracking challenges")
441
- if "mobile" in lowered or "tablet" in lowered:
442
- risks.append("Cross-device usability issues may affect adoption")
443
-
444
- return risks[:4]
445
-
446
- def build_success_metrics(text):
447
- metrics = [
448
- "Reduced time spent preparing business documentation",
449
- "Improved consistency of requirement outputs"
450
- ]
451
-
452
- lowered = text.lower()
453
- if "cart" in lowered or "checkout" in lowered:
454
- metrics.append("Higher checkout completion rate")
455
- if "support" in lowered:
456
- metrics.append("Lower support ticket volume")
457
- if "mobile" in lowered:
458
- metrics.append("Improved mobile task completion rate")
459
-
460
- return metrics[:4]
461
-
462
- def build_user_stories(text):
463
- lowered = text.lower()
464
- stories = []
465
-
466
- if "guest checkout" in lowered or "guest" in lowered:
467
- stories.append({
468
- "role": "customer",
469
- "goal": "complete checkout without creating an account",
470
- "benefit": "I can purchase faster",
471
- "given": "I have items in my cart",
472
- "when": "I proceed to checkout",
473
- "then": "I should be able to continue as a guest"
474
- })
475
-
476
- if "payment" in lowered or extract_payment_methods(text):
477
- methods = extract_payment_methods(text)
478
- method_text = ", ".join(methods) if methods else "multiple payment options"
479
- stories.append({
480
- "role": "customer",
481
- "goal": f"choose from {method_text}",
482
- "benefit": "I can use my preferred payment method",
483
- "given": "I am on the payment step",
484
- "when": "I review the payment options",
485
- "then": f"I should see {method_text}"
486
- })
487
-
488
- if "mobile" in lowered or "tablet" in lowered:
489
- device = "mobile device" if "mobile" in lowered else "tablet"
490
- stories.append({
491
- "role": "user",
492
- "goal": f"complete the journey smoothly on my {device}",
493
- "benefit": "I can finish the task without frustration",
494
- "given": f"I am using a {device}",
495
- "when": "I open the process flow",
496
- "then": "the experience should be clear and easy to use"
497
- })
498
-
499
- if "dashboard" in lowered:
500
- stories.append({
501
- "role": "business user",
502
- "goal": "view information in a dashboard",
503
- "benefit": "I can manage work more efficiently",
504
- "given": "I log into the dashboard",
505
- "when": "I review current records or updates",
506
- "then": "I should be able to access the information I need clearly"
507
- })
508
-
509
- if not stories:
510
- stories.append({
511
- "role": "end user",
512
- "goal": "complete the main process with fewer steps",
513
- "benefit": "I can save time and effort",
514
- "given": "I start the process",
515
- "when": "I move through the required steps",
516
- "then": "the journey should feel simple and efficient"
517
- })
518
- stories.append({
519
- "role": "business stakeholder",
520
- "goal": "receive clearer requirement documentation",
521
- "benefit": "delivery can be more consistent",
522
- "given": "stakeholder notes are captured",
523
- "when": "documentation is generated",
524
- "then": "the output should be structured and easy to review"
525
- })
526
-
527
- return stories[:5]
528
-
529
- def format_brd(notes):
530
- title = guess_title(notes)
531
- objectives = build_objectives(notes)
532
- scope = build_scope(notes)
533
- functional = build_functional_requirements(notes)
534
- non_functional = build_non_functional_requirements(notes)
535
- assumptions = build_assumptions(notes)
536
- risks = build_risks(notes)
537
- metrics = build_success_metrics(notes)
538
-
539
- brd = f"""# Business Requirements Document
540
- ## Project Title
541
- {title}
542
- ## Executive Summary
543
- 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.
544
- ## Business Problem
545
- 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.
546
- ## Objectives
547
- """ + "\n".join([f"- {item}" for item in objectives]) + """
548
- ## Scope
549
- """ + "\n".join([f"- {item}" for item in scope]) + """
550
- ## Functional Requirements
551
- """ + "\n".join([f"- {item}" for item in functional]) + """
552
- ## Non-Functional Requirements
553
- """ + "\n".join([f"- {item}" for item in non_functional]) + """
554
- ## Assumptions
555
- """ + "\n".join([f"- {item}" for item in assumptions]) + """
556
- ## Risks
557
- """ + "\n".join([f"- {item}" for item in risks]) + """
558
- ## Success Metrics
559
- """ + "\n".join([f"- {item}" for item in metrics])
560
-
561
- return brd
562
-
563
- def format_stories(notes):
564
- stories = build_user_stories(notes)
565
- sections = ["# BDD-Style User Stories"]
566
-
567
- for index, story in enumerate(stories, start=1):
568
- sections.append(
569
- f"""
570
- ## User Story {index}
571
- As a {story['role']},
572
- I want to {story['goal']},
573
- So that {story['benefit']}.
574
- ### Acceptance Criteria
575
- - Given {story['given']}
576
- - When {story['when']}
577
- - Then {story['then']}
578
- """.strip()
579
- )
580
-
581
- return "\n\n".join(sections)
582
-
583
- def format_before_after(notes):
584
- cleaned = notes.strip()
585
- bullet_lines = [line.strip(" -•\t") for line in cleaned.splitlines() if line.strip()]
586
- if not bullet_lines:
587
- bullet_lines = [part.strip() for part in re.split(r"[.;]\s*", cleaned) if part.strip()]
588
-
589
- before = "\n".join([f"- {line}" for line in bullet_lines[:8]])
590
-
591
- return f"""# Before vs After
592
- ## Before: Raw Stakeholder Notes
593
- {before}
594
- ## After: Business-Ready Output
595
- - Raw notes were grouped into a formal BRD structure
596
- - Requirements were separated into functional and non-functional areas
597
- - User needs were rewritten as BDD-style stories
598
- - The output is now easier to review, share, and present
599
- ## Portfolio Value
600
- This demonstrates BA lifecycle thinking, requirement structuring, and workflow automation in a recruiter-friendly format.
601
- """
602
-
603
- def generate_documents(notes):
604
- notes = notes.strip()
605
-
606
- if not notes:
607
- msg = "Please paste stakeholder notes first."
608
- return msg, msg, msg
609
-
610
- brd = format_brd(notes)
611
- stories = format_stories(notes)
612
- before_after = format_before_after(notes)
613
-
614
- return brd, stories, before_after
615
-
616
- with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Base()) as demo:
617
- gr.HTML("""
618
- <div class="hero-shell">
619
- <div class="hero-inner">
620
- <div class="eyebrow">Strategy • Requirements • Workflow Automation</div>
621
- <h1 class="hero-title">Agentic BA</h1>
622
- <p class="hero-subtitle">
623
- A Business Analyst portfolio solution that converts unstructured stakeholder notes into
624
- structured BRDs, BDD-style user stories, and a clear before-versus-after documentation view.
625
- </p>
626
- <div class="hero-bar">
627
- <div class="hero-stat">
628
- <strong>Structured Documentation</strong>
629
- <span>Converts rough notes into formal requirement outputs.</span>
630
- </div>
631
- <div class="hero-stat">
632
- <strong>Public Portfolio Demo</strong>
633
- <span>Built to share with recruiters and hiring teams.</span>
634
- </div>
635
- <div class="hero-stat">
636
- <strong>100% Free Stack</strong>
637
- <span>No paid APIs, subscriptions, or hidden usage costs.</span>
638
- </div>
639
- <div class="hero-stat">
640
- <strong>BA Lifecycle Focus</strong>
641
- <span>Highlights analysis, structuring, and requirement thinking.</span>
642
- </div>
643
- </div>
644
- </div>
645
- </div>
646
- """)
647
-
648
- with gr.Row(equal_height=True):
649
- with gr.Column(scale=5):
650
- gr.HTML("""
651
- <div class="panel">
652
- <div class="panel-head">
653
- <h2 class="panel-title">Input Workspace</h2>
654
- <p class="panel-copy">
655
- Provide stakeholder notes, workshop summaries, or interview observations.
656
- The application reorganizes them into clearer business deliverables.
657
- </p>
658
- </div>
659
- <div class="panel-body">
660
- <div class="metric-strip">
661
- <div class="metric-card">
662
- <strong>BRD Output</strong>
663
- <span>Formal business requirement structure</span>
664
- </div>
665
- <div class="metric-card">
666
- <strong>BDD Stories</strong>
667
- <span>User-centered requirement framing</span>
668
- </div>
669
- <div class="metric-card">
670
- <strong>Showcase View</strong>
671
- <span>Before-and-after transformation for interviews</span>
672
- </div>
673
- </div>
674
- """)
675
-
676
- notes_input = gr.Textbox(
677
- lines=16,
678
- label="Raw Stakeholder Notes",
679
- placeholder="Example: Customers are abandoning carts before payment. Stakeholders want easier checkout, UPI, cards, wallets, guest checkout, mobile-friendly flow, and fewer support issues."
680
- )
681
-
682
- with gr.Row():
683
- generate_btn = gr.Button("Generate Deliverables", variant="primary")
684
- clear_btn = gr.Button("Clear Input", variant="secondary")
685
-
686
- gr.Examples(
687
- examples=[
688
- ["Customers are abandoning carts before payment. They want easier checkout, UPI, cards, wallets, mobile-friendly pages, guest checkout, and fewer support issues."],
689
- ["Hospital reception staff say patient registration is slow. They want OTP verification, fewer manual steps, tablet support, and a simple dashboard for receptionists."],
690
- ["Users find login confusing. Stakeholders want optional sign-in where possible, a simpler user flow, faster completion, and fewer helpdesk calls."]
691
- ],
692
- inputs=notes_input,
693
- label="Sample Business Scenarios"
694
- )
695
-
696
- gr.HTML("</div></div>")
697
-
698
- with gr.Column(scale=7):
699
- gr.HTML("""
700
- <div class="panel">
701
- <div class="panel-head">
702
- <h2 class="panel-title">Output Review</h2>
703
- <p class="panel-copy">
704
- Review the generated documentation in a format designed for portfolio presentation
705
- and rapid recruiter understanding.
706
- </p>
707
- </div>
708
- """)
709
-
710
- with gr.Tabs():
711
- with gr.Tab("BRD"):
712
- brd_output = gr.Markdown()
713
- with gr.Tab("BDD User Stories"):
714
- stories_output = gr.Markdown()
715
- with gr.Tab("Before vs After"):
716
- before_after_output = gr.Markdown()
717
-
718
- gr.HTML("</div>")
719
-
720
- gr.HTML("""
721
- <div class="footer-banner">
722
- <strong>Recruiter takeaway:</strong> This project demonstrates how a Business Analyst can apply
723
- structured automation thinking to convert unclear stakeholder input into clearer, more consistent,
724
- and more presentation-ready requirement documentation.
725
- </div>
726
- """)
727
-
728
- generate_btn.click(
729
- fn=generate_documents,
730
- inputs=notes_input,
731
- outputs=[brd_output, stories_output, before_after_output]
732
- )
733
-
734
- clear_btn.click(
735
- fn=lambda: ("", "", "", ""),
736
- inputs=[],
737
- outputs=[notes_input, brd_output, stories_output, before_after_output]
738
- )
739
-
740
- demo.launch()
 
1
  import re
2
  import gradio as gr
3
 
 
4
  CUSTOM_CSS = """
5
  body {
6
  background: linear-gradient(180deg, #f4f6f8 0%, #edf1f5 100%);
 
125
  font-size: 0.88rem;
126
  line-height: 1.45;
127
  }
 
 
 
128
 
129
  /* Base Textbox & Textarea styling */
130
  textarea, [data-testid="textbox"] textarea {
 
173
  border-color: #b8c7d4 !important;
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  /* Output Prose styling */
177
  .prose, .prose * {
178
  color: #1e2f3d !important;
 
199
  color: #16324a;
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  /* Keep hero text white no matter what */
203
  .hero-shell *,
204
  .hero-inner *,
 
206
  .hero-subtitle,
207
  .eyebrow,
208
  .hero-stat strong,
209
+ .hero-stat span {
 
 
 
 
 
210
  color: #ffffff !important;
211
  }
212
 
 
219
  grid-template-columns: 1fr;
220
  }
221
  }
222
+
223
+ /* =========================================
224
+ SLEDGEHAMMER OVERRIDES FOR GRADIO BUGS
225
+ ========================================= */
226
+
227
+ /* 1. TABS VISIBILITY FIX */
228
+ div.tab-nav {
229
+ gap: 8px !important;
230
+ padding: 14px 22px 0 22px !important;
231
+ background: #ffffff !important;
232
+ }
233
+ button[role="tab"] {
234
+ color: #41586b !important; /* Forces unselected text to be dark grey */
235
+ border-radius: 999px !important;
236
+ border: 1px solid #d5dce4 !important;
237
+ background: #f7f9fb !important;
238
+ font-weight: 700 !important;
239
+ transition: all 0.2s ease !important;
240
+ }
241
+ button[role="tab"]:hover {
242
+ background: #edf3f8 !important;
243
+ color: #173954 !important;
244
+ border-color: #bfd0dd !important;
245
+ }
246
+ button[role="tab"].selected {
247
+ background: #173a59 !important; /* Force background on active */
248
+ color: #ffffff !important; /* Force white text on active */
249
+ border-color: #173a59 !important;
250
+ }
251
+
252
+ /* 2. EXAMPLES LABEL ("Sample Business Scenarios") FIX */
253
+ .examples .label-wrap span,
254
+ .examples > label,
255
+ div.examples > p {
256
+ color: #000000 !important; /* Force to solid black */
257
+ font-weight: 800 !important;
258
+ opacity: 1 !important;
259
+ }
260
+
261
+ /* 3. EXAMPLES TABLE HOVER & SELECTED STATE FIX */
262
+ /* Normal Row State */
263
+ .examples table tbody tr td,
264
+ .examples table tbody tr th {
265
+ color: #1c2733 !important; /* Dark text normally */
266
+ }
267
+ /* Hover Row State */
268
+ .examples table tbody tr:hover td,
269
+ .examples table tbody tr:hover th {
270
+ background-color: #eef4f8 !important; /* Light blue background */
271
+ color: #000000 !important; /* Solid black text on hover */
272
+ }
273
+ /* Selected Row State */
274
+ .examples table tbody tr.selected td,
275
+ .examples table tbody tr[aria-selected="true"] td {
276
+ background-color: #DCE6F2 !important; /* Slightly darker blue when clicked */
277
+ color: #000000 !important; /* Solid black text when clicked */
278
+ }
279
  """
280
 
281
  def guess_title(notes):
 
419
 
420
  lowered = text.lower()
421
  if "payment" in lowered:
422
+ risks.append("Payment integration complexity may delay release")