# rizkyfaza20/api-laravel-test-sre architecture

> Architecture diagram of the GitHub repository rizkyfaza20/api-laravel-test-sre, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rizkyfaza20/api-laravel-test-sre
- Repository: https://github.com/rizkyfaza20/api-laravel-test-sre

## Overview

##### Main Components

a) Application Layer:
- Laravel CRUD Application (Frontend & Backend)
- Authentication System
- Post Management System
- Prometheus Metrics Integration

b) Infrastructure Layer:
- Kubernetes Cluster (Minikube)
- Database (MySQL)
- Monitoring Stack (Prometheus & Grafana)
- ArgoCD for GitOps deployment

##### Client Layer (Top)
- Web Browser/Client Applications
- Ingress Controller

##### Application Layer (Middle)
- Laravel Application Pods
- HPA (Horizontal Pod Autoscaler)
- Health Check endpoints

##### Data Layer (Bottom)
- MySQL Database
- Persistent Storage

##### Monitoring Layer (Side)
- Prometheus Server
- Grafana Dashboard
- Metrics Flow

##### Deployment Layer (Side)
- ArgoCD
- Helm Charts
- GitHub Actions

##### Specific Elements

Use these visual elements:
- Rectangles: For main components (Laravel App, Database, Monitoring tools)
- Hexagons: For Kubernetes components (Pods, Services)

- Blue: Application components
- Green: Database components
- Orange: Monitoring components
- Purple: CI/CD components
- Gray: Infrastructure components

##### Component Relationships

Key interactions:
**Client → Ingress → Laravel Pods ↔ MySQL**
**Laravel Pods → Prometheus (metrics)**
**Prometheus → Grafana (visualization)**
**GitHub → ArgoCD → Kubernetes Resources**

##### Additional Details

Annotations for:
- Port numbers (8000 for Laravel, 3306 for MySQL)
- Health check endpoints
- HPA scaling parameters
- Volume mounts for persistence
- Prometheus metrics endpoint
- ArgoCD application configurations

##### Infrastructure Specifics

Highlight:
- Kubernetes Services
- ConfigMaps/Secrets for environment variables
- Persistent Volume Claims
- Resource limits and requests
- Health check configurations

##### Deployment Flow

GitOps workflow:
**GitHub Repository → GitHub Actions → Docker Hub**
**ArgoCD → Helm Charts → Kubernetes Resources**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
        Ingress["Ingress Controller"]:::k8s
    end

    subgraph "Application Layer"
        Laravel["Laravel CRUD App"]:::app
        click Laravel "https://github.com/rizkyfaza20/api-laravel-test-sre/tree/main/api-laravel-crud/"
        
        AuthSystem["Authentication System"]:::app
        click AuthSystem "https://github.com/rizkyfaza20/api-laravel-test-sre/tree/main/api-laravel-crud/app/Http/Controllers/Auth/"
        
        PostSystem["Post Management"]:::app
        click PostSystem "https://github.com/rizkyfaza20/api-laravel-test-sre/blob/main/api-laravel-crud/app/Http/Controllers/PostController.php"
        
        PrometheusInt["Prometheus Integration"]:::monitoring
        click PrometheusInt "https://github.com/rizkyfaza20/api-laravel-test-sre/blob/main/api-laravel-crud/app/Services/PrometheusService.php"
        
        HPA["HPA"]:::k8s
    end

    subgraph "Data Layer"
        MySQL[(MySQL DB)]:::db
        PVC["Persistent Volume"]:::storage
        click MySQL "https://github.com/rizkyfaza20/api-laravel-test-sre/blob/main/api-laravel-crud/config/database.php"
    end

    subgraph "Monitoring Stack"
        Prometheus["Prometheus Server"]:::monitoring
        Grafana["Grafana Dashboard"]:::monitoring
    end

    subgraph "Deployment Pipeline"
        GitHub["GitHub Repository"]:::cicd
        GHActions["GitHub Actions"]:::cicd
        click GHActions "https://github.com/rizkyfaza20/api-laravel-test-sre/blob/main/.github/workflows/docker-image.yml"
        
        ArgoCD["ArgoCD"]:::cicd
        click ArgoCD "https://github.com/rizkyfaza20/api-laravel-test-sre/blob/main/argocd/application-argocd.yaml"
        
        HelmCharts["Helm Charts"]:::cicd
        click HelmCharts "https://github.com/rizkyfaza20/api-laravel-test-sre/tree/main/argocd/laravel-minikube/"
        
        DockerHub["Docker Hub"]:::cicd
    end

    %% Relationships
    Browser --> Ingress
    Ingress --> Laravel
    Laravel --> AuthSystem
    Laravel --> PostSystem
    Laravel --> PrometheusInt
    Laravel <--> MySQL
    MySQL --- PVC
    HPA --> Laravel
    
    PrometheusInt -.-> Prometheus
    Prometheus -.-> Grafana
    
    GitHub --> GHActions
    GHActions --> DockerHub
    GitHub --> ArgoCD
    ArgoCD --> HelmCharts
    HelmCharts --> Laravel

    %% Styles
    classDef app fill:#3498db,stroke:#2980b9,color:white
    classDef db fill:#27ae60,stroke:#219a52,color:white
    classDef monitoring fill:#e67e22,stroke:#d35400,color:white
    classDef cicd fill:#9b59b6,stroke:#8e44ad,color:white
    classDef k8s fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef storage fill:#34495e,stroke:#2c3e50,color:white

    %% Legend
    subgraph Legend
        L1["Application Component"]:::app
        L2["Database Component"]:::db
        L3["Monitoring Component"]:::monitoring
        L4["CI/CD Component"]:::cicd
        L5["Kubernetes Component"]:::k8s
        L6["Storage Component"]:::storage
    end
```
