Core

Info

Architectural truth for Core in the Templates feature. This leaf module contains the domain logic, endpoints, and messaging contracts.

Architecture

FastEndpoints

  • CreateTemplateEndpoint
  • GetTemplateEndpoint
  • InstantiateDocumentEndpoint
  • ListProjectTemplatesEndpoint
  • PreviewTemplateEndpoint
  • UpdateTemplateEndpoint

Domain Models

  • GetTemplateRequest
  • ListProjectTemplatesRequest
  • ListTemplatesEndpoint

Caching (HybridCache)

Template blueprints (StructureJson / DocumentStyleJson) contain no secrets, so the read paths are cached (5-minute TTL) under tenant-scoped keys and invalidated by template writes:

  • ListProjectTemplatesEndpoint → template:{tenantId}:{projectId} (static LoadProjectTemplatesCachedAsync helper).
  • ListTemplatesEndpoint → template:{tenantId}:all (static LoadTemplatesCachedAsync helper).
  • GetTemplateEndpoint → template:{tenantId}:{templateId} (static LoadTemplateCachedAsync helper; a missing template returns null and is never cached, so 404 semantics are unchanged).
  • PreviewTemplateEndpoint is a pure in-memory render — deliberately not cached.

Invalidation

After SaveChangesAsync, each template write removes exactly the entries it could have changed (all via static helpers so integration tests drive the real mutation + invalidation):

WriteRemoved tags
CreateTemplateEndpointtemplate:{tenant}:{projectId} (when project-scoped) + template:{tenant}:all
UpdateTemplateEndpointtemplate:{tenant}:{projectId} + template:{tenant}:{templateId} + template:{tenant}:all
DeleteTemplateEndpointtemplate:{tenant}:{projectId} + template:{tenant}:{templateId} + template:{tenant}:all

DeleteTemplateEndpoint loads the full template row (not just an existence check) so ProjectId is available for the project tag. Keys/tags come from MILTON.Shared.Caching.CacheKeys.

0 items under this folder.