Project Structure
Relevant source files
The following files were used as context for generating this wiki page:
The Social-Connect project is a Swift-based iOS application designed to facilitate social interactions through a modular architecture. The system integrates deep linking capabilities, secure credential management, and an asynchronous networking layer to handle user-related actions such as following or unfollowing profiles.
The architecture follows a service-oriented approach where the AppDelegate acts as the entry point for system events, delegating specialized tasks to handlers and services. Authentication is managed centrally, ensuring that network requests are consistently authorized using stored tokens.
Sources: README.md:1-2, AppDelegate.swift:3-20, APIClient.swift:3-44
Core Architectural Components
The application is structured into several distinct layers, each responsible for a specific domain of functionality:
Application Lifecycle and Routing
The AppDelegate serves as the primary entry point, managing application initialization and external URL routing. It maintains a reference to the DeepLinkHandler to process incoming URLs.
Sources: AppDelegate.swift:6-20
Network Communication
The APIClient provides a centralized mechanism for making HTTP POST requests to a predefined base URL (https://api.socialconnect.com/v1/). It automatically handles header injection, specifically retrieving "Bearer" tokens from the KeychainManager.
Sources: APIClient.swift:4-44
Business Logic Services
Services like UserService encapsulate specific domain logic. They act as intermediaries between the UI/DeepLink layers and the networking layer, providing high-level methods for user actions and notifying the system of state changes via NotificationCenter.
Sources: UserService.swift:3-33
Security and Storage
The KeychainManager provides a secure interface for interacting with the iOS Keychain. It specifically manages the retrieval of the authToken used for API authentication.
Sources: KeychainManager.swift:6-30
Component Interaction Flow
The following diagram illustrates the high-level relationship between the different modules in the Social-Connect ecosystem.
The diagram shows how external triggers (Deep Links) flow through the system to execute business logic and network requests.
Sources: AppDelegate.swift:17-19, DeepLinkHandler.swift:6-10, UserService.swift:9-12, APIClient.swift:18-20
Deep Link Handling System
The application supports structured deep links to navigate to specific features or execute actions. The DeepLinkHandler parses URL components and hosts to determine the intended operation.
| Supported Host | Query Parameters | Action Performed |
|---|---|---|
profile | userId | Navigates to the user's profile view |
follow | userId | Automatically triggers a follow request |
message | - | Opens the messaging interface |
post | - | Displays a specific post |
Sources: DeepLinkHandler.swift:9-52
Deep Link Processing Sequence
When a user opens a link, the AppDelegate passes the URL to the DeepLinkHandler, which then interacts with the UserService if business logic is required.
Authentication and Security
The system implements a secure authentication flow where the API token is stored in the Keychain rather than UserDefaults.
- Keychain Retrieval: The
KeychainManagerquerieskSecClassGenericPasswordwith the account label "authToken". - Authorization Header: The
APIClientchecks for the existence of this token for every request. If present, it adds anAuthorizationheader with theBearerprefix.
// From APIClient.swift:18-20
if let token = KeychainManager.shared.getAuthToken() {
request.addValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
}
Sources: APIClient.swift:18-20, KeychainManager.swift:11-20
Data Synchronization
The application uses a notification-based system to keep the UI in sync with server-side changes. When a user is successfully followed or unfollowed, the UserService posts a userFollowStatusChanged notification.
Summary
The Social-Connect project structure emphasizes a clean separation of concerns. By isolating networking (APIClient), security (KeychainManager), and routing (DeepLinkHandler), the project ensures that business services (UserService) remain focused on domain-specific logic. This structure supports secure, authenticated communication and a reactive UI via internal notifications.