# khairu-aqsara/sholat-mini-project architecture

> Architecture diagram of the GitHub repository khairu-aqsara/sholat-mini-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khairu-aqsara/sholat-mini-project
- Repository: https://github.com/khairu-aqsara/sholat-mini-project

## Overview

##### Main Components

a) Core System Components:
- Web Application Layer (Public Interface)
- Controller Layer
- Service Layer
- Data Access Layer
- External Integration Layer

b) Supporting Components:
- Error Handling System
- Scheduled Tasks System
- Audio Management System

##### Data Flow Representation

**1. User Request Flow:**
- Browser -> Router -> Controller -> Service -> Model -> Database

**2. Prayer Time Sync Flow:**
- Scheduler -> ConcurrentRequestHandler -> esolat.gov.my API ->
- SongJsonFetcher -> Database

**3. Voice-over Playback Flow:**
- Scheduler -> BoxService -> SongService -> Audio System

##### Special Components

Create dedicated sections for:
a) Error Handling System:
- ExceptionLogger to all layers
- Email notification flow

b) Scheduled Tasks:
- Sync.php scheduler
- To ConcurrentRequestHandler
- SeederExecutor for data population

##### Database Relationships

A simplified version of the ERD showing:
- Subscribers
- Zones
- PrayingName
- Songs
- SubscriberBoxes

##### Technical Details

Annotations for:
- PHP 8.2 requirement
- Database connection details
- External API endpoints
- Audio playback requirements

##### Important Notes

Callouts for:
- Chrome autoplay policy considerations
- 7-day sync schedule
- Error notification system
- Database configuration requirements

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WI["Web Interface"]:::frontend
        Router["Router"]:::frontend
        View["View Template"]:::frontend
    end

    subgraph Controllers
        BC["Base Controller"]:::controller
        HC["Home Controller"]:::controller
    end

    subgraph Services
        BS["Box Service"]:::service
        PS["Prayer Service"]:::service
        SS["Subscriber Service"]:::service
        ZS["Zone Service"]:::service
        AS["Audio Service"]:::service
    end

    subgraph Models
        DB[(Database)]:::database
        BM["Box Model"]:::model
        PM["Prayer Model"]:::model
        SM["Subscriber Model"]:::model
        ZM["Zone Model"]:::model
        SongM["Song Model"]:::model
        SBM["Subscriber-Box Model"]:::model
        SWBM["Subscriber With Boxes"]:::model
        PTD["Prayer Time Data"]:::model
    end

    subgraph ErrorHandling
        EL["Exception Logger"]:::error
        DBE["Database Exception"]:::error
    end

    subgraph ScheduledTasks
        Sync["Prayer Time Sync"]:::scheduler
        CRH["Concurrent Request Handler"]:::scheduler
        SE["Seeder Executor"]:::scheduler
        Seeder["Seeder"]:::scheduler
    end

    subgraph ExternalSystems
        ESAPI["esolat.gov.my API"]:::external
        SJF["Song JSON Fetcher"]:::external
        AudioSys["Audio System"]:::external
    end

    %% Frontend Connections
    WI --> Router
    Router --> BC
    BC --> HC
    HC --> View

    %% Controller to Service Connections
    HC --> BS
    HC --> PS
    HC --> SS
    HC --> ZS
    HC --> AS

    %% Service to Model Connections
    BS --> BM
    PS --> PM
    SS --> SM
    ZS --> ZM
    AS --> SongM

    %% Model to Database Connections
    BM --> DB
    PM --> DB
    SM --> DB
    ZM --> DB
    SongM --> DB
    SBM --> DB
    SWBM --> DB
    PTD --> DB

    %% Error Handling Connections
    EL -.-> Controllers
    EL -.-> Services
    EL -.-> Models
    DBE -.-> DB

    %% Scheduled Tasks Connections
    Sync --> CRH
    CRH --> ESAPI
    SE --> Seeder
    Seeder --> DB

    %% External System Connections
    ESAPI --> SJF
    SJF --> DB
    AS --> AudioSys

    %% Click Events
    click WI "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/public/index.php"
    click Router "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Routes/Router.php"
    click View "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Views/index.php"
    click BC "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Controller.php"
    click HC "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Controllers/HomeController.php"
    click BS "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Services/BoxService.php"
    click PS "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Services/PrayingNameService.php"
    click SS "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Services/SubscriberService.php"
    click ZS "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Services/ZoneService.php"
    click AS "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Services/SongService.php"
    click BM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/Box.php"
    click PM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/PrayingName.php"
    click SM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/Subscriber.php"
    click ZM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/Zone.php"
    click SongM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/Song.php"
    click SBM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/SubscriberBox.php"
    click SWBM "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/SubscriberWithBoxes.php"
    click PTD "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/PrayingTimeData.php"
    click DB "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Models/Database.php"
    click EL "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Exceptions/ExceptionLogger.php"
    click DBE "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Exceptions/DatabaseException.php"
    click Sync "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/sync.php"
    click CRH "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Actions/ConcurrentRequestHandler.php"
    click Seeder "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Actions/Seeder.php"
    click SE "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Actions/SeederExecutor.php"
    click SJF "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/src/Actions/SongJsonFetcher.php"
    click AudioSys "https://github.com/khairu-aqsara/sholat-mini-project/blob/main/public/voice.mp3"

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef controller fill:#90EE90
    classDef service fill:#98FB98
    classDef model fill:#FFE4B5
    classDef database fill:#DEB887
    classDef error fill:#FFB6C1
    classDef scheduler fill:#FFA07A
    classDef external fill:#F08080
```
