How saiyedrushan/hadithstash works
Project type and purpose
• This is a cross-platform mobile application built with Expo (React Native) using Expo Router’s file-based routing.
• From the file tree and README, it appears to be a reading app (Hadith/book/chapter navigation) with three main tabs (Home, Library, Profile) and deep routes for books, chapters, and hadiths.
• It uses Supabase for backend services (authentication, database) and AsyncStorage for local persistence.
File structure
• Top-level directories:
• app/ – Exposes the file-based routing structure under (tabs) and flat routes
• components/ – Reusable UI components (cards, themed views, collapsibles, etc.)
• assets/ – Fonts and images
• libs/ – Abstraction over Supabase client (supabase.ts)
• constants/, types/ – Shared constants and TypeScript types
• scripts/ – Utility scripts (e.g., reset project)
• Configuration files: app.json (Expo config), tsconfig.json, package.json
• Testing assets under components/__tests__
README for additional insights
• Confirms this was bootstrapped with create-expo-app.
• No built-in backend in this repo beyond the Supabase client abstraction.
• Emphasizes file-based routing and standard Expo development flows.
a. Main components to represent:
1. Mobile Client (iOS, Android, Web)
• Presentation Layer (Screens under app/(tabs) + index.tsx)
• Navigation Layer (Expo Router, file-based routing)
• UI Components (components/* & components/ui/*)
• Hooks & State (hooks/*, constants/*, useThemeColor, AsyncStorage)
• Data Layer (libs/supabase.ts + types/supabase.ts)
2. Local Persistence
• AsyncStorage (types/asyncstorage.ts) for caching last-read state, theme prefs
3. External Service
• Supabase (Auth, Realtime DB, Storage)
4. Assets
• Fonts & Images (assets/fonts, assets/images)
5. Build & Deployment
• Expo CLI/Metro bundler (app.json, package.json scripts)
b. Relationships and interactions
• Screens call UI Components and Hooks.
• Hooks/data layer call libs/supabase to fetch or write data.
• libs/supabase communicates over HTTPS with Supabase Auth/DB.
• Successful API responses flow back into data layer → hooks → components → UI.
• Some state is persisted locally in AsyncStorage.
• Navigation orchestrates which screen is active based on route segments.
• Assets are loaded by UI components at render time.
c. Architectural patterns & design principles
• Component-based UI (React) separating presentational vs data concerns.
• File-based routing for screen discovery (Expo Router).
• Unidirectional data flow: UI → Hooks/Data Layer → External Service → UI.
• Abstraction of backend via libs/supabase to centralize API calls.
• Separation of concerns: “app/” for routes, “components/” for UI, “hooks/” for logic, “libs/” for external integrations.
d. Key technologies & libraries
• Expo (React Native)
• Expo Router (file-based navigation)
• React & React Native components
• Supabase JS client
• TypeScript
• AsyncStorage
• Jest (components/__tests__)
• Metro bundler & Expo CLI
Diagramming conventions
• Use clear, concise labels: e.g., “HomeScreen”, “Supabase Service”, “AsyncStorage”
• From Screens → Hooks/Data Layer → Supabase
• From Supabase → Data Layer → Screens
• From Screens ↔ AsyncStorage
• Orange for External Service (Supabase)
Detailed coverage
• Within Data Layer, break out functions like “fetchHadith()”, “loginUser()” if desired.
• If the script “reset-project.js” is important for CI/CD or developer workflows, show it as part of Build & Deployment.