# mdchad/myhadeethapp architecture

> Architecture diagram of the GitHub repository mdchad/myhadeethapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mdchad/myhadeethapp
- Repository: https://github.com/mdchad/myhadeethapp

## Overview

##### Project type and purpose
- This is a single‑repository, client‑only React Native application built with Expo and following a file‑based navigation paradigm via `expo-router`.
- Its purpose is to present Hadith content (with search, volume browsing, prayers, qibla compass, user notes, audio playback, and offline/local data support) on mobile devices.

##### File structure
- Top‑level folders:
- `app/` – primary entrypoint for screens & layouts (Expo Router).
- `app/components/` – reusable UI components.
- `app/shared/` – shared hooks, data‑fetcher logic, storage, online‑status utilities.
- `app/utils/` – standalone helpers (e.g., sharing, superscript conversion).
- `app/i18n/` – internationalization and locale files.
- `context/` – React context providers (global state, “warm up” logic).
- `assets/` – static assets (audio, fonts, media).
- `data/` – bundled JSON data (`hadith40.json`).
- Config files: `app.json`, `eas.json`, `babel.config.js`, `tailwind.config.js`.

##### README for additional insights
- Confirms use of Expo Router for native navigation.
- No custom backend in this repo; data is either local (`data/`) or fetched via shared fetcher hooks (could point to remote APIs or local JSON).
- Build & deployment use EAS and standard Expo workflows.

a. Main components:
1. Mobile App Container (Expo + React Native runtime)
2. Navigation Layer (Expo Router’s file‑based router)
3. Screen/Feature Modules (tabs: default, hadith, prayers, qibla, search, profile, settings, introduction, user/hadith40)
4. UI Component Library (`app/components/`)
5. Data Layer
– Local JSON (`data/hadith40.json`)
– Shared fetcher hooks (`app/shared/fetcher`)
– Local Storage (`app/shared/storage.js`)
– Online‑status manager (`useOnlineManager`)
6. Global State & Context Providers (`context/provider.js`)
7. Utilities & i18n (`app/utils/`, `app/i18n/`)
8. Static Assets (audio, fonts, media)
9. Build & Deployment (Expo CLI, EAS, Babel, Tailwind config)

b. Relationships & interactions:
– Navigation Layer orchestrates which Screen Modules are mounted.
– Screens invoke UI Components for rendering.
– Screens/hooks call Data Layer to fetch data (local JSON or remote API).
– Data Layer reads/writes to Local Storage and reacts to network status via Online Manager.
– Global Context wraps the entire `app/` subtree to provide theme, auth state, user preferences, etc.
– Utilities and i18n are injected into screens/components as needed.
– Static Assets are loaded by components (audio player, fonts).
– Build & Deployment tools consume config files and package the Mobile App Container.

c. Architectural patterns & design principles:
– File‑based routing (Expo Router) → implicit navigation graph.
– Component‑based UI (atomic/reusable components).
– Hooks for separation of concerns (data fetching, state, side effects).
– Context API for cross‐cutting global state.
– Layered architecture: Presentation → Domain (screens + hooks) → Data (fetcher + storage) → Assets.

d. Key technologies/frameworks/libraries:
– Expo Router & Expo SDK (navigation, asset loading)
– React Native & React Hooks
– Context API
– Tailwind CSS via `tailwind.config.js`
– Babel for transpilation
– EAS for build & over‑the‑air updates
– Localization with `react-i18n` style files

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        MobileContainer["Mobile App Container"]:::service
        Navigation["Navigation Layer (Expo Router)"]:::frontend
    end

    MobileContainer --> Navigation

    subgraph "Screen Modules"
        DefaultTab["Default Tab Screen Module"]:::frontend
        HadithTab["Hadith Tab Screen Module"]:::frontend
        HadithDetail["Hadith Detail Screen"]:::frontend
        PrayersTab["Prayers Tab Screen Module"]:::frontend
        QiblaTab["Qibla Tab Screen Module"]:::frontend
        SearchTab["Search Tab Screen Module"]:::frontend
        ProfileTab["Profile Tab Screen Module"]:::frontend
        Settings["Settings Screen Module"]:::frontend
        Introduction["Introduction Screen Module"]:::frontend
        Hadith40["Hadith40 Feature Module"]:::frontend
        UserNotes["User Notes Module"]:::frontend
    end

    Navigation --> DefaultTab
    Navigation --> HadithTab
    Navigation --> PrayersTab
    Navigation --> QiblaTab
    Navigation --> SearchTab
    Navigation --> ProfileTab
    Navigation --> Settings
    Navigation --> Introduction
    Navigation --> Hadith40
    Navigation --> UserNotes

    HadithTab --> HadithDetail

    %% UI Components
    UIComponents["UI Component Library"]:::frontend
    subgraph "Components Layer"
        UIComponents
    end
    DefaultTab --> UIComponents
    HadithTab --> UIComponents
    PrayersTab --> UIComponents
    QiblaTab --> UIComponents
    SearchTab --> UIComponents
    ProfileTab --> UIComponents
    Settings --> UIComponents
    Introduction --> UIComponents
    Hadith40 --> UIComponents
    UserNotes --> UIComponents

    %% Data Layer
    subgraph "Data Layer"
        LocalJSON["Local JSON\nhadith40.json"]:::data
        Fetcher["Data Fetcher Hooks"]:::data
        Storage["Local Storage"]:::data
        OnlineMgr["Online Status Manager"]:::data
        RemoteAPI["Remote API"]:::external
    end

    Fetcher --> LocalJSON
    Fetcher --> RemoteAPI
    Fetcher --> Storage
    OnlineMgr --> Fetcher

    DefaultTab --> Fetcher
    HadithTab --> Fetcher
    PrayersTab --> Fetcher
    QiblaTab --> Fetcher
    SearchTab --> Fetcher
    ProfileTab --> Fetcher
    Settings --> Fetcher
    Introduction --> Fetcher
    Hadith40 --> Fetcher
    UserNotes --> Fetcher

    DefaultTab --> Storage
    DefaultTab --> OnlineMgr

    %% Context & Utilities
    subgraph "Context & Utilities"
        Context["Global State & Context Providers"]:::data
        WarmUp["Warm‑up Logic Hook"]:::data
        UtilsShare["shareHadith.js"]:::data
        UtilsSuper["toSuperscript.js"]:::data
        I18n["Internationalization"]:::data
    end

    Context --> Navigation
    DefaultTab --> Context
    HadithTab --> Context
    PrayersTab --> Context
    QiblaTab --> Context
    SearchTab --> Context
    ProfileTab --> Context
    Settings --> Context
    Introduction --> Context
    Hadith40 --> Context
    UserNotes --> Context

    DefaultTab --> WarmUp
    HadithTab --> WarmUp

    DefaultTab --> UtilsShare
    HadithTab --> UtilsShare

    DefaultTab --> UtilsSuper
    SearchTab --> UtilsSuper

    DefaultTab --> I18n
    Settings --> I18n

    %% Static Assets
    Assets["Static Assets\n(audio, fonts)"]:::data
    UIComponents --> Assets

    %% Build & Deployment
    subgraph "Build & Deployment"
        Config["Config Files\napp.json, eas.json,\nbabel.config.js,\ntailwind.config.js"]:::service
        ExpoCLI["Expo CLI & EAS"]:::service
    end

    Config --> ExpoCLI
    ExpoCLI --> MobileContainer

    %% Click Events
    click MobileContainer "https://github.com/mdchad/myhadeethapp/blob/dev/app/_layout.js"
    click Navigation "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/_layout.jsx"
    click DefaultTab "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(default)/index.js"
    click HadithTab "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(hadeeth)/index.js"
    click HadithDetail "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(default)/hadith/[id].jsx"
    click PrayersTab "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(prayers)/index.js"
    click QiblaTab "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(qibla)/index.js"
    click SearchTab "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(search)/index.js"
    click ProfileTab "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/(tabs)/(profile)/index.jsx"
    click Settings "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/settings/index.js"
    click Introduction "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/introduction/index.js"
    click Hadith40 "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/hadith40/index.js"
    click UserNotes "https://github.com/mdchad/myhadeethapp/blob/dev/app/(app)/user/notes/index.jsx"
    click UIComponents "https://github.com/mdchad/myhadeethapp/tree/dev/app/components/"
    click LocalJSON "https://github.com/mdchad/myhadeethapp/blob/dev/data/hadith40.json"
    click Fetcher "https://github.com/mdchad/myhadeethapp/tree/dev/app/shared/fetcher/"
    click Storage "https://github.com/mdchad/myhadeethapp/blob/dev/app/shared/storage.js"
    click OnlineMgr "https://github.com/mdchad/myhadeethapp/blob/dev/app/shared/useOnlineManager.js"
    click Context "https://github.com/mdchad/myhadeethapp/blob/dev/context/provider.js"
    click WarmUp "https://github.com/mdchad/myhadeethapp/blob/dev/context/useWarmUpBrowser.js"
    click UtilsShare "https://github.com/mdchad/myhadeethapp/blob/dev/app/utils/shareHadith.js"
    click UtilsSuper "https://github.com/mdchad/myhadeethapp/blob/dev/app/utils/toSuperscript.js"
    click I18n "https://github.com/mdchad/myhadeethapp/blob/dev/app/i18n/index.js"
    click Assets "https://github.com/mdchad/myhadeethapp/tree/dev/assets/"
    click Config "https://github.com/mdchad/myhadeethapp/blob/dev/app.json"
    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
    classDef data fill:#c8e6c9,stroke:#1b5e20,stroke-width:1px
    classDef service fill:#ffe0b2,stroke:#e65100,stroke-width:1px
    classDef external fill:#ffffff,stroke:#757575,stroke-dasharray: 5 5,stroke-width:1px
```
