# shluf/asmr architecture

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

- Interactive diagram: https://gitdiagram.com/shluf/asmr
- Repository: https://github.com/shluf/asmr

## Overview

##### Project type and purpose
- This is a full-stack, monolithic Laravel application that uses Inertia.js with React (JSX files under resources/js) to deliver a Single-Page Application (SPA) in the browser.
- Purpose: “Aplikasi Surat Menyurat RT/RW” – an online letter-submission platform for residents (“warga”) and local administrators (RT/RW) to submit, approve, track, and archive official letters and to broadcast local work programs.

##### File structure
- Top-level:
- app/ contains the MVC backend (Controllers, Models, Middleware, Services, Observers)
- resources/js and resources/css hold the React SPA assets and styling (Vite + Tailwind)
- routes/ defines HTTP entry points (web.php, auth.php)
- database/ migrations & seeders for MySQL schema
- public/ index.php and compiled assets served to clients
- Architectural patterns:
- MVC (app/Models, app/Http/Controllers)
- Service layer (app/Services/SuratService.php)
- Observer pattern (app/Observers) for model event hooks
- Inertia.js bridges backend controllers to React pages
- Configuration & deployment:
- .env, config/*.php for environment & services
- vite.config.js, tailwind.config.js, package.json for frontend build
- artisan, composer.json for PHP commands & dependencies

##### README insights
- Tech stack: PHP 8+, Laravel 10, MySQL, Node.js, Vite, Inertia.js, React, Tailwind CSS
- Functional modules: Authentication, Role-based approval workflow, PDF generation (SuratPDFController), Email notifications, Program kerja display, Dashboard per role.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Client Browser (SPA)"]:::front
        Vite["Vite Dev/Build Server"]:::front
        React["React Pages & Components"]:::front
        CSS["CSS Assets"]:::front
        PublicIndex["public/index.php"]:::front
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Router["HTTP Router"]:::backend
        Inertia["Inertia.js Adapter"]:::backend
        subgraph "Controllers"
            ControllersAll["Controllers (MVC)"]:::backend
            AuthControllers["Auth Controllers"]:::backend
            SuratController["SuratController"]:::backend
            PengajuanController["PengajuanController"]:::backend
            SuratPDFController["SuratPDFController"]:::backend
            NotificationController["NotificationController"]:::backend
            ProgramKerjaController["ProgramKerjaController"]:::backend
            DashboardController["DashboardController"]:::backend
        end
        Service["Service Layer (SuratService)"]:::backend
        subgraph "Models & Observers"
            Models["Models"]:::backend
            Observer["Model Observers"]:::backend
        end
        subgraph "Mail & Queue"
            Mail["Mail Classes"]:::backend
            MailConfig["Mail Config"]:::backend
            QueueConfig["Queue Config"]:::backend
        end
        PDFTemplates["PDF Templates"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        DB["MySQL Database"]:::datastore
        FileStorage["File Storage"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        SMTP["SMTP / Email Provider"]:::external
    end

    %% Connections
    Browser -->|HTTPS Request| Router
    Vite -->|Serves Assets / HMR| Browser
    Router -->|Handles Routes| ControllersAll
    Router -->|Handles Routes| AuthControllers
    Router -->|Handles Routes| SuratController
    Router -->|Handles Routes| PengajuanController
    Router -->|Handles Routes| SuratPDFController
    Router -->|Handles Routes| NotificationController
    Router -->|Handles Routes| ProgramKerjaController
    Router -->|Handles Routes| DashboardController
    Inertia -->|Bridges to React| ControllersAll
    ControllersAll -->|Calls| Service
    Service -->|Uses| Models
    Models -->|Persists| DB
    Models -->|Triggers| Observer
    Observer -->|Sends Notification| Mail
    Mail -->|Queues| QueueConfig
    SuratPDFController -->|Generates PDF| PDFTemplates
    SuratPDFController -->|Stores PDF| FileStorage
    NotificationController -->|Sends Email| SMTP
    ProgramKerjaController -->|Reads/Writes| DB

    %% Click Events - Frontend
    click Browser "https://github.com/shluf/asmr/tree/main/resources/js/"
    click CSS "https://github.com/shluf/asmr/blob/main/resources/css/app.css"
    click PublicIndex "https://github.com/shluf/asmr/blob/main/public/index.php"
    click Vite "https://github.com/shluf/asmr/blob/main/vite.config.js"
    click Vite "https://github.com/shluf/asmr/blob/main/package.json"
    click Vite "https://github.com/shluf/asmr/blob/main/postcss.config.js"
    click Vite "https://github.com/shluf/asmr/blob/main/tailwind.config.js"
    click React "https://github.com/shluf/asmr/tree/main/resources/js/Pages/"
    click React "https://github.com/shluf/asmr/tree/main/resources/js/Components/"
    click React "https://github.com/shluf/asmr/tree/main/resources/js/Layouts/"

    %% Click Events - Backend
    click Router "https://github.com/shluf/asmr/blob/main/routes/web.php"
    click Router "https://github.com/shluf/asmr/blob/main/routes/auth.php"
    click Inertia "https://github.com/shluf/asmr/blob/main/app/Http/Middleware/HandleInertiaRequests.php"
    click ControllersAll "https://github.com/shluf/asmr/tree/main/app/Http/Controllers/"
    click AuthControllers "https://github.com/shluf/asmr/tree/main/app/Http/Controllers/Auth/"
    click SuratController "https://github.com/shluf/asmr/blob/main/app/Http/Controllers/SuratController.php"
    click PengajuanController "https://github.com/shluf/asmr/blob/main/app/Http/Controllers/PengajuanController.php"
    click SuratPDFController "https://github.com/shluf/asmr/blob/main/app/Http/Controllers/SuratPDFController.php"
    click NotificationController "https://github.com/shluf/asmr/blob/main/app/Http/Controllers/NotificationController.php"
    click ProgramKerjaController "https://github.com/shluf/asmr/blob/main/app/Http/Controllers/ProgramKerjaController.php"
    click DashboardController "https://github.com/shluf/asmr/blob/main/app/Http/Controllers/DashboardController.php"
    click Service "https://github.com/shluf/asmr/blob/main/app/Services/SuratService.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/User.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/Warga.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/RT.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/RW.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/PengajuanSurat.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/ApprovalSurat.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/ProgramKerja.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/Notifikasi.php"
    click Models "https://github.com/shluf/asmr/blob/main/app/Models/TemplateSurat.php"
    click Observer "https://github.com/shluf/asmr/blob/main/app/Observers/ApprovalSuratObserver.php"
    click Mail "https://github.com/shluf/asmr/blob/main/app/Mail/UserApprovalStatusMail.php"
    click MailConfig "https://github.com/shluf/asmr/blob/main/config/mail.php"
    click QueueConfig "https://github.com/shluf/asmr/blob/main/config/queue.php"

    %% Click Events - Modules & Config
    click AuthControllers "https://github.com/shluf/asmr/blob/main/config/auth.php"
    click AuthControllers "https://github.com/shluf/asmr/blob/main/database/migrations/0001_*_create_users_table.php"
    click PDFTemplates "https://github.com/shluf/asmr/tree/main/resources/views/templates/"
    click ProgramKerjaController "https://github.com/shluf/asmr/blob/main/app/Models/ProgramKerja.php"
    click ProgramKerjaController "https://github.com/shluf/asmr/tree/main/database/migrations/"
    click ProgramKerjaController "https://github.com/shluf/asmr/blob/main/database/seeders/ProgramKerjaSeeder.php"
    click DB "https://github.com/shluf/asmr/tree/main/database/migrations/"
    click DB "https://github.com/shluf/asmr/tree/main/database/seeders/"
    click FileStorage "https://github.com/shluf/asmr/tree/main/storage/app/private/"
    click FileStorage "https://github.com/shluf/asmr/tree/main/public/"
    click .env "https://github.com/shluf/asmr/blob/main/.env.example"
    click MailConfig "https://github.com/shluf/asmr/blob/main/config/*.php"

    %% Styles
    classDef front fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef datastore fill:#FFD580,stroke:#000,stroke-width:1px;
    classDef external fill:#D8BFD8,stroke:#000,stroke-width:1px;
```
