Blog Post

Transforming the MyPetParlor App API to a global and scalable API

The portrait photo of Luthando Allistair Vilakazi wearing a yellow turtleneck.

Luthando A. Vilakazi

24 Oct, 2024
Announcement
Diagram illustrating MyPetParlor App's multi-stamp API architecture, showing how the API Gateway routes requests to regional deployment stamps (A, B, and C) based on location headers 'za', 'us', and 'uk' across a world map.

In a strategic move to transform its API architecture, the MyPetParlor App team has successfully implemented a stamp-based design that enhances multi-tenant support, improves scalability, and enables regional deployments. This new multi-tenant and multi-stamp API not only optimises Firebase resource management but also establishes a unified platform that will drive both the current MyPetParlor App product and future offerings, including e-commerce solutions, to support our growing customer base's evolving needs.

Building on Previous Success

Following our successful Azure infrastructure migration completed in March 2024, which implemented the Deployment Stamps pattern for improved scalability and multi-tenant support, we've now extended this architectural approach to our API layer and Google Cloud infrastructure. This transformation enables us to support multiple tenants and their applications while maintaining optimal resource utilisation and preparing for global expansion.

The Challenge: Firebase Resource Limitations

A key driver for this transformation was the inherent limitations of Firebase resources within a single Google Cloud project. Our production environment was approaching critical limits with:

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:

  1. Creates multiple Google Cloud projects (stamps)

  2. Allocates 10 tenants per stamp

  3. 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 request

  • X-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:

  1. 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

  2. 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

  3. 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:

  1. Deployed as a standalone product

  2. Integrated as an add-on to existing MyPetParlor App installations

  3. 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:

  1. Launch our e-commerce platform

  2. Expand into new geographical regions

  3. Develop and deploy additional products

  4. 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.

MyPetParlor App logoMyPetParlor App

MyPetParlor App is the global pet care platform for mobile groomers and parlor groomers.

facebook

© 2024 MyBusiness App (Pty) Ltd. All rights reserved.