Root Structure
Source Directory Layout
Top-Level Directories
- Features & Domains
- Infrastructure
- Legacy
Feature Directory Structure
New features follow a consistent structure:Example: Perps Feature
State Directory Structure
State stores are organized by domain:Navigation Structure
Storage Structure
Analytics Structure
Logger Structure
Import Aliases
Rainbow uses TypeScript path aliases for cleaner imports:Usage
File Naming Conventions
Migration Patterns
From Legacy to Domain Organization
Identify Domain
Determine which domain/feature the code belongs to (e.g.,
perps, polymarket, positions)Organize by Layer
Move files into appropriate subdirectories:
- UI components →
components/orui/ - State stores →
stores/ordata/ - Utilities →
utils/ - Types →
types/
Example Migration
Before
After
Key Files to Know
src/App.tsx
src/App.tsx
Root application component that sets up providers and navigation
src/env.ts
src/env.ts
Environment detection and feature flags:
IS_DEV- Development modeIS_PROD- Production modeIS_TEST- Test environmentIS_IOS- iOS platformIS_ANDROID- Android platform
src/navigation/routesNames.ts
src/navigation/routesNames.ts
src/state/internal/types.ts
src/state/internal/types.ts
TypeScript types for store creators
Next Steps
State Management
Learn about Rainbow’s state management patterns
Navigation System
Understand the navigation architecture