Transforming the MyPetParlor App API to a global and scalable API
Published on 24th October, 2024Luthando A. Vilakazi
Author
MyPetParlor App transforms its API architecture to support multi-tenancy and regional deployments through a stamp-based design, enabling scalable Firebase resource management and paving the way for new product offerings like e-commerce.
In a strategic move to transform its API architecture, the MyPetParlor App
Building on Previous Success
Following our successful Azure migration Deployment Stamps Google Cloud
The Challenge: Firebase Resource Limitations
A key driver for this transformation was the inherent limitations of Firebase
A maximum of 30 Firebase Apps registered per project (we require 3 per tenant for Android, iOS, and web)
A single Firebase
Hosting
service per projectA single Firebase
App Check
service per projectA single Firebase
Cloud Firestore
service per projectA single Firebase
Authentication
service per projectA single Firebase
Analytics
(powered byGoogle Analytics
) service per projectA single Firebase
Crashlytics
service per projectA single Firebase
Performance Monitoring
service per projectA single Firebase
Cloud Messaging
service per project
Additionally, the 8 Firebase services that our tenants' Android, iOS, and web apps depended on to function could only be accessed by apps registered to the project. Once we reached 10 tenants, we needed a way to handle additional tenants and employ a solution that would allow us to scale beyond these constraints while maintaining the benefits of Firebase's ecosystem.
The Solution: Multi-Stamp Architecture for Google Cloud
Rather than migrating to alternative third-party services, we implemented a stamp-based approach similar to our Azure infrastructure. This innovative solution:
Creates multiple Google Cloud projects (stamps)
Allocates 10 tenants per stamp
Enables each tenant within a stamp to deploy:
1 Android application
1 iOS application
1 Web application (future-proofing)
This approach effectively multiplies our capacity by distributing tenants across multiple stamps while staying well within Firebase's project limits.
API Transformation: Enabling Multi-Application Support
To support this new architecture, we've implemented new API headers that enable intelligent routing and configuration:
X-MBA-Application-ID
: Identifies the specific application making the requestX-MBA-Application-Type
: Specifies the type of application (e.g., MyPetParlor App, E-commerce platform)X-MBA-Deployment-Location
: Determines the geographical deployment stamp (e.g., za, us, uk)
Intelligent Routing System
The transformed API now features a sophisticated routing system:
API Gateway Layer:
Uses the deployment location header to route requests to the correct regional stamp
Ensures optimal latency by directing traffic to the nearest deployment
Application Configuration:
Stores application-specific configurations in a centralised database
Maps application IDs to their corresponding Google Cloud resources
Maintains separate configurations for different applications
Resource Resolution:
Dynamically resolves Firebase and Google Cloud resource endpoints
Ensures requests are routed to the correct stamp's resources
Maintains isolation between tenants while enabling resource sharing
Enabling New Business Opportunities
This transformation positions us to launch our e-commerce platform, which can be:
Deployed as a standalone product
Integrated as an add-on to existing MyPetParlor App installations
Scaled independently across different regions
The multi-tenant, multi-stamp architecture ensures that we can maintain separate configurations and resources for different applications while leveraging shared infrastructure where appropriate.
Benefits of the New Architecture
The transformed API brings several key advantages:
Scalability: Effectively bypasses Firebase project limitations through stamp-based architecture
Regional Performance: Optimised request routing based on geographical location
Application Agnostic: Single API supporting multiple products and applications
Resource Optimisation: Efficient utilisation of Google Cloud and Firebase resources
Future-Ready: Prepared for additional products and regional expansions
Looking Forward
With this API transformation complete, we're well-positioned to:
Launch our e-commerce platform
Expand into new geographical regions
Develop and deploy additional products
Scale our tenant base efficiently
The new multi-tenant, multi-stamp API architecture represents a significant milestone in our platform's evolution, enabling us to serve more customers, support more products, and expand into new markets while maintaining optimal performance and resource utilisation.