Skip to content

Architecture Overview

Nuance iOS er bygget med The Composable Architecture (TCA) og en modulær Swift Package Manager struktur med 35 library targets.

Arkitektur-principper

┌─────────────────────────────────────────────────────────┐
│                      App Target                          │
│                   (Nuance.xcodeproj)                     │
└─────────────────────────┬───────────────────────────────┘

┌─────────────────────────▼───────────────────────────────┐
│                    Feature Layer                         │
│  AppFeature → AuthenticationFeature → LoggedInFeature   │
│              HomeFeature, TaskFeature, ProfileFeature    │
└─────────────────────────┬───────────────────────────────┘

┌─────────────────────────▼───────────────────────────────┐
│                    Client Layer                          │
│   APIClient, SessionClient, AnalyticsClient, etc.       │
│          (Protocol interfaces - no implementations)      │
└─────────────────────────┬───────────────────────────────┘

┌─────────────────────────▼───────────────────────────────┐
│                 Implementation Layer                     │
│  APIClientLive, AnalyticsClientMixpanel, ErrorClientSentry │
│            (Concrete implementations)                    │
└─────────────────────────┬───────────────────────────────┘

┌─────────────────────────▼───────────────────────────────┐
│                   Shared Layer                           │
│    SharedModels, Styleguide, SwiftUIHelpers, Helpers    │
└─────────────────────────────────────────────────────────┘

Feature Modules

Features indeholder UI + business logic med TCA reducers.

ModulAnsvar
AppFeatureRoot coordinator, app-level state machine
AuthenticationFeatureLogin, register, onboarding flows
LoggedInFeatureTab navigation container
HomeFeatureHome dashboard
TaskFeatureTask management
CoursesFeatureCourse content og progression
CommunityFeatureCommunity features
ProfileFeatureUser profile
SettingsFeatureApp settings
PaywallFeatureSubscription og in-app purchases
SplashFeatureApp launch splash screen
BrainDumpFeatureVoice-to-task brain dump

Client Protocols

Dependency interfaces - ingen implementationer, kun protokoller.

ModulAnsvar
APIClientDomain-level API interface (~80 endpoint signatures)
SessionClientAuthentication state management
AnalyticsClientEvent tracking interface
ErrorClientError reporting interface
KeychainClientSecure storage
UserDefaultsClientLocal preferences
AudioPlayerClientAudio playback
AudioRecorderClientVoice recording
SpeechRecognitionClientSpeech-to-text
RevenueCatClientSubscription management
PlatformAuthenticationClientOAuth (Google Sign-In)
RemoteNotificationsClientPush notifications
UserNotificationClientLocal notifications

Live Implementations

Konkrete implementationer af client protocols.

ModulImplementererEkstern dependency
APIClientLiveAPIClientOpenAPI Generator
AnalyticsClientMixpanelAnalyticsClientMixpanel SDK
ErrorClientSentryErrorClientSentry SDK
PlatformAuthenticationClientLivePlatformAuthenticationClientGoogle Sign-In
AudioRecorderClientLiveAudioRecorderClientAVFoundation
SpeechRecognitionClientLiveSpeechRecognitionClientSpeech framework

Shared Infrastructure

ModulAnsvar
SharedModelsDomain entities (User, Course, AppTask, etc.)
StyleguideDesign system, fonts, colors
SwiftUIHelpersReusable UI components
HelpersTCA utilities og extensions

Data Flow

User Action


┌─────────────┐
│    View     │  SwiftUI
└──────┬──────┘
       │ .send(.view(.buttonTapped))

┌─────────────┐
│   Reducer   │  TCA - Pure business logic
└──────┬──────┘
       │ Effect

┌─────────────┐
│   Client    │  Dependency protocol
└──────┬──────┘


┌─────────────┐
│    Live     │  Concrete implementation
└──────┬──────┘


  External API / SDK

TCA Reducer Pattern

swift
@Reducer
struct FeatureReducer {
    @ObservableState
    struct State: Equatable {
        var isLoading = false
        var items: [Item] = []
    }

    enum Action {
        case view(View)      // UI events
        case delegate(Delegate)  // Parent communication
        case `internal`(Internal)  // Private actions

        enum View {
            case onAppear
            case refreshTapped
        }
    }

    @Dependency(\.apiClient) var api

    var body: some ReducerOf<Self> {
        Reduce { state, action in
            switch action {
            case .view(.onAppear):
                state.isLoading = true
                return .run { send in
                    let items = try await api.getItems()
                    await send(.internal(.itemsLoaded(items)))
                }
            // ...
            }
        }
    }
}

API Contract

API client genereres automatisk fra OpenAPI spec:

  • Spec: Sources/APIClientLive/openapi.yaml (3350 lines, 52 operationIds)
  • Generator: Swift OpenAPI Generator plugin
  • Mapping: Sources/APIClientLive/Mappings/ - DTO → Domain conversions

Se API Endpoints for komplet reference (44 exposed / 52 total).


Navigation

Forstå TCA Development skill for dybere patterns.

AI-first documentation for Nuance iOS