How mrphansum/gauden works
Purpose and deployable entry points
Home Application Fix is an iOS SwiftUI catalog for selling non-consumable module/DLC content, backed by an Express/TypeScript API with MongoDB. The app executable starts at ios/HomeApplicationFix/App/HomeApplicationFixApp.swift; its root routing/state is in ios/HomeApplicationFix/App/RootView.swift. The backend process initializes from backend/src/index.ts, assembling Express in backend/src/app.ts.
Client composition and navigation
The SwiftUI root selects authentication and main product experiences based on app/session state. User-facing feature boundaries are authentication, module catalog/detail, and profile:
• ios/HomeApplicationFix/Features/Auth/AuthView.swift
• ios/HomeApplicationFix/Features/Catalog/CatalogView.swift
• ios/HomeApplicationFix/Features/ModuleDetail/ModuleDetailView.swift
• ios/HomeApplicationFix/Features/Profile/ProfileView.swift
Guests can see demo material; entitlement determines access to full module content.
iOS service and persistence boundary
Views call domain-facing services rather than directly forming HTTP requests or persisting credentials. ios/HomeApplicationFix/Core/Networking/APIClient.swift is the API transport boundary; auth, module, and IAP orchestration reside in:
• ios/HomeApplicationFix/Core/Services/AuthService.swift
• ios/HomeApplicationFix/Core/Services/ModuleService.swift
• ios/HomeApplicationFix/Core/Services/IAPService.swift
API request/response models are centralized at ios/HomeApplicationFix/Core/Models/APIModels.swift. Access and refresh tokens are persisted only through Keychain abstractions in ios/HomeApplicationFix/Core/Keychain/TokenStore.swift and ios/HomeApplicationFix/Core/Keychain/KeychainStore.swift.
Authentication lifecycle
The API supports registration/password login, Google ID-token login, access-token authentication, refresh rotation, and logout. Routes are declared in backend/src/routes/auth.ts; JWT creation/rotation logic is in backend/src/services/tokenService.ts; Google token validation is isolated in backend/src/services/googleAuthService.ts. Protected API endpoints cross backend/src/middleware/auth.ts. Mongo stores users and hashed refresh-token records via backend/src/models/User.ts and backend/src/models/RefreshToken.ts.
Module catalog and entitlement gate
The backend serves a dynamic module catalog, module detail, and protected/full content from backend/src/routes/modules.ts. Module definitions, including their App Store product association, persist through backend/src/models/Module.ts. The catalog is intentionally data-driven: adding modules requires database/catalog data rather than a dedicated iOS screen per product. Initial module data is provisioned through backend/src/scripts/seed.ts.
Purchase verification and source of truth
StoreKit 2 purchase/restore work is initiated on iOS through ios/HomeApplicationFix/Core/Services/IAPService.swift, then submitted to POST /api/iap/verify. Server-side verification and entitlement creation are handled by backend/src/routes/iap.ts and backend/src/services/iapService.ts. Purchase records are durable server-side state in backend/src/models/Purchase.ts; clients query account/purchase state via backend/src/routes/me.ts. The backend, not only StoreKit client state, controls full-content entitlement.
Runtime infrastructure and operational boundaries
The mobile client uses configurable API base URL in ios/HomeApplicationFix/Core/Config/AppConfig.swift, suitable for HTTPS or LAN development. Backend runtime configuration comes from backend/src/config/env.ts; errors cross a centralized Express boundary at backend/src/middleware/errorHandler.ts. Material external systems are MongoDB, Apple App Store/StoreKit non-consumable IAP verification, Google OAuth ID tokens, and iOS Keychain. Production deployment expects HTTPS/reverse proxy and real App Store verification rather than mock verification.
Main entry points: AuthService.swift Auth & module services · APIClient.swift API client · IAPService.swift IAP service · tokenService.ts Token & Google auth
Components 20
iOS app
- App entry
ios/HomeApplicationFix/App/HomeApplicationFixApp.swift - Root routing & session
ios/HomeApplicationFix/App/RootView.swift - Auth, catalog, detail & profile · Guests see demos; entitlement unlocks full content.
- API models
ios/HomeApplicationFix/Core/Models/APIModels.swift - Auth & module services
ios/HomeApplicationFix/Core/Services/AuthService.swift - IAP service
ios/HomeApplicationFix/Core/Services/IAPService.swift - API client
ios/HomeApplicationFix/Core/Networking/APIClient.swift - Token store · Persists access and refresh tokens only through Keychain.
ios/HomeApplicationFix/Core/Keychain/TokenStore.swift - API base URL config
ios/HomeApplicationFix/Core/Config/AppConfig.swift
Express API
- Backend entry
backend/src/index.ts - Express app
backend/src/app.ts - Auth, modules, IAP & account routes · Provides catalog, protected content, verification, and account state.
- JWT auth middleware
backend/src/middleware/auth.ts - Token & Google auth · Creates and rotates JWTs; validates Google ID tokens.
backend/src/services/tokenService.ts - Purchase verification · Verifies transactions and creates entitlements.
backend/src/services/iapService.ts - Modules & purchases · Data-driven catalog associates modules with App Store products.
backend/src/models/Module.ts
External systems
- MongoDB · Stores users, refresh tokens, modules, and purchases.
- Apple App Store
- Google OAuth
- iOS Keychain
Connections 23
- App entry → Root routing & session: launches
- Root routing & session → Auth, catalog, detail & profile: selects experience
- Auth, catalog, detail & profile → Auth & module services: uses
- Auth, catalog, detail & profile → IAP service: purchases/restores
- Auth & module services → API models: maps payloads
- Auth & module services → API client: calls
- IAP service → API client: submits transaction
- Auth & module services → Token store: reads/writes session
- Token store → iOS Keychain: stores tokens
- API base URL config → API client: configures base URL
- IAP service → Apple App Store: StoreKit 2
- API client → Backend entry: HTTPS API
- Backend entry → Express app: starts
- Express app → Auth, modules, IAP & account routes: mounts
- Auth, modules, IAP & account routes → JWT auth middleware: protects endpoints
- Auth, modules, IAP & account routes → Token & Google auth: login, refresh & Google login
- Token & Google auth → Google OAuth: validates ID token
- Auth, modules, IAP & account routes → Purchase verification: verifies purchase
- Purchase verification → Apple App Store: server verification
- Auth, modules, IAP & account routes → Modules & purchases: catalog and account state
- Token & Google auth → MongoDB: users & refresh tokens
- Modules & purchases → MongoDB: persists
- Purchase verification → MongoDB: persists purchases