Introduction
New Expensify is a cross-platform expense management application built with React Native, enabling users to track expenses, manage reports, communicate with teams, and integrate with accounting systems. The application runs on iOS, Android, Web, and Desktop platforms from a single codebase.Technology Stack
Core Framework
- React Native: Cross-platform mobile framework
- TypeScript: Type-safe JavaScript with strict mode enabled
- React Navigation: Navigation library for routing and deep linking
State Management
- React Native Onyx: Custom offline-first state management library
- Supports optimistic updates and automatic persistence
- Centralized key definitions in
src/ONYXKEYS.ts
Build & Development
- Webpack: Web bundling
- Metro: React Native bundling for iOS/Android
- Hermes: JavaScript engine for React Native
Architectural Principles
1. Offline-First Design
New Expensify is architected to work seamlessly offline. All user actions are designed to function without an internet connection:- Optimistic Updates: UI updates immediately before server confirmation
- Request Queue: API requests are queued and replayed when online
- Conflict Resolution: Built-in strategies for handling data conflicts
- Local Persistence: All critical data is persisted locally via Onyx
2. Cross-Platform Consistency
The same codebase powers all platforms:3. Component-Based Architecture
The UI is built from reusable components organized insrc/components/:
- Atomic Design: Small, composable components
- Type Safety: All components use TypeScript interfaces
- Performance: Memoization with React.memo and useMemo
Project Structure
Application Entry Points
App.tsx
The root component establishes the provider hierarchy:Provider Responsibilities
- SplashScreenStateContextProvider: Manages splash screen visibility
- InitialURLContextProvider: Handles deep linking and initial routes
- ThemeProvider: Manages light/dark theme
- LocaleContextProvider: Internationalization (i18n)
- OnyxListItemProvider: Connects to Onyx data layer
- SafeAreaProvider: Device safe areas for notches/rounded corners
- PopoverContextProvider: Global popover state
- KeyboardProvider: Keyboard state management
Core Modules
Data Layer (Onyx)
Onyx is the custom state management solution built specifically for offline-first apps:- Automatic persistence to AsyncStorage
- Optimistic updates
- Batched updates for performance
- TypeScript support
Action Modules
Business logic lives insrc/libs/actions/:
App.ts: Application lifecycleIOU.ts: Money requests and expensesReport.ts: Report managementPolicy/: Workspace operationsUser.ts: User account operationsSession.ts: Authentication
HybridApp Architecture
Key Integration Points
- The
@expensify/react-native-hybrid-appmodule manages transitions between OldDot and NewDot - Environment variables from Mobile-Expensify take precedence
STANDALONE_NEW_DOTenvironment variable controls build mode- Session state is shared between OldDot and NewDot
Build Modes
Standalone Mode
- Pure NewDot application (web only)
- Set via
STANDALONE_NEW_DOT=true
HybridApp Mode
- Combined OldDot + NewDot (mobile apps)
- Default for iOS and Android
- Manages transitions between old and new UI
React Native New Architecture
New Expensify uses React Native’s new architecture:- Fabric Renderer: New rendering system for better performance
- TurboModules: Improved native module system
- Hermes Engine: Optimized JavaScript engine
Performance Optimizations
Code Quality
- TypeScript Strict Mode: Catch errors at compile time
- ESLint: Automated code quality checks
- Prettier: Consistent code formatting
Runtime Performance
- Memoization: React.memo, useMemo, useCallback
- FlashList: Virtualized lists for better scrolling
- Bundle Optimization: Tree shaking and code splitting
Testing Strategy
- Unit Tests: Jest with React Native Testing Library
- Performance Tests: Reassure framework for regression detection
- Type Checking: TypeScript with strict mode
Deployment Pipeline
Key GitHub Actions workflows:deploy.yml: Production deploymentpreDeploy.yml: Staging deploymenttestBuild.yml: PR test buildstest.yml: Unit teststypecheck.yml: TypeScript validationlint.yml: Code quality checks
Related Repositories
Mobile-Expensify
- Contains the legacy OldDot application
- Source for all mobile builds
- HybridApp integration layer
- Path:
App/Mobile-Expensify/(submodule)
expensify-common
- Shared libraries and utilities
- Common validation and parsing functions
- Used across multiple Expensify repositories
Next Steps
React Native
Learn about React Native implementation details
State Management
Deep dive into Onyx state management
Navigation
Understand the navigation system
Offline-First
Explore offline-first architecture
