[Application] Implement CreateEbookCommand Handler with Background Processing Enqueue #36

Closed
opened 2026-05-10 17:35:50 +00:00 by Antigravity · 0 comments
Collaborator

Context: When a user clicks "Save to Library" in Blazor WASM, a robust command must handle saving the file, metadata, and initiating heavy background AI tasks.
Role: Senior Backend Engineer (Clean Architecture & CQRS specialist).
Task: Implement CreateEbookCommand and its handler in the Application project using MediatR.
Requirements:

  1. Command Data: The command must receive the raw IBrowserFile stream, and the verified ValidatedTitle and ValidatedAuthor.
  2. Infrastructure Interaction: Utilize an infrastructure file service to save the file to the configured FilePath (wwwroot/assets for local dev).
  3. Persistence: Save metadata (Title, Author, FilePath) to PostgreSQL via EF Core, setting IsReadyForReading to false.
  4. Asynchrony: Immediately upon saving, enqueue a background worker task (e.g., via Hangfire or Native .NET Worker Service) to start the heavy AI extraction (KnowledgeService calls to Gemini, vector generation). Ensure the command handler returns successfully without waiting for background completion.
**Context:** When a user clicks "Save to Library" in Blazor WASM, a robust command must handle saving the file, metadata, and initiating heavy background AI tasks. **Role:** Senior Backend Engineer (Clean Architecture & CQRS specialist). **Task:** Implement `CreateEbookCommand` and its handler in the `Application` project using MediatR. **Requirements:** 1. **Command Data:** The command must receive the raw `IBrowserFile` stream, and the verified `ValidatedTitle` and `ValidatedAuthor`. 2. **Infrastructure Interaction:** Utilize an infrastructure file service to save the file to the configured `FilePath` (`wwwroot/assets` for local dev). 3. **Persistence:** Save metadata (Title, Author, FilePath) to PostgreSQL via EF Core, setting `IsReadyForReading` to `false`. 4. **Asynchrony:** Immediately upon saving, enqueue a background worker task (e.g., via Hangfire or Native .NET Worker Service) to start the heavy AI extraction (`KnowledgeService` calls to Gemini, vector generation). Ensure the command handler returns successfully without waiting for background completion.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mjasin/Nexus.Reader#36