Mobile App Architecture Guidelines
When to use this skill
- •When initializing a new React Native Expo project.
- •When creating new features or modules to ensure they fit the established structure.
- •When refactoring existing code to align with architectural standards.
- •When you need to check where a specific file type (service, model, etc.) belongs.
Framework
- •Framework: React Native with Expo
- •Target Platforms: iOS, Android, Web
Architecture Pattern
- •Pattern: Clean Architecture / MVVM (Model-View-ViewModel)
- •Core Rule: Separate business logic from UI components.
- •Modularity: Components must be modular and reusable.
Folder Structure
Strictly adhere to this directory layout in /src:
code
/src /components # Reusable UI components (Buttons, Cards, Inputs) /screens # Screen/page components (Home, Profile, Settings) /services # API calls, external services, data fetching /utils # Pure helper functions, formatters, validators /models # TypeScript interfaces, types, data models /navigation # Navigation configuration and navigators /state # State management (Redux, Context, Zustand) /assets # Images, fonts, static files /config # Environment configurations, constants /hooks # Custom React hooks
Key Principles
- •Type Safety: All code must be written in TypeScript. Strict typing is required.
- •Single Responsibility: Each component, function, or service should have exactly one responsibility.
- •Environment Variables: Never hardcode API keys or endpoints. Use the
/configdirectory and environment variables. - •Reusable Components: If a UI element is used more than once, extract it to
/components. - •State Management: Keep local state local. Use global state (
/state) only for data shared across multiple screens.
Instructions for implementation
- •Check Structure: When evaluating code, verify it lives in the correct folder based on the structure above.
- •Verify Types: Ensure
interfaceortypedefinitions exist in/modelsfor all data structures. - •Review Logic: Ensure business logic (calculations, API calls) is NOT inside UI components (screens), but in
hooksorservices.