# mrphansum/hoc architecture

> Architecture diagram of the GitHub repository mrphansum/hoc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrphansum/hoc
- Repository: https://github.com/mrphansum/hoc

## Overview

#### Purpose and Runtime
GauDenApp is a native SwiftUI iOS authentication-oriented application with a post-login dashboard. The Xcode project is `GauDenApp/GauDenApp.xcodeproj`, and project generation/build metadata also exists in `GauDenApp/project.yml`.

#### Application Entry and Root Routing
`GauDenApp/GauDenApp/AuthApp.swift` is the SwiftUI application entry point. Root presentation is organized through `GauDenApp/GauDenApp/Presentation/ContentView.swift` and shared application/session state in `GauDenApp/GauDenApp/Presentation/State/AppState.swift`, which forms the boundary between unauthenticated auth screens and authenticated dashboard screens.

#### Authentication Presentation
Authentication UI is a tabbed flow rooted at `GauDenApp/GauDenApp/Presentation/Auth/AuthTabView.swift`, with distinct login and registration views:
- `GauDenApp/GauDenApp/Presentation/Auth/LoginView.swift`
- `GauDenApp/GauDenApp/Presentation/Auth/RegisterView.swift`
- `GauDenApp/GauDenApp/Presentation/Auth/AuthViewModel 2.swift`

The view model coordinates user input, async auth actions, and UI-visible loading/error/session state rather than calling transport code directly.

#### Domain Authentication Workflow
Use cases isolate business operations from SwiftUI and repository details:
- `GauDenApp/GauDenApp/Domain/UseCases/LoginUseCase 2.swift`
- `GauDenApp/GauDenApp/Domain/UseCases/RegisterUseCase 2.swift`
- `GauDenApp/GauDenApp/Domain/UseCases/TokenManagementUseCase.swift`

They operate on domain representations such as `GauDenApp/GauDenApp/Domain/Entities/UserEntity.swift`. The expected flow is ViewModel → use case → repository, returning domain-level results for state updates and routing.

#### Data, API, and Error Boundary
The data layer translates between domain workflows and authentication API payloads:
- `GauDenApp/GauDenApp/Data/Repositories/AuthRepository.swift`
- `GauDenApp/GauDenApp/Data/DTOs/AuthDTOs.swift`
- `GauDenApp/GauDenApp/Core/Network/AuthEndpoint.swift`

`GauDenApp/GauDenApp/Core/Network/NetworkClient.swift` centralizes HTTP execution; `Endpoint.swift` defines request abstraction and `APIError.swift` establishes the API failure boundary. The external dependency is an unspecified remote authentication service accessed through these endpoint definitions.

#### Session and Secure Credential Handling
Authentication tokens/session material cross into persistent storage through:
- `GauDenApp/GauDenApp/Data/Storage/SessionStorage.swift`
- `GauDenApp/GauDenApp/Core/SecureStorage/KeychainManager.swift`
- `GauDenApp/GauDenApp/Domain/UseCases/TokenManagementUseCase.swift`

Keychain-backed storage is the security boundary for sensitive credentials. Restored or cleared session state feeds `AppState`, determining whether the app enters auth or dashboard presentation.

#### Authenticated Dashboard and Notifications
After successful authentication, the dashboard is composed under:
- `GauDenApp/GauDenApp/Presentation/Dashboard/MainDashboardView.swift`
- `GauDenApp/GauDenApp/Presentation/Dashboard/HomeView.swift`
- `GauDenApp/GauDenApp/Presentation/Dashboard/DevicesView.swift`

Notification-related behavior is separated behind `GauDenApp/GauDenApp/Core/Notification/NotificationManager.swift` and presented by `GauDenApp/GauDenApp/Presentation/Dashboard/NotificationCenterView.swift`, keeping platform notification integration outside dashboard UI views.

Main entry points: [`GauDenApp/GauDenApp/Presentation/State/AppState.swift`](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/State/AppState.swift) (App state), [`GauDenApp/GauDenApp/Presentation/Auth/AuthViewModel 2.swift`](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/AuthViewModel%202.swift) (Auth view model), [`GauDenApp/GauDenApp/Presentation/Auth/AuthTabView.swift`](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/AuthTabView.swift) (Auth tabs), [`GauDenApp/GauDenApp/Presentation/Dashboard/MainDashboardView.swift`](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/MainDashboardView.swift) (Main dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["SwiftUI Presentation"]
  node_app(("GauDenApp<br/>SwiftUI app entry<br/>[AuthApp.swift]"))
  node_content["Root content router<br/>SwiftUI root view<br/>[ContentView.swift]"]
  node_app_state["App state<br/>session state<br/>[AppState.swift]"]
  node_auth_tabs["Auth tabs<br/>authentication UI<br/>[AuthTabView.swift]"]
  node_login_view["Login view<br/>SwiftUI view<br/>[LoginView.swift]"]
  node_register_view["Register view<br/>SwiftUI view<br/>[RegisterView.swift]"]
  node_auth_vm["Auth view model<br/>presentation model"]
  node_dashboard["Main dashboard<br/>authenticated UI"]
  node_dashboard_views["Home &amp; devices<br/>dashboard views<br/>[HomeView.swift]"]
  node_notification_view["Notification center<br/>dashboard view"]
end

subgraph group_domain["Authentication Domain"]
  node_auth_usecases["Login &amp; register<br/>auth use cases"]
  node_token_usecase["Token management<br/>session use case"]
  node_user_entity["User entity<br/>domain entity<br/>[UserEntity.swift]"]
end

subgraph group_data["Data &amp; Session"]
  node_auth_repo["Auth repository"]
  node_session_storage[("Session storage<br/>credential storage")]
end

subgraph group_platform["Platform Boundaries"]
  node_auth_endpoint["Auth endpoint &amp; DTOs<br/>API contract<br/>[AuthEndpoint.swift]"]
  node_network["Network client<br/>HTTP boundary"]
  node_keychain[("Keychain manager<br/>secure credential boundary")]
  node_notifications["Notification manager<br/>platform notification boundary"]
end

node_auth_service{{"Remote auth service<br/>external service"}}

node_app -->|"hosts"| node_content
node_content -->|"routes by"| node_app_state
node_app_state -->|"unauthenticated"| node_auth_tabs
node_app_state -->|"authenticated"| node_dashboard
node_auth_tabs -->|"contains"| node_login_view
node_auth_tabs -->|"contains"| node_register_view
node_login_view -->|"binds"| node_auth_vm
node_register_view -->|"binds"| node_auth_vm
node_auth_vm -->|"invokes"| node_auth_usecases
node_auth_vm -->|"updates session"| node_token_usecase
node_auth_usecases -->|"returns"| node_user_entity
node_auth_usecases -->|"uses"| node_auth_repo
node_auth_repo -->|"builds requests"| node_auth_endpoint
node_auth_endpoint -->|"executed by"| node_network
node_network -->|"HTTP"| node_auth_service
node_token_usecase -->|"persists/restores"| node_session_storage
node_session_storage -->|"secures tokens"| node_keychain
node_token_usecase -->|"restores or clears"| node_app_state
node_dashboard -->|"composes"| node_dashboard_views
node_dashboard -->|"composes"| node_notification_view
node_notification_view -->|"uses"| node_notifications

click node_app "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/AuthApp.swift"
click node_content "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/ContentView.swift"
click node_app_state "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/State/AppState.swift"
click node_auth_tabs "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/AuthTabView.swift"
click node_login_view "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/LoginView.swift"
click node_register_view "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/RegisterView.swift"
click node_auth_vm "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/AuthViewModel%202.swift"
click node_dashboard "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/MainDashboardView.swift"
click node_dashboard_views "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/HomeView.swift"
click node_notification_view "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/NotificationCenterView.swift"
click node_auth_usecases "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Domain/UseCases/LoginUseCase%202.swift"
click node_token_usecase "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Domain/UseCases/TokenManagementUseCase.swift"
click node_user_entity "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Domain/Entities/UserEntity.swift"
click node_auth_repo "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Data/Repositories/AuthRepository.swift"
click node_session_storage "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Data/Storage/SessionStorage.swift"
click node_auth_endpoint "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/Network/AuthEndpoint.swift"
click node_network "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/Network/NetworkClient.swift"
click node_keychain "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/SecureStorage/KeychainManager.swift"
click node_notifications "https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/Notification/NotificationManager.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_content,node_app_state,node_auth_tabs,node_login_view,node_register_view,node_auth_vm,node_dashboard,node_dashboard_views,node_notification_view toneBlue
class node_auth_usecases,node_token_usecase,node_user_entity toneAmber
class node_auth_repo,node_session_storage toneMint
class node_auth_endpoint,node_network,node_keychain,node_notifications toneRose
class node_auth_service toneNeutral
```

## Components

### SwiftUI Presentation

- [GauDenApp](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/AuthApp.swift): SwiftUI app entry · `GauDenApp/GauDenApp/AuthApp.swift`
- [Root content router](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/ContentView.swift): SwiftUI root view · `GauDenApp/GauDenApp/Presentation/ContentView.swift`
- [App state](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/State/AppState.swift): session state · Selects authentication or dashboard presentation. · `GauDenApp/GauDenApp/Presentation/State/AppState.swift`
- [Auth tabs](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/AuthTabView.swift): authentication UI · `GauDenApp/GauDenApp/Presentation/Auth/AuthTabView.swift`
- [Login view](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/LoginView.swift): SwiftUI view · `GauDenApp/GauDenApp/Presentation/Auth/LoginView.swift`
- [Register view](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/RegisterView.swift): SwiftUI view · `GauDenApp/GauDenApp/Presentation/Auth/RegisterView.swift`
- [Auth view model](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Auth/AuthViewModel%202.swift): presentation model · Coordinates input, async actions, and visible auth state. · `GauDenApp/GauDenApp/Presentation/Auth/AuthViewModel 2.swift`
- [Main dashboard](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/MainDashboardView.swift): authenticated UI · `GauDenApp/GauDenApp/Presentation/Dashboard/MainDashboardView.swift`
- [Home & devices](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/HomeView.swift): dashboard views · `GauDenApp/GauDenApp/Presentation/Dashboard/HomeView.swift`
- [Notification center](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Presentation/Dashboard/NotificationCenterView.swift): dashboard view · `GauDenApp/GauDenApp/Presentation/Dashboard/NotificationCenterView.swift`

### Authentication Domain

- [Login & register](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Domain/UseCases/LoginUseCase%202.swift): auth use cases · `GauDenApp/GauDenApp/Domain/UseCases/LoginUseCase 2.swift`
- [Token management](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Domain/UseCases/TokenManagementUseCase.swift): session use case · `GauDenApp/GauDenApp/Domain/UseCases/TokenManagementUseCase.swift`
- [User entity](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Domain/Entities/UserEntity.swift): domain entity · `GauDenApp/GauDenApp/Domain/Entities/UserEntity.swift`

### Data & Session

- [Auth repository](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Data/Repositories/AuthRepository.swift): repository · Maps API data into domain-level auth results. · `GauDenApp/GauDenApp/Data/Repositories/AuthRepository.swift`
- [Session storage](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Data/Storage/SessionStorage.swift): credential storage · `GauDenApp/GauDenApp/Data/Storage/SessionStorage.swift`

### Platform Boundaries

- [Auth endpoint & DTOs](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/Network/AuthEndpoint.swift): API contract · `GauDenApp/GauDenApp/Core/Network/AuthEndpoint.swift`
- [Network client](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/Network/NetworkClient.swift): HTTP boundary · Executes endpoint requests and surfaces API failures. · `GauDenApp/GauDenApp/Core/Network/NetworkClient.swift`
- [Keychain manager](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/SecureStorage/KeychainManager.swift): secure credential boundary · `GauDenApp/GauDenApp/Core/SecureStorage/KeychainManager.swift`
- [Notification manager](https://github.com/mrphansum/hoc/blob/main/GauDenApp/GauDenApp/Core/Notification/NotificationManager.swift): platform notification boundary · `GauDenApp/GauDenApp/Core/Notification/NotificationManager.swift`

### Other components

- **Remote auth service**: external service · Unspecified authentication backend.

## Connections

- GauDenApp → Root content router: hosts
- Root content router → App state: routes by
- App state → Auth tabs: unauthenticated
- App state → Main dashboard: authenticated
- Auth tabs → Login view: contains
- Auth tabs → Register view: contains
- Login view → Auth view model: binds
- Register view → Auth view model: binds
- Auth view model → Login & register: invokes
- Auth view model → Token management: updates session
- Login & register → User entity: returns
- Login & register → Auth repository: uses
- Auth repository → Auth endpoint & DTOs: builds requests
- Auth endpoint & DTOs → Network client: executed by
- Network client → Remote auth service: HTTP
- Token management → Session storage: persists/restores
- Session storage → Keychain manager: secures tokens
- Token management → App state: restores or clears
- Main dashboard → Home & devices: composes
- Main dashboard → Notification center: composes
- Notification center → Notification manager: uses
