Appearance
GrydReports Module
GrydReports is a comprehensive report generation module for .NET applications. It provides on-demand and scheduled report generation in multiple formats (PDF, Excel, CSV) with pluggable templates, data sources, delivery channels, and multi-tenancy support.
✨ Features
| Feature | Description |
|---|---|
| 📄 Multi-Format Output | Generate formats for registered renderers; shipped renderers provide PDF, Excel, and CSV |
| 🧩 Pluggable Templates | Code-first template definition with type-safe data and parameters |
| 📊 Data Sources | Typed data sources feed a materialized result to renderers; the streaming interface is not consumed by the generation path |
| ⏱️ Generation | On-demand synchronous generation and optional recurring background schedules |
| 📅 Scheduling (Optional) | Cron-based recurring generation via optional GrydReports.Scheduling.GrydJobs integration |
| 📬 Delivery | Built-in webhook; email is a placeholder unless the host supplies a delivery provider |
| 💾 File Storage | Generated files stored in GrydFiles: server-side hash and type check, retention, short-lived download URLs |
| 🏢 Multi-Tenancy | Tenant filtering for executions and schedules; generated files retain execution tenant ownership |
| 🔍 Observability | OpenTelemetry metrics and activity tracing |
| 🎣 Lifecycle Filters | Chain-of-responsibility hooks at every stage of generation |
The Permissions and GlobalReports option declarations do not currently enforce template authorization or bypass tenant filters. Apply host authorization policies and retain explicit tenant ownership. The report-definition registry is shared; generated execution and file records retain tenant scope.
📦 Packages
GrydReports follows Clean Architecture with modular packages:
📦 GrydReports
├── GrydReports.Core # Domain entities, abstractions, DTOs
├── GrydReports.Application # CQRS commands, queries, MediatR handlers
├── GrydReports.Infrastructure # EF Core, generation, GrydFiles storage, webhook and email placeholder
├── GrydReports.Scheduling.GrydJobs # Optional recurring scheduling integration with GrydJobs
├── GrydReports.Infrastructure.QuestPdf # QuestPDF renderer
├── GrydReports.Infrastructure.ClosedXml # ClosedXML (Excel) renderer
├── GrydReports.Infrastructure.CsvHelper # CsvHelper (CSV) renderer
├── GrydReports.API # REST controllers (15 endpoints)
└── GrydReports (meta-package) # All packages combined🚀 Quick Start
Installation
bash
# Install Reports core stack and the PDF renderer (without requiring Jobs)
dotnet add package GrydReports
dotnet add package GrydReports.Infrastructure.QuestPdfbash
# Core abstractions only
dotnet add package GrydReports.Core
# With specific renderers
dotnet add package GrydReports.Infrastructure.QuestPdf
dotnet add package GrydReports.Infrastructure.ClosedXml
dotnet add package GrydReports.Infrastructure.CsvHelper
# Optional: only if you need recurring schedules with GrydJobs
dotnet add package GrydReports.Scheduling.GrydJobsBasic Setup
Use the maintained gryd-api template for the complete host composition, including API versioning, authentication, GrydFiles, middleware, and migrations. Add the Reports registrations inside its service-registration section:
csharp
using Gryd.Infrastructure.Extensions;
using GrydReports;
using GrydReports.Core.Configuration;
using GrydReports.Infrastructure.QuestPdf;
using GrydFiles;
using GrydFiles.Infrastructure.ClamAv;
using Microsoft.EntityFrameworkCore;
// Generated files use the host's GrydFiles profile and object-storage configuration.
builder.Services.AddGrydObjectStorage(builder.Configuration);
builder.Services.AddGrydFiles(builder.Configuration);
builder.Services.AddGrydFilesClamAv(builder.Configuration);
builder.Services.AddGrydReportsQuestPdf();
builder.Services.AddGrydReports(
builder.Configuration,
db => db.UseNpgsql(builder.Configuration.GetConnectionString("GrydReports")));
builder.Services.Configure<GrydReportsOptions>(options =>
options.TemplateAssemblies.Add(typeof(Program).Assembly));The complete host setup and application pipeline are in the maintained gryd-api template. Recurring schedules are optional and require GrydJobs plus the GrydReports.Scheduling.GrydJobs package.
The shipped PDF, Excel, and CSV packages register renderers. ReportFormat.Html is an enum value; this release does not ship an HTML renderer. A format is usable only when its renderer is registered. The SalesDataSource below uses an application-owned AppDbContext with a Sales DbSet.
Create Your First Report
csharp
using GrydReports.Core.Abstractions;
using GrydReports.Core.Enums;
using GrydReports.Core.Models;
using Microsoft.EntityFrameworkCore;
// SalesData, SalesParameters, SaleItem and AppDbContext belong to the host.
// 1. Define the data model
public class SalesData
{
public string Period { get; set; }
public List<SaleItem> Items { get; set; }
public decimal Total { get; set; }
}
// 2. Implement the data source
public class SalesDataSource : IReportDataSource<SalesData, SalesParameters>
{
private readonly AppDbContext _db;
public SalesDataSource(AppDbContext db) => _db = db;
public async Task<SalesData> FetchDataAsync(
SalesParameters parameters, CancellationToken ct)
{
var items = await _db.Sales
.Where(s => s.Date >= parameters.FromDate && s.Date <= parameters.ToDate)
.ToListAsync(ct);
return new SalesData
{
Period = $"{parameters.FromDate:MMM yyyy}",
Items = items,
Total = items.Sum(i => i.Amount)
};
}
}
// 3. Define the template
public class MonthlySalesTemplate : IReportTemplate<SalesData>
{
public string TemplateId => "monthly-sales";
public string DisplayName => "Monthly Sales Report";
public string? Description => "Summarizes sales by period";
public IReadOnlyList<ReportFormat> SupportedFormats =>
[ReportFormat.Pdf];
public ReportMetadata GetMetadata(SalesData data) => new()
{
Title = $"Sales Report - {data.Period}",
Author = "Finance Department"
};
}
// Register app-owned data-source and template services for ReportTemplateRegistry.
builder.Services.AddScoped<IReportDataSource<SalesData, SalesParameters>, SalesDataSource>();
builder.Services.AddSingleton<IReportTemplate<SalesData>, MonthlySalesTemplate>();See Getting Started for the full walkthrough.
🏗️ Architecture
┌────────────────────────────────────────────────┐
│ GrydReports.API │
│ ReportsController SchedulesController │
├────────────────────────────────────────────────┤
│ GrydReports.Application │
│ Commands + Queries (MediatR/CQRS) │
├────────────────────────────────────────────────┤
│ GrydReports.Core │
│ Abstractions │ Entities │ DTOs │ Enums │
├────────────────────────────────────────────────┤
│ GrydReports.Infrastructure │
│ EF Core │ FileStore │ Delivery │ Scheduling │
├──────────┬──────────────┬──────────────────────┤
│ QuestPDF │ ClosedXML │ CsvHelper │
│ (PDF) │ (Excel) │ (CSV) │
└──────────┴──────────────┴──────────────────────┘📋 API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/reports | List available report templates |
GET | /api/v1/reports/history | Paginated execution history |
GET | /api/v1/reports/{id} | Get execution details |
POST | /api/v1/reports/generate | Generate report synchronously |
POST | /api/v1/reports/generate-async | Built-in response: 503 unavailable; hosts may provide a durable handler |
GET | /api/v1/reports/{id}/download | Download generated file |
DELETE | /api/v1/reports/{id} | Delete execution & file |
GET | /api/v1/reports/schedules | List schedules |
GET | /api/v1/reports/schedules/{id} | Get schedule details |
POST | /api/v1/reports/schedules | Create recurring schedule |
PUT | /api/v1/reports/schedules/{id} | Update schedule |
DELETE | /api/v1/reports/schedules/{id} | Delete schedule |
POST | /api/v1/reports/schedules/{id}/trigger | Trigger immediate execution |
POST | /api/v1/reports/schedules/{id}/pause | Pause schedule |
POST | /api/v1/reports/schedules/{id}/resume | Resume schedule |
🔗 Related
- Getting Started — Full setup walkthrough
- Configuration — All configuration options
- Templates — Code-first template guide
- Generation — Synchronous generation and one-shot async limitations
- Scheduling — Cron-based recurring reports
- Migration (No Jobs) — Remove forced Jobs usage safely
- Delivery — Delivery methods and host email transport requirements
- API Reference — Endpoint details and DTOs
- Advanced — Filters, data-source limits, monitoring