User Profile Management
Relevant source files
The following files were used as context for generating this wiki page:
User Profile Management in the Social-Connect project encompasses the logic for handling user social interactions, profile navigation, and identity-related data flows. This system facilitates actions such as following or unfollowing users and provides a mechanism to navigate to specific user profiles through deep linking.
The architecture relies on a centralized UserService to manage social state, an APIClient for remote communication, and a DeepLinkHandler to translate external URL requests into internal application actions. Security and authentication for these profile actions are maintained via a KeychainManager.
Core Components and Architecture
The user management system is built using a service-oriented approach where specific responsibilities are delegated to singleton or dedicated manager classes.
Service Relationships
The following class diagram illustrates the relationships between the primary components involved in user profile management.
The application lifecycle starts at the AppDelegate, which passes URL events to the DeepLinkHandler. This handler then invokes the UserService to perform profile-related actions.
Sources: AppDelegate.swift:5-20, DeepLinkHandler.swift:3-7, UserService.swift:3-7
Social Interactions
The system allows users to modify their relationship with other profiles through "Follow" and "Unfollow" operations. These actions are managed by the UserService.
Following and Unfollowing Logic
Social actions are performed via POST requests to specific user endpoints. Upon a successful state change, the system broadcasts a notification to update the local user cache and UI components.
| Action | Endpoint | Notification Triggered |
|---|---|---|
| Follow User | users/{userId}/follow | .userFollowStatusChanged |
| Unfollow User | users/{userId}/unfollow | .userFollowStatusChanged |
Sources: UserService.swift:9-30
Sources: UserService.swift:9-19, APIClient.swift:7-14
Deep Link Integration
The application supports deep links to facilitate direct navigation to user profiles or to trigger social actions from external sources.
Deep Link Schema
The DeepLinkHandler parses incoming URLs based on the host and query parameters. For profile management, the following paths are relevant:
- Profile Navigation: Navigates the UI to a specific user's profile view.
- Follow Action: Triggers an immediate follow request for a specified user ID.
| Host | Query Parameter | Action |
|---|---|---|
profile | userId | Calls navigateToProfile(userId:) |
follow | userId | Calls userService.followUser(userId:) |
Sources: DeepLinkHandler.swift:16-43
Navigation Flow
When a user clicks a link (e.g., socialconnect://profile?userId=123), the following flow occurs:
AppDelegatereceives the URL viaapplication(_:open:options:).- The URL is passed to
DeepLinkHandler.handleDeepLink(url:). - The host is identified as
profile. - The
userIdis extracted from query items. - The application routes to the profile screen.
Sources: AppDelegate.swift:17-20, DeepLinkHandler.swift:9-36
Security and Authentication
Every profile-related API request is authenticated using a Bearer token.
Token Retrieval
The APIClient automatically decorates outgoing requests with an Authorization header. It retrieves the current session token from the KeychainManager, which interacts with the iOS Security framework.
// Implementation in APIClient.swift
if let token = KeychainManager.shared.getAuthToken() {
request.addValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
}
Sources: APIClient.swift:20-23, KeychainManager.swift:8-27
Summary
User Profile Management in Social-Connect provides a robust framework for handling user identities and social graphs. By decoupling deep link handling from service logic and centralizing API communication, the system ensures that profile actions—whether triggered internally or externally—are processed consistently and securely with proper authentication and state notification.