Skip to main content

Ecosystem Integration Guide

Comprehensive guide for integrating and managing the Toto ecosystem components.

πŸ— Ecosystem Architecture​

Component Overview​

The Toto ecosystem consists of multiple interconnected projects, each serving specific purposes while maintaining a unified architecture:

Core Components:

  • toto-app: Main pet rescue application
  • toto-bo: Backoffice management system
  • toto-ai-hub: AI-powered assistance system
  • toto-wallet: Blockchain payment processing

Integration Strategy​

1. Unified Authentication

  • Single sign-on across all components
  • Shared user profiles and permissions
  • Centralized role management
  • Cross-project token validation

2. Data Synchronization

  • Real-time data updates across components
  • Event-driven architecture for changes
  • Consistent data models and validation
  • Firestore listeners for live data

3. API Integration

  • RESTful APIs for data exchange
  • Centralized API management
  • Rate limiting and security
  • Monitoring and analytics

πŸ” Firebase Project Separation​

Current Architecture​

Project Structure:

toto-f9d2f/           # Main application
β”œβ”€β”€ Authentication
β”œβ”€β”€ Firestore Database
β”œβ”€β”€ Storage
└── Functions

toto-bo/ # Backoffice system
β”œβ”€β”€ Authentication
β”œβ”€β”€ Firestore Database
β”œβ”€β”€ Storage
└── Functions

toto-ai-hub/ # AI system (App Hosting)
β”œβ”€β”€ Backend Service
└── Monitoring

Benefits of Separation​

Security:

  • Isolated access controls per project
  • Granular permission management
  • Reduced attack surface

Scalability:

  • Independent scaling per component
  • Resource allocation optimization
  • Performance isolation

Maintenance:

  • Easier project management
  • Independent deployments
  • Simplified troubleshooting

Cost Control:

  • Separate billing and quotas
  • Resource usage tracking
  • Budget allocation per component

πŸš€ Integration Patterns​

1. Cross-Project Communication​

Event-Driven Architecture:

  • Event bus for cross-project communication
  • Real-time event publishing and subscription
  • Decoupled component interactions

Real-Time Updates:

  • Firestore listeners for live data synchronization
  • Cross-project data sync
  • Automatic UI updates

2. Shared Data Models​

Common Interfaces:

  • Standardized data structures across projects
  • Consistent validation rules
  • Type-safe data exchange

Data Validation:

  • Schema validation using Zod
  • Input sanitization
  • Type checking

3. API Integration​

Centralized API Client:

  • Unified API client for all projects
  • Authentication token management
  • Error handling and retry logic

API Endpoints:

  • Main App: https://app.betoto.pet/api
  • Backoffice: https://bo.betoto.pet/api
  • AI Hub: https://toto-ai-hub-backend--toto-ai-hub.us-central1.hosted.app

πŸ”„ Data Synchronization​

1. Real-Time Updates​

Firestore Listeners:

  • Real-time collection listeners
  • Document-level synchronization
  • Automatic cleanup on unmount

Cross-Project Data Sync:

  • Main app to backoffice case synchronization
  • Backoffice updates to main app
  • Event-driven updates

2. Event Sourcing​

Event Store:

  • Immutable event log
  • Event versioning
  • Aggregate reconstruction

πŸ” Security & Access Control​

1. Cross-Project Authentication​

Token Sharing:

  • JWT token validation across projects
  • Token expiration management
  • Secure token refresh

Permission Validation:

  • Role-based access control
  • Cross-project permission checks
  • Granular permission management

2. Data Protection​

Security Measures:

  • Field-level encryption for sensitive data
  • Secure data transmission
  • Access logging and audit trails

πŸ“Š Monitoring & Analytics​

Cross-Project Metrics​

Performance Monitoring:

  • Request count tracking
  • Response time metrics
  • Error rate monitoring
  • Active user tracking

Error Tracking:

  • Centralized error logging
  • Error severity classification
  • Project-specific error filtering

πŸ“ž Support & Troubleshooting​

Common Integration Issues​

1. Authentication Problems:

  • Verify cross-project token sharing
  • Check service account permissions
  • Validate token expiration

2. Data Synchronization Issues:

  • Check Firestore security rules
  • Verify cross-project access permissions
  • Validate data model consistency

3. Performance Issues:

  • Monitor API response times
  • Check database query performance
  • Review Firestore indexes

Health Checks​

Project Health Monitoring:

  • Health check endpoints per project
  • Overall ecosystem health status
  • Automated health monitoring

Last Updated: January 2025
Status: Production Ready