# sebastiandeppisch/heinerenergie-sammelbestellung architecture

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

- Interactive diagram: https://gitdiagram.com/sebastiandeppisch/heinerenergie-sammelbestellung
- Repository: https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung

## Overview

##### Main Components
- Backend (Laravel):
- Controllers: Found under app/Http/Controllers (e.g., AdviceController, OrderController, etc.) which handle HTTP requests.
- Models: Under app/Models (Advice, Order, BulkOrder, Product, etc.) which represent your domain objects and interact with the database.
- Business Logic: Services like app/Actions (FetchCoordinateByAddress, FetchCoordinateByFreeText); jobs, listeners, and events (e.g., SendNewAdviceInfoToAdvisors, AfterAdviceIsCreated) implement domain logic and asynchronous tasks.
- Middleware and Requests: Under app/Http/Middleware and app/Http/Requests, which validate and secure requests.
- Console Commands: Located in app/Console/Commands, for tasks such as data import and installation routines.
- Database: Migrations, factories, and seeders that define and populate your database schema.
- Configuration & Service Providers: Under config/ and app/Providers, setting up services, authentication, broadcasting, etc.

- Frontend:
- Vue Components: Under resources/js/components and views (e.g., OrderForm.vue, Advices.vue, etc.) that build the user interface.
- Assets and Styles: CSS/SCSS files located in resources/css, resources/sass and public/css.
- JavaScript Setup: Vue router (resources/js/router.ts), store (resources/js/store.ts), and typescript definitions, which coordinate the client-side architecture.

- Infrastructure & Deployment:
- Build Tools: Vite (vite.config.js) and package management (package.json, package-lock.json).
- Environment Configuration: .env.example and config files for database, mail, etc.
- Version control and CI: GitHub workflows in .github/workflows and other CI configurations.
- Testing: Unit and feature tests under tests/ directory.

##### Relationships and Data Flow
- A web client (browser) loads the frontend Vue components and possibly Single Page Application (SPA) views.
- User requests are routed via Laravel’s routing files (routes/web.php, routes/api.php) to the appropriate controllers.
- Controllers receive input, validate it (using app/Http/Requests), and then invoke business logic. This might include calling Actions under app/Actions or dispatching Jobs (asynchronous tasks) or firing Events.
- The Models interact with the database (configured via migrations and defined in app/Models). The database represents the persistent state.
- Additional flows may include the sending of emails (app/Mail) and notifications (app/Notifications) triggered by events.

##### Architectural Patterns
- MVC Pattern: The project clearly follows Model-View-Controller architecture – the controllers and HTTP middleware manage the application’s input/output, while models encapsulate domain data.
- Event-Driven Design: Usage of events and listeners (found in app/Events and app/Listeners) shows asynchronous handling of tasks like sending notifications or recalculating coordinates.
- Separation of Concerns: Distinct directories separate the concerns of business logic, presentation (Vue, blade templates), infrastructure, and configuration.

##### Incorporate Technologies and Libraries
- Laravel Framework (Backend)
- Vue.js (Frontend) plus supporting libraries (e.g., router, state management)
- Vite as the build tool for frontend assets
- Database using Laravel migrations and Eloquent ORM
- Automated testing with PHPUnit and Pest
- GitHub Actions for continuous integration/deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer (Frontend)"
        direction TB
        FE1("Browser/Client"):::frontend
        FE2("Vue Components"):::frontend
        FE3("Vue Views"):::frontend
        FE4("Assets & Styles"):::frontend
        FE5("JS Setup"):::frontend
    end

    %% Application Layer (Backend)
    subgraph "Application Layer (Backend)"
        direction TB
        subgraph "HTTP Layer"
            direction TB
            HW1("Middleware & Requests"):::backend
            HW2("Controllers"):::backend
        end

        subgraph "Business Logic"
            direction TB
            BL1("Actions"):::backend
            BL2("Async Tasks"):::backend
            BL3("Console Commands"):::backend
        end

        subgraph "Domain Models"
            direction TB
            DM1("Models"):::backend
        end

        subgraph "Configuration & Providers"
            direction TB
            CP1("Config Files"):::backend
            CP2("Service Providers"):::backend
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        D1("Database (Migrations & Seeders)"):::database
    end

    %% Infrastructure & Deployment
    subgraph "Infrastructure & Deployment"
        direction TB
        ID1("Build Tools"):::infra
        ID2("Environment Config"):::infra
        ID3("CI/CD"):::infra
        ID4("Testing"):::infra
    end

    %% Connections between layers
    FE1 -->|"loads"| FE2
    FE2 -->|"renders UI"| FE3
    FE5 -->|"configures frontend"| FE2

    FE2 -->|"APIcalls"| HW2
    HW1 -->|"processes"| HW2
    HW2 -->|"invokes"| BL1
    HW2 -->|"triggers"| BL2
    BL1 -->|"calls"| DM1
    BL2 -->|"activates"| DM1
    DM1 -->|"CRUD"| D1

    ID1 -->|"buildsassets"| FE2
    ID2 -->|"suppliesEnv"| HW2
    ID3 -->|"deploys"| ID1
    BL3 -->|"maintenance"| D1

    CP1 -->|"configures"| HW2
    CP2 -->|"registers"| BL2

    %% Backend Detailed Components

    %% Controllers
    adviceController("AdviceController"):::backend
    orderController("OrderController"):::backend
    HW2 --> adviceController
    HW2 --> orderController

    %% Middleware & Request Validation
    authMiddleware("Authenticate"):::backend
    csrfMiddleware("VerifyCsrfToken"):::backend
    storeOrder("StoreOrderRequest"):::backend
    HW1 --> authMiddleware
    HW1 --> csrfMiddleware
    HW1 --> storeOrder

    %% Actions (Business Logic)
    actionAddress("FetchCoordinateByAddress"):::backend
    actionFreeText("FetchCoordinateByFreeText"):::backend
    BL1 --> actionAddress
    BL1 --> actionFreeText

    %% Asynchronous Tasks (Jobs & Events)
    jobCalc("CalculateCoordinatesForAdvice"):::backend
    jobSendAdvice("SendNewAdviceInfoToAdvisors"):::backend
    eventAdvice("AdviceCreated"):::backend
    eventOrder("OrderCreated"):::backend
    BL2 --> jobCalc
    BL2 --> jobSendAdvice
    BL2 --> eventAdvice
    BL2 --> eventOrder

    %% Console Commands
    cmdInstall("Install"):::backend
    cmdAdvicesImport("AdvicesImport"):::backend
    BL3 --> cmdInstall
    BL3 --> cmdAdvicesImport

    %% Models
    modelAdvice("Advice"):::backend
    modelOrder("Order"):::backend
    modelBulkOrder("BulkOrder"):::backend
    DM1 --> modelAdvice
    DM1 --> modelOrder
    DM1 --> modelBulkOrder

    %% Configuration & Providers Details
    providerApp("AppServiceProvider"):::backend
    providerEvent("EventServiceProvider"):::backend
    CP2 --> providerApp
    CP2 --> providerEvent

    %% Frontend Components & Views
    vueOrderForm("OrderForm.vue"):::frontend
    vueAdviceMails("AdviceMails.vue"):::frontend
    FE2 --> vueOrderForm
    FE2 --> vueAdviceMails

    vueAdvice("Advice.vue"):::frontend
    vueOrders("Orders.vue"):::frontend
    FE3 --> vueAdvice
    FE3 --> vueOrders

    %% Frontend Assets & Styles mapping
    cssResource("resources/css/app.css"):::frontend
    cssPublic("public/css/app.css"):::frontend
    sassResource("resources/sass/app.scss"):::frontend
    FE4 --> cssResource
    FE4 --> cssPublic
    FE4 --> sassResource

    %% JavaScript Setup mapping
    vueRouter("resources/js/router.ts"):::frontend
    vueStore("resources/js/store.ts"):::frontend
    FE5 --> vueRouter
    FE5 --> vueStore

    %% Infrastructure & Deployment mapping
    buildVite("vite.config.js"):::infra
    buildPackage("package.json"):::infra
    buildLock("package-lock.json"):::infra
    ID1 --> buildVite
    ID1 --> buildPackage
    ID1 --> buildLock

    envConfig(".env.example"):::infra
    ID2 --> envConfig

    ciCd("laravel.yml"):::infra
    ID3 --> ciCd

    testing("tests/"):::infra
    ID4 --> testing

    %% Database mapping
    migrations("database/migrations"):::database
    seeders("DatabaseSeeder.php"):::database
    D1 --> migrations
    D1 --> seeders

    %% Click Events
    click adviceController "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Http/Controllers/AdviceController.php"
    click orderController "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Http/Controllers/OrderController.php"
    click modelAdvice "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Models/Advice.php"
    click modelOrder "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Models/Order.php"
    click modelBulkOrder "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Models/BulkOrder.php"
    click actionAddress "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Actions/FetchCoordinateByAddress.php"
    click actionFreeText "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Actions/FetchCoordinateByFreeText.php"
    click jobCalc "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Jobs/CalculateCoordinatesForAdvice.php"
    click jobSendAdvice "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Jobs/SendNewAdviceInfoToAdvisors.php"
    click eventAdvice "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Events/AdviceCreated.php"
    click eventOrder "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Events/OrderCreated.php"
    click authMiddleware "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Http/Middleware/Authenticate.php"
    click csrfMiddleware "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Http/Middleware/VerifyCsrfToken.php"
    click storeOrder "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Http/Requests/StoreOrderRequest.php"
    click cmdInstall "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Console/Commands/Install.php"
    click cmdAdvicesImport "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Console/Commands/AdvicesImport.php"
    click migrations "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/tree/main/database/migrations"
    click seeders "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/database/seeders/DatabaseSeeder.php"
    click providerApp "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Providers/AppServiceProvider.php"
    click providerEvent "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/app/Providers/EventServiceProvider.php"
    click vueOrderForm "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/js/components/OrderForm.vue"
    click vueAdviceMails "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/js/components/AdviceMails.vue"
    click vueAdvice "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/js/views/Advice.vue"
    click vueOrders "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/js/views/Orders.vue"
    click cssResource "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/css/app.css"
    click cssPublic "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/public/css/app.css"
    click sassResource "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/sass/app.scss"
    click vueRouter "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/js/router.ts"
    click vueStore "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/resources/js/store.ts"
    click buildVite "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/vite.config.js"
    click buildPackage "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/package.json"
    click buildLock "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/package-lock.json"
    click envConfig "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/.env.example"
    click ciCd "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/blob/main/.github/workflows/laravel.yml"
    click testing "https://github.com/sebastiandeppisch/heinerenergie-sammelbestellung/tree/main/tests/"

classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
classDef backend fill:#90EE90,stroke:#000,stroke-width:1px;
classDef database fill:#FFFFE0,stroke:#000,stroke-width:1px;
classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
