## Web Client (WASM) and Shared UI Components
A brief overview of how the Blazor Web.Client (WASM) bootstraps, which platform services are swapped for browser execution, how shared reader UI components are composed, and how auth tokens are injected into client HTTP calls.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    flow_file_nexusreader_web_client_program_cs_file_1["Program.cs"]
    flow_file_nexusreader_web_client_services_wasmepubservice_cs_file_1["WasmEpubReader"]
    flow_file_nexusreader_web_client_services_webplatformservice_cs_file_1["WebPlatformService"]
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1["AuthenticationHeaderHandler"]
    flow_file_nexusreader_web_client_nexusreader_web_client_csproj_file_1["NexusReader.Web.Client.csproj"]
    flow_file_nexusreader_web_client_services_wasmknowledgeservice_cs_file_1["WasmKnowledgeService"]
    flow_type_nexusreader_web_client_handlers_authenticationheaderhandler_cs_authenticationheaderhandler_14[/"AuthenticationHeaderHandler"/]
    flow_type_nexusreader_web_client_program_cs_identityservice_32[/"IdentityService"/]
    flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55[/"NexusReader.Application (extension)"/]
    flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40[/"NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler"/]
    flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74[/"ThrowingBookStorageService"/]
    flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49[/"ThrowingDbContextFactory"/]
    flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61[/"ThrowingDbContextFactory"/]
    flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84[/"ThrowingEbookRepository"/]
    flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66[/"ThrowingEmbeddingGenerator"/]
    flow_type_nexusreader_web_client_program_cs_throwingsyncbroadcaster_94[/"ThrowingSyncBroadcaster"/]
    flow_type_nexusreader_web_client_program_cs_webplatformservice_18[/"WebPlatformService"/]
    flow_type_nexusreader_web_client_program_cs_webstorageservice_19[/"WebStorageService"/]
    flow_file_nexusreader_web_client_services_wasmepubservice_cs_file_1 -->|model WasmEpubMetadataExtractor| flow_type_nexusreader_web_client_services_wasmepubservice_cs_wasmepubmetadataextractor_43
    flow_file_nexusreader_web_client_services_wasmepubservice_cs_file_1 -->|model WasmEpubReader| flow_type_nexusreader_web_client_services_wasmepubservice_cs_wasmepubreader_8
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1 -->|model AuthenticationHeaderHandler| flow_type_nexusreader_web_client_handlers_authenticationheaderhandler_cs_authenticationheaderhandler_14
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IIdentityService| flow_type_nexusreader_web_client_program_cs_identityservice_32
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IServiceCollection application extension| flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55
    flow_file_nexusreader_web_client_program_cs_file_1 -->|NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler| flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingBookStorageService| flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IDbContextFactory AppDbContext>| flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingDbContextFactory| flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingEbookRepository| flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingEmbeddingGenerator| flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingSyncBroadcaster| flow_type_nexusreader_web_client_program_cs_throwingsyncbroadcaster_94
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IPlatformService| flow_type_nexusreader_web_client_program_cs_webplatformservice_18
    flow_file_nexusreader_web_client_program_cs_file_1 -->|INativeStorageService| flow_type_nexusreader_web_client_program_cs_webstorageservice_19
    flow_file_nexusreader_web_client_services_wasmepubservice_cs_file_1 -->|model WasmEpubMetadataExtractor| flow_type_nexusreader_web_client_services_wasmepubservice_cs_wasmepubmetadataextractor_43
    flow_file_nexusreader_web_client_services_wasmepubservice_cs_file_1 -->|model WasmEpubReader| flow_type_nexusreader_web_client_services_wasmepubservice_cs_wasmepubreader_8
    click flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1 href "vscode://file/NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs:1:1" "Open source"
    click flow_type_nexusreader_web_client_handlers_authenticationheaderhandler_cs_authenticationheaderhandler_14 href "vscode://file/NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs:14:1" "Open source"
    click flow_file_nexusreader_web_client_program_cs_file_1 href "vscode://file/NexusReader.Web.Client/Program.cs:1:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61 href "vscode://file/NexusReader.Web.Client/Program.cs:61:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66 href "vscode://file/NexusReader.Web.Client/Program.cs:66:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingsyncbroadcaster_94 href "vscode://file/NexusReader.Web.Client/Program.cs:94:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webplatformservice_18 href "vscode://file/NexusReader.Web.Client/Program.cs:18:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webstorageservice_19 href "vscode://file/NexusReader.Web.Client/Program.cs:19:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_identityservice_32 href "vscode://file/NexusReader.Web.Client/Program.cs:32:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40 href "vscode://file/NexusReader.Web.Client/Program.cs:40:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49 href "vscode://file/NexusReader.Web.Client/Program.cs:49:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55 href "vscode://file/NexusReader.Web.Client/Program.cs:55:1" "Open source"
    click flow_file_nexusreader_web_client_services_wasmepubservice_cs_file_1 href "vscode://file/NexusReader.Web.Client/Services/WasmEpubService.cs:1:1" "Open source"
    click flow_type_nexusreader_web_client_services_wasmepubservice_cs_wasmepubreader_8 href "vscode://file/NexusReader.Web.Client/Services/WasmEpubService.cs:8:1" "Open source"
    click flow_type_nexusreader_web_client_services_wasmepubservice_cs_wasmepubmetadataextractor_43 href "vscode://file/NexusReader.Web.Client/Services/WasmEpubService.cs:43:1" "Open source"
    click flow_file_nexusreader_web_client_services_wasmknowledgeservice_cs_file_1 href "vscode://file/NexusReader.Web.Client/Services/WasmKnowledgeService.cs:1:1" "Open source"
    click flow_file_nexusreader_web_client_services_webplatformservice_cs_file_1 href "vscode://file/NexusReader.Web.Client/Services/WebPlatformService.cs:1:1" "Open source"
    click flow_file_nexusreader_web_client_nexusreader_web_client_csproj_file_1 href "vscode://file/NexusReader.Web.Client/NexusReader.Web.Client.csproj:1:1" "Open source"
```

This dependency map shows Program.cs registering WASM implementations (WasmEpubReader, WasmKnowledgeService, WebPlatformService) and the AuthenticationHeaderHandler wired into HttpClient. It highlights browser-specific replacements and the project entry points used for DI and build validation.

```mermaid
flowchart TD
    subgraph flow_0_nexusreader_web_client_program_cs["Program.cs"]
    end
    flow_file_nexusreader_web_client_program_cs_file_1["Program.cs"]
    flow_method_nexusreader_web_client_nexusreader_web_client_csproj_msbuildproperties_3["MSBuildProperties"]
    flow_method_nexusreader_web_client_program_cs_buildandrun_59["BuildAndRun"]
    flow_file_nexusreader_web_client_nexusreader_web_client_csproj_file_1["NexusReader.Web.Client.csproj"]
    flow_type_nexusreader_web_client_program_cs_identityservice_32[/"IdentityService"/]
    flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55[/"NexusReader.Application (extension)"/]
    flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40[/"NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler"/]
    flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49[/"ThrowingDbContextFactory"/]
    flow_type_nexusreader_web_client_program_cs_webplatformservice_18[/"WebPlatformService"/]
    flow_type_nexusreader_web_client_program_cs_webstorageservice_19[/"WebStorageService"/]
    flow_file_nexusreader_web_client_nexusreader_web_client_csproj_file_1 -->|unknown| flow_method_nexusreader_web_client_nexusreader_web_client_csproj_msbuildproperties_3
    flow_file_nexusreader_web_client_program_cs_file_1 -->|middleware| flow_method_nexusreader_web_client_program_cs_buildandrun_59
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IIdentityService| flow_type_nexusreader_web_client_program_cs_identityservice_32
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IServiceCollection application extension| flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55
    flow_file_nexusreader_web_client_program_cs_file_1 -->|NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler| flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IDbContextFactory AppDbContext>| flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IPlatformService| flow_type_nexusreader_web_client_program_cs_webplatformservice_18
    flow_file_nexusreader_web_client_program_cs_file_1 -->|INativeStorageService| flow_type_nexusreader_web_client_program_cs_webstorageservice_19
    click flow_file_nexusreader_web_client_program_cs_file_1 href "vscode://file/NexusReader.Web.Client/Program.cs:1:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webplatformservice_18 href "vscode://file/NexusReader.Web.Client/Program.cs:18:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webstorageservice_19 href "vscode://file/NexusReader.Web.Client/Program.cs:19:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_identityservice_32 href "vscode://file/NexusReader.Web.Client/Program.cs:32:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40 href "vscode://file/NexusReader.Web.Client/Program.cs:40:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49 href "vscode://file/NexusReader.Web.Client/Program.cs:49:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55 href "vscode://file/NexusReader.Web.Client/Program.cs:55:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_buildandrun_59 href "vscode://file/NexusReader.Web.Client/Program.cs:59:1" "Open source"
    click flow_file_nexusreader_web_client_nexusreader_web_client_csproj_file_1 href "vscode://file/NexusReader.Web.Client/NexusReader.Web.Client.csproj:1:1" "Open source"
    click flow_method_nexusreader_web_client_nexusreader_web_client_csproj_msbuildproperties_3 href "vscode://file/NexusReader.Web.Client/NexusReader.Web.Client.csproj:3:1" "Open source"
```

This startup flow focuses on Program.cs: DI registration, service swaps for Web (IPlatformService → WebPlatformService, INativeStorageService → WebStorageService), registration of AuthenticationHeaderHandler, and throwing server stubs to satisfy DI during browser builds.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph flow_0_nexusreader_web_client_program_cs["Program.cs"]
    end
    flow_file_nexusreader_web_client_program_cs_file_1["Program.cs"]
    flow_method_nexusreader_web_client_program_cs_addauthor_84["AddAuthor"]
    flow_method_nexusreader_web_client_program_cs_addebook_84["AddEbook"]
    flow_method_nexusreader_web_client_program_cs_buildandrun_59["BuildAndRun"]
    flow_method_nexusreader_web_client_program_cs_createdbcontext_61["CreateDbContext"]
    flow_method_nexusreader_web_client_program_cs_findauthorbynameasync_84["FindAuthorByNameAsync"]
    flow_method_nexusreader_web_client_program_cs_generateasync_69["GenerateAsync"]
    flow_method_nexusreader_web_client_program_cs_getservice_71["GetService"]
    flow_method_nexusreader_web_client_program_cs_program_top_level_15["Program (top-level)"]
    flow_method_nexusreader_web_client_program_cs_savechangesasync_84["SaveChangesAsync"]
    flow_method_nexusreader_web_client_program_cs_savecoverasync_byte_74["SaveCoverAsync (byte[])"]
    flow_method_nexusreader_web_client_program_cs_savecoverasync_stream_74["SaveCoverAsync (Stream)"]
    flow_method_nexusreader_web_client_program_cs_saveebookasync_byte_74["SaveEbookAsync (byte[])"]
    flow_method_nexusreader_web_client_program_cs_saveebookasync_stream_74["SaveEbookAsync (Stream)"]
    flow_type_nexusreader_web_client_program_cs_identityservice_32[/"IdentityService"/]
    flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55[/"NexusReader.Application (extension)"/]
    flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40[/"NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler"/]
    flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74[/"ThrowingBookStorageService"/]
    flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49[/"ThrowingDbContextFactory"/]
    flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61[/"ThrowingDbContextFactory"/]
    flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84[/"ThrowingEbookRepository"/]
    flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66[/"ThrowingEmbeddingGenerator"/]
    flow_type_nexusreader_web_client_program_cs_webplatformservice_18[/"WebPlatformService"/]
    flow_type_nexusreader_web_client_program_cs_webstorageservice_19[/"WebStorageService"/]
    flow_file_nexusreader_web_client_program_cs_file_1 -->|AddAuthor| flow_method_nexusreader_web_client_program_cs_addauthor_84
    flow_file_nexusreader_web_client_program_cs_file_1 -->|AddEbook| flow_method_nexusreader_web_client_program_cs_addebook_84
    flow_file_nexusreader_web_client_program_cs_file_1 -->|middleware| flow_method_nexusreader_web_client_program_cs_buildandrun_59
    flow_file_nexusreader_web_client_program_cs_file_1 -->|CreateDbContext| flow_method_nexusreader_web_client_program_cs_createdbcontext_61
    flow_file_nexusreader_web_client_program_cs_file_1 -->|FindAuthorByNameAsync| flow_method_nexusreader_web_client_program_cs_findauthorbynameasync_84
    flow_file_nexusreader_web_client_program_cs_file_1 -->|GenerateAsync| flow_method_nexusreader_web_client_program_cs_generateasync_69
    flow_file_nexusreader_web_client_program_cs_file_1 -->|GetService| flow_method_nexusreader_web_client_program_cs_getservice_71
    flow_file_nexusreader_web_client_program_cs_file_1 -->|Program top-level| flow_method_nexusreader_web_client_program_cs_program_top_level_15
    flow_file_nexusreader_web_client_program_cs_file_1 -->|SaveChangesAsync| flow_method_nexusreader_web_client_program_cs_savechangesasync_84
    flow_file_nexusreader_web_client_program_cs_file_1 -->|SaveCoverAsync byte| flow_method_nexusreader_web_client_program_cs_savecoverasync_byte_74
    flow_file_nexusreader_web_client_program_cs_file_1 -->|SaveCoverAsync Stream| flow_method_nexusreader_web_client_program_cs_savecoverasync_stream_74
    flow_file_nexusreader_web_client_program_cs_file_1 -->|SaveEbookAsync byte| flow_method_nexusreader_web_client_program_cs_saveebookasync_byte_74
    flow_file_nexusreader_web_client_program_cs_file_1 -->|SaveEbookAsync Stream| flow_method_nexusreader_web_client_program_cs_saveebookasync_stream_74
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IIdentityService| flow_type_nexusreader_web_client_program_cs_identityservice_32
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IServiceCollection application extension| flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55
    flow_file_nexusreader_web_client_program_cs_file_1 -->|NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler| flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingBookStorageService| flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IDbContextFactory AppDbContext>| flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingDbContextFactory| flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingEbookRepository| flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84
    flow_file_nexusreader_web_client_program_cs_file_1 -->|model ThrowingEmbeddingGenerator| flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66
    flow_file_nexusreader_web_client_program_cs_file_1 -->|IPlatformService| flow_type_nexusreader_web_client_program_cs_webplatformservice_18
    flow_file_nexusreader_web_client_program_cs_file_1 -->|INativeStorageService| flow_type_nexusreader_web_client_program_cs_webstorageservice_19
    click flow_file_nexusreader_web_client_program_cs_file_1 href "vscode://file/NexusReader.Web.Client/Program.cs:1:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_program_top_level_15 href "vscode://file/NexusReader.Web.Client/Program.cs:15:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_createdbcontext_61 href "vscode://file/NexusReader.Web.Client/Program.cs:61:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_generateasync_69 href "vscode://file/NexusReader.Web.Client/Program.cs:69:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_getservice_71 href "vscode://file/NexusReader.Web.Client/Program.cs:71:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_saveebookasync_byte_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_saveebookasync_stream_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_savecoverasync_byte_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_savecoverasync_stream_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_findauthorbynameasync_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_addauthor_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_addebook_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_savechangesasync_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61 href "vscode://file/NexusReader.Web.Client/Program.cs:61:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66 href "vscode://file/NexusReader.Web.Client/Program.cs:66:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webplatformservice_18 href "vscode://file/NexusReader.Web.Client/Program.cs:18:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webstorageservice_19 href "vscode://file/NexusReader.Web.Client/Program.cs:19:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_identityservice_32 href "vscode://file/NexusReader.Web.Client/Program.cs:32:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40 href "vscode://file/NexusReader.Web.Client/Program.cs:40:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49 href "vscode://file/NexusReader.Web.Client/Program.cs:49:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55 href "vscode://file/NexusReader.Web.Client/Program.cs:55:1" "Open source"
    click flow_method_nexusreader_web_client_program_cs_buildandrun_59 href "vscode://file/NexusReader.Web.Client/Program.cs:59:1" "Open source"
```

This Program.cs method flow emphasizes lifecycle points (top-level boot, BuildAndRun) and where services and server-only throwing stubs are created to satisfy DI for the WASM runtime.

```mermaid
classDiagram
    class flow_file_nexusreader_web_client_program_cs_file_1["Program.cs"]
    class flow_type_nexusreader_web_client_program_cs_identityservice_32["IdentityService"]
    class flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55["NexusReader.Application (extension)"]
    class flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40["NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler"]
    class flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74["ThrowingBookStorageService"]
    class flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49["ThrowingDbContextFactory"]
    class flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61["ThrowingDbContextFactory"]
    class flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84["ThrowingEbookRepository"]
    class flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66["ThrowingEmbeddingGenerator"]
    class flow_type_nexusreader_web_client_program_cs_throwingsyncbroadcaster_94["ThrowingSyncBroadcaster"]
    class flow_type_nexusreader_web_client_program_cs_webplatformservice_18["WebPlatformService"]
    class flow_type_nexusreader_web_client_program_cs_webstorageservice_19["WebStorageService"]
    flow_file_nexusreader_web_client_program_cs_file_1 --> flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74 : model ThrowingBookStorageService
    flow_file_nexusreader_web_client_program_cs_file_1 --> flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61 : model ThrowingDbContextFactory
    flow_file_nexusreader_web_client_program_cs_file_1 --> flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84 : model ThrowingEbookRepository
    flow_file_nexusreader_web_client_program_cs_file_1 --> flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66 : model ThrowingEmbeddingGenerator
    flow_file_nexusreader_web_client_program_cs_file_1 --> flow_type_nexusreader_web_client_program_cs_throwingsyncbroadcaster_94 : model ThrowingSyncBroadcaster
    click flow_file_nexusreader_web_client_program_cs_file_1 href "vscode://file/NexusReader.Web.Client/Program.cs:1:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_61 href "vscode://file/NexusReader.Web.Client/Program.cs:61:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingembeddinggenerator_66 href "vscode://file/NexusReader.Web.Client/Program.cs:66:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingbookstorageservice_74 href "vscode://file/NexusReader.Web.Client/Program.cs:74:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingebookrepository_84 href "vscode://file/NexusReader.Web.Client/Program.cs:84:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingsyncbroadcaster_94 href "vscode://file/NexusReader.Web.Client/Program.cs:94:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webplatformservice_18 href "vscode://file/NexusReader.Web.Client/Program.cs:18:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_webstorageservice_19 href "vscode://file/NexusReader.Web.Client/Program.cs:19:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_identityservice_32 href "vscode://file/NexusReader.Web.Client/Program.cs:32:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_web_client_handlers_authenticationheaderhandler_40 href "vscode://file/NexusReader.Web.Client/Program.cs:40:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_throwingdbcontextfactory_49 href "vscode://file/NexusReader.Web.Client/Program.cs:49:1" "Open source"
    click flow_type_nexusreader_web_client_program_cs_nexusreader_application_extension_55 href "vscode://file/NexusReader.Web.Client/Program.cs:55:1" "Open source"
```

The class diagram enumerates the key DI contracts and models wired at startup (IdentityService, AuthenticationHeaderHandler, WebPlatformService) and the server stubs used to keep DI consistent in the browser.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph NexusReader_Web_Client_Handlers_AuthenticationHeaderHandler["AuthenticationHeaderHandler"]
    end
    subgraph NexusReader_Web_Client_Services_WebPlatformService["WebPlatformService"]
    end
    subgraph NexusReader_UI_Shared_Services_KnowledgeGraphService["KnowledgeGraphService"]
    end
    subgraph NexusReader_UI_Shared_Services_NexusAuthenticationStateProvider["NexusAuthenticationStateProvider"]
    end
    subgraph NexusReader_UI_Shared_Services_SyncService["SyncService"]
    end
    subgraph NexusReader_UI_Shared_Services_KnowledgeCoordinator["KnowledgeCoordinator"]
    end
    flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1["KnowledgeCoordinator"]
    flow_file_nexusreader_ui_shared_services_knowledgegraphservice_cs_file_1["KnowledgeGraphService"]
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1["NexusAuthenticationStateProvider"]
    flow_file_nexusreader_ui_shared_services_syncservice_cs_file_1["SyncService"]
    flow_file_nexusreader_web_client_services_webplatformservice_cs_file_1["WebPlatformService"]
    flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112["RequestSummaryAndQuizAsync"]
    flow_method_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_36["Clear"]
    flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84["CreateState"]
    flow_method_nexusreader_ui_shared_services_syncservice_cs_disposeasync_103["DisposeAsync"]
    flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112["CloneHttpRequestMessageAsync"]
    flow_method_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_32["GetDeviceContext"]
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_generatefullquiz_await_91_91["Waits for async work"]
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_requestsummary_await_83_83["Waits for async work"]
    flow_action_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_await_114_114["Waits for async work"]
    flow_action_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_branch_41_41{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_branch_93_93{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_services_syncservice_cs_disposeasync_branch_106_106{"Evaluates branch condition"}
    flow_action_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_branch_119_119{"Copy content if present"}
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1["AuthenticationHeaderHandler"]
    flow_action_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_return_34_34(["Returns result"])
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_generatefullquiz_await_91_91 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_requestsummary_await_83_83 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_action_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_return_34_34 -->|Wraps created context in Result.Ok| flow_action_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_return_34_34
    flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_file_nexusreader_ui_shared_services_knowledgegraphservice_cs_file_1 -->|Clear| flow_method_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_36
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1 -->|CreateState| flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84
    flow_file_nexusreader_ui_shared_services_syncservice_cs_file_1 -->|DisposeAsync| flow_method_nexusreader_ui_shared_services_syncservice_cs_disposeasync_103
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1 -->|CloneHttpRequestMessageAsync| flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112
    flow_file_nexusreader_web_client_services_webplatformservice_cs_file_1 -->|GetDeviceContext| flow_method_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_32
    flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112 -->|Waits for async work| flow_action_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_await_114_114
    flow_method_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_36 -->|true / false| flow_action_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_branch_41_41
    flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84 -->|true / false| flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_branch_93_93
    flow_method_nexusreader_ui_shared_services_syncservice_cs_disposeasync_103 -->|true / false| flow_action_nexusreader_ui_shared_services_syncservice_cs_disposeasync_branch_106_106
    flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112 -->|copy-content / no-content| flow_action_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_branch_119_119
    flow_method_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_32 -->|Returns result| flow_action_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_return_34_34
    click flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1 href "vscode://file/NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs:1:1" "Open source"
    click flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112 href "vscode://file/NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs:112:1" "Open source"
    click flow_action_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_branch_119_119 href "vscode://file/NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs:119:1" "Open source"
    click flow_file_nexusreader_web_client_services_webplatformservice_cs_file_1 href "vscode://file/NexusReader.Web.Client/Services/WebPlatformService.cs:1:1" "Open source"
    click flow_method_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_32 href "vscode://file/NexusReader.Web.Client/Services/WebPlatformService.cs:32:1" "Open source"
    click flow_action_nexusreader_web_client_services_webplatformservice_cs_getdevicecontext_return_34_34 href "vscode://file/NexusReader.Web.Client/Services/WebPlatformService.cs:34:1" "Open source"
    click flow_file_nexusreader_ui_shared_services_knowledgegraphservice_cs_file_1 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeGraphService.cs:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_36 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeGraphService.cs:36:1" "Open source"
    click flow_action_nexusreader_ui_shared_services_knowledgegraphservice_cs_clear_branch_41_41 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeGraphService.cs:41:1" "Open source"
    click flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1 href "vscode://file/NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84 href "vscode://file/NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs:84:1" "Open source"
    click flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_branch_93_93 href "vscode://file/NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs:93:1" "Open source"
    click flow_file_nexusreader_ui_shared_services_syncservice_cs_file_1 href "vscode://file/NexusReader.UI.Shared/Services/SyncService.cs:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_services_syncservice_cs_disposeasync_103 href "vscode://file/NexusReader.UI.Shared/Services/SyncService.cs:103:1" "Open source"
    click flow_action_nexusreader_ui_shared_services_syncservice_cs_disposeasync_branch_106_106 href "vscode://file/NexusReader.UI.Shared/Services/SyncService.cs:106:1" "Open source"
    click flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs:112:1" "Open source"
    click flow_action_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_await_114_114 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs:114:1" "Open source"
    click flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_requestsummary_await_83_83 href "vscode://file/NexusReader.UI.Shared/Components/Molecules/SelectionAiPanel.razor:83:1" "Open source"
    click flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_generatefullquiz_await_91_91 href "vscode://file/NexusReader.UI.Shared/Components/Molecules/SelectionAiPanel.razor:91:1" "Open source"
```

This method flow ties AuthenticationHeaderHandler behavior (cloning requests, adding JWTs, refreshing tokens) to shared UI services (KnowledgeCoordinator, KnowledgeGraphService, NexusAuthenticationStateProvider). It shows how UI components wait on async coordinator methods and how WebPlatformService provides device context.

### Key Files
- NexusReader.Web.Client/Program.cs
- NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs
- NexusReader.Web.Client/Services/WasmEpubService.cs
- NexusReader.Web.Client/Services/WasmKnowledgeService.cs
- NexusReader.Web.Client/Services/WebPlatformService.cs
- NexusReader.UI.Shared/Services/KnowledgeGraphService.cs
- NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs
- NexusReader.UI.Shared/Components/Reader/ReaderCanvas.razor
- NexusReader.UI.Shared/Components/Reader/ReaderFooter.razor
- NexusReader.UI.Shared/Components/Knowledge/KnowledgeGraph.razor

---

## See Also

- [Project Overview and High-level Architecture](../collections/overview.md)
- [Application Layer: Commands, Queries, DTOs and Handlers](application-cqs-and-handlers.md)
- [AI Features, Knowledge Graph and UX Integration](../integrations/ai-and-knowledge-ux.md)
- [Authentication, Authorization and Account Flows](../flows/authentication-and-account.md)
- [Real-time Synchronization and Sync Pipeline](../runtime/realtime-and-sync.md)
- [Mobile (MAUI) Application Integration](../runtime/mobile-maui.md)
- [Infrastructure Services (AI, Epub, Storage, Billing)](../infrastructure/infrastructure-services.md)
- [Top Business Flows](../business/top-business-flows.md)
