Spaces:
Paused
Paused
File size: 25,589 Bytes
3d4ed4f | 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 | # HeedX AI β Two-Mode Mental-Health AI Architecture
You are the primary AI software engineer working on **HeedX AI**, a Nigerian mental-health support and analysis application.
Your first responsibility is to **understand the existing codebase and architecture before changing it**.
Do not immediately rewrite the application.
Inspect the existing project, identify what is already working, and then redesign it around the architecture described below.
---
# 1. CORE CONCEPT
HeedX has **TWO DISTINCT INPUT MODES**.
They must remain conceptually separate even though they can share the same underlying AI/RAG infrastructure.
## Mode A β Professional / Case Analysis
This mode is intended for a psychologist, mental-health professional, researcher, or authorized user who already has patient/client text.
The professional can:
* upload a document
* paste patient/client text
* write patient/client text manually
HeedX then performs **qualitative analysis** of the supplied text.
Example:
> "The patient reports feeling persistently sad for approximately one month. She has difficulty sleeping, has withdrawn from friends, and is struggling to concentrate at university."
The system extracts and organizes information such as:
```text
Presenting concerns
β’ persistent sadness
β’ sleep difficulty
β’ social withdrawal
β’ difficulty concentrating
Duration
β’ approximately one month
Context
β’ university/academic environment
Potentially relevant symptoms/signals
β’ low mood
β’ sleep disturbance
β’ reduced social engagement
β’ concentration difficulty
Risk information
β’ no suicidal ideation established from the supplied text
β’ further assessment may be appropriate
```
This is **qualitative analysis**.
Do NOT turn this into:
```text
Depression = 78%
Anxiety = 15%
Normal = 5%
Suicidal = 2%
```
The system should not generate fake diagnostic probabilities.
---
# 2. Mode B β Conversational User Mode
This mode is for a person directly interacting with HeedX.
The user communicates naturally:
> "I've been feeling really down lately."
Then:
> "It's been happening for a few weeks and I can't sleep properly."
Then:
> "University has also been stressful."
The system should maintain conversation context and continuously update its understanding.
Conceptually:
```text
USER MESSAGE
β
UNDERSTAND CURRENT MESSAGE
β
UPDATE CONVERSATION STATE
β
RETRIEVE RELEVANT KNOWLEDGE
β
LLM
β
PERSONALIZED RESPONSE
β
USER CONTINUES
β
REPEAT
```
This mode should feel like a natural conversation, NOT like filling out a questionnaire.
---
# 3. VERY IMPORTANT: DO NOT ADD QUESTIONNAIRE SCREENING
For the current version, do NOT implement:
* PHQ-9
* GAD-7
* WHO-5
* Kessler
* questionnaire scoring
* questionnaire UI
* questionnaire-based diagnosis
This may be added in a future version.
The current system should primarily understand natural language.
---
# 4. VERY IMPORTANT: OLD CLASSIFIER IS NO LONGER THE PRIMARY ENGINE
The existing application may contain a classical ML classifier with classes such as:
```text
Normal
Anxiety
Depression
Suicidal
```
The old architecture was approximately:
```text
INPUT
β
CLASSICAL ML MODEL
β
class + probabilities
β
Python analysis
β
LLM
β
conversation
```
This classifier should NOT be the primary inference mechanism in the redesigned system.
It may be retained for:
* experimentation
* research comparison
* benchmarking
* future development
But the production user experience should NOT depend on the four-class classifier.
The new architecture is based on **qualitative semantic understanding + retrieval + conversational generation**.
---
# 5. TWO INPUTS, ONE SHARED INTELLIGENCE LAYER
The central architectural principle is:
```text
HEEDX
β
βββββββββββ΄ββββββββββ
β β
βΌ βΌ
PROFESSIONAL MODE CONVERSATION MODE
CASE ANALYSIS USER CHAT
β β
βΌ βΌ
Qualitative analysis Conversation
β understanding
β β
βββββββββββ¬ββββββββββ
βΌ
SHARED HEEDX CORE
β
βββββββββββββββΌββββββββββββββ
β β β
βΌ βΌ βΌ
Analysis RAG Safety
Engine Engine Layer
β β β
βββββββββββββββΌββββββββββββββ
βΌ
LLM
β
ββββββββββ΄βββββββββ
βΌ βΌ
Case output User response
```
Do NOT build two completely unrelated AI systems.
Build two input experiences that share common underlying services.
---
# 6. WHAT "QUALITATIVE ANALYSIS" MEANS
The analysis engine should identify meaningful information from text rather than forcing it into mutually exclusive diagnostic categories.
Potential structured fields include:
```json
{
"presenting_concerns": [],
"emotions": [],
"symptoms_or_signals": [],
"stressors": [],
"duration": null,
"functional_impact": [],
"social_context": [],
"protective_factors": [],
"risk_signals": [],
"support_needs": [],
"uncertainties": []
}
```
This is an **information representation**, not a diagnosis.
For example:
```json
{
"presenting_concerns": [
"persistent sadness"
],
"symptoms_or_signals": [
"sleep difficulty",
"loss of interest",
"social withdrawal"
],
"stressors": [
"academic pressure"
],
"duration": "approximately three weeks",
"risk_signals": [],
"uncertainties": [
"suicidal ideation not established"
]
}
```
The system should distinguish between:
* explicitly stated information
* reasonable semantic interpretation
* information that remains unknown
Do not invent information that the user/patient did not provide.
---
# 7. PROFESSIONAL / CASE ANALYSIS PIPELINE
The professional mode should follow:
```text
PROFESSIONAL
β
βΌ
Upload / Paste / Write Patient Text
β
βΌ
Text Extraction
β
βΌ
Qualitative Analysis
β
βββ concerns
βββ symptoms/signals
βββ emotions
βββ stressors
βββ duration
βββ functioning
βββ context
βββ risk signals
β
βΌ
Structured Case Representation
β
βΌ
Retrieval Query Construction
β
βΌ
Embedding
β
βΌ
Vector Search
β
βΌ
Relevant Evidence
β
βΌ
LLM
β
βΌ
Professional Case Summary / Evidence-Grounded Analysis
```
The professional should be able to see the resulting analysis clearly.
---
# 8. CONVERSATIONAL PIPELINE
The conversational mode should follow:
```text
USER
β
βΌ
Message
β
βΌ
Conversation Understanding
β
βββ current concerns
βββ symptoms/signals
βββ emotions
βββ stressors
βββ duration
βββ risk signals
β
βΌ
Update Conversation State
β
βΌ
Construct Retrieval Query
β
βΌ
Embedding
β
βΌ
Vector Search
β
βΌ
Relevant Evidence
β
βΌ
LLM
β
βΌ
Natural Personalized Response
β
βΌ
USER
```
This process can repeat on every meaningful turn.
---
# 9. CONVERSATION STATE
The conversational system should maintain a structured state.
Example:
```json
{
"main_concerns": [
"persistent sadness",
"sleep difficulty",
"loss of interest"
],
"duration": "approximately three weeks",
"stressors": [
"academic pressure",
"financial difficulty"
],
"functional_impact": [
"difficulty concentrating"
],
"risk_signals": [],
"risk_status": "not_established"
}
```
The state must evolve as the user provides new information.
For example:
### First message
> "I've been feeling down."
State:
```text
low mood
```
### Second message
> "For about three weeks and I can't sleep."
State becomes:
```text
low mood
+
three-week duration
+
sleep difficulty
```
### Third message
> "University has been stressful."
State becomes:
```text
low mood
+
three-week duration
+
sleep difficulty
+
academic stress
```
This state should help improve retrieval and personalization.
---
# 10. EMBEDDINGS AND VECTORS
There are TWO sides to embeddings.
## Static knowledge embeddings
Knowledge documents are processed before user interaction:
```text
Research / Guidelines / Knowledge
β
Text extraction
β
Chunking
β
Embedding model
β
Vectors
β
Vector database
```
These embeddings are relatively static.
## User/query embeddings
When relevant user information needs to be retrieved:
```text
Current user message
+
Conversation state
+
Structured signals
β
Retrieval query
β
Embedding model
β
Query vector
β
Vector similarity search
```
The same compatible embedding model should be used for knowledge chunks and retrieval queries.
Remember:
> The vector does not contain the knowledge itself.
The actual knowledge remains in the stored document chunks.
The vector allows the system to find semantically related chunks.
---
# 11. RETRIEVAL MUST USE THE USER'S INFORMATION
Do not build a RAG system where the user text is disconnected from retrieval.
The connection should be explicit:
```text
USER TEXT
β
UNDERSTANDING
β
STRUCTURED SIGNALS
β
RETRIEVAL QUERY
β
EMBEDDING
β
VECTOR SEARCH
β
RELEVANT KNOWLEDGE
```
For example:
User:
> "I haven't enjoyed football for weeks and I'm barely sleeping."
Possible retrieval representation:
```text
loss of interest
sleep disturbance
persistent symptoms
reduced enjoyment
mental health
```
The system then searches the knowledge base for semantically relevant evidence.
---
# 12. DO NOT BLINDLY EMBED THE ENTIRE CONVERSATION
The system should not simply concatenate every historical message forever and embed everything blindly.
Instead use:
```text
Current message
+
Relevant conversation state
+
Relevant context
+
Structured signals
```
to construct the retrieval query.
The full conversation history can still be supplied to the LLM where appropriate.
Retrieval context and conversational context are related but are not identical.
---
# 13. RAG KNOWLEDGE BASE
The knowledge base should be designed around reliable mental-health information, especially Nigerian/local context.
Suggested structure:
```text
knowledge/
β
βββ nigeria_evidence/
β βββ national/
β βββ depression/
β βββ anxiety/
β βββ suicide/
β βββ trauma/
β βββ substance_use/
β βββ adolescents/
β βββ university_students/
β βββ severe_mental_illness/
β
βββ nigeria_context/
β βββ stigma/
β βββ culture/
β βββ family/
β βββ religion_and_mental_health/
β βββ unemployment/
β βββ poverty/
β βββ conflict/
β βββ healthcare_access/
β
βββ scenarios/
β βββ academic_stress/
β βββ financial_stress/
β βββ grief/
β βββ relationships/
β βββ anxiety/
β βββ depression/
β βββ trauma/
β βββ suicide_risk/
β
βββ psychoeducation/
β
βββ recommendations/
β
βββ metadata/
```
Do not simply dump documents into a vector database.
Preserve useful metadata.
---
# 14. KNOWLEDGE CHUNK METADATA
Where possible, each chunk should retain:
```text
document_id
title
source
authors
year
country
state
population
sample_size
age_range
mental_health_domain
condition
study_design
measurement_tool
evidence_level
limitations
source_url
```
This allows future retrieval filtering and source attribution.
---
# 15. DETERMINISTIC MODULES STILL EXIST
RAG does NOT replace every existing static module.
Keep exact information in deterministic/structured data.
Examples:
```text
Emergency contacts
Facilities
Facility addresses
Verified URLs
Crisis procedures
Service directories
Application configuration
Other exact structured information
```
Do not ask the LLM to invent these.
The architecture should therefore have:
```text
HEEDX CORE
β
ββββββββββββββΌββββββββββββββ
β β β
βΌ βΌ βΌ
LLM RAG DETERMINISTIC
Conversation Knowledge Modules
β β β
β β βββ contacts
β β βββ facilities
β β βββ URLs
β β βββ exact data
β β
β βββ studies
β βββ guidance
β βββ psychoeducation
β βββ evidence
β
ββββββββββββββ¬ββββββββββββββ
βΌ
HEEDX
```
---
# 16. SAFETY LAYER
Safety must be separate from ordinary RAG.
For example, if a user says:
> "I want to kill myself."
the application must not simply perform normal semantic retrieval and answer like an ordinary mental-health question.
It must activate a dedicated safety pathway.
The safety layer should be able to:
* identify high-risk signals
* determine whether clarification is necessary
* prioritize immediate safety
* provide verified emergency/crisis resources
* encourage appropriate human support
* change the response strategy
* prevent unsafe conversational behavior
RAG can provide supporting evidence, but the safety mechanism itself must have explicit rules and guardrails.
---
# 17. NO DIAGNOSTIC CLAIMS
HeedX should not claim:
> "You have depression."
based solely on conversational analysis.
Prefer:
> "What you're describing includes experiences commonly associated with depression."
or:
> "These symptoms may be worth discussing with a mental-health professional."
The system is providing **support, qualitative analysis, and evidence-grounded information**, not replacing clinical diagnosis.
---
# 18. PROFESSIONAL OUTPUT VS USER OUTPUT
These two modes should have different presentation styles.
## Professional mode
The output can be structured:
```text
CASE ANALYSIS
Presenting concerns
...
Reported symptoms/signals
...
Duration
...
Stressors/context
...
Functional impact
...
Risk indicators
...
Relevant considerations
...
Evidence retrieved
...
Suggested areas for further assessment
...
```
Be clear that this is an AI-assisted analysis and not a definitive diagnosis.
## Conversational mode
The output should be natural:
```text
"I hear you. From what you've described, you've been dealing
with poor sleep and losing interest in things you normally enjoy.
That can be difficult, especially alongside academic stress.
Can I ask whether this has also affected your ability to attend
classes or carry out your normal daily activities?"
```
Do not expose vector databases, embeddings, retrieval mechanics, or internal analysis unless specifically requested.
---
# 19. LLM CONTEXT
The LLM should receive an appropriate combination of:
```text
System instructions
+
Current user/patient text
+
Relevant conversation history
+
Structured analysis
+
Conversation/case state
+
Retrieved evidence
+
Safety state
+
Deterministic information when required
```
For professional mode:
```text
Patient text
+
Qualitative analysis
+
Retrieved evidence
+
Safety information
+
Professional instructions
```
For conversational mode:
```text
Current user message
+
Conversation history
+
Conversation state
+
Retrieved evidence
+
Safety state
+
Conversational instructions
```
---
# 20. KNOWLEDGE SOURCES
The knowledge system should prioritize reliable sources such as:
* peer-reviewed Nigerian research
* reputable international research
* WHO guidance
* Nigerian government/public-health sources
* recognized clinical/public-health organizations
* evidence-based mental-health resources
Nigerian evidence should be prioritized where relevant.
Do not fabricate citations or sources.
---
# 21. EXISTING CODEBASE INSPECTION
Before changing the project, inspect:
1. Entry point
2. UI
3. Professional/case-analysis interface
4. Conversational interface
5. Existing classical ML model
6. Existing Python analysis
7. Existing LLM integration
8. Existing static modules
9. Existing recommendations
10. Emergency/crisis information
11. Facility/location data
12. Data files
13. Deployment configuration
14. Requirements/dependencies
15. Existing tests
Determine what should be:
* preserved
* refactored
* replaced
* deprecated
* newly added
Do not delete existing functionality simply because the architecture is changing.
---
# 22. TARGET ARCHITECTURE
The final conceptual architecture should resemble:
```text
HEEDX AI
β
ββββββββββββββββ΄βββββββββββββββ
β β
βΌ βΌ
PROFESSIONAL MODE CONVERSATIONAL MODE
CASE ANALYSIS USER CHAT
β β
Upload / Paste / Write User messages
β β
βΌ βΌ
Qualitative Analysis Conversation Understanding
β β
βΌ βΌ
Structured Case State Conversation State
β β
ββββββββββββββββ¬βββββββββββββββ
βΌ
RETRIEVAL ENGINE
β
Query creation
β
Embedding
β
Vector Database
β
Relevant Knowledge
β
ββββββββββββββββΌβββββββββββββββ
β β β
βΌ βΌ βΌ
RAG SAFETY DETERMINISTIC
Evidence Layer Modules
β β β
ββββββββββββββββΌβββββββββββββββ
βΌ
LLM
ββββββββ΄βββββββ
βΌ βΌ
Professional User-facing
output response
```
---
# 23. DEVELOPMENT ORDER
Implement incrementally.
### Stage 1 β Repository analysis
Understand the existing application.
Do not make destructive changes.
### Stage 2 β Separate the two input modes
Ensure the UI and backend conceptually distinguish:
```text
Professional / Case Analysis
```
from:
```text
Conversational User Mode
```
### Stage 3 β Build/refactor qualitative analysis
Create a structured qualitative analysis representation.
### Stage 4 β Build knowledge ingestion
Implement:
```text
documents
β extraction
β chunking
β metadata
β embeddings
β vector storage
```
### Stage 5 β Implement retrieval
Implement:
```text
query
β embedding
β similarity search
β relevant chunks
```
### Stage 6 β Connect retrieval to professional analysis
```text
patient text
β qualitative analysis
β retrieval
β evidence
β professional output
```
### Stage 7 β Connect retrieval to conversation
```text
user message
β conversation understanding
β state
β retrieval
β evidence
β LLM
β response
```
### Stage 8 β Implement safety layer
Keep safety behavior separate from ordinary RAG.
### Stage 9 β Test both modes separately
Test professional analysis independently from conversational behavior.
### Stage 10 β Integrate and refine UI
Only after the underlying architecture is working.
---
# 24. TEST CASES
Create tests/examples for both modes.
## Professional mode example
Input:
> "Patient reports feeling sad most days for the past month, has stopped enjoying social activities and is having difficulty sleeping. Academic workload has increased significantly."
Expected qualitative analysis should identify:
```text
persistent sadness
reduced interest/social withdrawal
sleep difficulty
academic stress
approximately one month duration
```
It should NOT output a fabricated diagnostic probability.
## Conversational mode example
User:
> "I've been feeling down lately."
Then:
> "It's been about three weeks and I barely sleep."
Then:
> "School has also been stressful."
The system should progressively update the conversation state and retrieve increasingly relevant evidence.
---
# 25. FINAL DESIGN PRINCIPLE
The most important architecture to preserve is:
```text
TWO INPUT MODES
β
ββββββββββββββ΄βββββββββββββ
β β
βΌ βΌ
PROFESSIONAL MODE CONVERSATION MODE
β β
Qualitative analysis Continuous understanding
β β
ββββββββββββββ¬βββββββββββββ
βΌ
SHARED CORE
β
βββββββββββΌββββββββββ
βΌ βΌ βΌ
Analysis RAG Safety
β
Embeddings
β
Vector search
β
βΌ
LLM
β
βββββββββββ΄ββββββββββ
βΌ βΌ
Professional output User response
```
Remember these principles throughout implementation:
1. **There are two distinct input modes.**
2. **Professional mode analyzes supplied patient/client text.**
3. **Conversational mode interacts continuously with the user.**
4. **The analysis is primarily qualitative, not a four-class probability prediction.**
5. **No questionnaire screening in this version.**
6. **RAG is shared infrastructure for both modes.**
7. **Knowledge documents are embedded and stored as vectors.**
8. **User/conversation information produces query embeddings for retrieval.**
9. **The user's actual text remains central; embeddings only facilitate retrieval.**
10. **Conversation state is maintained separately from the vector database.**
11. **Deterministic modules remain responsible for exact information.**
12. **Safety has its own explicit layer.**
13. **RAG provides evidence; it does not diagnose.**
14. **The LLM turns the analysis, context, evidence, and safety state into the appropriate output.**
Before implementing major changes, first inspect the repository and produce:
1. **Current architecture**
2. **Target architecture**
3. **Files/components that should be preserved**
4. **Files/components that should be changed**
5. **New components required**
6. **Implementation sequence**
Then proceed incrementally without unnecessarily destroying existing working functionality.
|