## Authentication, Authorization and Account Flows

This document summarizes identity, token and authorization responsibilities across server and client components, and how client auth state maps to server identity calls.

=== DIAGRAM 1: Dependency and Model Map (dependency-map) ===
```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1["IIdentityService.cs"]
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1["NexusAuthenticationStateProvider"]
    flow_file_nexusreader_web_services_nativestorageservice_cs_file_1["NativeStorageService"]
    flow_file_nexusreader_web_services_serveridentityservice_cs_file_1["ServerIdentityService"]
    flow_file_nexusreader_application_security_authorization_prouserhandler_cs_file_1["ProUserHandler"]
    flow_file_nexusreader_application_security_authorization_prouserrequirement_cs_file_1["ProUserRequirement"]
    flow_file_nexusreader_infrastructure_identity_tokenlimithandler_cs_file_1["TokenLimitHandler"]
    flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1["TokenLimitRequirement"]
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1["Login"]
    flow_file_nexusreader_ui_shared_pages_account_profile_razor_file_1["Profile.razor"]
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1["Register.razor"]
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1["AuthenticationHeaderHandler"]
    flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6[/"IIdentityService"/]
    flow_type_nexusreader_application_security_authorization_prouserrequirement_cs_prouserrequirement_8[/"ProUserRequirement"/]
    flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8[/"TokenLimitRequirement"/]
    flow_type_nexusreader_ui_shared_pages_account_login_razor_loginmodel_157[/"LoginModel"/]
    flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120[/"RegisterModel"/]
    flow_type_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_nexusauthenticationstateprovider_9[/"NexusAuthenticationStateProvider"/]
    flow_type_nexusreader_web_client_handlers_authenticationheaderhandler_cs_authenticationheaderhandler_14[/"AuthenticationHeaderHandler"/]
    flow_type_nexusreader_web_services_nativestorageservice_cs_nativestorageservice_12[/"NativeStorageService"/]
    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_security_authorization_prouserrequirement_cs_file_1 -->|model ProUserRequirement| flow_type_nexusreader_application_security_authorization_prouserrequirement_cs_prouserrequirement_8
    flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 -->|model TokenLimitRequirement| flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 -->|dto LoginModel| flow_type_nexusreader_ui_shared_pages_account_login_razor_loginmodel_157
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 -->|dto RegisterModel| flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1 -->|model NexusAuthenticationStateProvider| flow_type_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_nexusauthenticationstateprovider_9
    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_services_nativestorageservice_cs_file_1 -->|model NativeStorageService| flow_type_nexusreader_web_services_nativestorageservice_cs_nativestorageservice_12
    click flow_file_nexusreader_infrastructure_identity_tokenlimithandler_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitHandler.cs:1:1" "Open source"
    click flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:1:1" "Open source"
    click flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:6:1" "Open source"
    click flow_file_nexusreader_application_security_authorization_prouserhandler_cs_file_1 href "vscode://file/NexusReader.Application/Security/Authorization/ProUserHandler.cs:1:1" "Open source"
    click flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:1:1" "Open source"
    click flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:8:1" "Open source"
    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_application_security_authorization_prouserrequirement_cs_file_1 href "vscode://file/NexusReader.Application/Security/Authorization/ProUserRequirement.cs:1:1" "Open source"
    click flow_type_nexusreader_application_security_authorization_prouserrequirement_cs_prouserrequirement_8 href "vscode://file/NexusReader.Application/Security/Authorization/ProUserRequirement.cs:8: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_type_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_nexusauthenticationstateprovider_9 href "vscode://file/NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs:9:1" "Open source"
    click flow_file_nexusreader_web_services_nativestorageservice_cs_file_1 href "vscode://file/NexusReader.Web/Services/NativeStorageService.cs:1:1" "Open source"
    click flow_type_nexusreader_web_services_nativestorageservice_cs_nativestorageservice_12 href "vscode://file/NexusReader.Web/Services/NativeStorageService.cs:12:1" "Open source"
    click flow_file_nexusreader_web_services_serveridentityservice_cs_file_1 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:1:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:1:1" "Open source"
    click flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:120:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:1:1" "Open source"
    click flow_type_nexusreader_ui_shared_pages_account_login_razor_loginmodel_157 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:157:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_profile_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Profile.razor:1:1" "Open source"
```
This map shows high‑level dependencies between identity interfaces, client auth state, server services, authorization handlers and UI account pages. It highlights TokenLimit and ProUser types and where handlers/services live.

=== DIAGRAM 2: IIdentityService.cs Flow (primary-runtime) ===
```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph flow_0_nexusreader_application_abstractions_services_iidentityservice_cs["IIdentityService.cs"]
    end
    flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1["IIdentityService.cs"]
    flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126["HandleLogin"]
    flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110["OnInitialized"]
    flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84["HandleRegister"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131["Begins protected execution"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112{"Check for ErrorCode"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110["Handles exception path"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100{"Falls back to alternate path"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105{"Falls back to alternate path"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114["Runs cleanup or finalization"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107["Reads repository or persistence state"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89["Begins protected execution"]
    flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1["TokenLimitRequirement"]
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1["Login"]
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1["Register.razor"]
    flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6[/"IIdentityService"/]
    flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8[/"TokenLimitRequirement"/]
    flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120[/"RegisterModel"/]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110 -->|Runs cleanup or finalization| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 -->|Reads repository or persistence state| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107 -->|handled exception| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91
    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_infrastructure_identity_tokenlimitrequirement_cs_file_1 -->|model TokenLimitRequirement| flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 -->|HandleLogin| flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 -->|OnInitialized| flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 -->|HandleRegister| flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 -->|dto RegisterModel| flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120
    flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126 -->|Begins protected execution| flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131
    flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110 -->|map error to message / no-op| flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112
    flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84 -->|Begins protected execution| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89
    click flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:1:1" "Open source"
    click flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:6:1" "Open source"
    click flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:1:1" "Open source"
    click flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:8:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:84:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:89:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:91:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:92:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:94:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:95:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:98:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:100:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:105:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:107:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:110:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:114:1" "Open source"
    click flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:120:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:110:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:112:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:112:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:126:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:131:1" "Open source"
```
This runtime flow highlights how Login and Register UI handlers invoke IIdentityService operations and where TokenLimitRequirement is consulted. It shows async/guard patterns and protected execution around auth calls.

=== DIAGRAM 3: IIdentityService.cs Execution Control Flow (control-flow) ===
```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph NexusReader_UI_Shared_Pages_Account_Register["Register"]
    end
    subgraph NexusReader_UI_Shared_Pages_Account_Login["Login"]
    end
    flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126["HandleLogin"]
    flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110["OnInitialized"]
    flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84["HandleRegister"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_await_133_133["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131["Begins protected execution"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112{"Check for ErrorCode"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110["Handles exception path"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100{"Falls back to alternate path"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105{"Falls back to alternate path"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114["Runs cleanup or finalization"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107["Reads repository or persistence state"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89["Begins protected execution"]
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1["Login"]
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1["Register.razor"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_await_133_133
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110 -->|Runs cleanup or finalization| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 -->|Reads repository or persistence state| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107 -->|handled exception| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 -->|HandleLogin| flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 -->|OnInitialized| flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 -->|HandleRegister| flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84
    flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126 -->|Begins protected execution| flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131
    flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110 -->|map error to message / no-op| flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112
    flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84 -->|Begins protected execution| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89
    click flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_register_razor_handleregister_84 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:84:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:89:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:91:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:92:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:94:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:95:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:98:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:100:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:105:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:107:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:110:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:114:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:110:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:112:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:112:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_login_razor_handlelogin_126 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:126:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_try_131_131 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:131:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_handlelogin_await_133_133 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:133:1" "Open source"
```
This control flow isolates async points, guard clauses and try/catch/finally around account operations. It helps locate where token checks and failure handling occur in the UI code path.

=== DIAGRAM 4: IIdentityService.cs Contracts and Entities (class-diagram) ===
```mermaid
classDiagram
    class flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1["IIdentityService.cs"]
    class flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1["TokenLimitRequirement"]
    class flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1["Login"]
    class flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1["Register.razor"]
    class flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6["IIdentityService"]
    class flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8["TokenLimitRequirement"]
    class flow_type_nexusreader_ui_shared_pages_account_login_razor_loginmodel_157["LoginModel"]
    class flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120["RegisterModel"]
    flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 --> flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6 : interface IIdentityService
    flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 --> flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8 : model TokenLimitRequirement
    flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 --> flow_type_nexusreader_ui_shared_pages_account_login_razor_loginmodel_157 : dto LoginModel
    flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 --> flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120 : dto RegisterModel
    click flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:1:1" "Open source"
    click flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:6:1" "Open source"
    click flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:1:1" "Open source"
    click flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:8:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:1:1" "Open source"
    click flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:120:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:1:1" "Open source"
    click flow_type_nexusreader_ui_shared_pages_account_login_razor_loginmodel_157 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:157:1" "Open source"
```
This class diagram lists the key contracts and DTOs: IIdentityService, Register/Login models and the TokenLimitRequirement entity used by authorization.

=== DIAGRAM 5: IIdentityService.cs Layer View (dependency-map) ===
```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart LR
    subgraph layer_application["application"]
        flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1["IIdentityService.cs"]
        flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6[/"IIdentityService"/]
        flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 -->|interface IIdentityService| flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6
    end
    subgraph layer_unknown["unknown"]
        flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1["TokenLimitRequirement"]
        flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8[/"TokenLimitRequirement"/]
        flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 -->|model TokenLimitRequirement| flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8
    end
    subgraph layer_frontend["frontend"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91["Waits for async work"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94["Waits for async work"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98["Waits for async work"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92{"Evaluates branch condition"}
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95{"Evaluates branch condition"}
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110["Handles exception path"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100{"Falls back to alternate path"}
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105{"Falls back to alternate path"}
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114["Runs cleanup or finalization"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107["Reads repository or persistence state"]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89["Begins protected execution"]
        flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1["Login"]
        flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1["Register.razor"]
        flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120[/"RegisterModel"/]
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110 -->|Runs cleanup or finalization| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 -->|Reads repository or persistence state| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107 -->|handled exception| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110
        flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89 -->|Waits for async work| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91
        flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 -->|dto RegisterModel| flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120
    end
    click flow_file_nexusreader_application_abstractions_services_iidentityservice_cs_file_1 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:1:1" "Open source"
    click flow_type_nexusreader_application_abstractions_services_iidentityservice_cs_iidentityservice_6 href "vscode://file/NexusReader.Application/Abstractions/Services/IIdentityService.cs:6:1" "Open source"
    click flow_file_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:1:1" "Open source"
    click flow_type_nexusreader_infrastructure_identity_tokenlimitrequirement_cs_tokenlimitrequirement_8 href "vscode://file/NexusReader.Infrastructure/Identity/TokenLimitRequirement.cs:8:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_register_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:1:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_try_89_89 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:89:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:91:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:92:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:94:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:95:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:98:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:100:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:105:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_repository_read_107_107 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:107:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_catch_110_110 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:110:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_finally_114_114 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:114:1" "Open source"
    click flow_type_nexusreader_ui_shared_pages_account_register_razor_registermodel_120 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:120:1" "Open source"
    click flow_file_nexusreader_ui_shared_pages_account_login_razor_file_1 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:1:1" "Open source"
```
This layer view shows where IIdentityService lives (application), which token requirement is external/unknown, and how frontend register flows call into these layers.

=== DIAGRAM 6: IIdentityService.cs Guardrails and Failure Paths (control-flow) ===
```mermaid
flowchart TD
    subgraph NexusReader_UI_Shared_Pages_Account_Login["Login"]
    end
    flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110["OnInitialized"]
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112{"Check for ErrorCode"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98["Waits for async work"]
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95{"Evaluates branch condition"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100{"Falls back to alternate path"}
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105{"Falls back to alternate path"}
    flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 -->|true / false| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100
    flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 -->|fallback| flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105
    flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110 -->|map error to message / no-op| flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_91_91 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:91:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_92_92 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:92:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_94_94 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:94:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_branch_95_95 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:95:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_await_98_98 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:98:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_100_100 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:100:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_register_razor_handleregister_fallback_105_105 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Register.razor:105:1" "Open source"
    click flow_method_nexusreader_ui_shared_pages_account_login_razor_oninitialized_110 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:110:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_guard_clause_112_112 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:112:1" "Open source"
    click flow_action_nexusreader_ui_shared_pages_account_login_razor_oninitialized_branch_112_112 href "vscode://file/NexusReader.UI.Shared/Pages/Account/Login.razor:112:1" "Open source"
```
This diagram isolates guard clauses and fallback/error paths on Login/Register, useful to find where errors are mapped to UI messages and where fallback persistence reads occur.

=== DIAGRAM 7: Method Flow Details (method-flow) ===
```mermaid
flowchart TD
    subgraph NexusReader_Web_Client_Handlers_AuthenticationHeaderHandler["AuthenticationHeaderHandler"]
    end
    subgraph NexusReader_UI_Shared_Services_NexusAuthenticationStateProvider["NexusAuthenticationStateProvider"]
    end
    subgraph NexusReader_Web_Services_ServerIdentityService["ServerIdentityService"]
    end
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1["NexusAuthenticationStateProvider"]
    flow_file_nexusreader_web_services_serveridentityservice_cs_file_1["ServerIdentityService"]
    flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_clearcache_23["ClearCache"]
    flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84["CreateState"]
    flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112["CloneHttpRequestMessageAsync"]
    flow_method_nexusreader_web_services_serveridentityservice_cs_getprofileasync_108["GetProfileAsync"]
    flow_method_nexusreader_web_services_serveridentityservice_cs_logoutasync_72["LogoutAsync"]
    flow_method_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_106["RefreshTokenAsync"]
    flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_clearcache_notification_26_26["Sends notification"]
    flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_branch_93_93{"Evaluates branch condition"}
    flow_action_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_branch_119_119{"Copy content if present"}
    flow_action_nexusreader_web_services_serveridentityservice_cs_getprofileasync_guard_clause_110_110{"Ensure HttpContext user exists and is authenticated"}
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1["AuthenticationHeaderHandler"]
    flow_action_nexusreader_web_services_serveridentityservice_cs_logoutasync_return_76_76(["Return OK (no server-side sign-out performed here)"])
    flow_action_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_return_106_106(["Return OK immediately"])
    flow_action_nexusreader_web_services_serveridentityservice_cs_logoutasync_return_76_76 -->|Returns result| flow_action_nexusreader_web_services_serveridentityservice_cs_logoutasync_return_76_76
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1 -->|ClearCache| flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_clearcache_23
    flow_file_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_file_1 -->|CreateState| flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84
    flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_clearcache_23 -->|Sends notification| flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_clearcache_notification_26_26
    flow_method_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_84 -->|Evaluates branch condition| flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_createstate_branch_93_93
    flow_file_nexusreader_web_services_serveridentityservice_cs_file_1 -->|GetProfileAsync| flow_method_nexusreader_web_services_serveridentityservice_cs_getprofileasync_108
    flow_file_nexusreader_web_services_serveridentityservice_cs_file_1 -->|RefreshTokenAsync| flow_method_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_106
    flow_file_nexusreader_web_services_serveridentityservice_cs_file_1 -->|LogoutAsync| flow_method_nexusreader_web_services_serveridentityservice_cs_logoutasync_72
    flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112 -->|Copy content if present| flow_action_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_branch_119_119
    flow_method_nexusreader_web_services_serveridentityservice_cs_getprofileasync_108 -->|Ensure HttpContext user exists and is authenticated| flow_action_nexusreader_web_services_serveridentityservice_cs_getprofileasync_guard_clause_110_110
    flow_method_nexusreader_web_services_serveridentityservice_cs_logoutasync_72 -->|Return OK (no server-side sign-out performed here)| flow_action_nexusreader_web_services_serveridentityservice_cs_logoutasync_return_76_76
    flow_method_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_106 -->|Return OK immediately| flow_action_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_return_106_106
    flow_file_nexusreader_web_client_handlers_authenticationheaderhandler_cs_file_1 -->|CloneHttpRequestMessageAsync| flow_method_nexusreader_web_client_handlers_authenticationheaderhandler_cs_clonehttprequestmessageasync_112
    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_clearcache_23 href "vscode://file/NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs:23:1" "Open source"
    click flow_action_nexusreader_ui_shared_services_nexusauthenticationstateprovider_cs_clearcache_notification_26_26 href "vscode://file/NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs:26: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_web_services_serveridentityservice_cs_file_1 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:1:1" "Open source"
    click flow_method_nexusreader_web_services_serveridentityservice_cs_logoutasync_72 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:72:1" "Open source"
    click flow_action_nexusreader_web_services_serveridentityservice_cs_logoutasync_return_76_76 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:76:1" "Open source"
    click flow_method_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_106 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:106:1" "Open source"
    click flow_action_nexusreader_web_services_serveridentityservice_cs_refreshtokenasync_return_106_106 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:106:1" "Open source"
    click flow_method_nexusreader_web_services_serveridentityservice_cs_getprofileasync_108 href "vscode://file/NexusReader.Web/Services/ServerIdentityService.cs:108:1" "Open source"
```
This method‑level view shows NexusAuthenticationStateProvider producing client auth state and notifications, ServerIdentityService methods (RefreshToken, Logout, GetProfile) doing minimal server-side sign‑out and guarding on HttpContext, and the AuthenticationHeaderHandler cloning requests. It traces where client state triggers server calls and token refresh behavior.

### Key Files
- NexusReader.Application/Abstractions/Services/IIdentityService.cs  
- NexusReader.Infrastructure/Identity/TokenLimitHandler.cs  
- NexusReader.Application/Security/Authorization/ProUserHandler.cs  
- NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs  
- NexusReader.Web/Services/ServerIdentityService.cs  
- NexusReader.Web.Client/Handlers/AuthenticationHeaderHandler.cs  
- NexusReader.UI.Shared/Pages/Account/Login.razor, Register.razor, Profile.razor

---

## See Also

- [Project Overview and High-level Architecture](../collections/overview.md)
- [Web Client (WASM) and Shared UI Components](../domains/web-client-and-shared-ui.md)
- [Mobile (MAUI) Application Integration](../runtime/mobile-maui.md)
- [Application Layer: Commands, Queries, DTOs and Handlers](../domains/application-cqs-and-handlers.md)
- [Business Overview](../business/business-overview.md)
- [Top Business Flows](../business/top-business-flows.md)
