Onboarding Guide
Welcome to the cloudalt-frontend! This guide will help you get started with the project.
Prerequisites
Section titled “Prerequisites”Getting Started
Section titled “Getting Started”-
Clone the repository:
Terminal window git clone <repository-url>cd cloudalt-frontend -
Install dependencies:
Terminal window yarn installImportant: All dependencies are centrally managed in the root
package.json. Individual mobile and web apps no longer maintain their owndependenciesordevDependencies. This ensures consistency across the monorepo and eliminates redundant installations.
Workspace Structure
Section titled “Workspace Structure”This is an Nx workspace. Here’s a brief overview of the directory structure:
apps/: Contains all the applications.- Each application is further divided into
mobile(React Native/Expo) andweb(React/Vite) projects.
- Each application is further divided into
packages/: Contains shared libraries and packages used across applications.docs/: Contains documentation.scripts/: Contains utility scripts, including:verify-repo.sh: Runs comprehensive workspace validation (lint, typecheck, build, cycle detection)check-nested-node_modules.sh: Safeguard to prevent nested dependency installations
Dependency Management
Section titled “Dependency Management”All dependencies are centralized in the root package.json. Individual app package.json files contain only:
nameversionprivatescripts
This architecture ensures:
- Single source of truth for all package versions
- Faster installations (no redundant
node_modules) - Consistent dependency resolution across all apps
- Reduced repository size
⚠️ Never add dependencies or devDependencies to individual app package.json files. All packages must be added to the root.
Development
Section titled “Development”To run an application, use the nx command:
# To run a web applicationyarn nx serve <app-name>-web
# To run a mobile applicationyarn nx start <app-name>-mobileFor example, to run the pinkguest-web application:
yarn nx serve pinkguest-webAnd to run the pinkguest-mobile application:
yarn nx start pinkguest-mobile### Web (Vite) specifics
To keep web apps fast and isolated from React Native internals, ensure the following in each web app (e.g. `apps/.../web/`):
- Tailwind CSS v3 PostCSS plugins in `postcss.config.js`:
```js // Tailwind v3 standard module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, };-
Vite aliases to prevent RN code from entering the web bundle and to force the web entry of shared UI:
vite.config.ts resolve: {alias: {'react-native$': 'react-native-web','react-native-svg': 'react-native-svg-web','@cloudalt-frontend/ui': '@cloudalt-frontend/ui/index.web',},},optimizeDeps: {exclude: ['react-native'],},- Ensure a
servetarget exists inproject.jsonusing@nx/vite:dev-serverso you can run:
Terminal window yarn nx serve <app-name>-web - Ensure a
## Building Applications
To build an application for production, use the `nx` command:
```bash# To build a web applicationyarn nx build <app-name>-web
# To build a mobile application# (Refer to Expo documentation for building and deploying mobile apps)Running Tests
Section titled “Running Tests”To run tests for a specific project, use the nx command:
yarn nx test <project-name>Further Help
Section titled “Further Help”To get more help on the Nx CLI, check out the Nx documentation.
Verification & Quality Gates
Section titled “Verification & Quality Gates”The monorepo includes automated verification scripts to ensure code quality, dependency integrity, and build consistency.
Running Verification
Section titled “Running Verification”To run the full verification suite:
yarn verify# Or directly:./scripts/verify-repo.shThis runs the following stages:
- InstallIntegrity: Verifies yarn install succeeded without errors
- RegistrySchemaValidation: Validates
packages/brands/registry.jsonagainst schema - BrandTypesCheck: Ensures brand types are up-to-date (not stale)
- VitePathValidation: Checks Vite path configurations
- ProjectTargets: Validates project.json targets
- Lint: Runs eslint across the workspace
- Typecheck: Runs TypeScript type checking
- Build: Builds all packages
- UITreeShake: Verifies web bundle doesn’t include React Native code
- SizeThresholds: Checks bundle sizes against configured thresholds
- BundleScan: (Placeholder for future bundle analysis)
Output: Verification results are saved to .verify/ directory:
.verify/full-output.log: Complete verification log.verify/summary.json: Machine-readable summary with timings and status.verify/size-results.json: Bundle size measurements
Tip: Use jq to query the summary JSON:
# Check which stages failedjq '.stages[] | select(.status == "error")' .verify/summary.json
# Get total verification timejq '.duration.seconds' .verify/summary.json
# Check specific stage timingjq '.stages[] | select(.name == "Build") | .duration' .verify/summary.jsonBrand Registry Scripts
Section titled “Brand Registry Scripts”Tailwind Parity Guard
Section titled “Tailwind Parity Guard”Run this whenever you:
- add or modify Tailwind configs (app or Storybook)
- add a new UI package that uses Tailwind
- see styling differences between Storybook and an app
yarn tailwind:guardIt fails the run if Tailwind versions drift, v4-only artifacts are present, or configs don’t use the expected monorepo patterns.
Generate Brand Types
Section titled “Generate Brand Types”Generates TypeScript types and constants from the brand registry:
yarn generate-brand-types# Or directly:node scripts/generate-brand-types.mjsOutput:
packages/brands/src/generated-types.ts: Brand ID types and constantspackages/brands/src/generated-constants.ts: ALL_BRAND_IDS array
When to run:
- After adding/removing brands in
packages/brands/registry.json - After modifying brand properties
Stale detection: The verify script automatically detects stale types. If types are out of date, verification fails with a clear error message.
Generate Brand READMEs
Section titled “Generate Brand READMEs”Generates per-brand README files with auto-generated and custom sections:
# Generate/update all brand READMEsnode scripts/generate-brand-readme.mjs
# Check mode (dry-run)node scripts/generate-brand-readme.mjs --check
# Force overwrite (for migration)node scripts/generate-brand-readme.mjs --force-overwriteProtected Regions:
<!-- AUTO-GENERATED -->to<!-- END AUTO-GENERATED SECTION -->: Regenerated on every run- Custom content below auto-generated section: Preserved across regenerations
Output: apps/{family}/{brand}/mobile/README.md for each brand
Validate Brand Registry Schema
Section titled “Validate Brand Registry Schema”Fail-fast schema validation for the brand registry:
node scripts/validate-brand-registry.mjsExits with code 1 if registry.json doesn’t match the Zod schema. This runs automatically in the verify pipeline.
Quality & Performance Scripts
Section titled “Quality & Performance Scripts”Check UI Tree-Shake
Section titled “Check UI Tree-Shake”Verifies that the web build of @cloudalt/ui doesn’t include React Native code:
node scripts/check-ui-tree-shake.mjsWhat it checks:
- Web bundle (
packages/ui/dist/index.web.js) for React Native imports - Native bundle size vs web bundle size
- Reports size savings percentage
Expected: Web bundle should be ~50% smaller than native bundle
Check Size Thresholds
Section titled “Check Size Thresholds”Monitors bundle sizes and enforces regression guards:
# Check sizes (warns on violations)node scripts/check-size-thresholds.mjs
# Strict mode (fails on violations, for CI)node scripts/check-size-thresholds.mjs --strictConfiguration: size-thresholds.json defines per-package limits:
{ "packages/brands": { "softLimit": 40000, "hardLimit": 50000 }}Output: Results saved to .verify/size-results.json
Benchmark Build Tools
Section titled “Benchmark Build Tools”Compares build tool performance (tsc vs tsup):
node scripts/benchmark-build-tools.mjsFindings from M5:
tsc --emitDeclarationOnlyis 44-138% faster than tsup- Recommendation: Use tsc for declaration-only builds
Critical Naming Convention for Mobile Apps
Section titled “Critical Naming Convention for Mobile Apps”Problem: The default Nx Expo generator (@nx/expo:app) creates mobile applications with a generic package name ("name": "mobile") in their package.json file. This creates fatal Duplicate workspace name errors when running yarn install in a properly configured monorepo.
Policy: To prevent this, the following naming convention must be followed for all new mobile applications:
-
Package Name (
package.json): The name must be unique across the entire workspace and follow the formatapp-name-platform.- Example: For the
staymatch_appmobile app, the name must bestaymatch-app-mobile.
apps/stay_match/staymatch_app/mobile/package.json {"name": "staymatch-app-mobile",// ...} - Example: For the
-
App Name and Slug (
app.json): Thenameandslugfields in theapp.jsonfile must also be updated to match the unique package name.apps/stay_match/staymatch_app/mobile/app.json {"expo": {"name": "staymatch-app-mobile","slug": "staymatch-app-mobile",// ...}}
Common Dependency Issues & Resolutions
Section titled “Common Dependency Issues & Resolutions”This workspace has been configured to resolve several common dependency and peer dependency conflicts. Here are some key things to be aware of:
1. @swc/core Version Alignment
Section titled “1. @swc/core Version Alignment”- Problem: The version of
@swc/coreused by Nx and other tools can conflict with the version required by packages like@swc-node/register. This results inYN0060peer dependency warnings duringyarn install. - Resolution: The root
package.jsonhas been updated to use a specific version of@swc/core(^1.13.3) that satisfies all consumers. If you encounter this issue again, ensure the versions are aligned in the rootpackage.json.
2. react and react-dom Peer Dependencies
Section titled “2. react and react-dom Peer Dependencies”- Problem: Mobile applications generated with
@nx/expomay not includereactandreact-domin theirpackage.json, leading to peer dependency issues. - Resolution: All mobile applications must have
reactandreact-domlisted as dependencies. The versions have been standardized to~18.3.1across the workspace.
3. SafeAreaView Component Usage
Section titled “3. SafeAreaView Component Usage”-
Problem: The
SafeAreaViewcomponent fromreact-nativeis deprecated and can cause layout issues. -
Resolution: Always import
SafeAreaViewfromreact-native-safe-area-context. If the dependency is not present in a mobile app’spackage.json, add it.// Correct usageimport { SafeAreaView } from 'react-native-safe-area-context';
4. Workspace Integrity and Dependency Management
Section titled “4. Workspace Integrity and Dependency Management”- Problem: Incorrectly running
yarn installor other package management commands from within an individual application’s directory (e.g.,apps/some-app/mobile/) instead of the monorepo root can create nestednode_modulesfolders. This leads to unpredictable builds, dependency conflicts, and errors likeENOENT: no such file or directory, uv_cwd. - Policy: All package management commands must be executed from the monorepo root (
/Users/work-station/company/cloudalt/cloudalt-frontend). There should only be onenode_modulesdirectory at the top level of the workspace. - Verification and Cleanup Procedure:
- To ensure workspace integrity, periodically verify that no nested
node_modulesdirectories exist. - Run the following command from the monorepo root to find any incorrect installations:
Terminal window find . -name "node_modules" -type d -maxdepth 3 - If this command returns any path other than
./node_modules, those directories are incorrect and must be deleted immediately. For example:Terminal window # This indicates a problem./apps/some-app/mobile/node_modules# To fix, run:rm -rf ./apps/some-app/mobile/node_modules - After cleanup, run a single
yarn installfrom the monorepo root to ensure the workspace is in a correct and stable state.
- To ensure workspace integrity, periodically verify that no nested
Xcode Environment Setup: Offloading Data Directories to External SSD
Section titled “Xcode Environment Setup: Offloading Data Directories to External SSD”Note for Developers & GitHub Copilot:
We have relocated Xcode’s build artifacts, cache directories, and archives from the default system drive to an external SSD (T7). This change was implemented to optimize disk usage and improve overall build performance.
- DerivedData is now stored at:
/Volumes/T7/XcodeDerivedData - Archives are now stored at:
/Volumes/T7/XcodeArchives - CompilationCache.noindex is now stored at:
/Volumes/T7/XcodeCompilationCache.noindex
This setup uses symbolic links, so Xcode continues to reference the usual ~/Library/Developer/Xcode/ folders, while files are physically stored on the external drive. Future build, cache, and archive data will be preserved externally.
Important: Please ensure that the T7 drive is always mounted and available when working in Xcode, or resolving build and archive artifacts. If the drive is not present, Xcode will be unable to access these directories.
This setup benefits disk space and performance for larger projects and is safe for day-to-day development workflows.
Asset Management
Section titled “Asset Management”All assets in the monorepo follow a two-tier organization system to optimize bundle sizes and maintain clear ownership boundaries.
Monorepo-Wide Assets (packages/assets/)
Section titled “Monorepo-Wide Assets (packages/assets/)”Use for: Generic icons, illustrations, and company branding used across ALL apps.
Structure:
packages/assets/├── icons/│ ├── arrows/ # Navigation arrows│ ├── actions/ # Action icons (plus, trash, edit)│ ├── navigation/ # Nav icons (home, menu, back)│ └── social/ # Social media icons├── illustrations/ # Generic empty states, errors└── brand/logo/ # CloudAlt company logoGuidelines:
- Keep this directory minimal - assets here are bundled with ALL apps
- Only generic, truly universal assets belong here
- SVG format preferred for icons (< 5KB each)
- All assets must work for every brand
Brand-Specific Assets (apps/{division}/{brand}/shared/assets/)
Section titled “Brand-Specific Assets (apps/{division}/{brand}/shared/assets/)”Use for: Images, fonts, and assets unique to a specific brand.
Structure:
apps/{division}/{brand}/shared/assets/├── images/│ ├── hero/ # Hero/banner images│ ├── logos/ # Brand logos and wordmarks│ ├── features/ # Feature showcase images│ ├── onboarding/ # Tutorial and onboarding images│ ├── avatars/ # Default avatars, placeholders│ └── misc/ # Other brand-specific images├── fonts/ # Custom brand fonts (if needed)└── config/ # Brand-specific configurationImage Guidelines by Folder:
-
hero/- Landing page backgrounds- Target: < 300KB (optimized)
- Format: WebP (web), PNG/JPG (mobile)
- Naming:
hero-background.png,hero-background@2x.png
-
logos/- Brand logos- Target: < 25KB
- Format: SVG (preferred), PNG with transparency
- Naming:
logo.png,logo-white.png,logo-icon.png
-
features/- Feature screenshots- Target: < 150KB each
- Format: WebP (web), PNG/JPG (mobile)
- Naming:
feature-search.png,feature-messaging.png
-
onboarding/- Tutorial images- Target: < 100KB each
- Naming:
onboarding-step-1.png,welcome.png - Use sequential numbering for multi-step flows
-
avatars/- Default avatars- Target: < 50KB each
- Consistent dimensions (e.g., 200x200)
- Naming:
default-avatar.png,placeholder-user.png
-
misc/- Other images- Images that don’t fit other categories
- Use descriptive names
Setting Up Assets for a New Brand
Section titled “Setting Up Assets for a New Brand”Use the automated script to create the standard asset structure:
# Set up asset folders for all brandsscripts/setup-brand-assets.sh
# Or manually create for a specific brand:mkdir -p apps/{division}/{brand}/shared/assets/images/{hero,logos,features,onboarding,avatars,misc}Usage Examples
Section titled “Usage Examples”Web:
// Generic icon from packages/assetsimport ArrowRight from '@cloudalt-frontend/assets/icons/arrows/arrow-right.svg';
// Brand-specific hero imageimport heroImage from '../../shared/assets/images/hero/hero-background.png';Mobile:
// Generic icon from packages/assetsimport ArrowRight from '@cloudalt-frontend/assets/icons/arrows/arrow-right.svg';
// Brand-specific hero imageconst heroImage = require('../../shared/assets/images/hero/hero-background.png');Optimization Tools
Section titled “Optimization Tools”Before committing images:
- squoosh.app - Web-based image compressor
- tinypng.com - PNG/JPG compression
- imageoptim.com - macOS app for optimization
- SVGO - SVG optimization
Related Documentation
Section titled “Related Documentation”- Asset Management Strategy - Complete guide
- Component Architecture - Component organization