{"id":51064396,"url":"https://github.com/bluefunda/cai-ios","last_synced_at":"2026-06-23T05:02:05.594Z","repository":{"id":364338937,"uuid":"1248508789","full_name":"bluefunda/cai-ios","owner":"bluefunda","description":"BlueFunda AI - Native iOS app","archived":false,"fork":false,"pushed_at":"2026-06-12T16:44:51.000Z","size":307,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T17:27:13.955Z","etag":null,"topics":["bluefunda-ai","in-progress"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluefunda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-24T18:26:19.000Z","updated_at":"2026-06-12T16:44:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bluefunda/cai-ios","commit_stats":null,"previous_names":["bluefunda/cai-ios"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/bluefunda/cai-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluefunda%2Fcai-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluefunda%2Fcai-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluefunda%2Fcai-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluefunda%2Fcai-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluefunda","download_url":"https://codeload.github.com/bluefunda/cai-ios/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluefunda%2Fcai-ios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34675978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluefunda-ai","in-progress"],"created_at":"2026-06-23T05:02:04.880Z","updated_at":"2026-06-23T05:02:05.589Z","avatar_url":"https://github.com/bluefunda.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CAI iOS\n\nNative SwiftUI app for the BlueFunda Cognitive AI Interface.  \nConnects to the existing `cai-bff` backend via KrakenD gateway at `api.bluefunda.com`.\n\n---\n\n## Requirements\n\n| Tool | Version |\n|------|---------|\n| Xcode | 15.0+ |\n| iOS target | 17.0+ |\n| Swift | 5.9+ |\n| macOS (host) | 14.0+ (Sonoma) |\n\nNo third-party dependencies — only Apple SDKs.\n\n---\n\n## Setup\n\n1. **Clone**\n   ```\n   git clone \u003crepo-url\u003e\n   cd cai-ios\n   ```\n\n2. **Open in Xcode**\n   ```\n   open CAI.xcodeproj\n   ```\n\n3. **Configure signing**  \n   In Xcode → Project → Signing \u0026 Capabilities:\n   - Set your **Development Team**\n   - Bundle ID is `com.bluefunda.cai` (change if needed)\n\n4. **Register the URL scheme**  \n   The app uses the `cai://` custom URL scheme for Keycloak OAuth callbacks.  \n   Verify it exists in Info.plist → URL Types → `cai`.  \n   (Should already be present — check `CAI/Info.plist`.)\n\n5. **Run**  \n   Select an iPhone 15 simulator (iOS 17+) and press ▶.\n\n---\n\n## Authentication\n\nThe app authenticates with **Keycloak** (OIDC/OAuth2).\n\n- Default Keycloak URL: `https://auth.bluefunda.com`\n- Client ID: `cai-ios`\n- Redirect URI: `cai://auth/callback`\n- Realms: `individual`, `trm`\n\nOn first launch, tap **Sign in with Keycloak** → select a realm → complete login in Safari.  \nTokens are stored in the iOS Keychain and auto-refreshed silently.\n\n---\n\n## Architecture\n\n```\nCAI/\n├── CAIApp.swift              # Entry point, DI wiring, StateObject lifecycle\n├── Models/\n│   └── APIModels.swift       # Codable DTOs for all BFF endpoints\n├── Utilities/\n│   ├── APIClient.swift       # Generic URLSession wrapper with auth injection\n│   └── Extensions.swift      # Date, String, Color, View helpers\n├── Services/\n│   ├── ChatServiceProtocol.swift  # Streaming chat abstraction\n│   ├── BFFChatService.swift       # SSE streaming via POST /chats/{id}\n│   ├── BFFAPIService.swift        # REST calls (models, chats, MCP, etc.)\n│   ├── NATSChatService.swift      # Legacy NATS alternative\n│   └── AuthManager.swift          # Keycloak OAuth + Keychain\n├── ViewModels/\n│   └── ChatManager.swift     # Conversations, models, MCP, rate-limit state\n└── Views/\n    ├── ContentView.swift         # Auth gate + tab shell\n    ├── ChatView.swift            # Chat thread + SSE streaming\n    ├── ConversationsView.swift   # Chat history with search \u0026 delete\n    ├── SettingsView.swift        # Account, model, MCP settings\n    ├── RateLimitView.swift       # Token usage / rate-limit display\n    └── StorageView.swift         # Cloud storage placeholder\n```\n\nSee [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for a full walkthrough.\n\n---\n\n## API Endpoints\n\nAll endpoints are documented in [`docs/ENDPOINT_INVENTORY.md`](docs/ENDPOINT_INVENTORY.md).\n\nBase URL: `https://api.bluefunda.com/ai`\n\n| Feature | Endpoint |\n|---------|----------|\n| Chat streaming | `POST /chats/{id}` (SSE) |\n| List chats | `GET /chats` |\n| Available models | `GET /models` |\n| MCP servers | `GET /mcp`, `GET /mcp/user` |\n| Rate limits | `GET /rate-limit` |\n| User info | `GET /userinfo` |\n| Storage | `GET /storage/list`, `POST /storage/upload`, etc. |\n\n---\n\n## Features\n\n### MVP (Implemented)\n- ✅ Keycloak OAuth login (realm selector)\n- ✅ Silent token refresh + Keychain persistence\n- ✅ Chat send with SSE streaming\n- ✅ Stop generation\n- ✅ Conversation list (loaded from `/chats`)\n- ✅ Lazy message load (loaded on conversation select)\n- ✅ Auto title generation via `/chats/{id}/title`\n- ✅ LLM model selection (loaded from `/models`)\n- ✅ MCP server selection (loaded from `/mcp`)\n- ✅ Rate limit view (`/rate-limit`)\n- ✅ User account display\n- ✅ Sign out\n\n### Coming in Phase 3\n- Cloud storage browser (basic file list)\n- File upload for chat prompts\n- Push notifications\n- Offline message queue\n- Markdown rendering in AI responses\n\nSee [`docs/FEATURE_MAPPING.md`](docs/FEATURE_MAPPING.md) for the full web→iOS mapping.\n\n---\n\n## Tests\n\nUnit tests are in `CAITests/`. Run via:\n- Xcode: `⌘U`\n- CLI: `xcodebuild test -scheme CAI -destination 'platform=iOS Simulator,name=iPhone 15'`\n\nTest coverage includes:\n- `APIModels` — JSON decoding for all response types\n- `ChatManager` — conversation lifecycle, message sending, streaming\n- `Extensions` — string truncation, date parsing, size formatting\n\n---\n\n## Backend Compatibility\n\n| Component | Version |\n|-----------|---------|\n| cai-gw | KrakenD v2.8+ |\n| cai-bff | whatever ships behind the gateway |\n| Keycloak | 22+ |\n\nThe iOS app calls only the modern BFF endpoints (no `/rest/trm/v1` legacy paths).  \nDo not update the backend API contracts without a corresponding iOS update.\n\n---\n\n## Troubleshooting\n\n**\"Sign in\" button does nothing:**  \nCheck that the `cai://` URL scheme is registered in `Info.plist`.\n\n**401 errors after login:**  \nToken may have expired. Sign out and back in. If recurring, check Keycloak session limits.\n\n**Models or MCP list is empty:**  \nVerify the BFF backend is reachable at `https://api.bluefunda.com/ai/models`.\n\n**Chat stops mid-stream:**  \nCheck network connectivity. The SSE connection has a 120 s timeout on the iOS side.\n\n---\n\n## License\n\nInternal — BlueFunda proprietary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluefunda%2Fcai-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluefunda%2Fcai-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluefunda%2Fcai-ios/lists"}