Classes
This document provides an overview of all classes in the backend system. Each class represents a specific domain of functionality with its own state management, business logic, and API endpoints.
Core Classes
Core classes provide shared functionality, system services, and infrastructure support across all entity classes.
ApprovalManager
Centralized approval workflow management providing approval processing for all entity types with hybrid storage (MongoDB + RDK file storage) for handling large jsonPatch data, workflow integration, and comprehensive audit trails.
→ View ApprovalManager Documentation
RoleManager
Role and permission management system with dynamic role creation, permission-based access control, and deployment automation.
→ View Role Manager Documentation
LogManager
Centralized logging and audit trail system with hybrid storage (MongoDB + RDK file storage) for handling large log entries, providing entity-specific log management and paginated log retrieval across all classes.
→ View Log Manager Documentation
FileManager
Secure file storage and management system providing entity-based file organization with comprehensive validation, metadata tracking, and token-based security.
→ View File Manager Documentation
Setting
System configuration and reference data management including global settings, company groups, member types, tier types, and streaming capabilities.
SystemEmail
Email template management and delivery system with dynamic templates, approval workflows, and AWS SES integration for multi-purpose email delivery.
→ View SystemEmail Documentation
Workflow
Business process automation and workflow configuration providing rule definition and process automation integration.
Otp
OTP record storage and management service providing authentication workflow support with comprehensive audit trails and validation history.
Entity Classes
Entity classes manage the core business entities and their lifecycles in the loyalty program system.
Member
Core member profile and lifecycle management with comprehensive profile tabs, photo management, and eligibility rules.
Company
Management of companies participating in the loyalty program with CRUD operations, approval workflows, and hierarchical structures.
Tier
Individual membership tier management with eligibility rules, payment configurations, and approval workflows.
ProgramManagementUser
Administrative user management for program operators with role-based access, SSO (SAML 2.0) and email/password authentication, and invitation workflows.
→ View Program Management User Documentation
Architecture Overview
Method Types
The classes use four types of Rio methods:
- READ: Synchronous data retrieval (1-30s)
- WRITE: Synchronous state mutations (1-30s)
- QUEUED_WRITE: Asynchronous operations with longer processing times (1-890s)
- STATIC: Stateless utility methods (no instance required)
Success Response Standardization
All classes implement a unified success response system that provides:
- Consistent Response Structure: Standardized success response format across all classes
- Localization Support: Built-in multi-language support with fallback mechanisms
- Type Safety: Type-safe success definitions with class-specific constants
- Centralized Management: Success messages defined in
classes/*/constants/success.responses.ts
Success Response Pattern:
data.response = new SuccessResponse({
success: ClassSuccess.OPERATION_TYPE,
localization: culture,
body: { responseData }
})
Key Benefits:
- Consistency: All methods return standardized success responses
- Localization: Automatic message localization based on user culture
- Maintenance: Centralized success message management per class
- Type Safety: Compile-time validation of success response types
Error Response Standardization
All classes implement a unified error response system that provides:
- Consistent Error Structure: Standardized error response format with HTTP status codes
- Unique Error Codes: Class-specific error codes for precise error identification
- Localization Support: Multi-language error messages with fallback mechanisms
- Type Safety: Type-safe error definitions with class-specific constants
- Centralized Management: Error definitions in
classes/*/constants/error.responses.ts
Error Response Pattern:
// Throwing specific business logic errors
throw new ErrorResponse({
error: ClassError.SPECIFIC_ERROR_TYPE,
details: { additionalContext }
})
// Handling unexpected errors in catch blocks
catch (error) {
data.response = parseError(error, ClassIdentities.enum.ClassName, culture)
}
Error Response Format:
{
statusCode: 400 | 403 | 404 | 500 | 502,
body: {
code: number, // Unique error code per class
message: "Localized error message",
classId: "ClassName"
}
}
Error Code Ranges by Class:
- ProgramManagementUser: 4000-4099
- Member: 5000-5099
- Company: 6000-6099
- Tier: 7000-7099
- ApprovalManager: 8000-8099
- RoleManager: 9000-9099
- Setting: 10000-10099
- SystemEmail: 11000-11099
- LogManager: 12000-12099
- FileManager: 13000-13099
- Workflow: 14000-14099
- Otp: 15000-15099
Key Benefits:
- Traceability: Unique error codes enable precise error tracking and debugging
- Client Handling: Predictable error format simplifies client-side error handling
- Localization: Automatic error message translation based on user locale
- Maintainability: Centralized error definitions per class
- Type Safety: Compile-time validation prevents using non-existent error types
Inter-Class Dependencies
Classes integrate through:
- ApprovalManager: Used by classes needing approval workflows
- LogManager: Used across all classes for audit trails
- RoleManager: Provides authorization for ProgramManagementUser operations
- Setting: Provides configuration data to various classes
- SystemEmail: Authorized for use by all classes for email delivery (implementations pending)
API Documentation
Complete API documentation for all classes is available at /api in the live environment and rendered to docs/api directory.