Skip to main content

Feature Commands

Add framework features and modules to your PearDrop application.

peardrop feature auth

Inject authentication into a minimal PearDrop template.

peardrop feature auth

What It Does:

  1. Adds PearDrop.Authentication NuGet package to server project
  2. Updates Program.cs with authentication registration
  3. Adds login/registration UI (if not present)
  4. Configures connection string for auth database
  5. Creates initial migration for auth schema

Added configuration:

// Program.cs
builder.Services.AddPearDropAuthentication(builder.Configuration);

// appsettings.json
{
"ConnectionStrings": {
"PearDrop-Auth": "Server=localhost,1440;Database=MyApp;..."
}
}

When to Use

  • Starting with minimal template - Add auth to peardrop init projects
  • Custom auth requirements - Modify auth after injection

After Injection

  1. Review auth configuration - Check appsettings.json for connection strings
  2. Run migrations - peardrop migrate to create auth tables
  3. Configure auth providers - Use peardrop auth commands to add Entra ID
  4. Customize UI - Modify login/registration pages

peardrop feature multitenancy

Inject multi-tenancy support into your application.

# Host-based tenant resolution
peardrop feature multitenancy --strategy host

# URL-based tenant resolution
peardrop feature multitenancy --strategy url

What It Does:

  1. Adds PearDrop.Multitenancy NuGet package
  2. Configures tenant resolution strategy (host, URL, claim)
  3. Updates DbContext with tenant filtering
  4. Adds tenant management UI
  5. Creates multitenancy migrations

Added configuration:

// Program.cs
builder.Services.AddPearDropMultitenancy(builder.Configuration);

// appsettings.json
{
"PearDrop": {
"Multitenancy": {
"Strategy": "host",
"DefaultTenantId": "00000000-0000-0000-0000-000000000001"
}
},
"ConnectionStrings": {
"PearDrop-Multitenancy": "Server=localhost,1440;Database=MyApp;..."
}
}

Tenant Resolution Strategies

StrategyDescriptionExample
hostSubdomain-basedtenant1.myapp.com, tenant2.myapp.com
urlURL path segmentmyapp.com/tenant1, myapp.com/tenant2
claimJWT claimUser token contains tenant_id claim

When to Use

  • SaaS applications - Each customer gets isolated data
  • White-label products - Branded per tenant
  • Enterprise deployments - Department/division isolation

After Injection

  1. Run migrations - peardrop migrate for tenant tables
  2. Configure tenant resolution - Update appsettings.json strategy
  3. Implement tenant creation - Add tenant onboarding workflow
  4. Test tenant isolation - Verify data separation

peardrop add module

Add a PearDrop framework module to your application.

# Add files module
peardrop add module files

# Add messaging module
peardrop add module messaging

Available Modules:

ModulePurposeWhat It Provides
filesFile managementUpload, download, versioning, sharing
messagingIn-app messagingUser-to-user messages, notifications

For Each Module, It:

  1. Adds NuGet package - PearDrop.{Module}
  2. Registers services - Calls AddPearDrop{Module}() in Program.cs
  3. Configures connection strings - Module-specific database connection
  4. Adds API endpoints - Framework module controllers
  5. Creates migrations - Module schema setup
  6. Updates manifest - Adds module to usedModules in peardrop.json

Example: Files Module

// Added to Program.cs
builder.Services.AddPearDropFiles(builder.Configuration);

// Added to appsettings.json
{
"ConnectionStrings": {
"PearDrop-Files": "Server=localhost,1440;Database=MyApp;..."
},
"PearDrop": {
"Files": {
"StorageProvider": "AzureBlob",
"MaxFileSize": 104857600
}
}
}

When to Use

  • Rapid prototyping - Need file uploads without custom implementation
  • Standard features - Messaging/files are commodity features
  • Framework consistency - Follow PearDrop patterns

When NOT to Use

  • Custom requirements - Need domain-specific file handling
  • High customization - Module doesn't fit your workflow
  • Learning DDD - Better to build custom for understanding

After Adding Module

  1. Run migrations - peardrop migrate for module tables
  2. Configure module - Update appsettings.json with module settings
  3. Add UI references - Import module components in Blazor pages
  4. Test module endpoints - Verify APIs work with your auth

peardrop feature radzen

Add Radzen component library with helper integrations to your Blazor WASM client.

peardrop feature radzen

What It Does:

  1. Adds Radzen.Blazor NuGet package to client project
  2. Registers Radzen services - AddRadzenComponents() in Program.cs
  3. Adds Radzen theme to App.razor - Material design by default
  4. Injects Radzen.Blazor.min.js via runtime script loading (avoids Parcel bundler conflicts)
  5. Sets up PearDrop.Helpers.Radzen.Client for integrated UI helpers
  6. Configures _Imports.razor with @using Radzen directive

Added configuration:

// Program.cs
using Radzen;

builder.Services.AddRadzenComponents();

// _Imports.razor
@using Radzen

// App.razor
<RadzenTheme Theme="material" />
<RadzenComponents />

// Assets/index.pug (runtime injection)
script.
const radzenScript = document.createElement('script');
radzenScript.src = '/_content/Radzen.Blazor/Radzen.Blazor.min.js';
document.body.appendChild(radzenScript);

When to Use

  • Building rich UIs - Radzen provides 70+ pre-built components
  • Rapid prototyping - No CSS framework needed
  • PearDrop consistency - Integrated with email/SMS helpers for styled forms
  • Material design fans - Modern, professional look out-of-the-box

After Injection

  1. Restore packages - dotnet restore to pull Radzen and helper libraries
  2. Use in components - Import Radzen components: <RadzenButton Text="Click Me" />
  3. Customize theme - Modify Material theme or use Fluent variant
  4. Build client - npm install && npm run build in client directory

PearDrop.Helpers.Radzen.Client (Side Dialog Layouts)

The Radzen feature also enables PearDrop.Helpers.Radzen.Client, which includes reusable side-dialog layouts:

  • PearDropSideDialogLayout - For non-form dialogs (confirmations, review panels)
  • PearDropFormSideDialogLayout - For form dialogs with EditForm + FluentValidation

Required imports:

@using PearDrop.Helpers.Radzen.Client.SlideOut
@using Microsoft.AspNetCore.Components.Forms
@using Blazored.FluentValidation

Example: Non-form side dialog

<PearDropSideDialogLayout
Icon="folder_open"
Title="Move Items"
Description="Choose a destination folder for selected files."
PrimaryButtonText="Move"
SecondaryButtonText="Cancel"
IsPrimaryButtonBusy="@isSaving"
OnPrimaryClick="OnMoveAsync"
OnSecondaryClick="OnCancelAsync">
<Content>
<RadzenTree Data="@folders" />
</Content>
</PearDropSideDialogLayout>

Example: Form side dialog

<PearDropFormSideDialogLayout
Icon="edit"
Title="Rename Item"
Description="Provide a new name."
EditContext="@editContext"
PrimaryButtonText="Save"
SecondaryButtonText="Cancel"
IsPrimaryButtonBusy="@isSaving"
OnValidSubmit="OnSaveAsync"
OnSecondaryClick="OnCancelAsync">
<Content>
<FluentValidationValidator />
<RadzenTextBox @bind-Value="@model.Name" Name="Name" />
</Content>
</PearDropFormSideDialogLayout>

When to use these helpers:

  • Consistent side-panel UX across modules
  • Shared button layout, loading state, and dialog framing
  • Form workflows needing EditContext + validation

peardrop add email-helper

Add PearDrop.Helpers email service with SMTP configuration.

peardrop add email-helper

What It Does:

  1. Adds PearDrop.Helpers NuGet package
  2. Registers email service - IEmailService for DI
  3. Adds SMTP configuration to appsettings.json
  4. Provides templating support - Razor email templates

Added configuration:

// Program.cs
builder.Services.AddPearDropEmailHelper(builder.Configuration);

// appsettings.json
{
"PearDrop": {
"Email": {
"SmtpHost": "smtp.gmail.com",
"SmtpPort": 587,
"UseSsl": true,
"FromAddress": "noreply@myapp.com",
"FromName": "MyApp"
}
}
}

Usage in code:

public class SendWelcomeEmailCommandHandler : ICommandHandler<...>
{
private readonly IEmailService emailService;

public async Task<CommandResult> Handle(...)
{
await emailService.SendAsync(new EmailMessage
{
To = user.Email,
Subject = "Welcome to MyApp",
Body = await RenderTemplateAsync("welcome", user),
IsHtml = true
});
}
}

When to Use

  • Transactional emails - Welcome, password reset, notifications
  • Consistent styling - Centralized email templates
  • SMTP flexibility - Easy provider switching

After Adding

  1. Configure SMTP credentials - Update appsettings.json or use secrets
  2. Create email templates - Add Razor templates in EmailTemplates/
  3. Test email sending - Send test email to verify SMTP config
  4. Add to CI/CD secrets - Store SMTP password securely

Feature Combinations

Common feature combinations for different application types:

Simple Internal Tool

peardrop init MyApp
peardrop feature auth
peardrop feature radzen
# Done - single tenant with auth and Radzen UI

Modern SaaS Application

peardrop init MyApp
peardrop feature auth
peardrop feature multitenancy --strategy host
peardrop feature radzen
peardrop add email-helper
# Multi-tenant SaaS with Radzen UI and email notifications

Enterprise Application

peardrop init MyApp
peardrop feature auth
peardrop feature multitenancy --strategy claim
peardrop feature radzen
peardrop add module files
peardrop add module messaging
peardrop add email-helper
# Full-featured enterprise app with professional UI

Rich Admin Dashboard

peardrop init MyApp
peardrop feature auth
peardrop feature radzen
peardrop add module files
peardrop add email-helper
peardrop add sms-helper
# Admin dashboard with file management and notifications

Troubleshooting

Feature Already Exists

Problem: Feature injection fails with "feature already configured"

Solution:

  • Check Program.cs for existing AddPearDrop{Feature}() calls
  • Review appsettings.json for feature configuration
  • Feature may have been added during peardrop init with non-minimal template

Module Conflicts

Problem: Module registration throws DI errors

Solution:

  • Ensure module package version matches framework version
  • Run peardrop update to align package versions
  • Check for duplicate service registrations in Program.cs

Migration Failures After Feature Injection

Problem: peardrop migrate fails after adding feature

Solution:

# Clean and rebuild
dotnet clean
dotnet build

# Try migration again
peardrop migrate

# If still fails, manually add migration
dotnet ef migrations add AddAuthenticationModule --context AuthDbContext

Next Steps