157 lines
4.9 KiB
Markdown
157 lines
4.9 KiB
Markdown
# Lendair iOS App
|
|
|
|
Native iOS SwiftUI application for the Lendair peer-to-peer micro lending platform.
|
|
|
|
## Setup Instructions
|
|
|
|
### Prerequisites
|
|
|
|
- macOS with Xcode 15.0+ installed
|
|
- Homebrew (for package management)
|
|
|
|
### Installation
|
|
|
|
1. **Install XcodeGen** (project generator):
|
|
```bash
|
|
brew install xcodegen
|
|
```
|
|
|
|
2. **Generate the Xcode project**:
|
|
```bash
|
|
cd /home/mike/code/lendair/iOS
|
|
./generate.sh
|
|
```
|
|
|
|
3. **Open the workspace in Xcode**:
|
|
```bash
|
|
open Lendair.xcworkspace
|
|
```
|
|
|
|
### Project Structure
|
|
|
|
```
|
|
iOS/
|
|
├── project.yml # XcodeGen configuration
|
|
├── generate.sh # Project generation script
|
|
├── README.md # This file
|
|
└── Lendair/
|
|
├── Lendair.xcodeproj # Generated Xcode project
|
|
├── Lendair/
|
|
│ ├── LendairApp.swift # App entry point
|
|
│ ├── ContentView.swift # Root view with auth routing
|
|
│ ├── Services/ # Business logic layer
|
|
│ │ ├── TRPCService.swift # tRPC client
|
|
│ │ ├── AuthService.swift # Authentication
|
|
│ │ ├── LoanService.swift # Loan operations
|
|
│ │ ├── TransactionService.swift
|
|
│ │ └── AppState.swift # Global state management
|
|
│ ├── Models/ # Data models
|
|
│ │ ├── User.swift
|
|
│ │ ├── Loan.swift
|
|
│ │ └── Transaction.swift
|
|
│ ├── Screens/ # Feature screens
|
|
│ │ ├── Auth/
|
|
│ │ │ ├── LoginView.swift
|
|
│ │ │ └── SignupView.swift
|
|
│ │ ├── Main/
|
|
│ │ │ └── MainTabView.swift
|
|
│ │ ├── Home/
|
|
│ │ │ └── HomeView.swift
|
|
│ │ ├── Loans/
|
|
│ │ │ └── LoansTabView.swift
|
|
│ │ ├── Activity/
|
|
│ │ │ └── ActivityTabView.swift
|
|
│ │ └── Profile/
|
|
│ │ └── ProfileTabView.swift
|
|
│ ├── Components/UI/ # Reusable components
|
|
│ │ ├── PrimaryButton.swift
|
|
│ │ ├── LendairTextField.swift
|
|
│ │ ├── BalanceCard.swift
|
|
│ │ ├── LoanCard.swift
|
|
│ │ ├── TransactionRow.swift
|
|
│ │ ├── StatusBadge.swift
|
|
│ │ ├── LoadingView.swift
|
|
│ │ ├── ErrorView.swift
|
|
│ │ └── EmptyStateView.swift
|
|
│ └── Assets.xcassets/ # App icons, colors, images
|
|
├── LendairTests/ # Unit tests
|
|
└── LendairUITests/ # UI tests
|
|
```
|
|
|
|
### Architecture
|
|
|
|
- **Pattern**: MVVM with `@Observable` (Swift 5.9+)
|
|
- **Navigation**: NavigationStack with programmatic navigation
|
|
- **Networking**: tRPC over HTTPS via URLSession
|
|
- **State Management**: Singleton `AppState` with `@Observable`
|
|
|
|
### Dependencies
|
|
|
|
Managed via Swift Package Manager:
|
|
|
|
- **swift-collections** (v1.x): OrderedDictionary and other collection types
|
|
- **swift-algorithms** (v1.x): Pagination helpers and algorithms
|
|
|
|
### Building
|
|
|
|
From Xcode or command line:
|
|
|
|
```bash
|
|
# Debug build
|
|
xcodebuild -workspace Lendair.xcworkspace -scheme Lendair -configuration Debug build
|
|
|
|
# Release build
|
|
xcodebuild -workspace Lendair.xcworkspace -scheme Lendair -configuration Release build
|
|
```
|
|
|
|
### Running Tests
|
|
|
|
```bash
|
|
# Run all tests
|
|
xcodebuild test -workspace Lendair.xcworkspace -scheme Lendair -configuration Debug
|
|
|
|
# With coverage
|
|
xcodebuild test -workspace Lendair.xcworkspace -scheme Lendair -configuration Debug \
|
|
-enableCodeCoverage YES
|
|
```
|
|
|
|
### Environment Configuration
|
|
|
|
The app supports multiple environments:
|
|
|
|
| Environment | Base URL |
|
|
|-------------|----------|
|
|
| Development | https://dev.lendair.local |
|
|
| Staging | https://staging.lendair.app |
|
|
| Production | https://api.lendair.app |
|
|
|
|
Configure via `TRPCEndpoint` enum in `TRPCService.swift`.
|
|
|
|
### API Endpoints
|
|
|
|
The iOS app communicates with the SolidStart backend via tRPC:
|
|
|
|
- **Auth**: `/auth/signin`, `/auth/signup`, `/auth/me`
|
|
- **Loans**: `/loans/available`, `/loans/my`, `/loans/create`, `/loans/accept`
|
|
- **Transactions**: `/transactions/recent`, `/transactions/list`
|
|
|
|
See [FRE-455](https://git.freno.me/Mike/Lendair/issues/FRE-455) for full API specification.
|
|
|
|
### Key Features
|
|
|
|
- ✅ Tab bar navigation (Home, Loans, Activity, Profile)
|
|
- ✅ Authentication screens (Login, Signup)
|
|
- ✅ Home dashboard with balance card
|
|
- ✅ Loan browsing and creation
|
|
- ✅ Transaction history
|
|
- ✅ Profile management
|
|
- ⏳ Create loan form (in progress)
|
|
- ⏳ Accept/repay loan flows (pending)
|
|
- ⏳ Unit tests at NASA standards (pending)
|
|
|
|
### References
|
|
|
|
- **Parent Task**: [FRE-457](https://git.freno.me/Mike/Lendair/issues/FRE-457)
|
|
- **Design Spec**: [FRE-452](https://git.freno.me/Mike/Lendair/issues/FRE-452)
|
|
- **Tech Plan**: [FRE-450](https://git.freno.me/Mike/Lendair/issues/FRE-450)
|