## Project Overview and High-level Architecture
A concise high-level summary of the solution: projects include Web (server), Web.Client (WASM client), MAUI (mobile/desktop), Application (use-case & DTO contracts), Domain (entities), Infrastructure (implementations), Data (persistence). Server entrypoint: NexusReader.Web/Program.cs; WASM client entrypoint: NexusReader.Web.Client/Program.cs; MAUI entrypoint: NexusReader.Maui (platform project). The Application layer defines public interfaces (commands, queries, repositories, services) consumed by Infrastructure implementations and by Web/Web.Client/MAUI at runtime.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    flow_file_nexusreader_application_abstractions_services_ibillingservice_cs_file_1["IBillingService"]
    flow_file_nexusreader_application_abstractions_services_ibookstorageservice_cs_file_1["IBookStorageService"]
    flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1["IIdentityService.cs"]
    flow_file_nexusreader_application_abstractions_services_iknowledgeservice_cs_file_1["IKnowledgeService"]
    flow_file_nexusreader_application_abstractions_messaging_icommand_cs_file_1["ICommand.cs"]
    flow_file_nexusreader_application_abstractions_messaging_icommandhandler_cs_file_1["ICommandHandler.cs"]
    flow_file_nexusreader_application_abstractions_messaging_iquery_cs_file_1["IQuery<TResponse>"]
    flow_file_nexusreader_application_abstractions_messaging_iqueryhandler_cs_file_1["IQueryHandler"]
    flow_file_nexusreader_application_abstractions_persistence_iebookrepository_cs_file_1["IEbookRepository"]
    flow_file_nexusreader_infrastructure_identity_tokenlimithandler_cs_file_1["TokenLimitHandler"]
    flow_type_nexusreader_application_abstractions_messaging_icommand_cs_icommand_6[/"ICommand"/]
    flow_type_nexusreader_application_abstractions_messaging_icommand_cs_icommand_tresponse_10[/"ICommand<TResponse>"/]
    flow_type_nexusreader_application_abstractions_messaging_icommandhandler_cs_icommandhandler_tcommand_6[/"ICommandHandler<TCommand>"/]
    flow_type_nexusreader_application_abstractions_messaging_icommandhandler_cs_icommandhandler_tcommand_tresponse_11[/"ICommandHandler<TCommand, TResponse>"/]
    flow_type_nexusreader_application_abstractions_messaging_iquery_cs_iquery_tresponse_6[/"IQuery<TResponse>"/]
    flow_type_nexusreader_application_abstractions_messaging_iqueryhandler_cs_iqueryhandler_6[/"IQueryHandler"/]
    flow_type_nexusreader_application_abstractions_persistence_iebookrepository_cs_iebookrepository_9[/"IEbookRepository"/]
    flow_type_nexusreader_application_abstractions_services_ibillingservice_cs_ibillingservice_6[/"IBillingService"/]
    flow_type_nexusreader_application_abstractions_services_ibookstorageservice_cs_ibookstorageservice_6[/"IBookStorageService"/]
    flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6[/"IIdentityService"/]
    flow_file_nexusreader_application_abstractions_messaging_icommand_cs_file_1 -->|interface ICommand| flow_type_nexusreader_application_abstractions_messaging_icommand_cs_icommand_6
    flow_file_nexusreader_application_abstractions_messaging_icommand_cs_file_1 -->|interface ICommand TResponse>| flow_type_nexusreader_application_abstractions_messaging_icommand_cs_icommand_tresponse_10
    flow_file_nexusreader_application_abstractions_messaging_icommandhandler_cs_file_1 -->|interface ICommandHandler TCommand>| flow_type_nexusreader_application_abstractions_messaging_icommandhandler_cs_icommandhandler_tcommand_6
    flow_file_nexusreader_application_abstractions_messaging_icommandhandler_cs_file_1 -->|interface ICommandHandler TCommand, TResponse>| flow_type_nexusreader_application_abstractions_messaging_icommandhandler_cs_icommandhandler_tcommand_tresponse_11
    flow_file_nexusreader_application_abstractions_messaging_iquery_cs_file_1 -->|interface IQuery TResponse>| flow_type_nexusreader_application_abstractions_messaging_iquery_cs_iquery_tresponse_6
    flow_file_nexusreader_application_abstractions_messaging_iqueryhandler_cs_file_1 -->|interface IQueryHandler| flow_type_nexusreader_application_abstractions_messaging_iqueryhandler_cs_iqueryhandler_6
    flow_file_nexusreader_application_abstractions_persistence_iebookrepository_cs_file_1 -->|interface IEbookRepository| flow_type_nexusreader_application_abstractions_persistence_iebookrepository_cs_iebookrepository_9
    flow_file_nexusreader_application_abstractions_services_ibillingservice_cs_file_1 -->|interface IBillingService| flow_type_nexusreader_application_abstractions_services_ibillingservice_cs_ibillingservice_6
    flow_file_nexusreader_application_abstractions_services_ibookstorageservice_cs_file_1 -->|interface IBookStorageService| flow_type_nexusreader_application_abstractions_services_ibookstorageservice_cs_ibookstorageservice_6
    flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 -->|interface IIdentityService| flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6
    flow_file_nexusreader_application_abstractions_services_iknowledgeservice_cs_file_1 href "vscode://file/NexusReader.Application/Abstractions/Services/IKnowledgeService.cs:1:1" "Open source"
```

This dependency map highlights Application-layer public contracts (commands, queries, service and repository interfaces) and shows Infrastructure types (e.g., TokenLimitHandler) that implement or reference those contracts. It documents where each interface/type is defined so Application remains decoupled from concrete infra implementations.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph flow_1_nexusreader_web_client_program_cs["Program.cs"]
    end
    flow_file_nexusreader_web_client_program_cs_file_1["Program.cs"]
    flow_method_nexusreader_application_dependencyinjection_cs_addapplication_8["AddApplication"]
    flow_method_nexusreader_web_client_program_cs_buildandrun_59["BuildAndRun"]
    flow_file_nexusreader_application_dependencyinjection_cs_file_1["DependencyInjection"]
    flow_file_nexusreader_application_mappings_mappingconfig_cs_file_1["MappingConfig"]
    flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1["DependencyInjection"]
    flow_type_nexusreader_application_mappings_mappingconfig_cs_config_global_typeadapterconfig_19[/"config (global TypeAdapterConfig)"/]
    flow_type_nexusreader_application_mappings_mappingconfig_cs_servicemapper_20[/"ServiceMapper"/]
    flow_type_nexusreader_infrastructure_dependencyinjection_cs_appdbcontext_36[/"AppDbContext"/]
    flow_type_nexusreader_infrastructure_dependencyinjection_cs_appdbcontext_41[/"AppDbContext"/]
    flow_type_nexusreader_infrastructure_dependencyinjection_cs_hangfire_with_postgres_storage_66[/"Hangfire with Postgres storage"/]
    flow_type_nexusreader_infrastructure_dependencyinjection_cs_neo4j_driver_61[/"Neo4j.Driver"/]
    flow_type_nexusreader_infrastructure_dependencyinjection_cs_qdrantclient_57[/"QdrantClient"/]
    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_application_dependencyinjection_cs_file_1 -->|service-registration| flow_method_nexusreader_application_dependencyinjection_cs_addapplication_8
    flow_file_nexusreader_application_mappings_mappingconfig_cs_file_1 -->|TypeAdapterConfig| flow_type_nexusreader_application_mappings_mappingconfig_cs_config_global_typeadapterconfig_19
    flow_file_nexusreader_application_mappings_mappingconfig_cs_file_1 -->|IMapper| flow_type_nexusreader_application_mappings_mappingconfig_cs_servicemapper_20
    flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1 -->|AppDbContext factory| flow_type_nexusreader_infrastructure_dependencyinjection_cs_appdbcontext_36
    flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1 -->|AppDbContext| flow_type_nexusreader_infrastructure_dependencyinjection_cs_appdbcontext_41
    flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1 -->|uses| flow_type_nexusreader_infrastructure_dependencyinjection_cs_hangfire_with_postgres_storage_66
    flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1 -->|IDriver| flow_type_nexusreader_infrastructure_dependencyinjection_cs_neo4j_driver_61
    flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1 -->|QdrantClient| flow_type_nexusreader_infrastructure_dependencyinjection_cs_qdrantclient_57
    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_application_mappings_mappingconfig_cs_file_1 href "vscode://file/NexusReader.Application/Mappings/MappingConfig.cs:1:1" "Open source"
    click flow_type_nexusreader_application_mappings_mappingconfig_cs_config_global_typeadapterconfig_19 href "vscode://file/NexusReader.Application/Mappings/MappingConfig.cs:19:1" "Open source"
    click flow_type_nexusreader_application_mappings_mappingconfig_cs_servicemapper_20 href "vscode://file/NexusReader.Application/Mappings/MappingConfig.cs:20: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_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_application_dependencyinjection_cs_file_1 href "vscode://file/NexusReader.Application/DependencyInjection.cs:1:1" "Open source"
    click flow_method_nexusreader_application_dependencyinjection_cs_addapplication_8 href "vscode://file/NexusReader.Application/DependencyInjection.cs:8:1" "Open source"
    click flow_file_nexusreader_infrastructure_dependencyinjection_cs_file_1 href "vscode://file/NexusReader.Infrastructure/DependencyInjection.cs:1:1" "Open source"
    click flow_type_nexusreader_infrastructure_dependencyinjection_cs_appdbcontext_36 href "vscode://file/NexusReader.Infrastructure/DependencyInjection.cs:36:1" "Open source"
    click flow_type_nexusreader_infrastructure_dependencyinjection_cs_appdbcontext_41 href "vscode://file/NexusReader.Infrastructure/DependencyInjection.cs:41:1" "Open source"
    click flow_type_nexusreader_infrastructure_dependencyinjection_cs_qdrantclient_57 href "vscode://file/NexusReader.Infrastructure/DependencyInjection.cs:57:1" "Open source"
    click flow_type_nexusreader_infrastructure_dependencyinjection_cs_neo4j_driver_61 href "vscode://file/NexusReader.Infrastructure/DependencyInjection.cs:61:1" "Open source"
    click flow_type_nexusreader_infrastructure_dependencyinjection_cs_hangfire_with_postgres_storage_66 href "vscode://file/NexusReader.Infrastructure/DependencyInjection.cs:66:1" "Open source"
```

This startup diagram shows Web.Client Program.cs registering Application and Infrastructure services, mapping configuration, and runtime dependencies (AppDbContext, Neo4j, Qdrant, Hangfire). It documents which platform services (IPlatformService, INativeStorageService) and HTTP handlers are wired into the client runtime.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph flow_0_nexusreader_web_program_cs["Program.cs"]
    end
    flow_file_nexusreader_web_program_cs_file_1["Program.cs"]
    flow_method_nexusreader_web_program_cs_configure_pipeline_and_run_225["Configure pipeline and run"]
    flow_method_nexusreader_web_program_cs_database_initialization_and_seeding_with_retries_175["Database initialization and seeding with retries"]
    flow_method_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_250["GetEpubContent (GET /api/epub/{ebookId}/{index})"]
    flow_method_nexusreader_web_program_cs_getmyebooks_get_api_library_books_355["GetMyEbooks (GET /api/library/books)"]
    flow_method_nexusreader_web_program_cs_handlesubscriptioncancellation_434["HandleSubscriptionCancellation"]
    flow_method_nexusreader_web_program_cs_handlesubscriptionsuccess_410["HandleSubscriptionSuccess"]
    flow_method_nexusreader_web_program_cs_identity_login_get_identity_login_google_453["Identity Login (GET /identity/login/google)"]
    flow_method_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_330["IngestEbook (POST /api/library/ingest)"]
    flow_method_nexusreader_web_program_cs_knowledge_api_group_mappings_261["Knowledge API group mappings"]
    flow_method_nexusreader_web_program_cs_map_identity_api_mapgroup_identity_451["Map Identity API (MapGroup /identity)"]
    flow_method_nexusreader_web_program_cs_program_top_level_29["Program (top-level)"]
    flow_method_nexusreader_web_program_cs_stripewebhook_post_api_stripewebhook_367["StripeWebhook (POST /api/StripeWebhook)"]
    flow_method_nexusreader_web_program_cs_usehangfiredashboard_163["UseHangfireDashboard"]
    flow_type_nexusreader_web_program_cs_addapplication_78[/"AddApplication()"/]
    flow_type_nexusreader_web_program_cs_addinfrastructure_iconfiguration_79[/"AddInfrastructure(IConfiguration)"/]
    flow_type_nexusreader_web_program_cs_framework_34[/"framework"/]
    flow_type_nexusreader_web_program_cs_identity_ef_stores_107[/"Identity + EF stores"/]
    flow_type_nexusreader_web_program_cs_named_httpclient_58[/"named HttpClient"/]
    flow_type_nexusreader_web_program_cs_nexusreader_infrastructure_services_billingservice_93[/"NexusReader.Infrastructure.Services.BillingService"/]
    flow_type_nexusreader_web_program_cs_registerservicesfromassemblies_81[/"RegisterServicesFromAssemblies"/]
    flow_type_nexusreader_web_program_cs_serveridentityservice_75[/"ServerIdentityService"/]
    flow_type_nexusreader_web_program_cs_tokenlimithandler_87[/"TokenLimitHandler"/]
    flow_type_nexusreader_web_program_cs_webplatformservice_47[/"WebPlatformService"/]
    flow_file_nexusreader_web_program_cs_file_1 -->|middleware| flow_method_nexusreader_web_program_cs_configure_pipeline_and_run_225
    flow_file_nexusreader_web_program_cs_file_1 -->|unknown| flow_method_nexusreader_web_program_cs_database_initialization_and_seeding_with_retries_175
    flow_file_nexusreader_web_program_cs_file_1 -->|GetEpubContent GET / api / epub / ebookId / index| flow_method_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_250
    flow_file_nexusreader_web_program_cs_file_1 -->|GetMyEbooks GET / api / library / books| flow_method_nexusreader_web_program_cs_getmyebooks_get_api_library_books_355
    flow_file_nexusreader_web_program_cs_file_1 -->|HandleSubscriptionCancellation| flow_method_nexusreader_web_program_cs_handlesubscriptioncancellation_434
    flow_file_nexusreader_web_program_cs_file_1 -->|HandleSubscriptionSuccess| flow_method_nexusreader_web_program_cs_handlesubscriptionsuccess_410
    flow_file_nexusreader_web_program_cs_file_1 -->|Identity Login GET / identity / login / google| flow_method_nexusreader_web_program_cs_identity_login_get_identity_login_google_453
    flow_file_nexusreader_web_program_cs_file_1 -->|IngestEbook POST / api / library / ingest| flow_method_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_330
    flow_file_nexusreader_web_program_cs_file_1 -->|Knowledge API group mappings| flow_method_nexusreader_web_program_cs_knowledge_api_group_mappings_261
    flow_file_nexusreader_web_program_cs_file_1 -->|Map Identity API MapGroup / identity| flow_method_nexusreader_web_program_cs_map_identity_api_mapgroup_identity_451
    flow_file_nexusreader_web_program_cs_file_1 -->|Program top-level| flow_method_nexusreader_web_program_cs_program_top_level_29
    flow_file_nexusreader_web_program_cs_file_1 -->|StripeWebhook POST / api / StripeWebhook| flow_method_nexusreader_web_program_cs_stripewebhook_post_api_stripewebhook_367
    flow_file_nexusreader_web_program_cs_file_1 -->|middleware| flow_method_nexusreader_web_program_cs_usehangfiredashboard_163
    flow_file_nexusreader_web_program_cs_file_1 -->|Application layer| flow_type_nexusreader_web_program_cs_addapplication_78
    flow_file_nexusreader_web_program_cs_file_1 -->|Infrastructure layer| flow_type_nexusreader_web_program_cs_addinfrastructure_iconfiguration_79
    flow_file_nexusreader_web_program_cs_file_1 -->|Razor / Blazor services| flow_type_nexusreader_web_program_cs_framework_34
    flow_file_nexusreader_web_program_cs_file_1 -->|uses| flow_type_nexusreader_web_program_cs_identity_ef_stores_107
    flow_file_nexusreader_web_program_cs_file_1 -->|uses| flow_type_nexusreader_web_program_cs_named_httpclient_58
    flow_file_nexusreader_web_program_cs_file_1 -->|IBillingService| flow_type_nexusreader_web_program_cs_nexusreader_infrastructure_services_billingservice_93
    flow_file_nexusreader_web_program_cs_file_1 -->|MediatR handlers| flow_type_nexusreader_web_program_cs_registerservicesfromassemblies_81
    flow_file_nexusreader_web_program_cs_file_1 -->|IIdentityService| flow_type_nexusreader_web_program_cs_serveridentityservice_75
    flow_file_nexusreader_web_program_cs_file_1 -->|IAuthorizationHandler| flow_type_nexusreader_web_program_cs_tokenlimithandler_87
    flow_file_nexusreader_web_program_cs_file_1 -->|IPlatformService| flow_type_nexusreader_web_program_cs_webplatformservice_47
    click flow_file_nexusreader_web_program_cs_file_1 href "vscode://file/NexusReader.Web/Program.cs:1:1" "Open source"
    click flow_method_nexusreader_web_program_cs_program_top_level_29 href "vscode://file/NexusReader.Web/Program.cs:29:1" "Open source"
    click flow_method_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_250 href "vscode://file/NexusReader.Web/Program.cs:250:1" "Open source"
    click flow_method_nexusreader_web_program_cs_knowledge_api_group_mappings_261 href "vscode://file/NexusReader.Web/Program.cs:261:1" "Open source"
    click flow_method_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_330 href "vscode://file/NexusReader.Web/Program.cs:330:1" "Open source"
    click flow_method_nexusreader_web_program_cs_getmyebooks_get_api_library_books_355 href "vscode://file/NexusReader.Web/Program.cs:355:1" "Open source"
    click flow_method_nexusreader_web_program_cs_stripewebhook_post_api_stripewebhook_367 href "vscode://file/NexusReader.Web/Program.cs:367:1" "Open source"
    click flow_method_nexusreader_web_program_cs_handlesubscriptionsuccess_410 href "vscode://file/NexusReader.Web/Program.cs:410:1" "Open source"
    click flow_method_nexusreader_web_program_cs_handlesubscriptioncancellation_434 href "vscode://file/NexusReader.Web/Program.cs:434:1" "Open source"
    click flow_method_nexusreader_web_program_cs_map_identity_api_mapgroup_identity_451 href "vscode://file/NexusReader.Web/Program.cs:451:1" "Open source"
    click flow_method_nexusreader_web_program_cs_identity_login_get_identity_login_google_453 href "vscode://file/NexusReader.Web/Program.cs:453:1" "Open source"
    click flow_type_nexusreader_web_program_cs_framework_34 href "vscode://file/NexusReader.Web/Program.cs:34:1" "Open source"
    click flow_type_nexusreader_web_program_cs_webplatformservice_47 href "vscode://file/NexusReader.Web/Program.cs:47:1" "Open source"
    click flow_type_nexusreader_web_program_cs_named_httpclient_58 href "vscode://file/NexusReader.Web/Program.cs:58:1" "Open source"
    click flow_type_nexusreader_web_program_cs_serveridentityservice_75 href "vscode://file/NexusReader.Web/Program.cs:75:1" "Open source"
    click flow_type_nexusreader_web_program_cs_addapplication_78 href "vscode://file/NexusReader.Web/Program.cs:78:1" "Open source"
    click flow_type_nexusreader_web_program_cs_addinfrastructure_iconfiguration_79 href "vscode://file/NexusReader.Web/Program.cs:79:1" "Open source"
    click flow_type_nexusreader_web_program_cs_registerservicesfromassemblies_81 href "vscode://file/NexusReader.Web/Program.cs:81:1" "Open source"
    click flow_type_nexusreader_web_program_cs_tokenlimithandler_87 href "vscode://file/NexusReader.Web/Program.cs:87:1" "Open source"
    click flow_type_nexusreader_web_program_cs_nexusreader_infrastructure_services_billingservice_93 href "vscode://file/NexusReader.Web/Program.cs:93:1" "Open source"
    click flow_type_nexusreader_web_program_cs_identity_ef_stores_107 href "vscode://file/NexusReader.Web/Program.cs:107:1" "Open source"
    click flow_method_nexusreader_web_program_cs_usehangfiredashboard_163 href "vscode://file/NexusReader.Web/Program.cs:163:1" "Open source"
    click flow_method_nexusreader_web_program_cs_database_initialization_and_seeding_with_retries_175 href "vscode://file/NexusReader.Web/Program.cs:175:1" "Open source"
    click flow_method_nexusreader_web_program_cs_configure_pipeline_and_run_225 href "vscode://file/NexusReader.Web/Program.cs:225:1" "Open source"
```

This diagram shows the server Program.cs responsibilities: request endpoints, pipeline configuration, DB initialization/seeding, identity, billing webhook, and how AddApplication/AddInfrastructure compose the runtime. It maps HTTP routes to handlers and indicates where MediatR, authorization handlers, and platform services are wired.

```mermaid
classDiagram
    class flow_file_nexusreader_web_program_cs_file_1["Program.cs"]
    class flow_type_nexusreader_web_program_cs_addapplication_78["AddApplication()"]
    class flow_type_nexusreader_web_program_cs_addinfrastructure_iconfiguration_79["AddInfrastructure(IConfiguration)"]
    class flow_type_nexusreader_web_program_cs_askquestionrequest_569["AskQuestionRequest"]
    class flow_type_nexusreader_web_program_cs_framework_34["framework"]
    class flow_type_nexusreader_web_program_cs_groundednessrequest_567["GroundednessRequest"]
    class flow_type_nexusreader_web_program_cs_identity_ef_stores_107["Identity + EF stores"]
    class flow_type_nexusreader_web_program_cs_knowledgerequest_566["KnowledgeRequest"]
    class flow_type_nexusreader_web_program_cs_named_httpclient_58["named HttpClient"]
    class flow_type_nexusreader_web_program_cs_nexusreader_infrastructure_services_billingservice_93["NexusReader.Infrastructure.Services.BillingService"]
    class flow_type_nexusreader_web_program_cs_registerservicesfromassemblies_81["RegisterServicesFromAssemblies"]
    class flow_type_nexusreader_web_program_cs_semanticsearchrequest_568["SemanticSearchRequest"]
    class flow_type_nexusreader_web_program_cs_serveridentityservice_75["ServerIdentityService"]
    class flow_type_nexusreader_web_program_cs_tokenlimithandler_87["TokenLimitHandler"]
    class flow_type_nexusreader_web_program_cs_webplatformservice_47["WebPlatformService"]
    flow_file_nexusreader_web_program_cs_file_1 --> flow_type_nexusreader_web_program_cs_askquestionrequest_569 : dto AskQuestionRequest
    flow_file_nexusreader_web_program_cs_file_1 --> flow_type_nexusreader_web_program_cs_groundednessrequest_567 : dto GroundednessRequest
    flow_file_nexusreader_web_program_cs_file_1 --> flow_type_nexusreader_web_program_cs_knowledgerequest_566 : dto KnowledgeRequest
    flow_file_nexusreader_web_program_cs_file_1 --> flow_type_nexusreader_web_program_cs_semanticsearchrequest_568 : dto SemanticSearchRequest
    click flow_file_nexusreader_web_program_cs_file_1 href "vscode://file/NexusReader.Web/Program.cs:1:1" "Open source"
    click flow_type_nexusreader_web_program_cs_knowledgerequest_566 href "vscode://file/NexusReader.Web/Program.cs:566:1" "Open source"
    click flow_type_nexusreader_web_program_cs_groundednessrequest_567 href "vscode://file/NexusReader.Web/Program.cs:567:1" "Open source"
    click flow_type_nexusreader_web_program_cs_semanticsearchrequest_568 href "vscode://file/NexusReader.Web/Program.cs:568:1" "Open source"
    click flow_type_nexusreader_web_program_cs_askquestionrequest_569 href "vscode://file/NexusReader.Web/Program.cs:569:1" "Open source"
    click flow_type_nexusreader_web_program_cs_framework_34 href "vscode://file/NexusReader.Web/Program.cs:34:1" "Open source"
    click flow_type_nexusreader_web_program_cs_webplatformservice_47 href "vscode://file/NexusReader.Web/Program.cs:47:1" "Open source"
    click flow_type_nexusreader_web_program_cs_named_httpclient_58 href "vscode://file/NexusReader.Web/Program.cs:58:1" "Open source"
    click flow_type_nexusreader_web_program_cs_serveridentityservice_75 href "vscode://file/NexusReader.Web/Program.cs:75:1" "Open source"
    click flow_type_nexusreader_web_program_cs_addapplication_78 href "vscode://file/NexusReader.Web/Program.cs:78:1" "Open source"
    click flow_type_nexusreader_web_program_cs_addinfrastructure_iconfiguration_79 href "vscode://file/NexusReader.Web/Program.cs:79:1" "Open source"
    click flow_type_nexusreader_web_program_cs_registerservicesfromassemblies_81 href "vscode://file/NexusReader.Web/Program.cs:81:1" "Open source"
    click flow_type_nexusreader_web_program_cs_tokenlimithandler_87 href "vscode://file/NexusReader.Web/Program.cs:87:1" "Open source"
    click flow_type_nexusreader_web_program_cs_nexusreader_infrastructure_services_billingservice_93 href "vscode://file/NexusReader.Web/Program.cs:93:1" "Open source"
    click flow_type_nexusreader_web_program_cs_identity_ef_stores_107 href "vscode://file/NexusReader.Web/Program.cs:107:1" "Open source"
```

The class diagram extracts DTOs and Program-level contracts (AskQuestionRequest, KnowledgeRequest, service registrations). It documents the public data contracts produced/consumed by the HTTP surface and which infrastructure/service classes are referenced at startup.

```mermaid
flowchart TD
    subgraph NexusReader_Web_Program["Program"]
    end
    flow_method_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_250["GetEpubContent (GET /api/epub/{ebookId}/{index})"]
    flow_method_nexusreader_web_program_cs_getmyebooks_get_api_library_books_355["GetMyEbooks (GET /api/library/books)"]
    flow_method_nexusreader_web_program_cs_handlesubscriptioncancellation_434["HandleSubscriptionCancellation"]
    flow_method_nexusreader_web_program_cs_handlesubscriptionsuccess_410["HandleSubscriptionSuccess"]
    flow_method_nexusreader_web_program_cs_identity_login_get_identity_login_google_453["Identity Login (GET /identity/login/google)"]
    flow_method_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_330["IngestEbook (POST /api/library/ingest)"]
    flow_method_nexusreader_web_program_cs_program_top_level_29["Program (top-level)"]
    flow_action_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_guard_clause_252_252{"Extract userId"}
    flow_action_nexusreader_web_program_cs_getmyebooks_get_api_library_books_guard_clause_357_357{"Ensure authenticated user"}
    flow_action_nexusreader_web_program_cs_handlesubscriptioncancellation_guard_clause_439_439{"Guards early exit or rejection path"}
    flow_action_nexusreader_web_program_cs_handlesubscriptionsuccess_guard_clause_416_416{"Guards early exit or rejection path"}
    flow_action_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_guard_clause_332_332{"Ensure authenticated user"}
    flow_action_nexusreader_web_program_cs_program_top_level_branch_62_62{"Evaluates branch condition"}
    flow_action_nexusreader_web_program_cs_identity_login_get_identity_login_google_return_460_460(["Return Challenge to Google"])
    flow_method_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_250 -->|continue| flow_action_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_guard_clause_252_252
    flow_method_nexusreader_web_program_cs_getmyebooks_get_api_library_books_355 -->|Unauthorized / continue| flow_action_nexusreader_web_program_cs_getmyebooks_get_api_library_books_guard_clause_357_357
    flow_method_nexusreader_web_program_cs_handlesubscriptioncancellation_434 -->|exit / continue| flow_action_nexusreader_web_program_cs_handlesubscriptioncancellation_guard_clause_439_439
    flow_method_nexusreader_web_program_cs_handlesubscriptionsuccess_410 -->|exit / continue| flow_action_nexusreader_web_program_cs_handlesubscriptionsuccess_guard_clause_416_416
    flow_method_nexusreader_web_program_cs_identity_login_get_identity_login_google_453 -->|Return Challenge to Google| flow_action_nexusreader_web_program_cs_identity_login_get_identity_login_google_return_460_460
    flow_method_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_330 -->|Unauthorized / continue| flow_action_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_guard_clause_332_332
    flow_method_nexusreader_web_program_cs_program_top_level_29 -->|true / false| flow_action_nexusreader_web_program_cs_program_top_level_branch_62_62
    click flow_method_nexusreader_web_program_cs_program_top_level_29 href "vscode://file/NexusReader.Web/Program.cs:29:1" "Open source"
    click flow_action_nexusreader_web_program_cs_program_top_level_branch_62_62 href "vscode://file/NexusReader.Web/Program.cs:62:1" "Open source"
    click flow_method_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_250 href "vscode://file/NexusReader.Web/Program.cs:250:1" "Open source"
    click flow_action_nexusreader_web_program_cs_getepubcontent_get_api_epub_ebookid_index_guard_clause_252_252 href "vscode://file/NexusReader.Web/Program.cs:252:1" "Open source"
    click flow_method_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_330 href "vscode://file/NexusReader.Web/Program.cs:330:1" "Open source"
    click flow_action_nexusreader_web_program_cs_ingestebook_post_api_library_ingest_guard_clause_332_332 href "vscode://file/NexusReader.Web/Program.cs:332:1" "Open source"
    click flow_method_nexusreader_web_program_cs_getmyebooks_get_api_library_books_355 href "vscode://file/NexusReader.Web/Program.cs:355:1" "Open source"
    click flow_action_nexusreader_web_program_cs_getmyebooks_get_api_library_books_guard_clause_357_357 href "vscode://file/NexusReader.Web/Program.cs:357:1" "Open source"
    click flow_method_nexusreader_web_program_cs_handlesubscriptionsuccess_410 href "vscode://file/NexusReader.Web/Program.cs:410:1" "Open source"
    click flow_action_nexusreader_web_program_cs_handlesubscriptionsuccess_guard_clause_416_416 href "vscode://file/NexusReader.Web/Program.cs:416:1" "Open source"
    click flow_method_nexusreader_web_program_cs_handlesubscriptioncancellation_434 href "vscode://file/NexusReader.Web/Program.cs:434:1" "Open source"
    click flow_action_nexusreader_web_program_cs_handlesubscriptioncancellation_guard_clause_439_439 href "vscode://file/NexusReader.Web/Program.cs:439:1" "Open source"
    click flow_method_nexusreader_web_program_cs_identity_login_get_identity_login_google_453 href "vscode://file/NexusReader.Web/Program.cs:453:1" "Open source"
    click flow_action_nexusreader_web_program_cs_identity_login_get_identity_login_google_return_460_460 href "vscode://file/NexusReader.Web/Program.cs:460:1" "Open source"
```

This control-flow view highlights guard clauses and failure/early-exit paths for key endpoints (auth checks, subscription handling, external identity challenge). It helps identify where authorization and validation short-circuit requests.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph NexusReader_Infrastructure_Helpers_ContentHasher["ContentHasher"]
    end
    subgraph NexusReader_Infrastructure_RealTime_SignalRSyncBroadcaster["SignalRSyncBroadcaster"]
    end
    subgraph NexusReader_Infrastructure_RealTime_SyncHub["SyncHub"]
    end
    subgraph NexusReader_UI_Shared_Services_KnowledgeCoordinator["KnowledgeCoordinator"]
    end
    flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1["ContentHasher"]
    flow_file_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_file_1["SignalRSyncBroadcaster"]
    flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1["KnowledgeCoordinator"]
    flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9["ComputeHash"]
    flow_method_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_21["BroadcastProgressAsync"]
    flow_method_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_28["OnConnectedAsync"]
    flow_method_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_38["OnDisconnectedAsync"]
    flow_method_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_19["UpdateProgress"]
    flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112["RequestSummaryAndQuizAsync"]
    flow_action_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_branch_11_11{"Evaluates branch condition"}
    flow_action_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_guard_clause_30_30{"check excludedConnectionId presence"}
    flow_action_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_repository_read_30_30["Reads repository or persistence state"]
    flow_action_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_repository_read_40_40["Reads repository or persistence state"]
    flow_action_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_repository_read_21_21["Reads repository or persistence state"]
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85["Waits for async work"]
    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_file_nexusreader_infrastructure_realtime_synchub_cs_file_1["SyncHub"]
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85 -->|ContentHasher.ComputeHash| flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9
    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_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1 -->|ComputeHash| flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9
    flow_file_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_file_1 -->|BroadcastProgressAsync| flow_method_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_21
    flow_file_nexusreader_infrastructure_realtime_synchub_cs_file_1 -->|OnConnectedAsync| flow_method_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_28
    flow_file_nexusreader_infrastructure_realtime_synchub_cs_file_1 -->|OnDisconnectedAsync| flow_method_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_38
    flow_file_nexusreader_infrastructure_realtime_synchub_cs_file_1 -->|UpdateProgress| flow_method_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_19
    flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9 -->|true / false| flow_action_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_branch_11_11
    flow_method_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_21 -->|enter branch: attempts exclusion comment / else: normal send| flow_action_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_guard_clause_30_30
    flow_method_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_28 -->|Reads repository or persistence state| flow_action_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_repository_read_30_30
    flow_method_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_38 -->|Reads repository or persistence state| flow_action_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_repository_read_40_40
    flow_method_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_19 -->|Reads repository or persistence state| flow_action_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_repository_read_21_21
    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
    click flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:85:1" "Open source"
    click flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:1:1" "Open source"
    click flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:9:1" "Open source"
    click flow_action_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_branch_11_11 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:11:1" "Open source"
    click flow_file_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_file_1 href "vscode://file/NexusReader.Infrastructure/RealTime/SignalRSyncBroadcaster.cs:1:1" "Open source"
    click flow_method_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_21 href "vscode://file/NexusReader.Infrastructure/RealTime/SignalRSyncBroadcaster.cs:21:1" "Open source"
    click flow_action_nexusreader_infrastructure_realtime_signalrsyncbroadcaster_cs_broadcastprogressasync_guard_clause_30_30 href "vscode://file/NexusReader.Infrastructure/RealTime/SignalRSyncBroadcaster.cs:30:1" "Open source"
    click flow_file_nexusreader_infrastructure_realtime_synchub_cs_file_1 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:1:1" "Open source"
    click flow_method_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_19 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:19:1" "Open source"
    click flow_action_nexusreader_infrastructure_realtime_synchub_cs_updateprogress_repository_read_21_21 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:21:1" "Open source"
    click flow_method_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_28 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:28:1" "Open source"
    click flow_action_nexusreader_infrastructure_realtime_synchub_cs_onconnectedasync_repository_read_30_30 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:30:1" "Open source"
    click flow_method_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_38 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:38:1" "Open source"
    click flow_action_nexusreader_infrastructure_realtime_synchub_cs_ondisconnectedasync_repository_read_40_40 href "vscode://file/NexusReader.Infrastructure/RealTime/SyncHub.cs:40: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"
```

This method-flow highlights runtime interactions between helpers (ContentHasher), real-time components (SignalR broadcaster, SyncHub) and UI coordinator logic; it calls out async waits and repository reads that affect responsiveness and concurrency.

### Key Files
- NexusReader.Web/Program.cs
- NexusReader.Web.Client/Program.cs
- NexusReader.Maui/ (MAUI project entrypoints)
- NexusReader.Application/DependencyInjection.cs
- NexusReader.Infrastructure/DependencyInjection.cs
- NexusReader.Application/Mappings/MappingConfig.cs
- NexusReader.Application/Abstractions/Persistence/IEbookRepository.cs
- NexusReader.Application/Abstractions/Services/IIdentityService.cs
- NexusReader.Application/Abstractions/Services/IKnowledgeService.cs
- NexusReader.Infrastructure/Identity/TokenLimitHandler.cs
- NexusReader.Infrastructure/RealTime/SyncHub.cs

---

## See Also

- [Application Layer: Commands, Queries, DTOs and Handlers](../domains/application-cqs-and-handlers.md)
- [Web Client (WASM) and Shared UI Components](../domains/web-client-and-shared-ui.md)
- [Mobile (MAUI) Application Integration](../runtime/mobile-maui.md)
- [Infrastructure Services (AI, Epub, Storage, Billing)](../infrastructure/infrastructure-services.md)
- [Authentication, Authorization and Account Flows](../flows/authentication-and-account.md)
- [Real-time Synchronization and Sync Pipeline](../runtime/realtime-and-sync.md)
- [AI Features, Knowledge Graph and UX Integration](../integrations/ai-and-knowledge-ux.md)
- [Business Overview](../business/business-overview.md)
- [Top Business Flows](../business/top-business-flows.md)
