Data Models
The ROAR backend architecture uses data models to represent the data entities and their relationships. These models are designed to be flexible, scalable, and maintainable, allowing for easy integration with various data sources and services.
Data Model Design Principles
Each data model is an interface that defines the structure and behavior of a specific data entity. It provides a clear and consistent way to interact with the data, ensuring data integrity and consistency across the system. Data models should be designed with extensibility in mind, allowing for easy addition of new fields or relationships without breaking existing code. Data models are agnostic to the underlying data storage mechanism, allowing for easy integration with various data sources and services.
Core Data Models
The ROAR platform is built around several key data models:
Administration Model
The Administration
model represents a collection of assessments administered to a specific set of organizations. It includes:
- Assessment configurations
- Organization settings
- Access control information
- Status tracking
User Model
The User
model represents individuals who interact with the platform and includes:
- Basic profile information
- Authentication details
- System-wide unique identifier
- Creation and update timestamps
Organization Model
The OrgBase
model represents educational institutions and other organizations using the platform:
- Hierarchical organization structure
- Organizational metadata
- Identification information
Identity Provider Model
The IdentityProvider
model manages integration with external authentication systems:
- Provider type and configuration
- Synchronization status and metadata
- Mapping between external and internal identifiers
Model Relationships
Data models in ROAR maintain relationships through references rather than direct embedding:
- Administration to Organization: Many-to-many relationship tracked through organization lists
- User to Organization: Many-to-many relationship managed through claims
- Administration to Assessment: One-to-many relationship with assessments as properties of an administration
- User to Identity Provider: Many-to-one relationship establishing authentication source
Base Model
All data models extend the BaseModel
interface which provides common properties:
id
: A unique identifier within the collectioncreatedAt
: Timestamp indicating when the entity was createdupdatedAt
: Timestamp indicating the last modificationname
: Human-readable identifier (where applicable)
Type Safety and Validation
The ROAR platform uses TypeScript interfaces to ensure type safety across all data models. This provides:
- Compile-time validation
- Better developer experience with IDE autocompletion
- Clear documentation of expected data structures
- Runtime type checking when interfacing with external systems
Data Model Evolution
As the ROAR platform evolves, data models may need to change. The architecture supports:
- Backward compatibility through optional fields
- Version tracking for data migrations
- Transformation utilities for converting between different versions of models
- Schema validation to ensure data integrity during transitions
Data Model Implementation
Each data model has an associated repository class that implements the interface. The class provides methods for creating, reading, updating, and deleting data entities. It also provides methods for querying and filtering data entities based on specific criteria. The attributes of each model can also be defined as an interface that extends the base model interface. This allows for increased type safety and better code organization.
You can find the complete definition of all data models in the Interfaces section of the API documentation.