BaseAppLib is the foundational library suite for the MagicPets multi-tenant SaaS platform. It provides shared MVVM architecture, UI components, and infrastructure services that are consumed by AdminApp, StoreApp, and ConsumerApp. Built on .NET 9.0, it implements a modular package-based architecture with Blazor components that work across both WebAssembly and MAUI platforms.
BaseAppLib/
├── BaseApp.ViewModels/ # Core MVVM framework (NuGet package)
├── BaseApp.BlazorUI/ # Core Blazor components (NuGet package)
├── ViewModels/ # Application-specific ViewModels
├── BlazorUI/ # Application-specific Blazor components
├── WASMApp/ # Blazor WebAssembly application
├── MAUIApp/ # .NET MAUI mobile/desktop app
├── LzAppLoading/ # Loading animation component (package)
├── LzAppConsole/ # Console integration component (package)
├── Blazorise.Icons.FontAwesome/ # FontAwesome icon provider (package)
└── MakePackage.targets # Build automation
BaseAppLib serves as the foundation layer in a hierarchical architecture:
┌─────────────────────────────────────────┐
│ AdminApp / StoreApp / ConsumerApp │ ← Consumer Applications
├─────────────────────────────────────────┤
│ Application-Specific Layers │ ← App-specific ViewModels & UI
├─────────────────────────────────────────┤
│ BaseApp.* Libraries │ ← Shared Foundation Layer
├─────────────────────────────────────────┤
│ LazyMagic Framework │ ← Infrastructure Layer
└─────────────────────────────────────────┘
Purpose: Provides the core MVVM framework and shared business logic ViewModels.
Key Classes:
BaseAppSessionViewModel
: Abstract base class for user sessions with authentication supportIBaseAppSessionViewModel
: Interface defining session capabilities and lifecycleBaseAppSessionsViewModel<T>
: Generic base class for managing collections of sessionsIBaseAppSessionsViewModel<T>
: Interface for session collection managementPetViewModel
: Individual pet management with CRUD operations and validationPetsViewModel
: Collection management for pets with filtering and searchCategoryViewModel/CategoriesViewModel
: Pet category management hierarchyTagViewModel/TagsViewModel
: Pet tag management with multiple selectionTenantConfigViewModel
: Tenant-specific configuration managementTenantConfig
: Data transfer object for tenant settingsBrowserFingerprint
: Client identification for security and analyticsMethodExtensions
: Utility methods for dynamic method invocationConfigureBaseAppViewModels
: Dependency injection configurationKey Features:
[Factory]
and [Reactive]
attributes for automationDependencies:
Purpose: Provides core Blazor components and UI infrastructure shared across applications.
Key Components:
Pet.razor
: Basic pet display component with minimal stylingPetsList.razor
: Pet collection display using MudTable with sorting and paginationCategorySelect.razor
: Category selection dropdown with hierarchical supportTagsSelect.razor
: Multi-select tag component with search functionalityPetStatusSelect.razor
: Pet status selection with predefined valuesAppInfo.razor
: Application information dialog with version and build detailsAppUpdates.razor
: Update notification component for new releasesBusy.razor
: Loading indicator with CSS animations and customizable messagingOnLine.razor
: Connectivity status indicator with real-time updatesSignedIn.razor
: Authentication status display with user informationLanguageSelect.razor
: Multi-language selection componentConfigureBaseAppBlazorUI
: Service registration for Blazor componentsConfigureBaseAppMessages
: Internationalization and messaging setupWindowSize.cs
: Browser window size tracking and responsive behaviorKey Features:
Dependencies:
Purpose: Animated loading screen component with customizable progress indicators.
Key Classes:
LzAppLoading.razor
: Main loading component with SVG-based circular progressLzAppLoading.razor.css
: CSS animations for smooth progress transitionsFeatures:
Usage Example:
<LzAppLoading Duration="3000" ShowProgress="true" OnCompleted="@HandleLoadComplete" />
Purpose: Browser console integration for debugging and diagnostics.
Key Classes:
LzConsole.razor
: Console component with JavaScript interopLzConsoleInterop.cs
: JavaScript bridge for console operationsFeatures:
Purpose: Complete FontAwesome 6 icon provider for Blazorise components.
Key Classes:
FontAwesomeIconProvider.cs
: Icon mapping implementation with 2000+ iconsFontAwesomeIcons.cs
: Static icon constant definitionsIcon.razor
: Custom icon component with styling supportFeatures:
Purpose: Application-specific ViewModels that extend BaseApp.ViewModels for concrete implementations.
Key Classes:
SessionViewModel
: Concrete implementation of session management with API integrationSessionsViewModel
: Global application state managementICurrentSessionViewModel
: Interface for accessing current active sessionConfigureViewModels
: Complete dependency injection setup including API clientsIntegration Pattern:
// Extends base classes with application-specific logic
public class SessionViewModel : BaseAppSessionViewModel
{
// Application-specific session handling
}
Purpose: Application-specific Blazor components that build on BaseApp.BlazorUI.
Key Components:
MainLayout.razor
: Primary application layout with MudBlazor integration
LoadingLayout.razor
: Minimal layout for loading states
NavMenu.razor
: Application-specific navigation menu
HomePage.razor
: Application home page with authentication integrationPetPage.razor
: Individual pet management and viewingPetsPage.razor
: Pet listing with search, filter, and paginationMain.razor
: Application root component with router and initializationConfig/ConfigureBlazorUI
: Service registration and configurationPurpose: Blazor WebAssembly application for web deployment.
Key Features:
Purpose: .NET MAUI hybrid application for cross-platform deployment.
Supported Platforms:
net9.0-android
)net9.0-ios
)net9.0-maccatalyst
)net9.0-windows10.0.19041.0
)Key Features:
BaseAppLib builds on ReactiveUI to provide a robust MVVM framework:
Base Classes:
LzItemViewModelBase<T>
: Base class for individual entity ViewModelsLzItemsViewModelBase<T>
: Base class for collection ViewModelsLzSessionViewModel
: Session-aware ViewModels with authenticationProperty Management:
// Automatic property change notifications via Fody
[Reactive] public string Name { get; set; }
// Reactive commands for async operations
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
Code generation creates factories for dependency injection:
[Factory]
public class PetViewModel : LzItemViewModel<Pet, PetModel>
{
public PetViewModel(
[FactoryInject] ILogger<PetViewModel> logger,
[FactoryInject] IPetApi petApi,
// ... other dependencies
)
}
// Auto-generated factory
public interface IPetViewModelFactory
{
PetViewModel Create(/* parameters */);
}
Built-in support for Cognito authentication:
public class SessionViewModel : BaseAppSessionViewModel
{
public IAuthProcess AuthProcess { get; }
// Automatic authentication state management
public bool IsSignedIn => AuthProcess.IsSignedIn;
}
BaseAppLib provides extension methods for clean service registration:
public static IServiceCollection AddBaseAppViewModels(this IServiceCollection services)
{
// Register base framework services
BaseAppViewModelsRegisterFactories.BaseAppViewModelsRegister(services);
services.TryAddSingleton<ILzMessages, LzMessages>();
services.AddLazyMagicAuthCognito();
return services;
}
public static IServiceCollection AddBaseAppBlazorUI(this IServiceCollection services)
{
// Register Blazor components and services
services.AddMudServices();
services.TryAddSingleton<IStaticAssets, StaticAssets>();
return services;
}
Different configuration strategies for different platforms:
WASM Configuration:
// Browser-based configuration via JavaScript
var config = await JSRuntime.InvokeAsync<TenantConfig>("getAppConfig");
MAUI Configuration:
// Embedded resource configuration
var configStream = await FileSystem.OpenAppPackageFileAsync("tenantconfig.json");
Built-in multi-tenancy support:
public class TenantConfigViewModel : LzItemViewModelBase<TenantConfig>
{
// Tenant-specific configuration
public string TenantName { get; set; }
public Dictionary<string, object> AuthConfigs { get; set; }
public AssetConfig Assets { get; set; }
}
Standardized API integration patterns:
// Module client integration
services.AddSingleton<IPublicModuleClient>(provider =>
provider.GetService<IPublicApi>()!.PublicModuleClient);
// HTTP client configuration
services.AddHttpClient<ApiClient>(client =>
{
client.BaseAddress = new Uri(apiBaseUrl);
client.DefaultRequestHeaders.Add("User-Agent", "MagicPets-Client");
});
Global application state via reactive ViewModels:
// singleton current session
services.Add<ISessionViewModel, SessionViewModel>();
Dynamic asset loading with tenant support:
public interface IStaticAssets
{
Task<T> GetAsync<T>(string path, string? tenant = null);
Task<string> GetStringAsync(string path, string? tenant = null);
}
BaseAppLib enables significant code reuse across AdminApp, StoreApp, and ConsumerApp:
cd BaseAppLib
dotnet build
# Creates versioned NuGet packages in /Packages/
# Web version
cd WASMApp
dotnet run
# Mobile version
cd MAUIApp
dotnet build -f net9.0-windows10.0.19041.0
# Packages are automatically versioned and built
# Format: {PackageName}.{Version}.nupkg
# Example: BaseApp.ViewModels.1.3.0.nupkg
BaseAppLib serves as the solid foundation that enables rapid development of the AdminApp, StoreApp, and ConsumerApp while maintaining consistency, quality, and performance across the entire MagicPets platform.