File size: 9,446 Bytes
d1f3f31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# βœ… GETTING STARTED CHECKLIST

Use this checklist to ensure everything is working properly.

---

## 🟒 PHASE 1: Environment Setup (5 minutes)

### Step 1: Verify Python Installation
- [ ] Open PowerShell in project root
- [ ] Run: `.venv\Scripts\python.exe --version`
- [ ] Expected: Python 3.11+ (e.g., Python 3.11.0)
- [ ] If fails: Install Python or activate venv

### Step 2: Check Dependencies
- [ ] Run: `python test_system.py`
- [ ] Look for: βœ… "ALL TESTS COMPLETED SUCCESSFULLY!"
- [ ] Check: spaCy model loaded
- [ ] Check: Whisper model loaded
- [ ] If fails: Run `pip install -r requirements.txt` then `python -m spacy download en_core_web_sm`

### Step 3: Verify Node.js (for Frontend)
- [ ] Open new PowerShell window
- [ ] Run: `node --version`
- [ ] Expected: v18+ (e.g., v22.11.0)
- [ ] Run: `npm --version`
- [ ] Expected: 10+ (e.g., 10.9.0)
- [ ] If fails: Download from https://nodejs.org/

### Step 4: Check Frontend Dependencies
- [ ] Navigate: `cd frontend`
- [ ] Run: `npm install` (only if node_modules missing)
- [ ] Should complete within 2 minutes
- [ ] If fails: Check npm/node installation

---

## 🟑 PHASE 2: Start Services (3 minutes)

### Option A: Automated Startup (Easiest)
- [ ] In project root, double-click: `START.bat`
- [ ] Watch three windows open
- [ ] Wait 10-15 seconds for models to load
- [ ] All three should show "running" or "ready"

### Option B: Manual Startup (Full Control)

#### Window 1 - Backend API
- [ ] Open PowerShell in project root
- [ ] Run: `.venv\Scripts\python.exe -m uvicorn src.api.server:app --reload --port 8000`
- [ ] Wait for: **"Application startup complete"**
- [ ] Keep window open

#### Window 2 - Frontend Dev Server
- [ ] Open new PowerShell
- [ ] Navigate: `cd frontend`
- [ ] Run: `npm run dev`
- [ ] Wait for: **"Local: http://localhost:5173"**
- [ ] Keep window open

#### Window 3 - Browser
- [ ] Open Web Browser
- [ ] Navigate to: `http://localhost:5173`
- [ ] You should see the sentiment analysis UI

---

## 🟒 PHASE 3: Verify Backend (2 minutes)

### Test 1: Health Check
- [ ] Open browser and go to: `http://localhost:8000/health`
- [ ] Expected response:
  ```json
  {"status": "ok", "spacy_model": "...", "whisper_model": "small", "whisper_device": "cpu"}
  ```
- [ ] βœ… If you see this, backend is working

### Test 2: Simple Text Analysis
- [ ] Open New PowerShell Window
- [ ] Run:
  ```powershell
  $body = @{text="The camera is great but battery is bad"}
  Invoke-RestMethod -Uri "http://localhost:8000/api/analyze" -Method Post -Body $body
  ```
- [ ] Expected: JSON response with "products" array
- [ ] Check: Products include "camera" and "battery"
- [ ] βœ… If successful, API is working

### Test 3: Using Test Client
- [ ] Open: `test_client.html` (in project root)
- [ ] In browser: Type text in textarea
- [ ] Click: "Analyze" button
- [ ] Watch: Real-time results panel
- [ ] Expected: Products extracted with sentiment scores
- [ ] βœ… If working, API integration is good

---

## πŸ”΅ PHASE 4: Test Frontend UI (5 minutes)

### Test 1: Text Input
- [ ] Frontend should be open at `http://localhost:5173`
- [ ] Click: Text area in "Input" section
- [ ] Type: `"The product is excellent but shipping took forever"`
- [ ] Click: "Analyze" button
- [ ] Wait: For processing to complete
- [ ] Expected: 
  - [ ] Results show in right panel
  - [ ] "product" sentiment appears correct
  - [ ] "shipping" sentiment appears negative
- [ ] βœ… Text input working

### Test 2: Pipeline Visualization
- [ ] Check the pipeline shows steps:
  - [ ] βœ“ Uploading
  - [ ] βœ“ Speech-to-text (skipped for text)
  - [ ] βœ“ NLP extraction
  - [ ] βœ“ Sentiment analysis
- [ ] Each should show "completed" status
- [ ] βœ… Pipeline display working

### Test 3: Results Display
- [ ] Results panel should show:
  - [ ] Sentiment gauge (circular)
  - [ ] Positive/Neutral/Negative breakdown
  - [ ] Product table with items
- [ ] Click: On a product item
- [ ] Expected: Highlights to appear in transcript
- [ ] βœ… Results display working

### Test 4: Audio Input (Optional)
- [ ] Click: "Input Type" dropdown
- [ ] Select: "Audio File"
- [ ] File selector appears
- [ ] Choose: Any .wav or .mp3 file
- [ ] Click: "Analyze"
- [ ] Wait: 3-10 seconds (longer for audio)
- [ ] Expected: Same results as text
- [ ] βœ… Audio processing working

---

## 🟒 PHASE 5: Verify Results Accuracy (3 minutes)

### Sample Test Case 1
```
Input: "The camera quality is stunning with sharp details. 
        Battery drains quickly though. Performance is excellent."

Expected Results:
- camera: POSITIVE (score > 0.7)
- battery: NEGATIVE (score < -0.5)
- performance: POSITIVE (score > 0.7)
- Positive%: 67%
- Negative%: 33%
```

### Sample Test Case 2
```
Input: "Excellent customer service but product is fragile"

Expected Results:
- customer service: POSITIVE
- product: NEGATIVE (due to "fragile")
- Positive%: 50%
- Negative%: 50%
```

### Sample Test Case 3
```
Input: "The device works fine"

Expected Results:
- device: NEUTRAL or slightly POSITIVE
- Mostly NEUTRAL or balanced sentiment
```

---

## πŸ”΄ PHASE 6: Troubleshooting (If Something Fails)

### Problem: "API Connection Refused"
**Solution:**
1. Check backend window is running
2. Verify no other app uses port 8000
3. Restart backend:
   ```powershell
   .venv\Scripts\python.exe -m uvicorn src.api.server:app --reload --port 8000
   ```
4. Try health check: `http://localhost:8000/health`

### Problem: "Frontend Won't Load"
**Solution:**
1. Check frontend window is running
2. Verify no other app uses port 5173
3. Look for errors in terminal
4. Restart frontend:
   ```powershell
   cd frontend && npm run dev
   ```

### Problem: "spaCy Model Not Found"
**Solution:**
```powershell
python -m spacy download en_core_web_sm
```

### Problem: "Whisper Model Download Stuck"
**Solution:**
1. Press Ctrl+C to cancel
2. Ensure internet connection works
3. Try again:
   ```powershell
   python -c "import whisper; whisper.load_model('small')"
   ```

### Problem: "No Products Extracted"
**Try:**
- Longer input text (5+ sentences)
- More descriptive text (mention actual products)
- Use English language
- Example: "The phone camera is good and display is bright"

### Problem: "Sentiment Scores Seem Wrong"
**Check:**
1. Are the products actually mentioned? (algorithm extracts nouns)
2. Is there adjective context? ("amazing camera" vs just "camera")
3. Try more obvious sentiment: "Absolutely terrible" vs "not great"
4. Context window might be isolating different phrase

---

## 🟒 FINAL VERIFICATION CHECKLIST

When everything is working:

- [ ] Backend console shows no error messages
- [ ] Frontend console (F12) shows no red errors
- [ ] `http://localhost:8000/health` returns 200 OK
- [ ] `http://localhost:5173` loads the UI
- [ ] Test input produces sentiment scores
- [ ] Products are correctly extracted
- [ ] Sentiment labels match your expectations
- [ ] Export buttons work (JSON/PDF)
- [ ] No crashes or freezing

---

## 🎯 Quick Restart (If Something Breaks)

### Complete Restart
1. Close all PowerShell windows
2. Close browser tabs
3. Run `START.bat` again
4. Or manually restart both terminals

### Clean Test Run
```powershell
# In project root
python test_system.py  # Should pass all tests
```

### Verify Again
```powershell
# Check health
curl http://localhost:8000/health

# Try test API request
$body = @{text="Test input"}
Invoke-RestMethod -Uri "http://localhost:8000/api/analyze" -Method Post -Body $body
```

---

## πŸŽ‰ Success Indicators

You'll know everything is working when:

1. βœ… Browser shows the sentiment analysis dashboard
2. βœ… You can type text and see results in < 1 second
3. βœ… Products are extracted from your input
4. βœ… Sentiment is labeled (positive/negative/neutral)
5. βœ… Confidence scores appear (0-1 range)
6. βœ… No error messages in any console
7. βœ… Tests pass when you run `python test_system.py`

---

## πŸ“š Using the System

### Basic Workflow
1. **Paste Text** or **Upload Audio** in the input section
2. **Click Analyze** button
3. **Watch** the real-time pipeline
4. **View Results** in the dashboard
5. **Export** as JSON or PDF if needed

### Advanced Features
- Multi-language support (select language before upload)
- Audio transcription (Whisper)
- Confidence scoring
- Context highlighting
- Product deduplication
- Trend analysis

---

## πŸ“ˆ Next Steps

### Short-term
- [ ] Test with your own data
- [ ] Try different languages
- [ ] Test with audio files
- [ ] Export results

### Medium-term
- [ ] Add more test cases
- [ ] Customize product categories
- [ ] Adjust sentiment thresholds
- [ ] Build integrations

### Long-term
- [ ] Deploy to production
- [ ] Add database for history
- [ ] Build API clients (Python, JavaScript, etc.)
- [ ] Create dashboard for analytics

---

## πŸ“ž Support

**If you get stuck:**

1. Read the SYSTEM_GUIDE.md
2. Check API_DOCUMENTATION.md
3. Run: `python test_system.py`
4. Review terminal output for error messages
5. Check test_client.html for manual API testing

---

## βœ… Verification Summary

```
Phase 1 (Environment):  ⏳ β†’ βœ…
Phase 2 (Services):     ⏳ β†’ βœ…
Phase 3 (Backend):      ⏳ β†’ βœ…
Phase 4 (Frontend):     ⏳ β†’ βœ…
Phase 5 (Accuracy):     ⏳ β†’ βœ…
Phase 6 (Crisis):       N/A (hopefully!)

Overall Status: 🟒 READY
```

---

**Checklist Version:** 1.0
**Last Updated:** April 13, 2026
**Status:** Production Ready