# divfadli/goravel architecture

> Architecture diagram of the GitHub repository divfadli/goravel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/divfadli/goravel
- Repository: https://github.com/divfadli/goravel

## Overview

##### Main Components Identification

The system is a full-stack web application built with the Goravel framework (a Go framework inspired by Laravel). The main components should be organized as follows:

A. Application Layer
- HTTP Server (app/http)
- gRPC Server (app/grpc)
- Console Applications (app/console)

B. Core Components
- Models Layer (app/models)
- Controllers Layer (app/http/controllers)
- Middleware Layer (app/http/middleware)
- Request Validation Layer (app/http/requests)

C. Infrastructure Layer
- Database (PostgreSQL/MySQL based on migrations)
- File Storage System (storage/app)
- Cache System
- Queue System

**┌─────────────────────────────────────────────────────────┐**
- Client Layer                         │
- (Web Browsers / API Clients / gRPC Clients)           │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Entry Points                         │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- HTTP Route │  │ gRPC Server │  │   Console   │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Middleware Layer                      │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- CORS     │  │     JWT     │  │   Others    │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Application Layer                      │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- Controllers │  │  Requests   │  │  Services   │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Domain Layer                         │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- Models    │  │  Providers  │  │   Events    │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Infrastructure Layer                     │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────┐     │
- Database   │  │    Cache    │  │   Storage   │     │
- ┘  └─────────────┘  └─────────────┘     │
- ┘

##### Important Relationships to Highlight

- Request flow from client through middleware to controllers
- Data flow between controllers and models
- Demonstrate file storage operations for reports and photos
- Authentication/authorization flow
- Event handling and queue processing paths

##### Additional Notes

- Database schema relationships
- Integration points with external services
- Document the caching strategy

This system design should effectively communicate the architecture while maintaining clarity and providing sufficient detail for implementation guidance.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph CL[Client Layer]
        WB[Web Browsers]
        AC[API Clients]
        GC[gRPC Clients]
    end

    %% Entry Points Layer
    subgraph EP[Entry Points]
        HR["HTTP Routes"]:::routes
        GS["gRPC Server"]:::grpc
        CS["Console Apps"]:::console
    end

    %% Middleware Layer
    subgraph ML[Middleware Layer]
        MW["JWT Auth"]:::security
        CORS["CORS"]:::security
        Other["Other Middleware"]:::security
    end

    %% Application Layer
    subgraph AL[Application Layer]
        CTRL["Controllers"]:::controller
        REQ["Request Validation"]:::request
        SEC["Security Controller"]:::security
        SAF["Safety Controller"]:::security
        RPT["Report Generator"]:::controller
    end

    %% Domain Layer
    subgraph DL[Domain Layer]
        MOD["Models"]:::model
        PROV["Service Providers"]:::provider
        EVT["Events"]:::event
    end

    %% Infrastructure Layer
    subgraph IL[Infrastructure Layer]
        DB[(Database)]:::db
        CACHE[(Cache)]:::cache
        STORE["File Storage"]:::storage
        VIEWS["Views/Templates"]:::view
        CFG["Configuration"]:::config
    end

    %% Relationships
    WB & AC --> HR
    GC --> GS
    HR & GS --> MW
    MW --> CTRL
    CTRL --> REQ
    CTRL --> SEC
    CTRL --> SAF
    CTRL --> RPT
    CTRL --> MOD
    MOD --> DB
    RPT --> VIEWS
    RPT --> STORE
    PROV --> CACHE
    CS --> CTRL

    %% Styles
    classDef routes fill:#2196F3,stroke:#1565C0,color:white
    classDef grpc fill:#00BCD4,stroke:#00838F,color:white
    classDef console fill:#607D8B,stroke:#455A64,color:white
    classDef security fill:#F44336,stroke:#C62828,color:white
    classDef controller fill:#4CAF50,stroke:#2E7D32,color:white
    classDef model fill:#FFC107,stroke:#FFA000,color:black
    classDef provider fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef event fill:#FF9800,stroke:#F57C00,color:white
    classDef db fill:#795548,stroke:#4E342E,color:white
    classDef cache fill:#9E9E9E,stroke:#616161,color:white
    classDef storage fill:#3F51B5,stroke:#283593,color:white
    classDef view fill:#009688,stroke:#00695C,color:white
    classDef config fill:#673AB7,stroke:#4527A0,color:white
    classDef request fill:#8BC34A,stroke:#558B2F,color:white

    %% Click Events
    click HR "https://github.com/divfadli/goravel/blob/main/routes/web.go"
    click CTRL "https://github.com/divfadli/goravel/tree/main/app/http/controllers/"
    click MOD "https://github.com/divfadli/goravel/tree/main/app/models/"
    click MW "https://github.com/divfadli/goravel/blob/main/app/http/middleware/jwt.go"
    click REQ "https://github.com/divfadli/goravel/tree/main/app/http/requests/"
    click STORE "https://github.com/divfadli/goravel/tree/main/storage/app/"
    click DB "https://github.com/divfadli/goravel/tree/main/database/migrations/"
    click VIEWS "https://github.com/divfadli/goravel/tree/main/resources/views/"
    click RPT "https://github.com/divfadli/goravel/tree/main/app/http/controllers/generator/"
    click GS "https://github.com/divfadli/goravel/tree/main/app/grpc/"
    click CS "https://github.com/divfadli/goravel/tree/main/app/console/"
    click PROV "https://github.com/divfadli/goravel/tree/main/app/providers/"
    click CFG "https://github.com/divfadli/goravel/tree/main/config/"
    click SEC "https://github.com/divfadli/goravel/blob/main/app/http/controllers/kejadian_keamanan_controller.go"
    click SAF "https://github.com/divfadli/goravel/blob/main/app/http/controllers/kejadian_keselamatan_controller.go"
```
