# ekoyanu99/simplemrp architecture

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

- Interactive diagram: https://gitdiagram.com/ekoyanu99/simplemrp
- Repository: https://github.com/ekoyanu99/simplemrp

## Overview

##### Main Components
- Frontend (Presentation Layer):
- Views: Located in the resources/views directory, which includes Blade files for authentication, sales, items, BOM, profiles, etc.
- Assets: Resources like CSS and JavaScript in resources/js and public directories.
- Backend (Business Logic Layer):
- Controllers: Found under app/Http/Controllers (includes authentication controllers, domain-specific controllers such as BomMstrController, SalesMstrController, etc.).
- Models: In app/Models. These represent the Eloquent ORM models for interacting with the database.
- Requests & Policies: In app/Http/Requests and app/Policies, which handle validation and authorization respectively.
- Core Laravel Infrastructure: Providers, middleware (implied by Laravel’s structure), and configuration files in config.
- Database:
- Migrations & Seeders: Under database/migrations and database/seeders for schema definition and initial data.
- Routing & Middleware:
- Routes: Defined in the routes folder (web.php, auth.php, etc.) which map HTTP requests to controllers.
- External Services & Utilities:
- Third-party integrations: Mail, queues, sessions, cache, and real-time broadcasting as configured.
- Package dependencies and assets managed by composer.json and package.json.

##### Relationships and Data Flow
- HTTP Request Flow:
- Request flows into the public/index.php file, then is handed off to the Laravel routing system.
- Routing and Controllers:
- Routes (from routes/web.php and similar files) determine which controller method handles the request.
- Controllers process the request, interact with models/services, and return responses.
- Business Data Handling:
- Controllers rely on Eloquent models for database interactions (CRUD operations) based on the migrations and seeders.
- Validation and authorization are performed via Request classes and Policies.
- Response Flow:
- Processed data is passed to blade templates (views) to generate the final HTML/JSON response, which is sent back to the client.
- Additional Interactions:
- Configuration files (under config) and service providers (app/Providers) underline other dependencies, such as session, cache, logging, and external APIs.

##### Architectural Patterns and Key Technologies
- MVC Pattern:
- Dependency Injection & Middleware:
- Mention that Laravel’s Service Container and middleware are used to inject and manage dependencies.
- Security & Authentication:
- Dedicated authentication layer (auth controllers and requests) handling user sessions and security.
- Frontend/Asset Management:
- Integration with modern JavaScript (as seen in resources/js and public/js) and CSS/Sass (resources/css, resources/sass) for interactive UI components.
- Laravel-specific Components:
- To call out Laravel’s Eloquent ORM, routing engine, and Blade templating system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client Browser"]:::client
    B["public/index.php"]:::infra
    C["Routes"]:::infra
    L["Core Laravel Infra"]:::infra
    D["Auth Controllers"]:::backend
    E["Business Controllers"]:::backend
    F["Form Requests & Validation"]:::backend
    G["Authorization Policies"]:::backend
    H["Models"]:::backend
    I["Database (Migrations & Seeders)"]:::db
    J["Blade Views"]:::frontend
    K["Frontend Assets"]:::frontend

    %% Request Flow
    A -->|"sendsRequest"| B
    B -->|"routesTo"| C
    C -->|"toAuth"| D
    C -->|"toBusiness"| E

    %% Core Infrastructure interactions
    L -->|"configRoutes"| C
    L -->|"injectDeps"| D
    L -->|"injectDeps"| E

    %% Validation & Authorization services
    D -->|"validates"| F
    D -->|"authorizes"| G
    E -->|"validates"| F
    E -->|"authorizes"| G

    %% Controller interactions with Models and Views
    D -->|"dataOp"| H
    E -->|"dataOp"| H
    H -->|"dbOps"| I
    D -->|"renders"| J
    E -->|"renders"| J

    %% Frontend assets integration and response
    J -->|"includesAssets"| K
    J -->|"responds"| A

    %% Click Events
    click J "https://github.com/ekoyanu99/simplemrp/tree/main/resources/views"
    click K "https://github.com/ekoyanu99/simplemrp/tree/main/resources/js"
    click D "https://github.com/ekoyanu99/simplemrp/tree/main/app/Http/Controllers/Auth"
    click E "https://github.com/ekoyanu99/simplemrp/tree/main/app/Http/Controllers"
    click H "https://github.com/ekoyanu99/simplemrp/tree/main/app/Models"
    click F "https://github.com/ekoyanu99/simplemrp/tree/main/app/Http/Requests"
    click G "https://github.com/ekoyanu99/simplemrp/tree/main/app/Policies"
    click L "https://github.com/ekoyanu99/simplemrp/tree/main/config"
    click I "https://github.com/ekoyanu99/simplemrp/tree/main/database/migrations"
    click C "https://github.com/ekoyanu99/simplemrp/tree/main/routes"
    click B "https://github.com/ekoyanu99/simplemrp/blob/main/public/index.php"

    %% Styles
    classDef client fill:#cfc,stroke:#333,stroke-width:2px;
    classDef infra fill:#ffc,stroke:#333,stroke-width:2px;
    classDef backend fill:#cff,stroke:#333,stroke-width:2px;
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef db fill:#fcf,stroke:#333,stroke-width:2px;
```
