How akamfoad/hacker-native works
Project type and purpose
• This is a React Native mobile client (Expo-based) for browsing Hacker News content.
• It uses Expo’s managed workflow, React/TypeScript, the new app‑directory-based router, and fetches data from the public Hacker News API.
File structure
• Top‑level config: .eslintrc.js, tsconfig.json, babel.config.js, app.json, package.json.
• app/: Expo Router screens and layouts (index.tsx, [itemId].tsx, users/[userId].tsx, _layout.tsx).
• api/: Data‑fetching layer (endpoints.ts).
• components/: Reusable UI components organized by domain (posts/, comments/, common controls like Spinner.tsx, Select.tsx).
• shared/: Cross‑cutting TypeScript types.
• lib/: Utility functions (text processing).
• scripts/: Automation scripts (e.g., reset-project.js).
Key insights from the README
• Expo project built with create-expo-app.
• Supports listing and filtering HN stories, viewing post details, comments, and user profiles.
• No custom backend—relies on Hacker News’s public REST endpoints (topstories.json, etc.).
Main components
a. Mobile Client (Expo App)
• Screens & Navigation (Expo Router)
• UI Components (PostsList, PostDetails, CommentDetails, UserProfile)
• State & Caching (in‑memory React state + optionally React Query or Context)
b. Data Layer (api/endpoints.ts)
• HTTP client to Hacker News REST API
c. Utilities & Shared Types
• Text processing, constants, TS types
d. Assets
e. External Service
• Hacker News public API (Firebase‑backed JSON endpoints)
Relationships and interactions
• Navigation routes map to Screens in app/.
• Screens render UI Components (components/) and invoke functions in api/endpoints.ts.
• API calls fetch JSON from the Hacker News API and return typed objects (shared/types.ts).
• Screens pass data to presentational components.
• Utilities in lib/ transform raw API data for rendering.
Architectural patterns and design principles
• Separation of Concerns:
• Presentation (components/) vs Data‑fetching (api/) vs Routing (app/) vs Utilities (lib/, constants/).
• Modular, feature‑based directory structure (posts, comments, users).
• Typed contracts across layers via shared/types.ts.
• Asset bundling by Expo.