How gitzak/expo-app-react-native-coffee-app works
Project Type and Purpose
• This is a single-code-base mobile application built with React Native/Expo.
• It uses file-based routing to render screens, fetches coffee data from a remote API, and applies custom theming and design via shared components.
File Structure
• Top-level “app” directory: contains screen components and layout (_layout.tsx), file-based routing (index.tsx, coffee/[id].tsx).
• “components”: reusable UI pieces (Card, CoffeeCard, ThemedText).
• “hooks”: business logic hooks (useFetchQuery for data fetching, useThemeColors for theming).
• “assets”: fonts & images packaged with the app.
README for Insights
• Built with Expo (so you have an Expo runtime, bundler, and optional native modules).
• File-based router powering navigation.
• No backend code here—data comes from external coffee-store API.
Main Components & Their Relationships
a. Mobile Client (Expo App)
• Screens:
– Home screen (app/index.tsx)
– Coffee detail screen (app/coffee/[id].tsx)
• Layout: Common wrapper (_layout.tsx)
• UI Components: Card, CoffeeCard, ThemedText, others
• Hooks/Data Layer: useFetchQuery (calls REST API), useThemeColors
• Assets: images & fonts
b. External Services
• Coffee Data API (REST endpoint)
• Optional Analytics / Crash Reporting (e.g., Expo’s services)
c. Platform & Build Tools
• Expo runtime & bundler (Metro)
• VSCode / CLI (npm, eas.json for EAS builds)
Architectural Patterns & Design Principles
• Separation of concerns: UI vs. data fetching vs. styling vs. navigation.
• File-based routing = navigation mapping.
• Custom hooks encapsulate side effects (data + theme).
• Component reusability: small Card components used across screens.
• Constants for design tokens ensure consistency.
• Inside, subdivide into layers (top to bottom):
1. Navigation/File-Based Routing
2. Screen Components
3. Reusable Components (Card, CoffeeCard, ThemedText)
4. Hooks/Data Layer
5. Constants & Assets
• UseFetchQuery → HTTP GET → API
• At the bottom or side, add “Expo Services” (optional) for analytics, builds.
• User taps Screen → triggers Hooks → fetches data → returns JSON → passes to components → renders UI.
• Blue for UI layers, green for data layers, orange for external services, gray for assets/constants.