evaldoc 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/.env.staging.example +19 -0
  2. package/.firebaserc +6 -0
  3. package/.github/workflows/auto-merge-to-main.yml +28 -0
  4. package/.github/workflows/ci.yml +27 -0
  5. package/.github/workflows/npxhub-publish.yml +170 -0
  6. package/.prettierignore +4 -0
  7. package/.prettierrc.json +7 -0
  8. package/README.md +142 -0
  9. package/SRS.md +448 -0
  10. package/apphosting.staging.yaml +48 -0
  11. package/apphosting.yaml +50 -0
  12. package/bin/evaldoc.cjs +105 -0
  13. package/cors.json +8 -0
  14. package/docs/ARCHITECTURE.md +769 -0
  15. package/docs/ARCHITECTURE_SUMMARY.md +323 -0
  16. package/docs/DEPLOYMENT.md +86 -0
  17. package/docs/DEPLOYMENT_STEPS.md +373 -0
  18. package/docs/DEPLOY_FIRESTORE_RULES.md +239 -0
  19. package/docs/DEPLOY_STORAGE_RULES.md +82 -0
  20. package/docs/DOCTOR_TUTORIAL.md +467 -0
  21. package/docs/FIREBASE_STORAGE_CORS_FIX.md +131 -0
  22. package/docs/FIXES_APPLIED.md +128 -0
  23. package/docs/IMPLEMENTATION.md +498 -0
  24. package/docs/IMPLEMENTATION_COMPLETE.md +317 -0
  25. package/docs/LLM-SETUP.md +216 -0
  26. package/docs/MANUAL_TEST_GUIDE.md +327 -0
  27. package/docs/PATIENT_GUIDE.md +451 -0
  28. package/docs/PLATFORM_OVERVIEW.md +194 -0
  29. package/docs/QUICKSTART.md +252 -0
  30. package/docs/QUICK_REFERENCE.md +222 -0
  31. package/docs/READY_TO_TEST.md +383 -0
  32. package/docs/RUN.md +237 -0
  33. package/docs/START_TESTING.md +130 -0
  34. package/docs/STRIPE_CONNECT_SETUP.md +454 -0
  35. package/docs/SYSTEM_READY.md +345 -0
  36. package/docs/THREADS_IMPLEMENTATION_COMPLETE.md +431 -0
  37. package/docs/THREAD_IMPLEMENTATION_GUIDE.md +345 -0
  38. package/docs/firebasefiles.md +21 -0
  39. package/docs/homepage.md +1208 -0
  40. package/docs/payments.md +159 -0
  41. package/eslint.config.js +76 -0
  42. package/firebase.json +27 -0
  43. package/firestore.indexes.json +88 -0
  44. package/firestore.rules +125 -0
  45. package/functions/package-lock.json +2884 -0
  46. package/functions/package.json +20 -0
  47. package/functions/src/analytics.js +101 -0
  48. package/functions/src/audit.js +28 -0
  49. package/functions/src/auth.js +19 -0
  50. package/functions/src/drafts.js +128 -0
  51. package/functions/src/feedback.js +164 -0
  52. package/functions/src/firebase-init.js +29 -0
  53. package/functions/src/i18n.js +134 -0
  54. package/functions/src/limits.js +27 -0
  55. package/functions/src/llm.js +271 -0
  56. package/functions/src/ner.js +162 -0
  57. package/functions/src/notifications.js +273 -0
  58. package/functions/src/orgs.js +127 -0
  59. package/functions/src/patient-api.js +545 -0
  60. package/functions/src/payment.js +830 -0
  61. package/functions/src/safety.js +188 -0
  62. package/functions/src/stripe-config.js +33 -0
  63. package/functions/src/topics.js +94 -0
  64. package/functions/src/triage.js +191 -0
  65. package/functions/src/utils.js +28 -0
  66. package/functions/src/validate.js +177 -0
  67. package/functions/test-firebase.js +36 -0
  68. package/jest.config.js +18 -0
  69. package/package.json +52 -0
  70. package/public/404.html +93 -0
  71. package/public/app/analytics.html +336 -0
  72. package/public/app/analytics.js +177 -0
  73. package/public/app/app.css +1400 -0
  74. package/public/app/app.js +1754 -0
  75. package/public/app/config.js +14 -0
  76. package/public/app/inbox-threads.js +843 -0
  77. package/public/app/inbox.html +598 -0
  78. package/public/app/inbox.js +397 -0
  79. package/public/app/index.html +612 -0
  80. package/public/assets/logo.jpg +0 -0
  81. package/public/chat.html +137 -0
  82. package/public/css/chat.css +870 -0
  83. package/public/css/landing-enhance.css +298 -0
  84. package/public/css/styles.css +1198 -0
  85. package/public/favicon.svg +5 -0
  86. package/public/find-doctor.html +220 -0
  87. package/public/index.html +399 -0
  88. package/public/js/chat-threads.js +513 -0
  89. package/public/js/chat.js +832 -0
  90. package/public/js/search.js +41 -0
  91. package/public/privacy.html +101 -0
  92. package/public/robots.txt +6 -0
  93. package/public/site.webmanifest +12 -0
  94. package/public/terms.html +110 -0
  95. package/scripts/create-test-provider.js +55 -0
  96. package/scripts/deploy-staging.sh +51 -0
  97. package/scripts/fix-provider.js +39 -0
  98. package/scripts/quick-test.sh +37 -0
  99. package/scripts/test-chat.sh +54 -0
  100. package/scripts/test-multi-turn.js +137 -0
  101. package/scripts/test-ner-simple.js +28 -0
  102. package/scripts/test-ner.js +60 -0
  103. package/scripts/test-stripe-connect.js +304 -0
  104. package/scripts/test-webhook-secret.sh +24 -0
  105. package/server.js +3864 -0
  106. package/storage.rules +22 -0
  107. package/test-api.json +1 -0
  108. package/tests/emulator/README.md +38 -0
  109. package/tests/emulator/counters.emulator.test.js +81 -0
  110. package/tests/integration/api-account-selfserve.test.js +312 -0
  111. package/tests/integration/api-admin-digest.test.js +202 -0
  112. package/tests/integration/api-chat-satisfaction.test.js +259 -0
  113. package/tests/integration/api-doctor-drafts.test.js +236 -0
  114. package/tests/integration/api-doctor-inbox.test.js +401 -0
  115. package/tests/integration/api-org.test.js +328 -0
  116. package/tests/integration/api-payment.test.js +664 -0
  117. package/tests/integration/api-provider-settings.test.js +475 -0
  118. package/tests/integration/api-qr.test.js +121 -0
  119. package/tests/integration/api-security.test.js +241 -0
  120. package/tests/integration/api-stripe-search.test.js +303 -0
  121. package/tests/integration/api-webhook-deletion.test.js +231 -0
  122. package/tests/mocks/firebase-admin.js +220 -0
  123. package/tests/unit/analytics.test.js +151 -0
  124. package/tests/unit/audit-bugs.test.js +203 -0
  125. package/tests/unit/chat-ui-logic.test.js +283 -0
  126. package/tests/unit/drafts.test.js +104 -0
  127. package/tests/unit/feedback.test.js +148 -0
  128. package/tests/unit/i18n.test.js +229 -0
  129. package/tests/unit/llm-retry.test.js +122 -0
  130. package/tests/unit/notifications.test.js +155 -0
  131. package/tests/unit/orgs.test.js +328 -0
  132. package/tests/unit/payment.test.js +889 -0
  133. package/tests/unit/safety-edge-cases.test.js +509 -0
  134. package/tests/unit/safety-srs-compliance.test.js +252 -0
  135. package/tests/unit/safety.test.js +291 -0
  136. package/tests/unit/server-helpers.test.js +774 -0
  137. package/tests/unit/topics-limits.test.js +158 -0
  138. package/tests/unit/triage.test.js +152 -0
  139. package/tests/unit/validate.test.js +408 -0
@@ -0,0 +1,467 @@
1
+ # EvalDoc Doctor Tutorial Guide
2
+
3
+ ## 🎯 Welcome, Doctor!
4
+
5
+ This guide will help you get started with EvalDoc and make the most of the platform to serve your patients efficiently.
6
+
7
+ ---
8
+
9
+ ## 📋 Table of Contents
10
+
11
+ 1. [Getting Started](#getting-started)
12
+ 2. [Setting Up Your Profile](#setting-up-your-profile)
13
+ 3. [Sharing Your Link](#sharing-your-link)
14
+ 4. [Managing Your Inbox](#managing-your-inbox)
15
+ 5. [Understanding AI Responses](#understanding-ai-responses)
16
+ 6. [Replying to Patients](#replying-to-patients)
17
+ 7. [Analytics Dashboard](#analytics-dashboard)
18
+ 8. [Best Practices](#best-practices)
19
+ 9. [Troubleshooting](#troubleshooting)
20
+
21
+ ---
22
+
23
+ ## 1. Getting Started
24
+
25
+ ### Step 1: Sign Up
26
+
27
+ 1. Visit `https://evaldoctor.ai/app`
28
+ 2. Click **"Create Account"**
29
+ 3. Enter your email and create a password
30
+ 4. Click **"Create account"** button
31
+
32
+ ### Step 2: Sign In
33
+
34
+ 1. Enter your email and password
35
+ 2. Click **"Sign in"**
36
+ 3. You'll be taken to the onboarding screen
37
+
38
+ ---
39
+
40
+ ## 2. Setting Up Your Profile
41
+
42
+ ### Required Information
43
+
44
+ **Display Name**: Your professional name (e.g., "Dr. Sarah Amina")
45
+
46
+ **Specialty**: Your medical specialty (e.g., "Family Medicine", "Pediatrics")
47
+
48
+ **Country**: Your practice location (e.g., "United States", "United Kingdom", "Nigeria")
49
+
50
+ **Handle**: Your unique URL identifier (e.g., "dr-sarah-amina")
51
+ - This becomes your shareable link: `evaldoctor.ai/dr-sarah-amina`
52
+ - Must be unique across the platform
53
+ - Use only letters, numbers, and hyphens
54
+
55
+ ### Optional Branding
56
+
57
+ **Welcome Message**: Custom greeting for your patients
58
+ - Default: "Welcome. Choose a topic to get started."
59
+ - Example: "Hello! I'm Dr. Sarah. How can I help you today?"
60
+
61
+ **Brand Colors**:
62
+ - Primary Color: Main accent color (default: teal)
63
+ - Secondary Color: Secondary accent
64
+
65
+ **Logo**: Upload your practice logo (coming soon)
66
+
67
+ ### Topics Configuration
68
+
69
+ Select which topics your AI assistant can help with:
70
+
71
+ - ✅ **Medication Information & Safety**: Questions about medications
72
+ - ✅ **Appointments & Preparation**: Scheduling and prep info
73
+ - ✅ **General Health Information**: Basic health education
74
+ - ✅ **Clinic Services & Hours**: Your practice information
75
+ - ✅ **Insurance & Billing FAQ**: Payment and insurance questions
76
+ - ✅ **Post-Procedure Guidance**: Recovery instructions
77
+
78
+ **Tip**: Start with all topics enabled, then refine based on your practice needs.
79
+
80
+ ### Profile Status
81
+
82
+ - **Draft**: Your profile is not public yet
83
+ - **Published**: Your link is active and patients can chat
84
+ - **Suspended**: Temporarily disabled
85
+
86
+ **Remember to set status to "Published" when ready!**
87
+
88
+ ---
89
+
90
+ ## 3. Sharing Your Link
91
+
92
+ ### Your Unique Link
93
+
94
+ Once published, your link is:
95
+ ```
96
+ https://evaldoctor.ai/your-handle
97
+ ```
98
+
99
+ Example: `https://evaldoctor.ai/dr-sarah-amina`
100
+
101
+ ### Ways to Share
102
+
103
+ #### 1. **WhatsApp**
104
+ ```
105
+ Hi [Patient Name],
106
+
107
+ You can now chat with my AI assistant 24/7 for quick health questions:
108
+ https://evaldoctor.ai/dr-sarah-amina
109
+
110
+ I review all conversations and will step in when needed.
111
+
112
+ - Dr. Sarah
113
+ ```
114
+
115
+ #### 2. **SMS**
116
+ ```
117
+ Your doctor is now available 24/7 via AI assistant: evaldoctor.ai/dr-sarah-amina
118
+ Dr. Sarah monitors all chats.
119
+ ```
120
+
121
+ #### 3. **QR Code** (Coming Soon)
122
+ - Download QR code from your dashboard
123
+ - Print on business cards
124
+ - Display in clinic waiting room
125
+ - Add to appointment reminder cards
126
+
127
+ #### 4. **Email Signature**
128
+ ```
129
+ Dr. Sarah Amina, MD
130
+ Family Medicine
131
+ 📱 Chat 24/7: evaldoctor.ai/dr-sarah-amina
132
+ ```
133
+
134
+ #### 5. **Social Media**
135
+ - Add to Facebook/Twitter bio
136
+ - Share in patient groups
137
+ - Post on clinic social media
138
+
139
+ ---
140
+
141
+ ## 4. Managing Your Inbox
142
+
143
+ ### Accessing Your Inbox
144
+
145
+ 1. Sign in at `https://evaldoctor.ai/app`
146
+ 2. Click **"Inbox"** in the navigation menu
147
+ 3. You'll see all patient conversations
148
+
149
+ ### Inbox Layout
150
+
151
+ #### Left Sidebar: Conversation List
152
+ - **Green name**: Patient identifier (name, email, or session)
153
+ - **Gray text**: Last message preview
154
+ - **Time**: How long ago (e.g., "2h ago", "3d ago")
155
+ - **Badge**: "⚠️ Escalated" for urgent cases
156
+
157
+ #### Right Panel: Conversation Detail
158
+ - **Patient Info**: Name, email, phone (if provided)
159
+ - **Message Count**: Number of messages in conversation
160
+ - **Timestamp**: When conversation started
161
+ - **Messages**: Full conversation history
162
+
163
+ ### Filtering Conversations
164
+
165
+ Use the filter buttons at the top:
166
+
167
+ - **All**: Show all conversations
168
+ - **Escalated**: Only urgent cases flagged by AI
169
+ - **Today**: Conversations from today
170
+ - **This Week**: Last 7 days
171
+
172
+ ### Understanding Message Types
173
+
174
+ - **👤 PATIENT**: Message from the patient
175
+ - **🤖 AI ASSISTANT**: Response from the AI
176
+ - **👨‍⚕️ YOU**: Your manual response (coming soon)
177
+
178
+ ### Color Coding
179
+
180
+ - **Light Green Background**: Patient messages
181
+ - **Gray Background**: AI responses
182
+ - **Dark Green Background**: Your manual replies
183
+
184
+ ---
185
+
186
+ ## 5. Understanding AI Responses
187
+
188
+ ### What the AI Does
189
+
190
+ ✅ **Educational Information**
191
+ - Explains medical concepts in simple terms
192
+ - Provides general health guidance
193
+ - Suggests when to seek care
194
+
195
+ ✅ **Red Flag Detection**
196
+ - Identifies serious symptoms
197
+ - Escalates urgent cases
198
+ - Notifies you immediately
199
+
200
+ ✅ **Safe Boundaries**
201
+ - Never diagnoses conditions
202
+ - Never prescribes medications
203
+ - Always includes disclaimers
204
+
205
+ ### AI Response Quality
206
+
207
+ **Primary AI**: DeepSeek (better medical accuracy)
208
+ **Fallback AI**: Google Gemini (if DeepSeek fails)
209
+
210
+ The AI has been trained to:
211
+ - Use simple, patient-friendly language
212
+ - Be empathetic and supportive
213
+ - Err on the side of caution
214
+ - Encourage professional consultation
215
+
216
+ ### When AI Escalates
217
+
218
+ The AI flags conversations when it detects:
219
+ - Chest pain or pressure
220
+ - Difficulty breathing
221
+ - Severe bleeding
222
+ - Loss of consciousness
223
+ - Suicidal thoughts
224
+ - Severe pain (8-10/10)
225
+ - Allergic reactions
226
+
227
+ **You'll see**: ⚠️ URGENT badge on the conversation
228
+
229
+ ### Example Conversations
230
+
231
+ **Good AI Response:**
232
+ ```
233
+ Patient: "What should I do about my child's fever?"
234
+
235
+ AI: "For a child with fever:
236
+ - Monitor temperature regularly
237
+ - Keep them hydrated
238
+ - Use a cool compress
239
+ - Give them rest
240
+
241
+ ⚠️ Seek immediate care if:
242
+ - Fever over 38.5°C (101.3°F)
243
+ - Lasts more than 3 days
244
+ - Child is very sleepy or irritable
245
+ - Has trouble breathing
246
+
247
+ This is educational information. For medication advice,
248
+ please contact Dr. Sarah directly."
249
+ ```
250
+
251
+ **AI Escalation:**
252
+ ```
253
+ Patient: "I have severe chest pain"
254
+
255
+ AI: "🚨 URGENT: Chest pain requires immediate medical attention.
256
+
257
+ Please:
258
+ 1. Call emergency services NOW
259
+ 2. Do NOT wait
260
+ 3. This could be serious
261
+
262
+ Dr. Sarah has been notified of this urgent message.
263
+
264
+ ⚠️ This is a medical emergency. Go to the nearest
265
+ hospital or call emergency services immediately."
266
+ ```
267
+
268
+ ---
269
+
270
+ ## 6. Replying to Patients (Coming Soon)
271
+
272
+ ### When to Reply Manually
273
+
274
+ - AI has escalated the conversation
275
+ - Patient asks a specific question about your practice
276
+ - You need to provide personalized medical advice
277
+ - Patient requests an appointment
278
+ - Follow-up on a recent visit
279
+
280
+ ### How to Reply
281
+
282
+ 1. Open the conversation in your inbox
283
+ 2. Scroll to the bottom
284
+ 3. Type your message in the reply box
285
+ 4. Click **"Send Reply"**
286
+
287
+ Your reply will:
288
+ - Show as "👨‍⚕️ YOU" in the conversation
289
+ - Be marked with dark green background
290
+ - Override AI for this conversation
291
+ - Notify the patient (future feature)
292
+
293
+ ### Reply Best Practices
294
+
295
+ ✅ **Be Clear**: Use simple language
296
+ ✅ **Be Prompt**: Reply to urgent cases within 1 hour
297
+ ✅ **Be Professional**: Maintain doctor-patient boundaries
298
+ ✅ **Document**: Treat as part of medical record
299
+
300
+ ❌ **Don't**: Give detailed diagnoses via chat
301
+ ❌ **Don't**: Prescribe without proper consultation
302
+ ❌ **Don't**: Share sensitive info without verification
303
+
304
+ ---
305
+
306
+ ## 7. Analytics Dashboard
307
+
308
+ ### Accessing Analytics
309
+
310
+ 1. Sign in at `https://evaldoctor.ai/app`
311
+ 2. Click **"Analytics"** in the navigation
312
+
313
+ ### Key Metrics
314
+
315
+ #### Summary Cards
316
+
317
+ **Total Doctors**: Number of providers on platform
318
+ **Active Doctors**: Published profiles
319
+ **Total Conversations**: All chat sessions
320
+ **Unique Patients**: Individual users served
321
+
322
+ #### Doctor Performance Table
323
+
324
+ View detailed stats:
325
+ - **Conversations**: Total chat sessions
326
+ - **Unique Patients**: Different users
327
+ - **Messages**: Total message count
328
+ - **Join Date**: When you signed up
329
+
330
+ ### Time Filters
331
+
332
+ - All Time
333
+ - Today
334
+ - This Week
335
+ - This Month
336
+ - This Quarter
337
+
338
+ ### Using Analytics
339
+
340
+ **Monitor Growth**: Track patient engagement
341
+ **Identify Patterns**: See peak usage times
342
+ **Measure Impact**: Conversations handled by AI
343
+ **Plan Capacity**: Anticipate when manual replies needed
344
+
345
+ ---
346
+
347
+ ## 8. Best Practices
348
+
349
+ ### Setting Up
350
+
351
+ ✅ Complete your full profile
352
+ ✅ Upload a professional photo (coming soon)
353
+ ✅ Write a warm welcome message
354
+ ✅ Enable relevant topics for your practice
355
+ ✅ Set status to "Published"
356
+
357
+ ### Sharing Your Link
358
+
359
+ ✅ Add to all patient touchpoints
360
+ ✅ Include in appointment reminders
361
+ ✅ Mention during consultations
362
+ ✅ Share on social media
363
+ ✅ Print on business cards
364
+
365
+ ### Managing Conversations
366
+
367
+ ✅ Check inbox daily (at least once)
368
+ ✅ Respond to escalated cases within 1 hour
369
+ ✅ Review AI responses periodically
370
+ ✅ Reply manually when needed
371
+ ✅ Document significant conversations
372
+
373
+ ### Patient Communication
374
+
375
+ ✅ Set expectations: "AI handles routine, I handle medicine"
376
+ ✅ Clarify: "This is for education, not diagnosis"
377
+ ✅ Encourage: "I review all conversations"
378
+ ✅ Reassure: "I'm here when you need me"
379
+
380
+ ### Safety & Compliance
381
+
382
+ ✅ Treat chats as part of medical records
383
+ ✅ Follow local telemedicine regulations
384
+ ✅ Maintain patient confidentiality
385
+ ✅ Document any medical advice given
386
+ ✅ Don't diagnose or prescribe via chat without proper consultation
387
+
388
+ ---
389
+
390
+ ## 9. Troubleshooting
391
+
392
+ ### Common Issues
393
+
394
+ #### "My link doesn't work"
395
+ - Check profile status is "Published"
396
+ - Verify handle is correct (no spaces)
397
+ - Try opening in incognito/private browsing
398
+
399
+ #### "I'm not receiving conversations"
400
+ - Confirm patients are using correct link
401
+ - Check internet connection
402
+ - Sign out and sign in again
403
+ - Clear browser cache
404
+
405
+ #### "AI is giving poor responses"
406
+ - Review which topics are enabled
407
+ - Consider adjusting enabled topics
408
+ - Contact support if issues persist
409
+
410
+ #### "Can't access inbox"
411
+ - Ensure you're signed in
412
+ - Try refreshing the page
413
+ - Clear browser cookies
414
+ - Use Chrome/Firefox/Safari
415
+
416
+ #### "Analytics not loading"
417
+ - Check internet connection
418
+ - Try different time filter
419
+ - Refresh the page
420
+ - Contact support if persists
421
+
422
+ ### Getting Help
423
+
424
+ **Email Support**: helpme@evaldoctor.ai
425
+
426
+ **Include in Your Message**:
427
+ - Your doctor handle
428
+ - Description of issue
429
+ - Screenshots (if applicable)
430
+ - Browser and device info
431
+
432
+ **Response Time**: Within 24 hours
433
+
434
+ ---
435
+
436
+ ## 🎓 Quick Start Checklist
437
+
438
+ Use this checklist to get started quickly:
439
+
440
+ - [ ] Sign up for account
441
+ - [ ] Complete profile information
442
+ - [ ] Set handle (your custom URL)
443
+ - [ ] Write welcome message
444
+ - [ ] Enable topics
445
+ - [ ] Set status to "Published"
446
+ - [ ] Copy your unique link
447
+ - [ ] Share link with first 10 patients
448
+ - [ ] Check inbox daily
449
+ - [ ] Review first conversations
450
+ - [ ] Adjust settings as needed
451
+
452
+ ---
453
+
454
+ ## 📞 Need Help?
455
+
456
+ - **Support Email**: helpme@evaldoctor.ai
457
+ - **Website**: evaldoctor.ai
458
+ - **Documentation**: Check this guide regularly for updates
459
+
460
+ ---
461
+
462
+ **Welcome to EvalDoc! We're excited to help you serve your patients more efficiently.** 🎉
463
+
464
+ ---
465
+
466
+ *Last Updated: January 2026*
467
+ *Version: 1.0*
@@ -0,0 +1,131 @@
1
+ # Firebase Storage CORS Configuration Fix
2
+
3
+ ## Issue
4
+ File uploads to Firebase Storage are failing with CORS errors when running on `http://localhost:8080`.
5
+
6
+ ## Error Message
7
+ ```
8
+ Access to XMLHttpRequest at 'https://firebasestorage.googleapis.com/...' from origin 'http://localhost:8080'
9
+ has been blocked by CORS policy: Response to preflight request doesn't pass access control check
10
+ ```
11
+
12
+ ## Solution
13
+
14
+ ### Option 1: Using Google Cloud Console (Recommended)
15
+
16
+ 1. **Install Google Cloud SDK** (if not already installed)
17
+ ```bash
18
+ # macOS (using Homebrew)
19
+ brew install google-cloud-sdk
20
+
21
+ # Or download from: https://cloud.google.com/sdk/docs/install
22
+ ```
23
+
24
+ 2. **Authenticate with Google Cloud**
25
+ ```bash
26
+ gcloud auth login
27
+ ```
28
+
29
+ 3. **Set your project**
30
+ ```bash
31
+ gcloud config set project evaldocplatform
32
+ ```
33
+
34
+ 4. **Apply CORS configuration**
35
+ ```bash
36
+ gsutil cors set cors.json gs://evaldocplatform.firebasestorage.app
37
+ ```
38
+
39
+ 5. **Verify CORS configuration**
40
+ ```bash
41
+ gsutil cors get gs://evaldocplatform.firebasestorage.app
42
+ ```
43
+
44
+ ### Option 2: Using Firebase Console
45
+
46
+ 1. Go to [Firebase Console](https://console.firebase.google.com/)
47
+ 2. Select your project: **evaldocplatform**
48
+ 3. Go to **Storage** in the left sidebar
49
+ 4. Click on the **Rules** tab
50
+ 5. Update your storage rules to be more permissive (temporary fix for development):
51
+
52
+ ```javascript
53
+ rules_version = '2';
54
+ service firebase.storage {
55
+ match /b/{bucket}/o {
56
+ match /certificates/{userId}/{allPaths=**} {
57
+ // Allow authenticated users to upload their own certificates
58
+ allow write: if request.auth != null && request.auth.uid == userId;
59
+ // Allow read for authenticated users (for verification)
60
+ allow read: if request.auth != null;
61
+ }
62
+
63
+ match /{allPaths=**} {
64
+ allow read, write: if request.auth != null;
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ### Option 3: Alternative Upload Strategy (Quick Fix)
71
+
72
+ Instead of uploading directly from the browser, we can upload via the backend server:
73
+
74
+ **Update**: This would require backend changes and is more complex. Stick with Option 1 or 2.
75
+
76
+ ## Testing After Fix
77
+
78
+ 1. Restart your local development server:
79
+ ```bash
80
+ # Kill existing server if running
81
+ pkill -f "node server.js"
82
+
83
+ # Start server
84
+ node server.js
85
+ ```
86
+
87
+ 2. Clear browser cache and try uploading a certificate again
88
+
89
+ 3. Check browser console for any remaining errors
90
+
91
+ ## CORS Configuration File (cors.json)
92
+
93
+ The `cors.json` file has been created with the following configuration:
94
+
95
+ ```json
96
+ [
97
+ {
98
+ "origin": ["*"],
99
+ "method": ["GET", "POST", "PUT", "DELETE", "HEAD"],
100
+ "maxAgeSeconds": 3600,
101
+ "responseHeader": ["Content-Type", "Authorization"]
102
+ }
103
+ ]
104
+ ```
105
+
106
+ **Note**: Using `"origin": ["*"]` allows all origins. For production, you should restrict this to your actual domains:
107
+
108
+ ```json
109
+ [
110
+ {
111
+ "origin": ["http://localhost:8080", "https://evaldoctor.ai", "https://yourdomain.com"],
112
+ "method": ["GET", "POST", "PUT", "DELETE", "HEAD"],
113
+ "maxAgeSeconds": 3600,
114
+ "responseHeader": ["Content-Type", "Authorization"]
115
+ }
116
+ ]
117
+ ```
118
+
119
+ ## Recommended Approach
120
+
121
+ **For now (development)**: Use Option 1 with wildcard origin to unblock development.
122
+
123
+ **For production**:
124
+ 1. Apply CORS with specific domain origins
125
+ 2. Ensure Firebase Storage Rules are properly configured for security
126
+ 3. Add file size limits and file type validation in storage rules
127
+
128
+ ## Additional Notes
129
+
130
+ - The "Unable to load provider" error in the console is expected for new users who haven't created a provider profile yet. It's caught and handled properly.
131
+ - The CORS error is the main blocker for file uploads.
@@ -0,0 +1,128 @@
1
+ # Fixes Applied - EvalDoc
2
+
3
+ ## Issues Fixed
4
+
5
+ ### 1. ✅ Firebase Storage CORS Error
6
+
7
+ **Problem:**
8
+ ```
9
+ Access to XMLHttpRequest at 'https://firebasestorage.googleapis.com/...' from origin 'http://localhost:8080'
10
+ has been blocked by CORS policy
11
+ ```
12
+
13
+ **Solution Applied:**
14
+ - Created `cors.json` with permissive CORS configuration
15
+ - Applied CORS configuration using: `gsutil cors set cors.json gs://evaldocplatform.firebasestorage.app`
16
+ - Verified configuration: CORS is now properly set to allow all origins (*)
17
+
18
+ **Files Created:**
19
+ - `cors.json` - CORS configuration file
20
+ - `storage.rules` - Firebase Storage security rules (5MB limit, PDF/images only)
21
+ - `firebase.json` - Updated to include storage rules reference
22
+
23
+ ### 2. ✅ "Unable to load provider" Error
24
+
25
+ **Problem:**
26
+ ```
27
+ Error in checkOnboarding: Error: Unable to load provider
28
+ ```
29
+
30
+ **Analysis:**
31
+ - This error is **expected behavior** for new users who haven't created a provider profile yet
32
+ - The error is properly caught and handled in `app.js` (lines 263-269)
33
+ - When the error occurs, the app correctly shows the onboarding form
34
+ - **No fix needed** - this is working as intended
35
+
36
+ **How it works:**
37
+ 1. New user signs up → No provider profile exists
38
+ 2. `/api/me` returns 404 → `loadProvider()` returns `null`
39
+ 3. If any other error occurs → Caught by try/catch block
40
+ 4. User is shown onboarding form to create provider profile
41
+
42
+ ### 3. ✅ Theme Updated with Feyti Medical Group Colors
43
+
44
+ **Changes:**
45
+ - Homepage (`/public/index.html` + `/public/css/styles.css`)
46
+ - Updated to Feyti green (#297B56) and off-white (#FBFBFB)
47
+ - Changed font from Space Grotesk to Inter
48
+ - Added complete company information in footer
49
+
50
+ - Provider Console (`/public/app/` files)
51
+ - Updated `app.css` with Feyti Medical Group theme
52
+ - Changed font to Inter to match homepage
53
+ - All buttons, links, and interactive elements use green theme
54
+
55
+ ## Next Steps for Testing
56
+
57
+ 1. **Test the file upload now:**
58
+ ```bash
59
+ # The server should already be running on port 8080
60
+ # If not, start it:
61
+ node server.js
62
+ ```
63
+
64
+ 2. **Register a new doctor:**
65
+ - Go to http://localhost:8080/app
66
+ - Create a new account
67
+ - Fill in the onboarding form
68
+ - Upload a test certificate (PDF or image, under 5MB)
69
+ - Submit the form
70
+
71
+ 3. **What should happen:**
72
+ - ✅ File uploads without CORS error
73
+ - ✅ Provider profile is created in Firestore
74
+ - ✅ Certificate is stored in Firebase Storage under `certificates/{userId}/`
75
+ - ✅ Dashboard loads with provider information
76
+
77
+ ## Firebase Storage Security
78
+
79
+ The storage rules now enforce:
80
+ - ✅ Only authenticated users can upload
81
+ - ✅ Users can only upload to their own `certificates/{userId}/` folder
82
+ - ✅ Maximum file size: 5MB
83
+ - ✅ Only PDF and image files are allowed
84
+ - ✅ Any authenticated user can read (for admin verification purposes)
85
+
86
+ ## For Production Deployment
87
+
88
+ When deploying to production, update `cors.json` to restrict origins:
89
+
90
+ ```json
91
+ [
92
+ {
93
+ "origin": ["https://evaldoctor.ai", "https://yourdomain.com"],
94
+ "method": ["GET", "POST", "PUT", "DELETE", "HEAD"],
95
+ "maxAgeSeconds": 3600,
96
+ "responseHeader": ["Content-Type", "Authorization"]
97
+ }
98
+ ]
99
+ ```
100
+
101
+ Then reapply:
102
+ ```bash
103
+ gsutil cors set cors.json gs://evaldocplatform.firebasestorage.app
104
+ ```
105
+
106
+ ## Files Modified/Created
107
+
108
+ ### Created:
109
+ - `cors.json`
110
+ - `storage.rules`
111
+ - `FIREBASE_STORAGE_CORS_FIX.md`
112
+ - `FIXES_APPLIED.md` (this file)
113
+
114
+ ### Modified:
115
+ - `firebase.json` (added storage rules reference)
116
+ - `public/css/styles.css` (Feyti theme)
117
+ - `public/index.html` (Feyti theme + company info)
118
+ - `public/app/app.css` (Feyti theme)
119
+ - `public/app/index.html` (Inter font)
120
+
121
+ ## Summary
122
+
123
+ ✅ CORS issue is fixed - file uploads should work now
124
+ ✅ Theme is updated across the entire app
125
+ ✅ Firebase Storage security rules are in place
126
+ ✅ "Unable to load provider" is expected behavior, not a bug
127
+
128
+ **You can now test the provider registration flow!**