# EpubMetadataExtractor

- File ID: file:d3gg9l:epubmetadataextractor-cs
- Path: NexusReader.Infrastructure/Services/EpubMetadataExtractor.cs
- Role: service
- Layer: infrastructure

## Purpose

Provides a lightweight infrastructure service that reads metadata (title, author, description, cover image) from an EPUB stream without persisting anything; used by the ingestion UI prior to upload confirmation.

## Key Details

No persistence; uses VersOne.Epub to open/read EPUB; defensive defaults for missing title/author; converts exceptions into FluentResults failures for upstream handling by UI ingestion flow.

## Symbols

- EpubMetadataExtractor: Provides a lightweight infrastructure service that reads metadata (title, author, description, cover image) from an EPUB stream without persisting anything; used by the ingestion UI prior to upload confirmation.
- ExtractMetadataAsync(): Opens an EPUB stream, reads title/author/description/cover (async), and returns a FluentResults success with LocalEpubMetadata or a failure wrapping the exception.
- EpubMetadataExtractor: Infrastructure implementation of IEpubMetadataExtractor that reads EPUB metadata from a stream.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions/Services/IEpubMetadataExtractor.cs (interface implemented)
- dependency-target: NexusReader.Application/Queries/Reader/LocalEpubMetadata.cs (returned DTO model)

## Coverage

- Symbols: 3
- Executable symbols: 1
- Executable symbols with control flow: 1
- Grounded edges: 3
- Unresolved references: 2
- Control-flow fragments: 1
- Unresolved jumps: 0
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 3

## Control Flow Fragments

- ExtractMetadataAsync: 16 nodes, 15 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### EpubMetadataExtractor Neighborhood

```mermaid
flowchart LR
    class_1oxys0a_epubmetadataextractor("EpubMetadataExtractor")
    file_d3gg9l_epubmetadataextractor_cs("EpubMetadataExtractor")
    method_1vt6hc7_extractmetadataasync[["ExtractMetadataAsync()"]]
    type_1oku42b_epubmetadataextractor[/"EpubMetadataExtractor"/]
```

### EpubMetadataExtractor Execution Overview

```mermaid
flowchart TD
    class_1oxys0a_epubmetadataextractor("EpubMetadataExtractor")
    method_1vt6hc7_extractmetadataasync[["ExtractMetadataAsync()"]]
    class_1oxys0a_epubmetadataextractor -->|contains| method_1vt6hc7_extractmetadataasync
```

### ExtractMetadataAsync() Control Flow

```mermaid
flowchart TD
    method_1vt6hc7_extractmetadataasync__action_17_extractmetadataasync_try_17_0__try("Begins protected execution")
    method_1vt6hc7_extractmetadataasync__action_19_extractmetadataasync_await_19_1__await[["Waits for async work"]]
    method_1vt6hc7_extractmetadataasync__action_19_resource_open_await_19__linear("Open EPUB book asynchronously")
    method_1vt6hc7_extractmetadataasync__action_20_fallback_default_20__linear("Default title when missing")
    method_1vt6hc7_extractmetadataasync__action_21_fallback_default_21__linear("Default author when missing")
    method_1vt6hc7_extractmetadataasync__action_22_read_property_22__linear("Read description")
    method_1vt6hc7_extractmetadataasync__action_23_async_call_23__linear("Read cover image bytes")
    method_1vt6hc7_extractmetadataasync__action_23_extractmetadataasync_await_23_2__await[["Waits for async work"]]
    method_1vt6hc7_extractmetadataasync__action_24_return_success_24__linear("Return metadata success")
    method_1vt6hc7_extractmetadataasync__action_26_extractmetadataasync_catch_26_4__catch("catch Exception ex")
    method_1vt6hc7_extractmetadataasync__action_26_try_catch_26__linear("Catch and convert any exception to a FluentResults failure")
    method_1vt6hc7_extractmetadataasync__action_28_return_failure_28__linear("Return failure with diagnostic message")
    method_1vt6hc7_extractmetadataasync__entry(["ExtractMetadataAsync entry"])
    method_1vt6hc7_extractmetadataasync__action_24_extractmetadataasync_return_24_3__return(["Returns result"])
    method_1vt6hc7_extractmetadataasync__action_28_extractmetadataasync_return_28_5__return(["Returns result"])
    method_1vt6hc7_extractmetadataasync__implicit_return(["return"])
    method_1vt6hc7_extractmetadataasync__action_17_extractmetadataasync_try_17_0__try -->|next| method_1vt6hc7_extractmetadataasync__action_19_extractmetadataasync_await_19_1__await
    method_1vt6hc7_extractmetadataasync__action_19_extractmetadataasync_await_19_1__await -->|next| method_1vt6hc7_extractmetadataasync__action_19_resource_open_await_19__linear
    method_1vt6hc7_extractmetadataasync__action_19_resource_open_await_19__linear -->|next| method_1vt6hc7_extractmetadataasync__action_20_fallback_default_20__linear
    method_1vt6hc7_extractmetadataasync__action_20_fallback_default_20__linear -->|next| method_1vt6hc7_extractmetadataasync__action_21_fallback_default_21__linear
    method_1vt6hc7_extractmetadataasync__action_21_fallback_default_21__linear -->|next| method_1vt6hc7_extractmetadataasync__action_22_read_property_22__linear
    method_1vt6hc7_extractmetadataasync__action_22_read_property_22__linear -->|next| method_1vt6hc7_extractmetadataasync__action_23_extractmetadataasync_await_23_2__await
    method_1vt6hc7_extractmetadataasync__action_23_async_call_23__linear -->|return| method_1vt6hc7_extractmetadataasync__action_24_extractmetadataasync_return_24_3__return
    method_1vt6hc7_extractmetadataasync__action_23_extractmetadataasync_await_23_2__await -->|next| method_1vt6hc7_extractmetadataasync__action_23_async_call_23__linear
    method_1vt6hc7_extractmetadataasync__action_24_extractmetadataasync_return_24_3__return -->|next| method_1vt6hc7_extractmetadataasync__action_24_return_success_24__linear
    method_1vt6hc7_extractmetadataasync__action_24_return_success_24__linear -->|exception| method_1vt6hc7_extractmetadataasync__action_26_extractmetadataasync_catch_26_4__catch
    method_1vt6hc7_extractmetadataasync__action_26_extractmetadataasync_catch_26_4__catch -->|next| method_1vt6hc7_extractmetadataasync__action_26_try_catch_26__linear
    method_1vt6hc7_extractmetadataasync__action_26_try_catch_26__linear -->|return| method_1vt6hc7_extractmetadataasync__action_28_extractmetadataasync_return_28_5__return
    method_1vt6hc7_extractmetadataasync__action_28_extractmetadataasync_return_28_5__return -->|next| method_1vt6hc7_extractmetadataasync__action_28_return_failure_28__linear
    method_1vt6hc7_extractmetadataasync__action_28_return_failure_28__linear -->|return| method_1vt6hc7_extractmetadataasync__implicit_return
    method_1vt6hc7_extractmetadataasync__entry -->|next| method_1vt6hc7_extractmetadataasync__action_17_extractmetadataasync_try_17_0__try
```

## Diagram Validation

- Status: pass
