How d4t4-dev/app_nasa_examen works
Project type and purpose
• This is a cross-platform (Android & Web) React Native + Expo application
• It consumes multiple NASA public APIs (APOD, Earth, EPIC, NeoWs, Rover)
• Architecture: CLEAN layered + MVVM, Redux Toolkit for global state, AsyncStorage fallback
File structure
• Top-level:
– App.tsx / index.ts (entry point)
– app.config.ts, babel.config.js, tsconfig.json, package.json
• Layers under src/:
– core/ (shared utilities, API client, fallbacks, themes, validators, interfaces)
– data/ (datasources, mappers, models, repository implementations)
– domain/ (entities, repository interfaces, use case implementations)
– presentation/ (UI screens, components, hooks, view-models)
– navigation/ (React Navigation stacks, tabs, drawers, linking)
– store/ (Redux slices, thunks, store configuration)
– di/ (dependency injection container & factories)
– services/ (local persistence via AsyncStorage)
README for additional insights
• Emphasis on CLEAN + MVVM, SOLID, DRY, KISS, YAGNI
• Required patterns: Observer (ViewModel subscriptions), Strategy (online/offline), Factory (DI/factories)
• Key tech: Redux Toolkit, React Navigation (Stack, Tabs, Drawer), Reanimated, Axios, AsyncStorage, react-hook-form
Main components & their interactions
a. Presentation Layer
– Components & Screens: UI controls, navigation flows (RootNavigator → Tabs/Drawer/Stacks)
– ViewModels: useApodViewModel, useEarthViewModel, etc. (implement Observer pattern to notify UI)
– Hooks: useConnectivity (Strategy for online/offline), useTheme
b. State Management
– Redux store: slices (apodSlice, earthSlice, etc.), thunks (apodThunks, earthThunk…)
– Presentation dispatches thunks / reacts to slice state
c. Domain Layer
– Entities: Apod, Earth, Epic, NeoWs, Rover
– Repository interfaces: ApodRepository, EarthRepository, GenericRepository, etc.
– UseCases: FetchDataApod, FetchDataEarthOffLine (encapsulate business logic)
d. Data Layer
– Datasources: ApodApi, EarthApi, … (Axios clients to NASA endpoints)
– Mappers: transform raw API models to domain entities
– Models: ApodNasa, EarthNasa, …
– RepositoriesImpl: ApodRepositoryImpl implements ApodRepository
– StorageService: AsyncStorage fallback via core/fallBacks.ts & services/storage.ts (Strategy)
e. Dependency Injection
– di/container.ts wires use cases → repositories → datasources
– factories create specific use case instances (Factory pattern)
f. External Services
– NASA REST APIs
– AsyncStorage (mobile) + fallback for web
– React Navigation
Architectural patterns & design principles
• CLEAN + MVVM: strict separation of UI, ViewModel, domain, data
• SOLID:
– Single Responsibility: each layer has one focus (e.g., mappers only map)
– Open/Closed: new APIs can be added via new datasource + mapper + use case without modifying existing code
– Liskov: repositories implement a common interface
– Interface Segregation: small interfaces per API/use case
– Dependency Inversion: high-level modules (use cases) depend on abstractions (repositories)
• Observer: ViewModels expose observables/state to UI
• Strategy: connectivity strategy chooses online vs offline data source
• Factory: DI factories for use cases