# hubertfus/brewlogix architecture

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

- Interactive diagram: https://gitdiagram.com/hubertfus/brewlogix
- Repository: https://github.com/hubertfus/brewlogix

## Overview

##### Main Layers and Components
- Presentation Layer
- Blazor Razor Components (Components/Layout, Components/Pages)
- Static Assets (wwwroot: bootstrap CSS/JS)
- Application (Business) Layer
- Program.cs (app startup, DI container)
- Services (BatchService, ClientService, IngredientService, etc.)
- Validation Attributes (AtLeastOneIngredientAttribute, UniqueIngredientsAttribute)
- Data Access Layer
- EF Core AppDbContext (Services/AppDbContext)
- DbContextProvider & DBName (dbhelpers)
- Migrations (BrewLogix/Migrations) & Seeders (BrewLogix/Seeders)
- Database
- Relational DB (PostgreSQL via connection string in appsettings.json)
- External Frameworks & Libraries
- ASP.NET Core, Blazor, EF Core
- Bootstrap (wwwroot/lib/bootstrap)

##### Relationships and Data Flows
- User ↔ Browser (UI events over HTTP/SignalR for server-side Blazor)
- Browser → Razor Component (user clicks, form submissions)
- Razor Component → Service (injected via DI; calls CRUD methods)
- Service → AppDbContext (LINQ queries, SaveChanges)
- AppDbContext → Database (SQL commands applied)
- Startup Sequence → Migrations & Seeders (automated schema creation and test data)

##### Architectural Patterns
- Layered Architecture (Presentation → Business → Data → Database)
- Dependency Injection (all services & DbContext registered in Program.cs)
- Repository-like pattern via EF Core DbContext
- Model-View separation: Razor UI vs Models + Services

##### Technologies
- .NET 7+ / ASP.NET Core Host
- Blazor (Server-Side)
- Entity Framework Core (code-first migrations)
- PostgreSQL (or other RDBMS)
- Bootstrap for responsive UI
- appsettings.json for configuration

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Presentation Layer"
        RC["Blazor Razor Components"]:::frontend
        Layout["Layout Components"]:::frontend
        Pages["Page Components"]:::frontend
        Boot["Bootstrap CSS/JS"]:::frontend
        AppCSS["Custom CSS"]:::frontend
    end

    subgraph "Application Layer"
        PS["Program.cs\n(app startup, DI)"]:::service
        subgraph Services
            BS["BatchService"]:::service
            CS["ClientService"]:::service
            IS["IngredientService"]:::service
            KS["KegService"]:::service
            OS["OrderService"]:::service
            RS["RecipeService"]:::service
            SES["StockEntriesService"]:::service
            DI["DatabaseInitializer"]:::service
        end
        subgraph Validation
            V1["AtLeastOneIngredientAttribute"]:::service
            V2["UniqueIngredientsAttribute"]:::service
        end
    end

    subgraph "Data Access Layer"
        ADC["AppDbContext"]:::dataaccess
        DCP["DbContextProvider"]:::dataaccess
        DBN["DBName Enum"]:::dataaccess
        subgraph Migrations
            M1["20250415144029_InitialCreate"]:::dataaccess
            M2["20250415150502_InitialCreate"]:::dataaccess
            SNAP["AppDbContextModelSnapshot"]:::dataaccess
        end
        subgraph Seeders
            SBatch["BatchSeeder"]:::dataaccess
            SClient["ClientSeeder"]:::dataaccess
            SIng["IngredientSeeder"]:::dataaccess
            SKeg["KegSeeder"]:::dataaccess
            SOrder["OrderSeeder"]:::dataaccess
            SRecipe["RecipeSeeder"]:::dataaccess
            SRIng["RecipeIngredientSeeder"]:::dataaccess
            SStock["StockEntrySeeder"]:::dataaccess
        end
    end

    DB["Relational Database\n(PostgreSQL)"]:::db
    Config["appsettings.json\n(connection strings)"]:::config

    RC -->|"user actions"| BS
    PS -->|"registers DI"| BS
    PS -->|"registers DI"| ADC
    Config -->|"provides config"| PS
    PS -->|"runs migrations"| M1
    PS -->|"runs migrations"| M2
    PS -->|"runs seeders"| SBatch
    BS -->|"calls CRUD"| ADC
    ADC -->|"executes SQL"| DB

    click RC "https://github.com/hubertfus/brewlogix/tree/main/BrewLogix/Components"
    click Layout "https://github.com/hubertfus/brewlogix/tree/main/BrewLogix/Components/Layout"
    click Pages "https://github.com/hubertfus/brewlogix/tree/main/BrewLogix/Components/Pages"
    click Boot "https://github.com/hubertfus/brewlogix/tree/main/BrewLogix/wwwroot/lib/bootstrap"
    click AppCSS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/wwwroot/app.css"
    click PS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Program.cs"
    click BS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/BatchService.cs"
    click CS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/ClientService.cs"
    click IS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/IngredientService.cs"
    click KS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/KegService.cs"
    click OS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/OrderService.cs"
    click RS "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/RecipeService.cs"
    click SES "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/StockEntriesService.cs"
    click DI "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/DatabaseInitializer.cs"
    click ADC "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Services/AppDbContext.cs"
    click DCP "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/dbhelpers/DbContextProvider.cs"
    click DBN "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/dbhelpers/DBName.cs"
    click M1 "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Migrations/20250415144029_InitialCreate.cs"
    click M2 "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Migrations/20250415150502_InitialCreate.cs"
    click SNAP "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Migrations/AppDbContextModelSnapshot.cs"
    click SBatch "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/BatchSeeder.cs"
    click SClient "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/ClientSeeder.cs"
    click SIng "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/IngredientSeeder.cs"
    click SKeg "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/KegSeeder.cs"
    click SOrder "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/OrderSeeder.cs"
    click SRecipe "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/RecipeSeeder.cs"
    click SRIng "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/RecipeIngredientSeeder.cs"
    click SStock "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Seeders/StockEntrySeeder.cs"
    click V1 "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Validation/AtLeastOneIngredientAttribute.cs"
    click V2 "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/Validation/UniqueIngredientsAttribute.cs"
    click Config "https://github.com/hubertfus/brewlogix/blob/main/BrewLogix/appsettings.json"

    classDef frontend fill:#ADD8E6,stroke:#000
    classDef service fill:#90EE90,stroke:#000
    classDef dataaccess fill:#FFA500,stroke:#000
    classDef db fill:#D3D3D3,stroke:#000
    classDef config fill:#DDA0DD,stroke:#000
```
