# mohamedmagdy233/worker architecture

> Architecture diagram of the GitHub repository mohamedmagdy233/worker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamedmagdy233/worker
- Repository: https://github.com/mohamedmagdy233/worker

## Overview

This repository contains standalone PHP jobs that generate Islamic social-media posts and publish them to a Facebook page: salawat and reflections, Quran verses, hadith, and quote images. The main workflow is content selection or retrieval, message/image preparation, then publication. The hadith job also tracks published IDs to avoid repeats. Source excerpts show these flows, but do not establish how the jobs are invoked; scheduling configuration is therefore omitted.

Main entry points: [`p2p.php`](https://github.com/mohamedmagdy233/worker/blob/main/p2p.php) (Hadith selection), [`p3p.php`](https://github.com/mohamedmagdy233/worker/blob/main/p3p.php) (Image rendering), [`p5p.php`](https://github.com/mohamedmagdy233/worker/blob/main/p5p.php) (Verse retrieval), [`p1p.php`](https://github.com/mohamedmagdy233/worker/blob/main/p1p.php) (Salawat publisher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_text_posts["Text post jobs"]
  node_salawat_content["Salawat content<br/>[p1p.php]"]
  node_salawat_publish["Salawat publisher<br/>[p1p.php]"]
  node_quran_retrieval["Verse retrieval<br/>[p5p.php]"]
  node_quran_formatting["Verse formatting<br/>[p5p.php]"]
  node_quran_publish["Verse publisher<br/>[p5p.php]"]
end

subgraph group_hadith_job["Hadith publishing"]
  node_hadith_fetch["Hadith retrieval<br/>[p2p.php]"]
  node_hadith_selection["Hadith selection<br/>[p2p.php]"]
  node_published_ledger[("Published ID ledger")]
  node_hadith_formatting["Post formatting<br/>[p2p.php]"]
  node_hadith_publish["Facebook publisher<br/>[p2p.php]"]
end

subgraph group_image_posts["Image post job"]
  node_quote_selection["Quote selection<br/>[p3p.php]"]
  node_image_rendering["Image rendering<br/>[p3p.php]"]
  node_image_publish["Image publisher<br/>[p3p.php]"]
end

node_hadeethenc{{"HadeethEnc API"}}
node_quran_api{{"AlQuran Cloud API"}}
node_facebook{{"Facebook Graph API"}}
node_imagemagick{{"ImageMagick"}}

node_salawat_content -->|"submits text"| node_salawat_publish
node_salawat_publish -->|"publishes feed"| node_facebook
node_quran_retrieval -->|"fetches verse"| node_quran_api
node_quran_retrieval -->|"provides verse"| node_quran_formatting
node_quran_formatting -->|"submits text"| node_quran_publish
node_quran_publish -->|"publishes feed"| node_facebook
node_hadith_fetch -->|"requests categories"| node_hadeethenc
node_hadith_fetch -->|"provides results"| node_hadith_selection
node_hadith_selection -->|"requests details"| node_hadeethenc
node_hadith_selection -->|"checks IDs"| node_published_ledger
node_hadith_formatting -->|"submits text"| node_hadith_publish
node_hadith_publish -->|"publishes feed"| node_facebook
node_hadith_publish -->|"records success"| node_published_ledger
node_quote_selection -->|"provides quote"| node_image_rendering
node_image_rendering -->|"renders assets"| node_imagemagick
node_image_rendering -->|"provides image"| node_image_publish
node_image_publish -->|"publishes photo"| node_facebook

click node_salawat_content "https://github.com/mohamedmagdy233/worker/blob/main/p1p.php"
click node_salawat_publish "https://github.com/mohamedmagdy233/worker/blob/main/p1p.php"
click node_quran_retrieval "https://github.com/mohamedmagdy233/worker/blob/main/p5p.php"
click node_quran_formatting "https://github.com/mohamedmagdy233/worker/blob/main/p5p.php"
click node_quran_publish "https://github.com/mohamedmagdy233/worker/blob/main/p5p.php"
click node_hadith_fetch "https://github.com/mohamedmagdy233/worker/blob/main/p2p.php"
click node_hadith_selection "https://github.com/mohamedmagdy233/worker/blob/main/p2p.php"
click node_published_ledger "https://github.com/mohamedmagdy233/worker/blob/main/published_hadiths.json"
click node_hadith_formatting "https://github.com/mohamedmagdy233/worker/blob/main/p2p.php"
click node_hadith_publish "https://github.com/mohamedmagdy233/worker/blob/main/p2p.php"
click node_quote_selection "https://github.com/mohamedmagdy233/worker/blob/main/p3p.php"
click node_image_rendering "https://github.com/mohamedmagdy233/worker/blob/main/p3p.php"
click node_image_publish "https://github.com/mohamedmagdy233/worker/blob/main/p3p.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_salawat_content,node_salawat_publish,node_quran_retrieval,node_quran_formatting,node_quran_publish toneBlue
class node_hadith_fetch,node_hadith_selection,node_published_ledger,node_hadith_formatting,node_hadith_publish toneAmber
class node_quote_selection,node_image_rendering,node_image_publish,node_hadeethenc,node_quran_api,node_facebook toneMint
class node_imagemagick toneIndigo
```

## Components

### Text post jobs

- [Salawat content](https://github.com/mohamedmagdy233/worker/blob/main/p1p.php): `p1p.php`
- [Salawat publisher](https://github.com/mohamedmagdy233/worker/blob/main/p1p.php): `p1p.php`
- [Verse retrieval](https://github.com/mohamedmagdy233/worker/blob/main/p5p.php): `p5p.php`
- [Verse formatting](https://github.com/mohamedmagdy233/worker/blob/main/p5p.php): `p5p.php`
- [Verse publisher](https://github.com/mohamedmagdy233/worker/blob/main/p5p.php): `p5p.php`

### Hadith publishing

- [Hadith retrieval](https://github.com/mohamedmagdy233/worker/blob/main/p2p.php): `p2p.php`
- [Hadith selection](https://github.com/mohamedmagdy233/worker/blob/main/p2p.php): `p2p.php`
- [Published ID ledger](https://github.com/mohamedmagdy233/worker/blob/main/published_hadiths.json): `published_hadiths.json`
- [Post formatting](https://github.com/mohamedmagdy233/worker/blob/main/p2p.php): `p2p.php`
- [Facebook publisher](https://github.com/mohamedmagdy233/worker/blob/main/p2p.php): `p2p.php`

### Image post job

- [Quote selection](https://github.com/mohamedmagdy233/worker/blob/main/p3p.php): `p3p.php`
- [Image rendering](https://github.com/mohamedmagdy233/worker/blob/main/p3p.php): `p3p.php`
- [Image publisher](https://github.com/mohamedmagdy233/worker/blob/main/p3p.php): `p3p.php`

### Other components

- **HadeethEnc API**
- **AlQuran Cloud API**
- **Facebook Graph API**
- **ImageMagick**

## Connections

- Salawat content → Salawat publisher: submits text (evidence: `p1p.php`)
- Salawat publisher → Facebook Graph API: publishes feed (evidence: `p1p.php`)
- Verse retrieval → AlQuran Cloud API: fetches verse (evidence: `p5p.php`)
- Verse retrieval → Verse formatting: provides verse (evidence: `p5p.php`)
- Verse formatting → Verse publisher: submits text (evidence: `p5p.php`)
- Verse publisher → Facebook Graph API: publishes feed (evidence: `p5p.php`)
- Hadith retrieval → HadeethEnc API: requests categories (evidence: `p2p.php`)
- Hadith retrieval → Hadith selection: provides results (evidence: `p2p.php`)
- Hadith selection → HadeethEnc API: requests details (evidence: `p2p.php`)
- Hadith selection → Published ID ledger: checks IDs (evidence: `p2p.php`)
- Post formatting → Facebook publisher: submits text (evidence: `p2p.php`)
- Facebook publisher → Facebook Graph API: publishes feed (evidence: `p2p.php`)
- Facebook publisher → Published ID ledger: records success (evidence: `p2p.php`)
- Quote selection → Image rendering: provides quote (evidence: `p3p.php`)
- Image rendering → ImageMagick: renders assets (evidence: `p3p.php`)
- Image rendering → Image publisher: provides image (evidence: `p3p.php`)
- Image publisher → Facebook Graph API: publishes photo (evidence: `p3p.php`)
