Architecture Overview
DPM Delivery Mobile is built using Expo Router with a file-based routing system, TanStack Query for server state management, and MMKV for local storage. The app follows a modular architecture with clear separation of concerns.Technology Stack
- Framework: React Native with Expo
- Routing: Expo Router (file-based routing)
- State Management: TanStack Query for server state
- Storage: MMKV (native) and SecureStore (tokens)
- HTTP Client: Axios with custom interceptors
- UI Components: HeroUI Native
- Styling: NativeWind (Tailwind CSS for React Native)
Folder Structure
Key Design Patterns
1. Service Layer Pattern
All API calls are abstracted into service classes:2. Repository Pattern with TanStack Query
Query options are defined separately and reused:3. Provider Pattern
All global providers are composed in a single component:4. Storage Abstraction Pattern
Platform-specific storage implementations are unified:Module Organization
Feature Modules
Features are organized into self-contained modules undersrc/modules/:
- auth/: Login forms, validation schemas
- dashboard/parcels/riders/: Rider-specific features
- home/: Dashboard components
- request-payout/: Payout flow
- shipment/: Shipment management
Shared Components
Reusable components live insrc/components/:
- UI components: Basic building blocks (
ui/) - Form components:
form-field.tsx,select-field.tsx - Business components:
shipment-card.tsx
Services
Each domain has its own service:- auth.service.ts: Authentication operations
- users.service.ts: User management
- shipments.service.ts: Shipment operations
- payment.service.ts: Payment processing
HttpClient for consistent error handling and token management.
Cross-Cutting Concerns
Error Handling
Centralized error handling in the HTTP client:Logging
Centralized logging with the Logger utility:Authentication
Token management with automatic refresh:- Tokens stored in SecureStore (native) or Web Crypto (web)
- Auth token attached to requests via interceptor
- Automatic token refresh on 401 responses
- Logout on refresh failure
Platform-Specific Code
The app handles platform differences using:- Platform checks:
Platform.OS === "web" - Platform-specific files:
use-color-scheme.web.ts,icon-symbol.ios.tsx - Conditional implementations: Different storage strategies per platform
Next Steps
- Routing - Learn about file-based routing and route groups
- State Management - Understand TanStack Query setup
- Storage - Explore storage strategies for different platforms