Social-Connect Wiki Home
Relevant source files
The following files were used as context for generating this wiki page:
The Social-Connect project is a Swift-based application designed to facilitate social interactions through a structured networking layer and deep-linking capabilities. The system provides a foundation for user relationship management, secure authentication storage, and external link handling to navigate or trigger actions within the app.
The core architecture is built around a centralized APIClient for network communication, a UserService for business logic related to user interactions, and a DeepLinkHandler that integrates with the iOS AppDelegate to process incoming URL schemes.
Sources: README.md:1-2, AppDelegate.swift:3-20
Architecture Overview
Social-Connect follows a modular architecture where responsibilities are separated into networking, service, and utility layers.
Component Relationship
The following diagram illustrates the high-level relationship between the main components of the system.
The application lifecycle is managed by the AppDelegate, which delegates URL handling to the DeepLinkHandler. Business logic is encapsulated in UserService, which utilizes APIClient for network requests. Authentication tokens required for these requests are retrieved from KeychainManager.
Sources: AppDelegate.swift:7-19, DeepLinkHandler.swift:4-6, UserService.swift:5-6, APIClient.swift:19-21
Networking and Security
The networking layer is centered around the APIClient class, which manages requests to the base URL https://api.socialconnect.com/v1/.
API Client Implementation
The APIClient uses URLSession for executing data tasks. It specifically implements a post method that automatically injects authorization headers if a token is available.
| Component | Responsibility |
|---|---|
baseURL | Defines the root endpoint for all API calls. |
post(endpoint:completion:) | Handles asynchronous HTTP POST requests with JSON content types. |
KeychainManager | Provides secure storage and retrieval of the authToken. |
Sources: APIClient.swift:4-15, KeychainManager.swift:6-28
Authentication Flow
Requests are authenticated using a Bearer token pattern. The APIClient queries the KeychainManager before every request to see if a token exists.
User Services
The UserService acts as the intermediary between the UI/DeepLink layers and the networking layer. It provides high-level methods for social actions like following and unfollowing users.
Key Service Methods
followUser(userId:completion:): Constructs theusers/{userId}/followendpoint and executes a POST request.unfollowUser(userId:completion:): Constructs theusers/{userId}/unfollowendpoint.
Upon successful completion of these actions, the service broadcasts a NotificationCenter event named .userFollowStatusChanged to notify other parts of the application to refresh their state.
Sources: UserService.swift:8-27
Deep Link Handling
The system supports external navigation and action triggering via a custom URL scheme. The DeepLinkHandler parses incoming URLs and routes them to the appropriate service or view controller.
Deep Link Routing Logic
The handler examines the host of the URL to determine the action:
| Host | Action | Parameters |
|---|---|---|
follow | Triggers userService.followUser | userId |
profile | Navigates to the user's profile | userId |
message | Implementation for messaging | N/A |
post | Implementation for viewing posts | N/A |
Sources: DeepLinkHandler.swift:15-32
Navigation Flow
The following flowchart demonstrates how a deep link is processed from the AppDelegate to the final service call.
Summary
Social-Connect provides a structured approach to iOS social networking features. By decoupling the KeychainManager for security, APIClient for communication, and DeepLinkHandler for external entry points, the project ensures that social interactions like following users are handled securely and can be triggered both internally and via external links.
Sources: APIClient.swift:4-6, UserService.swift:4-6, DeepLinkHandler.swift:4-6