# mahmoudrabbas/holy-quran architecture

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

- Interactive diagram: https://gitdiagram.com/mahmoudrabbas/holy-quran
- Repository: https://github.com/mahmoudrabbas/holy-quran

## Overview

##### Project type and purpose
- This is a single‐page, front‐end React application (no custom backend) that fetches and displays verses (“Ayahs”) and chapters (“Surahs”) from an external Holy Quran API.
- It uses Redux for client‐side state management.

##### File structure
- Top‐level directories:
- public/ – static assets (index.html, robots.txt)
- src/ – application code
- Under src/:
- api/index.js – encapsulates HTTP calls to the external Quran API
- components/ – React UI components, organized by feature (Surah, home, header, footer)
- redux/ – state management
– actions/ (async calls, action types)
– reducers/ (handle state updates)
– store.js (Redux store configuration)
- Entry points: src/index.js (ReactDOM.render), src/App.js (main layout & routing)

##### Key insights from README
- Users can fetch random Ayahs or select a specific Surah.
- No server/DB of its own; it relies on an external REST API.
- Built with create‐react‐app (npm start/yarn start).

##### Main components
a. UI Layer (React Components)
- Header, Home view, Surah view, Footer
b. State Management Layer (Redux)
- Store, Actions, Reducers
c. API Layer
- api/index.js (fetch requests, error handling)
d. External Service
- Quran REST API (hosted externally)

##### Relationships and data flow
- UI components dispatch Redux actions (e.g., “GET_RANDOM_AYAH” or “GET_SURAH_BY_ID”).
- Actions call the API layer to perform HTTP requests.
- API responses are returned to actions, which then dispatch success/failure actions.
- Reducers update the Redux store.
- Store changes flow back into subscribed components via mapStateToProps (or useSelector), causing re-renders.

##### Architectural patterns & design principles
- Flux architecture (unidirectional data flow) with Redux
- Container/Presentational split implicitly: components consume store data and dispatch actions
- Separation of concerns: UI vs. state vs. API calls

##### Technologies / frameworks
- React
- Redux (actions, reducers, store)
- Fetch or Axios (inside src/api/index.js)
- create‐react‐app tooling

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Points
    subgraph "Entry Points"
        Index["React Entry Point"]:::entry
        App["Main App Layout & Routing"]:::entry
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Header["Header Component"]:::ui
        Home["Home View Component"]:::ui
        Surah["Surah View Component"]:::ui
        Footer["Footer Component"]:::ui
    end

    %% State Management Layer
    subgraph "State Management Layer"
        ActionTypes["Action Types"]:::redux
        SurahActions["Surah Actions"]:::redux
        Reducers["Root Reducer"]:::redux
        SurahReducer["Surahs Reducer"]:::redux
        Store["Redux Store"]:::redux
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        APIModule["API Module"]:::api
    end

    %% External Service
    External["Quran REST API"]:::external

    %% Connections
    Index --> App
    App --> Header
    App --> Home
    App --> Surah
    App --> Footer

    Header -->|"dispatch GET_RANDOM_AYAH / GET_SURAH"| SurahActions
    Home -->|"dispatch GET_RANDOM_AYAH"| SurahActions
    Surah -->|"dispatch GET_SURAH_BY_ID"| SurahActions

    SurahActions -->|"uses types"| ActionTypes
    SurahActions -->|"calls API"| APIModule

    APIModule -->|"HTTP GET /ayah or /surah/{id}"| External
    External -->|"API Response"| APIModule
    APIModule -->|"returns data"| SurahActions

    SurahActions -->|"dispatch SUCCESS/FAILURE"| SurahReducer
    SurahReducer -->|"combined by"| Reducers
    Reducers -->|"creates"| Store

    Store -->|"state updates"| Header
    Store -->|"state updates"| Home
    Store -->|"state updates"| Surah

    %% Click Events
    click Header "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/components/header/Header.js"
    click Footer "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/components/footer/Footer.js"
    click Home "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/components/home/Home.js"
    click Surah "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/components/Surur/Surah.js"
    click App "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/App.js"
    click Index "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/index.js"
    click APIModule "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/api/index.js"
    click Store "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/redux/store.js"
    click ActionTypes "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/redux/actions/types.js"
    click SurahActions "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/redux/actions/surahs.js"
    click Reducers "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/redux/reducers/index.js"
    click SurahReducer "https://github.com/mahmoudrabbas/holy-quran/blob/main/src/redux/reducers/surahs.js"

    %% Styles
    classDef entry fill:#f0f0f0,stroke:#333,stroke-width:1px;
    classDef ui fill:#cce5ff,stroke:#2a6f9e,stroke-width:2px;
    classDef redux fill:#d4edda,stroke:#3c763d,stroke-width:2px;
    classDef api fill:#ffe5b4,stroke:#cc8400,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
