# tcrakn/islamic-prayer-times-display-esp32 architecture

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

- Interactive diagram: https://gitdiagram.com/tcrakn/islamic-prayer-times-display-esp32
- Repository: https://github.com/tcrakn/islamic-prayer-times-display-esp32

## Overview

##### Project type and purpose
- This is an embedded IoT application running on an ESP32‐based TTGO T‑Display board.
- It fetches geolocation and prayer‐time data over WiFi, renders maps and schedules on a small TFT, and manages deep‐sleep/WAKE cycles.

##### (implied) file structure
- Top‐level sketch folder (“Islamic Prayer Times Display‑TTGO”) containing:
– The main .ino/Arduino sketch
– Library includes (WiFiManager, ArduinoJson, TFT_eSPI)
– Configuration files (User_Setup_Select.h modifications)
- Ancillary docs: ChangeLog.md, LICENSE, README.md

##### README insights
- Uses muwaqqit.com JSON API for prayer times
- Uses Google Maps/Geocoding API for location and static map images
- Incorporates NTP time‑sync, captive‐portal WiFiManager, deep‑sleep, OTA update via portal
- Handles button inputs for UI navigation (map zoom, view toggle, config portal, WAKE)

##### Main components and relationships
1. ESP32 SoC + peripherals
- SPI bus → ST7789 TFT display
- GPIO → buttons (top, bottom, wake)
- Li‑Po battery & power‐management IC
2. Persistent storage
- Flash (stores WiFi credentials & firmware bin)

B. Software modules (middle layer)
1. Boot & Wake Manager
- Handles reset, deep‐sleep entry/exit based on button or timer
2. WiFi Manager
- Auto‐connect to stored SSID/PW or launch captive‐portal (SSID “Muwaqqit-AP”)
- Handles OTA binary upload via HTTP
3. Time Sync (NTP Client)
- Queries NTP server to set RTC
4. Geolocation Module
- HTTP GET → Google Geocoding API for address & static map
- Parses image URL or JPEG/PNG response
5. Prayer Times Module
- HTTP GET → muwaqqit.com API
- ArduinoJson to parse Fajr, Dhuhr, etc.
6. & Graphics (TFT_eSPI)
- UI state machine with timeout transitions
7. Button Handler
- Maps button presses to zoom in/out, view toggle, skip to timetable, enter config
8. Deep‐Sleep & Power Manager
- After inactivity or display cycle completion → ESP32 deep‐sleep

C. External Services (top layer)
- NTP Pool (time)
- Google Maps/Geocoding API (address + map)
- muwaqqit.com Prayer Times API

##### Final checklist
- Arrowheads indicating request/response or data flow direction

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services Layer
    subgraph "External Services"
        direction TB
        NTP["NTP Pool"]:::external
        GoogleAPI["Google Maps/Geocoding API"]:::external
        MuwaqqitAPI["muwaqqit.com Prayer Times API"]:::external
    end

    %% Software Modules Layer
    subgraph "Embedded Software Modules"
        direction TB
        BootWake["Boot & Wake Manager"]:::software
        WiFiMgr["WiFi Manager\n(captive-portal & OTA)"]:::software
        TimeSync["Time Sync (NTP Client)"]:::software
        Geolocation["Geolocation Module\n(Google Geocoding + Static Map)"]:::software
        PrayerFetch["Prayer Times Module\n(muwaqqit.com API)"]:::software
        DisplayGraphics["Display & Graphics\n(TFT_eSPI UI State Machine)"]:::software
        ButtonHandler["Button Handler\n(zoom, toggle, skip, config)"]:::software
        SleepMgr["Deep-Sleep & Power Manager"]:::software
    end

    %% Hardware Layer
    subgraph "Hardware / Device"
        direction TB
        Board["ESP32 SoC + Peripherals"]:::hardware
        Flash["Flash Storage"]:::storage
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        MainSketch["Main Sketch (.ino)"]:::docs
        click MainSketch "https://github.com/tcrakn/islamic-prayer-times-display-esp32/blob/main/Islamic Prayer Times Display‑TTGO/Islamic_Prayer_Times_Display‑TTGO.ino"
        ConfigHeader["User_Setup_Select.h"]:::docs
        click ConfigHeader "https://github.com/tcrakn/islamic-prayer-times-display-esp32/blob/main/Islamic Prayer Times Display‑TTGO/User_Setup_Select.h"
        LibFolder["Libraries Folder"]:::docs
        click LibFolder "https://github.com/tcrakn/islamic-prayer-times-display-esp32/tree/main/Islamic Prayer Times Display‑TTGO/lib/"
        README["README.md"]:::docs
        click README "https://github.com/tcrakn/islamic-prayer-times-display-esp32/blob/main/README.md"
        ChangeLog["ChangeLog.md"]:::docs
        click ChangeLog "https://github.com/tcrakn/islamic-prayer-times-display-esp32/blob/main/ChangeLog.md"
        License["LICENSE"]:::docs
        click License "https://github.com/tcrakn/islamic-prayer-times-display-esp32/tree/main/LICENSE"
        TopFolder["Project Root Folder"]:::docs
        click TopFolder "https://github.com/tcrakn/islamic-prayer-times-display-esp32/tree/main/Islamic Prayer Times Display‑TTGO/"
    end

    %% Connections between layers
    NTP -->|"NTP request"| TimeSync
    GoogleAPI -->|"HTTP GET geocode/map"| Geolocation
    MuwaqqitAPI -->|"HTTP GET prayer times"| PrayerFetch

    BootWake -->|"on wake/reset"| WiFiMgr
    WiFiMgr -->|"connected"| TimeSync
    TimeSync -->|"time set"| Geolocation
    Geolocation -->|"location & map"| DisplayGraphics
    PrayerFetch -->|"prayer JSON"| DisplayGraphics
    DisplayGraphics -->|"renders UI"| Board
    Board -->|"SPI"| DisplayGraphics
    Board -->|"GPIO"| ButtonHandler
    ButtonHandler -->|"events"| DisplayGraphics
    DisplayGraphics -->|"timeout/inactivity"| SleepMgr
    SleepMgr -->|"deep-sleep cycle"| BootWake
    Board -->|"stores creds & firmware"| Flash
    WiFiMgr -->|"reads/writes cred"| Flash
    WiFiMgr -->|"OTA upload"| Flash

    %% Class Definitions
    classDef software fill:#D0E8FF,stroke:#2196F3,color:#000;
    classDef external fill:#FFE0B2,stroke:#FB8C00,color:#000;
    classDef hardware fill:#ECECEC,stroke:#757575,color:#000;
    classDef storage fill:#C8E6C9,stroke:#388E3C,color:#000;
    classDef docs fill:#F3E5F5,stroke:#8E24AA,color:#000;
```
