Introduction
Architecture guide
SwiftStruct is built as a monorepo using Turborepo, containing three main applications that work together to provide a complete iOS app starter kit.
Project structure
The project is organized into three main applications:
- iOS app - Native SwiftUI application with Firebase integration
- Admin dashboard - Next.js web application for managing users and data
- Firebase backend - Cloud Functions, Firestore, and Storage configuration
All applications share a common configuration and can be developed, built, and deployed together using Turborepo scripts.
iOS application
The iOS app is located in apps/ios and is built with SwiftUI. It follows a modular architecture with feature-based organization.
Feature modules
The app is organized into logical modules:
- Auth - Authentication flows with Firebase Auth (email/password, social login)
- Firestore - Data layer and Firestore integration
- Profile - User profile management
- Settings - App settings and preferences
- Posts - Example feature for content management
- Pro - In-app purchases and subscriptions via RevenueCat
- Changelog - App update history and release notes
- Sentry - Error tracking and crash reporting
- Messaging - Push notifications and Firebase Cloud Messaging
- UI - Shared UI components and design system
- General - Utilities and shared code
Key patterns
The iOS app follows these architectural patterns:
- MVVM - View models handle business logic and state management
- SwiftUI - Declarative UI with reactive data binding
- Async/await - Modern concurrency for Firebase operations
- Environment - Dependency injection for testability
Admin dashboard
The admin dashboard is a Next.js application located in apps/admin that provides a web interface for managing your app.
Features
- User management - View, create, disable, and delete users
- Analytics - Dashboard with app statistics and metrics
- Firebase Admin - Direct access to Firebase Admin SDK for user operations
Technology stack
- Next.js 15 - App Router with React Server Components
- Shadcn/ui - Component library built on Radix UI
- Tailwind CSS - Utility-first styling
- Firebase Admin SDK - Server-side Firebase operations
- TanStack Table - Data tables with sorting and filtering
Firebase backend
The Firebase configuration lives in apps/firebase and includes:
Cloud Functions
Serverless functions for backend logic:
- User management - Custom user operations and triggers
- Data validation - Firestore triggers for data integrity
- Background jobs - Scheduled tasks and async processing
Firestore
NoSQL database with security rules:
- Collections - Organized data structure
- Security rules - Role-based access control
- Indexes - Query optimization
Storage
File storage with security rules:
- User uploads - Profile pictures and content
- Security rules - Access control for files
Monorepo tooling
SwiftStruct uses Turborepo to manage the monorepo and coordinate tasks across all applications.
Available scripts
npm run dev
npm run build
npm run test
npm run lint
npm run format
These commands run across all workspaces in parallel, speeding up development and CI/CD.
Environment management
Environment variables are managed at the root level:
.env.example- Template for required variablesscripts/sync-env-ios.js- Syncs.envto iOS configurationscripts/sync-github-secrets.js- Syncs to GitHub secrets for CI/CD
Integration services
SwiftStruct integrates with several third-party services:
Firebase
- Authentication - User sign-up, login, password reset
- Firestore - Real-time database
- Cloud Functions - Serverless backend
- Storage - File hosting
- Cloud Messaging - Push notifications
RevenueCat
- Subscriptions - In-app purchase management
- Paywalls - Monetization flows
- Analytics - Revenue tracking
Sentry
- Error tracking - Crash reporting and debugging
- Performance monitoring - App performance metrics
Xcode Cloud (optional)
- CI/CD - Automated builds and testing
- TestFlight - Beta distribution
Development workflow
The typical development workflow:
- Clone the repository and run
npm run setup - Configure Firebase and third-party services
- Develop the iOS app in Xcode
- Test the admin dashboard with
npm run dev - Deploy Firebase backend with deployment scripts
- Update from template using
npm run update
See the Installation guide for detailed setup instructions.