# zamancodexpress/thaqva-masjid architecture

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

- Interactive diagram: https://gitdiagram.com/zamancodexpress/thaqva-masjid
- Repository: https://github.com/zamancodexpress/thaqva-masjid

## Overview

This repo is a **static single-page frontend website** (no backend, no build pipeline) for a mosque community site. The “system” is primarily **browser-side modules** that:
- render static sections (story/about/location),
- fetch **prayer times** from **azantimes.in**,
- compute and animate a **countdown to next Salah**,
- keep the UI bilingual (EN/ML) via a separate translation module,
- embed a **Google Map**.

##### File structure analysis (map files → components)
Top-level is the whole app; each file is a major architectural unit:

- `index.html`
**UI shell + section layout** (navbar, hero, about, countdown, prayer table, map embed). This is the DOM contract that JS modules attach to.

- `style.css`

- `script.js`
**Main runtime**:
- API client logic (fetch azantimes.in)
- normalization of times (12h→24h)
- countdown engine (`setInterval`)
- DOM rendering of table/strip/countdown
- navbar interactions + active link tracking
- GSAP + ScrollTrigger animation orchestration

- `translator.js`
**Independent translation subsystem (IIFE module)**:
- language toggle UI injection
- LocalStorage persistence
- translation of static strings
- **MutationObserver-based translation** of dynamic prayer names after `script.js` renders them

- `README.md`
Only documentation, but it reveals the key architectural “edges”: external API, GSAP, LocalStorage, Google Maps embed.

- **azantimes.in Prayer Times API** (network dependency; required for live times)
- **Google Maps Embed** (iframe/script embed; location display)
- **GSAP 3 + ScrollTrigger** (animation library used by `script.js`)
- **Google Fonts** (Amiri + Inter; external asset dependency)
- **Web Storage API (LocalStorage)** (browser persistence for language selection)

Shows the user, the browser SPA, and external services.

Breaks the SPA into the specific modules and subcomponents (API client, countdown engine, translation module, rendering targets).

This keeps it detailed without inventing backend components that don’t exist.

##### UI / DOM Structure (from `index.html`)
- Navbar + language toggle mount point
- Hero
- About
- Countdown section (digits + upcoming prayer label)
- Prayer Times table
- Prayer strip (highlight upcoming)
- Location section (Google map embed container)

##### Runtime logic (from `script.js`)
- **Prayer Times API Client**
- fetch() to azantimes.in
- response parse/normalize
- **Prayer Schedule Model**
- canonical list of prayers + times for the day
- current/upcoming prayer identification
- **Countdown Engine**
- computes next prayer
- runs 1-second tick loop
- **Renderer / DOM Updater**
- fills prayer times table
- updates highlight states
- updates countdown digits + labels
- **Navigation Controller**
- hamburger menu (small screens)
- active section highlighting on scroll
- **Animation Orchestrator (GSAP/ScrollTrigger)**
- on-load animations
- scroll-triggered reveals
- digit transitions for countdown

##### Translation subsystem (from `translator.js`)
- **Language State Manager**
- current language (EN/ML)
- persistence via LocalStorage
- **Translator / Dictionary**
- mapping keys for static + dynamic strings
- **DOM Translator**
- initial translation pass for static DOM
- **MutationObserver pipeline** to translate dynamic nodes created/updated by `script.js`
- **Language Toggle UI**
- injected into navbar
- event handlers to switch language

##### User → Browser SPA
- loads `index.html`, `style.css`, `script.js`, `translator.js`
##### script.js → azantimes.in API
- fetch prayer times for Kozhikode North
##### azantimes.in API → script.js
- returns today’s schedule
##### script.js → DOM
- renders prayer table, strip, next prayer label, countdown digits
##### script.js → GSAP
- triggers animations, scroll reveals, digit transitions
##### translator.js ↔ LocalStorage
- read saved language on load
- write language on toggle
##### translator.js → DOM
- translate static content immediately
##### translator.js (MutationObserver) → DOM
- watches for dynamic prayer labels and translates after `script.js` updates

##### UI embedding
- **index.html → Google Maps Embed**
- Loads from Google as an embedded widget (iframe)
- **index.html/CSS → Google Fonts**
- fonts loaded from external CDN

##### Architectural patterns / principles to highlight

- **No backend**: all logic runs client-side; external API is direct from the browser.
- **Module separation by responsibility**:
- `script.js` owns data fetching + timing + rendering + animations
- `translator.js` is intentionally decoupled and “observes” DOM changes rather than coupling to `script.js`
- **Reactive-ish behavior via MutationObserver**:
- translation is applied post-render to dynamic content
- **Time-based loop**:
- countdown uses `setInterval` tick; recalculates next prayer dynamically

- Actor: Visitor (mobile/desktop)
- Container: Browser running “Thaqva Masjid SPA”
- External: azantimes.in API
- External: Google Maps Embed
- External: Google Fonts
- Library: GSAP/ScrollTrigger (can be shown as external dependency or “included via CDN” inside browser)

Inside “Thaqva Masjid SPA”:
- UI Shell / Sections (index.html)
- Styling (style.css)
- script.js:
- API Client
- Schedule Model
- Countdown Engine
- Renderer (Table/Strip/Countdown)
- Navigation Controller
- GSAP Animation Orchestrator
- translator.js:
- Language Toggle UI
- LocalStorage Language State
- Static Translator
- MutationObserver Dynamic Translator
- Shared: DOM (as the integration hub)
- Browser service: LocalStorage

That set of components, with the interactions described above, is “as detailed as possible” for this repo without making assumptions.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================================================
  %% Diagram 1: System Context / Container-ish (Browser + externals)
  %% =========================================================
  subgraph "Diagram 1 — System Context (Frontend-only SPA)"
    direction TB

    User["Visitor (Mobile/Desktop)"]:::actor

    subgraph "Browser (Client Runtime Boundary)"
      direction TB
      SPA["Thaqva Masjid SPA (Static SPA)"]:::container
      DOM1["DOM (Rendered Sections + Dynamic Nodes)"]:::platform
      LS1[("Web Storage API\nLocalStorage")]:::platform
    end

    AZAN["azantimes.in\nPrayer Times API"]:::external
    GMAPS["Google Maps Embed\n(iframe/widget)"]:::external
    GFONTS["Google Fonts CDN\n(Amiri + Inter)"]:::external
    GSAPLIB["GSAP 3 + ScrollTrigger\n(3rd-party library)"]:::library

    User -->|"loads_site"| SPA
    SPA -->|"renders_updates"| DOM1
    SPA -->|"HTTP_GET_schedule"| AZAN
    AZAN -->|"today_schedule_JSON"| SPA

    SPA -->|"uses_animations"| GSAPLIB

    DOM1 -->|"hosts_embed_container"| GMAPS
    SPA -->|"reads_writes_language"| LS1
    SPA -->|"loads_fonts"| GFONTS
  end

  %% =========================================================
  %% Diagram 2: Component (inside browser)
  %% =========================================================
  subgraph "Diagram 2 — Client Component Diagram (Inside Browser)"
    direction TB

    subgraph "Static Assets"
      direction TB
      IndexHtml["UI Shell + Section Layout (index.html)\nNavbar/Hero/About/Countdown/Table/Map Container"]:::ui
      StyleCss["Styling / Presentation Layer (style.css)\nResponsive layout + animations + CSS variables"]:::css
    end

    subgraph "Runtime Modules"
      direction TB

      subgraph "Core App Logic (script.js)"
        direction TB
        ScriptMain["Main Runtime / Core App Logic (script.js)"]:::module

        ApiClient["Prayer Times API Client\n(fetch + parse + normalize 12h→24h)"]:::component
        Model["Prayer Schedule Model\n(canonical prayers + next prayer identification)"]:::component
        Countdown["Countdown Engine\n(setInterval 1s tick + next Salah computation)"]:::component
        Renderer["Renderer / DOM Updater\n(table + strip + countdown digits/label)"]:::component
        NavCtrl["Navigation Controller\n(hamburger + active link on scroll)"]:::component
        Anim["Animation Orchestrator\n(GSAP + ScrollTrigger)"]:::component

        ScriptMain -->|"owns"| ApiClient
        ScriptMain -->|"owns"| Model
        ScriptMain -->|"owns"| Countdown
        ScriptMain -->|"owns"| Renderer
        ScriptMain -->|"owns"| NavCtrl
        ScriptMain -->|"owns"| Anim

        ApiClient -->|"normalized_times"| Model
        Model -->|"next_prayer_time"| Countdown
        Countdown -->|"tick_updates"| Renderer
        Model -->|"schedule"| Renderer
        NavCtrl -->|"UI_state_updates"| Renderer
      end

      subgraph "Translation & i18n (translator.js)"
        direction TB
        TranslatorMain["Translation Subsystem / i18n Runtime (translator.js)"]:::module

        LangUI["Language Toggle UI\n(inject into navbar + handlers)"]:::component
        LangState["Language State Manager\n(EN/ML + LocalStorage persistence)"]:::component
        StaticDOMT["DOM Translator\n(initial static translation pass)"]:::component
        DynObserver["MutationObserver Dynamic Translation Pipeline\n(translate dynamic prayer labels post-render)"]:::component

        TranslatorMain -->|"injects"| LangUI
        TranslatorMain -->|"manages"| LangState
        TranslatorMain -->|"translates_static"| StaticDOMT
        TranslatorMain -->|"watches_translates_dynamic"| DynObserver

        LangUI -->|"toggle_language"| LangState
      end
    end

    subgraph "Browser Platform Surfaces"
      direction TB
      DOM2["DOM Integration Hub\n(Sections + Prayer Table + Strip + Countdown UI)"]:::platform
      LocalStorage[("LocalStorage\n(language selection)")]:::platform
    end

    subgraph "External Dependencies"
      direction TB
      AzanAPI["azantimes.in API"]:::external
      GMapsEmbed["Google Maps Embed"]:::external
      GFonts["Google Fonts CDN"]:::external
      GSAP["GSAP + ScrollTrigger"]:::library
    end

    %% Static asset relationships
    IndexHtml -->|"defines_DOM_contract"| DOM2
    StyleCss -->|"styles_layout_animations"| DOM2

    %% Core runtime interactions
    ApiClient -->|"HTTP_GET_schedule"| AzanAPI
    AzanAPI -->|"schedule_JSON"| ApiClient

    Renderer -->|"renders_updates"| DOM2
    Anim -->|"animates_on_load_scroll_digits"| GSAP
    Anim -->|"applies_to"| DOM2

    %% Translation interactions
    LangState <-->|"read_write"| LocalStorage
    StaticDOMT -->|"translate_static_nodes"| DOM2
    DynObserver -.->|"observe_mutations"| DOM2
    DynObserver -->|"translate_dynamic_labels"| DOM2

    %% Embeds / assets
    IndexHtml -->|"contains_map_container"| GMapsEmbed
    StyleCss -->|"imports_fonts"| GFonts

    %% Coupling via DOM (important integration surface)
    Renderer -->|"creates_dynamic_prayer_nodes"| DOM2
    DOM2 -.->|"mutation_events"| DynObserver
  end

  %% =========================================================
  %% Documentation Node (for click)
  %% =========================================================
  Readme["Documentation / Architectural Notes (README.md)"]:::doc

  %% =========================================================
  %% Click Events (from component_mapping)
  %% =========================================================
  click IndexHtml "https://github.com/zamancodexpress/thaqva-masjid/blob/main/index.html"
  click StyleCss "https://github.com/zamancodexpress/thaqva-masjid/blob/main/style.css"

  click ScriptMain "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"
  click ApiClient "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"
  click Model "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"
  click Countdown "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"
  click Renderer "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"
  click NavCtrl "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"
  click Anim "https://github.com/zamancodexpress/thaqva-masjid/blob/main/script.js"

  click TranslatorMain "https://github.com/zamancodexpress/thaqva-masjid/blob/main/translator.js"
  click LangState "https://github.com/zamancodexpress/thaqva-masjid/blob/main/translator.js"
  click StaticDOMT "https://github.com/zamancodexpress/thaqva-masjid/blob/main/translator.js"
  click DynObserver "https://github.com/zamancodexpress/thaqva-masjid/blob/main/translator.js"
  click LangUI "https://github.com/zamancodexpress/thaqva-masjid/blob/main/translator.js"

  click SPA "https://github.com/zamancodexpress/thaqva-masjid/blob/main/index.html"
  click DOM1 "https://github.com/zamancodexpress/thaqva-masjid/blob/main/index.html"
  click DOM2 "https://github.com/zamancodexpress/thaqva-masjid/blob/main/index.html"

  click Readme "https://github.com/zamancodexpress/thaqva-masjid/blob/main/README.md"

  %% =========================================================
  %% Styles (Color is required)
  %% =========================================================
  classDef actor fill:#111827,stroke:#0b1220,color:#ffffff,stroke-width:1px
  classDef container fill:#1d4ed8,stroke:#1e3a8a,color:#ffffff,stroke-width:1px
  classDef module fill:#2563eb,stroke:#1e40af,color:#ffffff,stroke-width:1px
  classDef component fill:#60a5fa,stroke:#1e3a8a,color:#0b1220,stroke-width:1px
  classDef ui fill:#0ea5e9,stroke:#075985,color:#ffffff,stroke-width:1px
  classDef css fill:#38bdf8,stroke:#075985,color:#0b1220,stroke-width:1px
  classDef platform fill:#9ca3af,stroke:#374151,color:#111827,stroke-width:1px
  classDef external fill:#f59e0b,stroke:#92400e,color:#111827,stroke-width:1px
  classDef library fill:#22c55e,stroke:#166534,color:#052e16,stroke-width:1px
  classDef doc fill:#e5e7eb,stroke:#6b7280,color:#111827,stroke-width:1px
```
