How marcgirbaub/marvelapp works
Project type and purpose
• This is a React Native mobile app (“Marvel App”) built in TypeScript.
• It serves as an interactive guide to the Marvel universe: users log in, browse paginated lists of heroes and comics, get detail screens, and data is fetched from the external Marvel API.
File structure
• Top‐level native shells: /android and /ios directories containing platform projects, Gradle and Xcode configurations, native entry points (MainActivity.java, AppDelegate.m).
• JS entrypoints: index.js and App.tsx.
• src folder organized by layers:
• components/ (presentational UI)
• screens/ (pages wired to navigation)
• navigation/ (React Navigation stack, routes, wrappers)
• hooks/ (custom hooks encapsulating data‐loading and business logic)
• store/ (React Context + Redux Toolkit slices, providers, store setup)
• utils/, constants/, types/, styles/
• Config files for build, linting, testing (.eslintrc.js, babel.config.js, metro.config.js, jest.setup.ts).
README for additional insights
• Tech stack: React Native, TypeScript, React Context, Redux Toolkit, Apisauce (HTTP client), React Navigation.
• Architectural patterns: adapter pattern for separating logic (hooks) from components, caching via proxy object, Clean Code / SOLID.
Main components
a. Native Shells
• Android and iOS platform projects launch the React Native runtime and load the JS bundle.
b. JS Runtime & Bundler
• Metro Bundler → delivers JS bundle to device, runs in JSCore/V8.
c. Presentation Layer
• Screens (HomeScreen, HeroDetailScreen, LoginScreen), Components (HeroCard, ComicsList, Header, etc.)
• React Navigation StackNavigator routes and wrappers.
d. Domain Layer (Business Logic)
• Custom Hooks (useLoadData, useLoadCurrentHero, useUser, useStorage) implementing the adapter pattern.
e. State & Data Layer
• React Context providers (ApiRequestContext, CachedRequestsProvider)
• Redux store (slices for hero and user), dispatchers exposed via hooks (store/redux/hooks.ts)
f. API Layer
• Apisauce clients configured to call Marvel API endpoints
• Caching proxy object intercepting identical requests and serving cached responses
g. External Services
• Marvel REST API over HTTPS
h. Local Persistence
• AsyncStorage (invoked via useStorage hook) for user/session tokens
i. Testing & CI (optional)
• Jest + React Native Testing Library suites under src/**/*.test.tsx
• GitHub Actions workflows (testing.yaml, sonar.yaml, audit.yaml)
Relationships and interactions
• User taps UI → triggers component callback → calls custom hook or dispatches Redux action.
• Hooks/Redux middleware → call ApiRequestContext → Apisauce client → caching layer → network → external Marvel API.
• Response travels back: cache proxy → context or Redux store → components re-render with new data.
• Navigation layer sits between screens; on press events it pushes new routes.
• useStorage hook interacts with AsyncStorage for persisting tokens or cache.
Architectural patterns & design principles
• Layered architecture (presentation → domain → data → external).
• Adapter pattern: components are “dumb” and receive props; hooks/adapters encapsulate logic.
• Caching proxy: performance optimization, reduces redundant API calls.
• SOLID and Clean Code: clear separation of concerns, single‐responsibility components.
How to capture essential elements without overthinking
• Break the system into as many discrete components as needed, but maintain clarity by placing them into logical lanes or layers.