This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
TypoFixer is a macOS desktop application that uses AI (Google Gemini or OpenAI) to correct Czech language text for grammar, spelling, and style. Users paste text, click "Fix", and receive corrected output.
# Build (Debug)
xcodebuild -project TypoFixer.xcodeproj -scheme TypoFixer -configuration Debug build
# Build (Release)
xcodebuild -project TypoFixer.xcodeproj -scheme TypoFixer -configuration Release build
# Run Tests
xcodebuild -project TypoFixer.xcodeproj -scheme TypoFixer testNo package manager is used. The project has zero external dependencies—only native Apple frameworks.
Layered SwiftUI structure:
- Presentation:
ContentView.swift,SettingsView.swift,Views/*.swift(reusable components) - ViewModel:
ContentViewModel.swift(@Observable, coordinates state and AI service) - Services:
Services/AIService.swift(actor-based API orchestration) - Business Logic:
AIRequestBuilder.swift(request construction, response parsing),TextProcessor.swift(response cleaning) - Configuration:
AIProviderConfig.swift(provider selection in UserDefaults) - Security:
KeychainHelper.swift(API key storage in macOS Keychain) - Protocols:
Protocols/*.swift(KeychainProviding, AIConfigProviding for testability) - Environment:
Environment/EnvironmentKeys.swift(SwiftUI dependency injection)
Key patterns:
- Singletons for shared state:
AIProviderConfig.shared,KeychainHelper.shared - Actor pattern for thread-safe
AIService @Observablefor reactiveContentViewModel- Protocol-based dependency injection for testability
- SwiftUI environment keys for dependency distribution
- NotificationCenter for cross-component communication (
apiKeyDidChange,providerDidChange) - NSViewRepresentable bridges for custom keyboard handling (Cmd+Return to fix, Escape to switch focus)
API Integration:
- Gemini: API key in URL query param, response at
candidates[0].content.parts[0].text - OpenAI: API key in Authorization Bearer header, response at
choices[0].message.content - Providers: gemini-flash-lite (default), gemini-flash, openai-gpt4, openai-gpt35
App & Views:
TypoFixerApp.swift- App entry point with main Window and Settings scenesContentView.swift- Main UI with input/output editors and fix buttonSettingsView.swift- Provider selection and API key managementViews/FixButton.swift- Branded button with loading state and Cmd+Return supportViews/InputTextEditor.swift- NSViewRepresentable with Cmd+Return detectionViews/OutputTextEditor.swift- NSViewRepresentable with Escape key handling
Logic & Services:
ContentViewModel.swift- @Observable view model managing state and AI serviceServices/AIService.swift- Actor handling API requests with dependency injectionAIRequestBuilder.swift- Builds requests and parses responses for both providersTextProcessor.swift- Cleans API responses (removes unwanted wrapping quotes)
Configuration & Security:
AIProviderConfig.swift- Manages provider selection (4 providers)KeychainHelper.swift- Secure API key storage in macOS KeychainTypoFixer.entitlements- App Sandbox with keychain and network access
Protocols & Environment:
Protocols/KeychainProviding.swift- Protocol for keychain operationsProtocols/AIConfigProviding.swift- Protocol for AI configurationEnvironment/EnvironmentKeys.swift- SwiftUI environment keys for DI
Test Files:
TypoFixerTests/AIRequestBuilderTests.swift- Request building and response parsing (11 tests)TypoFixerTests/AIServiceTests.swift- API key retrieval and provider selection (3 tests)TypoFixerTests/TextProcessorTests.swift- Quote handling logic (8 tests)
Mocks:
TypoFixerTests/Mocks/MockKeychain.swift- In-memory keychain with call countingTypoFixerTests/Mocks/MockAIConfig.swift- Configurable provider mock
Testing patterns: XCTest framework, async/await tests, error case testing with XCTAssertThrowsError, protocol-based mocking