# ashrahx/salutix architecture

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

- Interactive diagram: https://gitdiagram.com/ashrahx/salutix
- Repository: https://github.com/ashrahx/salutix

## Overview

##### Main Components
- Client/Browser Layer: Represents the users accessing the system (different roles such as admin, doctor, cashier, and possibly guest users).
- Frontend Assets: Reside in directories like public (static assets) and resources (CSS, JavaScript, and Blade view templates). Also note the integration of Vite (via vite.config.js and npm scripts) for asset bundling.
- Laravel Application Core:
- Controllers: Located in app/Http/Controllers (with sub-folders like Admin and Auth). These manage the incoming HTTP requests (routing from routes/web.php, routes/auth.php) and enforce business logic.
- Middleware: Found in app/Http/Middleware, handling role-based access (e.g., Admin, Cashier, Doctor) and security.
- Models: In app/Models (e.g. User, Patient, Shift) which interact with the database through the Eloquent ORM.
- Requests: Custom request validation logic in app/Http/Requests.
- Views: Stored in resources/views (including layouts, admin-specific views, components, and error pages) that define the UI.
- Providers and Configuration: In app/Providers and config/ directory, which set up the global settings, service providers, and dependency injection.
- Database Layer: Managed via migrations in the database/migrations (creating tables like users, patients, shifts, etc.) and seeded by database/seeders.
- Development and Build Tools: Artisan commands (artisan file), Composer dependencies (composer.json), NodeJS dependencies (package.json), and build configurations (Vite, Tailwind, PostCSS).

##### Relationships and Interactions
- Requests from the client pass to the Laravel backend through defined routes (in routes/web.php, routes/auth.php).
- Middleware intercepts requests to apply authentication and role-based permissions.
- Controllers process the requests, interacting with Models to perform CRUD operations on the database.
- Responses are rendered through Blade view templates (resources/views) and served back to the client.
- Frontend build process uses Vite and NodeJS tooling to compile assets, which are then referenced by the view layer.

##### Important Architectural Patterns and Design Principles
- MVC Pattern: Clear division among Models, Views, and Controllers to manage application logic.
- Layered Architecture: Separation between presentation (Blade views, assets), business logic (controllers, middleware, requests), persistence (models and databases), and configuration.
- Role-Based Access Control: Multiple middleware components and role-specific controllers (Admin, Doctor, Cashier) indicate separation of concerns based on user roles.
- Dependency Injection & Service Providers: The app structure leverages Laravel’s service container (e.g., app/Providers) for bootstrapping various services.

##### Relevant Technologies, Frameworks, and Libraries
- Laravel (Backend framework)
- PHP (Server-side language; version requirements are given)
- MySQL (Database)
- Composer (Dependency management for PHP)
- NodeJS, Vite, Tailwind, PostCSS (Frontend tooling and asset compilation)
- Eloquent ORM (Data modeling)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        ClientBrowser["Client/Browser"]:::client
        StaticAssets["Static Assets (public)"]:::client
    end

    %% Frontend Assets
    subgraph "Frontend Assets"
        CSSAsset["CSS (app.css)"]:::frontend
        JSAsset["JS (app.js)"]:::frontend
        ViteConfigFE["Vite Config"]:::frontend
    end

    %% Laravel Application Core
    subgraph "Laravel Application Core"
        HTTPControllers["HTTP Controllers (Admin,Auth,General)"]:::controllers
        RequestValidation["Request Validation"]:::controllers
        Middleware["Middleware (Admin,Cashier,Doctor)"]:::middleware
        Models["Models (User,Patient,Shift)"]:::models
        ViewTemplates["View Templates (Blade)"]:::views
        ServiceProviders["Service Providers & Configurations"]:::providers
    end

    %% Database Layer
    subgraph "Database Layer"
        Database["Database (MySQL)"]:::database
        MigrationsSeeders["Migrations & Seeders"]:::database
    end

    %% Development & Build Tools
    subgraph "Development & Build Tools"
        ArtisanCLI["Artisan CLI"]:::development
        Composer["Composer Dependencies"]:::development
        PackageManager["NodeJS Dependencies"]:::development
        TailwindConfig["Tailwind Config"]:::development
        PostCSSConfig["PostCSS Config"]:::development
    end

    %% Connections - Client Layer
    ClientBrowser -->|"fetches"| StaticAssets
    ClientBrowser -->|"HTTP_Request"| HTTPControllers

    %% Connections - Frontend Assets to Application Core
    ViteConfigFE ---|"bundled_assets"| CSSAsset
    ViteConfigFE --- JSAsset
    CSSAsset ---|"linked_assets"| ViewTemplates
    JSAsset ---|"linked_assets"| ViewTemplates

    %% Connections within Laravel Application Core
    HTTPControllers -->|"validate"| RequestValidation
    HTTPControllers -->|"pass-through"| Middleware
    Middleware -->|"calls"| Models
    Models -->|"CRUD_operations"| Database
    HTTPControllers -->|"render_view"| ViewTemplates
    ServiceProviders -->|"bootstraps"| HTTPControllers
    ViewTemplates -->|"HTML_response"| ClientBrowser

    %% Connections - Development Tools to Frontend Assets
    PackageManager -->|"trigger_build"| ViteConfigFE

    %% Click Events
    click StaticAssets "https://github.com/ashrahx/salutix/tree/main/public"
    click ViewTemplates "https://github.com/ashrahx/salutix/tree/main/resources/views"
    click CSSAsset "https://github.com/ashrahx/salutix/blob/main/resources/css/app.css"
    click JSAsset "https://github.com/ashrahx/salutix/blob/main/resources/js/app.js"
    click ViteConfigFE "https://github.com/ashrahx/salutix/blob/main/vite.config.js"
    click HTTPControllers "https://github.com/ashrahx/salutix/tree/main/app/Http/Controllers"
    click Middleware "https://github.com/ashrahx/salutix/tree/main/app/Http/Middleware"
    click Models "https://github.com/ashrahx/salutix/tree/main/app/Models"
    click RequestValidation "https://github.com/ashrahx/salutix/tree/main/app/Http/Requests"
    click ServiceProviders "https://github.com/ashrahx/salutix/tree/main/app/Providers"
    click ServiceProviders "https://github.com/ashrahx/salutix/tree/main/config"
    click MigrationsSeeders "https://github.com/ashrahx/salutix/tree/main/database/migrations"
    click MigrationsSeeders "https://github.com/ashrahx/salutix/tree/main/database/seeders"
    click ArtisanCLI "https://github.com/ashrahx/salutix/tree/main/artisan"
    click Composer "https://github.com/ashrahx/salutix/blob/main/composer.json"
    click PackageManager "https://github.com/ashrahx/salutix/blob/main/package.json"
    click TailwindConfig "https://github.com/ashrahx/salutix/blob/main/tailwind.config.js"
    click PostCSSConfig "https://github.com/ashrahx/salutix/blob/main/postcss.config.js"

    %% Styles
    classDef client fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef frontend fill:#ffdead,stroke:#856404,stroke-width:2px;
    classDef controllers fill:#b0c4de,stroke:#000,stroke-width:2px;
    classDef middleware fill:#dda0dd,stroke:#000,stroke-width:2px;
    classDef models fill:#98fb98,stroke:#000,stroke-width:2px;
    classDef views fill:#ffb6c1,stroke:#000,stroke-width:2px;
    classDef providers fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef database fill:#f4a460,stroke:#000,stroke-width:2px;
    classDef development fill:#ffffe0,stroke:#000,stroke-width:2px;
```
