Database Implementations
The ROAR platform backend architecture is designed to support multiple database implementations. This is achieved through the use of a flexible and extensible data model that can be easily adapted to different database systems. The architecture also includes a set of standardized APIs that allow developers to interact with the data in a consistent and predictable way, regardless of the underlying database implementation.
Each backend implementation is instantiated using a factory pattern, which allows for easy creation and management of database connections. The factory pattern also provides a level of abstraction between the backend implementation and the rest of the application, making it easier to switch between different database systems without affecting the rest of the codebase.
Firebase Implementation
The Firebase implementation uses Firebase Firestore and Google Cloud Functions for serverless backend services. This implementation is created using the createFirestoreImplementation()
factory function from the @roar-firebase-functions/core
package.
Implementation Structure
The Firestore implementation contains the following components:
Repository Classes: Specialized data access classes for different entity types:
FirestoreAdministrationRepository
FirestoreIdentityProviderRepository
FirestoreOrgRepository
FirestoreUserRepository
FirestoreUserClaimRepository
FirestoreBaseRepository
(base class with common functionality)
Service Classes: Business logic layers that use repositories:
AdministrationService
IdentityProviderService
Filter Adapters: Tools for converting abstract filter conditions to Firestore-specific queries:
FirestoreFilterAdapter
Usage
To use the Firestore implementation, import the factory function and call it:
import { createFirestoreImplementation } from "@roar-firebase-functions/core";
const firestoreImpl = createFirestoreImplementation();
This returns a FirestoreImplementation
object containing all initialized repositories and services, ready to use with standardized APIs for data access and manipulation.
Benefits
- Serverless Architecture: No need to manage server infrastructure
- Real-time Data: Built-in support for real-time updates
- Scalability: Automatically scales with usage
- Security: Integrated with Firebase Authentication and security rules
- Integration: Seamless integration with other Google Cloud services