# ahmadghani27/galleryfoto architecture

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

- Interactive diagram: https://gitdiagram.com/ahmadghani27/galleryfoto
- Repository: https://github.com/ahmadghani27/galleryfoto

## Overview

##### Identifikasi Tipe & Tujuan Proyek
- Proyek ini adalah *full-stack web application* monolitik berbasis Laravel (MVC) dengan frontend Blade + Tailwind CSS, backend Laravel + Laravel Breeze untuk Auth, dan MySQL sebagai database.
- Fungsinya untuk CRUD foto & folder, upload massal, operasi massal, favorit, arsip dengan kata sandi, serta manajemen pengguna.

##### Analisis Struktur File
- Top-level:
- **app/** – kode inti (Models, Controllers, Middleware, View Components)
- **config/** – konfigurasi aplikasi (DB, Mail, Queue, dsb.)
- **database/** – migrations, factories, seeders
- **public/** – entry-point index.php, asset (CSS/JS build output)
- **resources/** – Blade views, CSS/JS sumber, komponen UI
- **routes/** – definisi route (web.php, auth.php)
- **storage/** – penyimpanan file upload & cache/sessions
- **tests/** – automated tests (Feature & Unit)
- **artisan**, **composer.json**, **vite.config.js**, dsb.

##### Insight dari README
- Penggunaan Laravel Breeze (Auth), Tailwind CSS, Vite untuk build frontend.
- Database MySQL ‘galeri’ (tabel users, folders, photos, archives).
- Relasi: User→Photos (1-M), Folder→Photos (1-M), Photo→Archive (1-1).
- Fitur utama: upload massal, hapus massal, favorit, pencarian, arsip.

a. **Client/Browser**
- Mengakses tampilan via HTTPS, mengirim form request (upload, CRUD, auth).
b. **Web Server / Application Server**
- Nginx/Apache → `public/index.php` → Laravel HTTP Kernel → Middleware → Controller
c. **MVC Layers**
- **Controllers** (AccountController, PhotoController, dst.)
- **Models** (User, Photo, Folder, Archive)
- **Views** (Blade templates di resources/views)
d. **Database**
- MySQL (tabel users, folders, photos, archives)
e. **File Storage**
- `storage/app/public` untuk foto, `storage/app/private` untuk file arsip jika perlu
f. **Cache/Session**
- File/session cache di `storage/framework`
g. **External Services**
- SMTP/Email (EmailVerificationNotificationController)
- Optional: Queue Worker jika queue dipakai

##### Interaksi & Alur Data
- Client → (HTTPS) → Web Server → Laravel Router → Controller
- Controller ↔ Model → Query ke MySQL
- Controller ↔ FileSystem (upload/download foto)
- Controller → View → HTML/CSS/JS dikembalikan ke Client
- Auth flow: laravel-breeze middleware → RegisteredUserController → Session

##### Pola Arsitektur & Prinsip
- MVC monolith
- Separation of Concerns: Auth, Photo Management, Folder Management
- RESTful Controllers untuk CRUD
- Blade Components untuk reusable UI
- Configuration via `.env` & config/*.php
- Testing: PHPUnit/Pest

- **Panah Berarah** menunjukkan alur request dan data flow (misalnya: Browser → Controller, Controller → Database).
- Kotak biru untuk Application Server
- Silinder hijau untuk Database
- **Keterangan Singkat** di dekat panah jika perlu (e.g., “POST /photos”, “SELECT * FROM photos WHERE …”).

[Browser]
↓ HTTPS
[Nginx/Apache]
↓
[Laravel App (index.php → Kernel)]
├─ [Middleware (Auth)]
├─ [Controllers] → [Models] → [MySQL DB]
├─ [Controllers] → [Storage (File System)]
└─ [Views (Blade) + Tailwind/Vite JS]
↓
[Response HTML/CSS/JS]
↓
[Browser]

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Client/Browser"]:::browser
    click Browser "https://github.com/ahmadghani27/galleryfoto/tree/main/resources/views/"

    %% Server Layer Entry
    Browser -->|"HTTPS Request"| WebServer["Nginx/Apache"]:::server
    WebServer --> AppEntry["public/index.php"]:::server
    click AppEntry "https://github.com/ahmadghani27/galleryfoto/blob/main/public/index.php"
    AppEntry --> Bootstrap["bootstrap/app.php"]:::server
    click Bootstrap "https://github.com/ahmadghani27/galleryfoto/blob/main/bootstrap/app.php"
    Bootstrap --> HTTPKernel["HTTP Kernel"]:::server

    %% Routing & Middleware
    HTTPKernel --> RoutesSubgraph
    subgraph "Routing Layer"
        direction TB
        WebRoutes["routes/web.php"]:::server
        click WebRoutes "https://github.com/ahmadghani27/galleryfoto/blob/main/routes/web.php"
        AuthRoutes["routes/auth.php"]:::server
        click AuthRoutes "https://github.com/ahmadghani27/galleryfoto/blob/main/routes/auth.php"
    end
    RoutesSubgraph --> Middleware["AdminOnly Middleware"]:::server
    click Middleware "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Middleware/AdminOnly.php"
    Middleware --> ControllersSubgraph

    %% Controllers & Requests
    subgraph "Controllers Layer"
        direction TB
        BaseController["Controller (Base)"]:::server
        click BaseController "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/Controller.php"
        subgraph "Auth & User Controllers"
            direction TB
            RegUserCtrl["RegisteredUserController"]:::server
            click RegUserCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/Auth/RegisteredUserController.php"
            AuthSessionCtrl["AuthenticatedSessionController"]:::server
            click AuthSessionCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/Auth/AuthenticatedSessionController.php"
            EmailNotifCtrl["EmailVerificationNotificationController"]:::server
            click EmailNotifCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/Auth/EmailVerificationNotificationController.php"
            ProfileCtrl["ProfileController"]:::server
            click ProfileCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/ProfileController.php"
        end
        subgraph "Photo & Folder Controllers"
            direction TB
            PhotoCtrl["PhotoController"]:::server
            click PhotoCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/PhotoController.php"
            FolderCtrl["FolderController"]:::server
            click FolderCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/FolderController.php"
            ArchiveCtrl["ArchiveController"]:::server
            click ArchiveCtrl "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Http/Controllers/ArchiveController.php"
        end
        subgraph "HTTP Request Validations"
            direction TB
            Requests["app/Http/Requests/"]:::server
            click Requests "https://github.com/ahmadghani27/galleryfoto/tree/main/app/Http/Requests/"
        end
    end
    ControllersSubgraph --> BaseController
    BaseController --> RegUserCtrl
    BaseController --> AuthSessionCtrl
    BaseController --> EmailNotifCtrl
    BaseController --> ProfileCtrl
    BaseController --> PhotoCtrl
    BaseController --> FolderCtrl
    BaseController --> ArchiveCtrl
    ControllersSubgraph --> Requests

    %% Models Layer
    ControllersSubgraph --> ModelsSubgraph
    subgraph "Models Layer"
        direction TB
        UserModel["User Model"]:::server
        click UserModel "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Models/User.php"
        PhotoModel["Photo Model"]:::server
        click PhotoModel "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Models/Photo.php"
        FolderModel["Folder Model"]:::server
        click FolderModel "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Models/Folder.php"
        AccountModel["Account Model"]:::server
        click AccountModel "https://github.com/ahmadghani27/galleryfoto/blob/main/app/Models/Account.php"
    end

    %% Persistence Layer
    ModelsSubgraph --> DB["MySQL Database"]:::db
    FileStorage["File Storage"]:::storage
    click FileStorage "https://github.com/ahmadghani27/galleryfoto/tree/main/storage/app/public/"
    click FileStorage "https://github.com/ahmadghani27/galleryfoto/tree/main/storage/app/private/"
    ControllersSubgraph --> FileStorage
    CacheSession["Cache & Session"]:::storage
    click CacheSession "https://github.com/ahmadghani27/galleryfoto/tree/main/storage/framework/cache/"
    click CacheSession "https://github.com/ahmadghani27/galleryfoto/tree/main/storage/framework/sessions/"
    ControllersSubgraph --> CacheSession

    %% Views Layer
    ControllersSubgraph --> ViewsSubgraph
    subgraph "Views & Assets"
        direction TB
        BladeViews["Blade Views"]:::server
        click BladeViews "https://github.com/ahmadghani27/galleryfoto/tree/main/resources/views/"
        ViewComponents["Blade Components"]:::server
        click ViewComponents "https://github.com/ahmadghani27/galleryfoto/tree/main/app/View/Components/"
        CSSJS["Frontend Assets (CSS/JS)"]:::server
        click CSSJS "https://github.com/ahmadghani27/galleryfoto/blob/main/resources/css/app.css"
        click CSSJS "https://github.com/ahmadghani27/galleryfoto/blob/main/resources/js/app.js"
    end

    %% External Services
    ControllersSubgraph --> SMTP["SMTP Email Service"]:::external
    click SMTP "https://github.com/ahmadghani27/galleryfoto/blob/main/config/mail.php"
    ControllersSubgraph --> Queue["Queue Worker"]:::external
    click Queue "https://github.com/ahmadghani27/galleryfoto/blob/main/config/queue.php"

    %% Response to Client
    ViewsSubgraph -->|"HTML/CSS/JS Response"| Browser

    classDef browser fill:#D5E8D4,stroke:#82B366;
    classDef server fill:#DAE8FC,stroke:#6C8EBF;
    classDef db fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef storage fill:#F8CECC,stroke:#B85450;
    classDef external fill:#FFE6CC,stroke:#D69F00;
```
