Entity Review Summary - Complete Data Model Standardization
Overview
This document summarizes the comprehensive review and standardization of all data models across the Toto ecosystem. The goal was to establish a single source of truth for each entity that all applications can extend, rather than having disparate definitions.
Entities Reviewed
✅ 1. Cases
Status: Complete
Base Model: toto-docs/app/docs/architecture/case-base-model.ts
Key Changes:
- Removed
donationGoalandanimalTypefields - Added optional social media URLs (
instagramUrl,twitterUrl,facebookUrl) - Standardized status, priority, and category types
- Denormalized
guardianNameandguardianImageUrlremoved (fetch from users collection)
UI Connections:
- ✅ toto-app: Home screen (CaseCard), CaseChatModal, CaseFullScreenModal, GuardianDetailsModal
- ✅ toto-bo: Dashboard cases management, case creation/editing
Missing Fields in UI: None identified
✅ 2. Users
Status: Complete
Base Model: toto-docs/app/docs/architecture/user-base-model.ts
Key Changes:
- Removed
departmentfield - Standardized
lastActive(string),timeSinceJoined(number) - Made
address,rating,reviewsoptional - Added
updatedAt(required) - Made
firebaseUidoptional - Changed
contactInfoto optional object with phone - Standardized
socialLinksas typed object - Added stars rating system (
rating,reviewsCount,reviews)
UI Connections:
- ✅ toto-app: Profile screen, GuardianDetailsModal
- ✅ toto-bo: User management dashboard
Missing Fields in UI:
- ⚠️
ratingandreviewsnot displayed in UI (should be added to profile/guardian details)
✅ 3. Donations
Status: Complete
Base Model: toto-docs/app/docs/architecture/donation-base-model.ts
Key Changes:
- Removed Stellar-related fields (
originalAmount,convertedAmount,paymentProvider,partnerTransactionId) - Simplified to bank transfers only (
paymentMethod: 'bank_transfer') - Added
proofUrl(optional) for donation proof - Simplified status to
'pending' | 'verified' - Added
updatedAtandverifiedAttimestamps caseIdorguardianIdrequired (one of both)
UI Connections:
- ✅ toto-app: Profile screen (shows verified donations count)
- ✅ toto-bo: Donations management dashboard
Missing Fields in UI:
- ⚠️
proofUrlnot displayed/uploaded in UI (should be added for donation submission) - ⚠️
verifiedAtnot displayed in donation history
✅ 4. Follows
Status: Complete
Base Model: toto-docs/app/docs/architecture/follow-base-model.ts
Key Changes:
- Standardized on composite keys for IDs (
${userId}_${caseId}or${userId}_${guardianId}) - Added
notificationsEnabled: truedefault - Added
updatedAt(optional, set tocreatedAton creation) followTypeis array (currently['like'])caseIdorguardianIdrequired (one of both)
UI Connections:
- ✅ toto-app: CaseCard (like button), GuardianDetailsModal (follow button)
- ✅ toto-bo: Follows management (if exists)
Missing Fields in UI:
- ⚠️
notificationsEnabledtoggle not available in UI (should be added to settings)
✅ 5. Case Updates
Status: Complete
Base Model: toto-docs/app/docs/architecture/case-update-base-model.ts
Key Changes:
- Removed
typefield - Added
updatedAt(required) - Clarified that
status/previousStatustrack case status changes, not update status - Implemented Firebase Auth for
updatedByandupdatedByName
UI Connections:
- ✅ toto-app: CaseFullScreenModal (displays updates)
- ✅ toto-bo: Case updates management, API route with Firebase Auth
Missing Fields in UI: None identified
✅ 6. Conversations
Status: Complete
Base Model: toto-docs/app/docs/architecture/conversation-base-model.ts
Key Changes:
- Changed
isActive→isArchived(more explicit) - Added
updatedAtfield - Standardized timestamps to ISO 8601 strings
- Added
actionTakenas optional field - Removed
platformfrom messages (kept only at conversation level) - Always generate message IDs
UI Connections:
- ✅ toto-app: Inbox screen, CaseChatModal
- ❌ toto-bo: Not connected (conversations are mobile-app only)
Missing Fields in UI:
- ⚠️
actionTakennot displayed in conversation list (could show badges for donations/shares) - ⚠️
isArchivedtoggle not available in UI
✅ 7. Support Tickets
Status: Complete
Base Model: toto-docs/app/docs/architecture/support-ticket-base-model.ts
Key Changes:
- Fixed critical field name inconsistency:
requesterId→userId,requesterEmail→userEmail - Standardized collection name to
support_tickets(snake_case) - Made
userIdoptional (require at least one ofuserIdoruserEmail) - Added
caseIdandguardianIdoptional fields for related entities - Included
'cancelled'status in type definitions
UI Connections:
- ❌ toto-app: Not connected (support tickets are backoffice-only)
- ✅ toto-bo: Support hub dashboard, ticket management
Missing Fields in UI:
- ⚠️
caseIdandguardianIdnot displayed/selectable when creating tickets - ⚠️ Related case/guardian not shown in ticket details
⏭️ 8. Audit Logs
Status: Skipped (Backoffice Infrastructure) Reason: Audit logs are admin-only, backoffice infrastructure, not user-facing entities. They don't need cross-app standardization.
UI Connections:
- ❌ toto-app: Not connected (admin-only)
- ✅ toto-bo: Audit logs dashboard
Firestore Collections Structure
Active Collections (Used in Code)
Core Collections
-
users- User accounts and profiles- ✅ Used in: toto-app, toto-bo
- ✅ Rules defined in both apps
-
cases- Pet rescue cases- ✅ Used in: toto-app, toto-bo
- ✅ Rules defined in both apps
- Subcollection:
cases/{caseId}/updates
-
donations- Donation records- ✅ Used in: toto-app, toto-bo
- ✅ Rules defined in both apps
-
follows- User subscriptions (likes/follows)- ✅ Used in: toto-app, toto-bo
- ✅ Rules defined in both apps
-
updates- Case updates (top-level)- ✅ Used in: toto-app, toto-bo
- ✅ Rules defined in both apps
- Note: Also exists as subcollection
cases/{caseId}/updates
-
conversations- AI chat conversations- ✅ Used in: toto-app only
- ✅ Rules defined in toto-app
-
support_tickets- Support ticket management- ✅ Used in: toto-bo only
- ✅ Rules defined in both apps (for future mobile support)
-
notifications- User notifications- ✅ Used in: toto-app, toto-bo
- ✅ Rules defined in both apps
-
audit_logs- System audit trail- ✅ Used in: toto-bo only (admin-only)
- ✅ Rules defined in toto-bo
Twitter Bot Collections (Backoffice Only)
-
guardians- Guardian management (Twitter bot)- ✅ Used in: toto-bo only
- ✅ Rules defined in toto-bo
-
guardianTweets- Guardian tweets- ✅ Used in: toto-bo only
- ✅ Rules defined in toto-bo
-
twitterBotConfig- Twitter bot configuration- ✅ Used in: toto-bo only
- ✅ Rules defined in toto-bo
Other Collections
partners- Business partners- ✅ Used in: toto-app (read-only for marketing)
- ✅ Rules defined in toto-app
Potentially Unused Collections
Based on Firestore rules and codebase search, these collections may be unused:
-
waitlist- Mentioned in init script cleanup but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used in Cloud Functions or external services
-
analytics- Mentioned in init script but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used for analytics tracking
-
chats- Mentioned in init script but not in rules- ⚠️ Likely replaced by
conversations- can be removed - Action: Verify no legacy code references this
- ⚠️ Likely replaced by
-
analytics_cache- Mentioned in init script but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used for caching analytics data
-
accounts- Mentioned in init script but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used for account management
-
sessions- Mentioned in init script but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used for session management
-
verification_tokens- Mentioned in init script but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used for email verification
-
collaborators- Mentioned in init script but not in rules- ⚠️ Check if still needed or can be removed
- Action: Verify if used for collaboration features
Collections Used But Not in Rules
socialMediaPosts- Used in API routes but not in Firestore rules- ⚠️ Action Required: Add Firestore rules for this collection
- Location:
toto-bo/src/app/api/social-media/posts/route.ts
UI Connection Summary
Entities Connected to Both UIs
- ✅ Cases - toto-app (home, details) + toto-bo (management)
- ✅ Users - toto-app (profile) + toto-bo (management)
- ✅ Donations - toto-app (profile stats) + toto-bo (management)
- ✅ Follows - toto-app (like/follow buttons) + toto-bo (if exists)
- ✅ Case Updates - toto-app (case details) + toto-bo (management)
- ✅ Notifications - toto-app (inbox) + toto-bo (management)
Entities Connected to Single UI
- ✅ Conversations - toto-app only (inbox, chat)
- ✅ Support Tickets - toto-bo only (support hub)
- ✅ Audit Logs - toto-bo only (admin dashboard)
Critical Issues Found
⚠️ Field Name Inconsistency - FIXED
Donations: App Firestore rules used donorId but model uses userId
- Status: ✅ Fixed in
toto-app/firebase/firestore.rules - Impact: Rules now match the standardized model
Missing Fields in UI - Action Items
High Priority
-
Donations -
proofUrl- Where: toto-app donation flow
- Action: Add file upload for donation proof
- Impact: Required for donation verification
-
Support Tickets -
caseId/guardianId- Where: toto-bo ticket creation form
- Action: Add dropdown to link ticket to case/guardian
- Impact: Better ticket organization and tracking
-
Users -
ratingandreviews- Where: toto-app profile screen, GuardianDetailsModal
- Action: Display star rating and reviews
- Impact: User trust and transparency
Medium Priority
-
Follows -
notificationsEnabled- Where: toto-app settings or follow details
- Action: Add toggle to enable/disable notifications for follows
- Impact: Better user control
-
Conversations -
actionTaken- Where: toto-app inbox/conversation list
- Action: Show badges (e.g., "Donation Made", "Shared")
- Impact: Visual feedback on conversation outcomes
-
Conversations -
isArchived- Where: toto-app inbox
- Action: Add archive/unarchive functionality
- Impact: Better conversation management
-
Donations -
verifiedAt- Where: toto-app profile donation history
- Action: Display verification timestamp
- Impact: Transparency on verification status
Low Priority
- Support Tickets - Related case/guardian display
- Where: toto-bo ticket details view
- Action: Show linked case/guardian information
- Impact: Better context for ticket resolution
Next Steps
-
Clean Up Unused Collections
- Review and remove:
waitlist,analytics,chats,analytics_cache,accounts,sessions,verification_tokens,collaborators - Verify they're not used in Cloud Functions or other services
- Review and remove:
-
Implement Missing UI Fields
- Prioritize high-priority items (donation proof, ticket linking, user ratings)
- Add medium-priority features incrementally
- Document low-priority items for future consideration
-
Migration Script
- Create migration script to update existing Firestore documents to match new base models
- Test migration on staging before production
-
Documentation Updates
- Update API documentation with new field names
- Update developer guides with base model references
- Create migration guide for existing data
Files Created/Updated
Base Models (Single Source of Truth)
toto-docs/app/docs/architecture/case-base-model.tstoto-docs/app/docs/architecture/user-base-model.tstoto-docs/app/docs/architecture/donation-base-model.tstoto-docs/app/docs/architecture/follow-base-model.tstoto-docs/app/docs/architecture/case-update-base-model.tstoto-docs/app/docs/architecture/conversation-base-model.tstoto-docs/app/docs/architecture/support-ticket-base-model.ts
Analysis Documents
toto-docs/app/docs/architecture/user-model-analysis.mdtoto-docs/app/docs/architecture/donation-model-analysis.mdtoto-docs/app/docs/architecture/follow-model-analysis.mdtoto-docs/app/docs/architecture/case-update-model-analysis.mdtoto-docs/app/docs/architecture/conversation-model-analysis.mdtoto-docs/app/docs/architecture/support-ticket-model-analysis.md
Implementation Summaries
toto-docs/app/docs/architecture/conversation-model-summary.mdtoto-docs/app/docs/architecture/support-ticket-model-summary.md
Conclusion
All major user-facing entities have been reviewed, standardized, and documented. Each entity now has:
- ✅ A base model as single source of truth
- ✅ Consistent field names and types
- ✅ Proper validation and constraints
- ✅ Clear documentation
The remaining work focuses on:
- UI implementation of missing fields
- Cleanup of unused collections
- Migration of existing data
- Testing and validation