# jhoel0521/bancofassil architecture

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

- Interactive diagram: https://gitdiagram.com/jhoel0521/bancofassil
- Repository: https://github.com/jhoel0521/bancofassil

## Overview

##### Project Type & Purpose
- The project is a PHP web application built using a custom MVC framework.
- It handles both web and API requests (note the existence of separate controllers for RESTful API calls like ApiController.php and AuthApiController.php, as well as standard controllers).
- It includes functionality for user authentication, account management, and even PDF generation (using an integrated FPDF library).

##### Analyzing the File Structure
- Entry Point & Bootstrapping:
– The index.php file at the root serves as the application’s single entry point, initializing the environment (via autoload.php, configuration files, and functions.php).
- Core Framework:
– The Core directory contains essential framework components:
◦ Routing (Router.php, Route.php, RouteNotFoundException.php)
◦ Request/Response handling (Request.php, Response.php)
◦ Database abstraction (DB.php, QueryBuilder.php, Model.php)
◦ Session and validation utilities.
– A dedicated PDF generation subsystem is present in Core/fpdf.
- Application Layer:
– The App folder is organized into Controllers, Models, Middleware, and Enums – establishing the MVC and layered architectural patterns.
- Presentation Layer:
– The resources/views directory holds PHP view templates that render the UI.
– The public directory contains static assets (CSS, fonts, images, JS), supporting the frontend.
- Routing & Language Support:
– The routes folder (with api.php and web.php) defines the application’s endpoints and API routes.
– The langs folder provides localization support.
- Database:
– The database folder includes migrations and seeders for setting up the database schema (e.g., offices, script constructs).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Client["Client/Browser"]:::client

    %% Entry Point & Bootstrapping
    subgraph "Entry Point & Bootstrapping"
        entryIndex["index.php"]:::bootstrap
        entryAutoload["autoload.php"]:::bootstrap
        entryFunctions["functions.php"]:::bootstrap
    end

    %% Core Framework
    subgraph "Core Framework"
        router["Router (Core/Router.php)"]:::core
        route["Route (Core/Route.php)"]:::core
        routeException["RouteNotFoundException (Core/Exceptions/RouteNotFoundException.php)"]:::core
        routesAPI["API Routes (routes/api.php)"]:::core
        routesWeb["Web Routes (routes/web.php)"]:::core
        request["Request (Core/Request.php)"]:::core
        response["Response (Core/Response.php)"]:::core
        db["DB (Core/DB.php)"]:::core
        querybuilder["QueryBuilder (Core/QueryBuilder.php)"]:::core
        modelFramework["Model (Core/Model.php)"]:::core
        pdf["PDF Generation (Core/fpdf)"]:::core
    end

    %% Application Layer
    subgraph "Application Layer"
        controllers["Controllers (App/Controllers)"]:::app
        middleware["Middleware (App/Middleware)"]:::app
        models["Models (App/Models)"]:::app
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        views["View Templates (resources/views)"]:::present
        staticAssets["Static Assets (public)"]:::present
    end

    %% Support & Infrastructure
    subgraph "Support & Infrastructure"
        languages["Language Support (langs)"]:::support
        migrations["Database Migrations (database/migrations)"]:::support
        seeders["Database Seeders (database/seeders)"]:::support
    end

    %% Connections
    Client -->|"requests"| entryIndex

    entryIndex -->|"initializes"| entryAutoload
    entryIndex -->|"initializes"| entryFunctions
    entryIndex -->|"parses"| request

    request -->|"routed by"| router

    router -->|"uses"| route
    router -->|"handles"| routeException
    router -->|"loads"| routesAPI
    router -->|"loads"| routesWeb
    router -->|"forwards to"| middleware

    middleware -->|"filters request"| controllers

    controllers -->|"invokes"| models
    controllers -->|"renders via"| views
    controllers -->|"generates PDF via"| pdf
    controllers -->|"sends"| response

    models -->|"queries via"| db
    models -->|"builds queries with"| querybuilder
    models -->|"extends"| modelFramework

    modelFramework -->|"applies"| migrations
    modelFramework -->|"populates via"| seeders

    views -->|"localizes with"| languages

    %% Styles and Classes
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef bootstrap fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef app fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef present fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef support fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click entryIndex "https://github.com/jhoel0521/bancofassil/blob/main/index.php"
    click entryAutoload "https://github.com/jhoel0521/bancofassil/blob/main/autoload.php"
    click entryFunctions "https://github.com/jhoel0521/bancofassil/blob/main/functions.php"
    click router "https://github.com/jhoel0521/bancofassil/blob/main/Core/Router.php"
    click route "https://github.com/jhoel0521/bancofassil/blob/main/Core/Route.php"
    click routeException "https://github.com/jhoel0521/bancofassil/blob/main/Core/Exceptions/RouteNotFoundException.php"
    click routesAPI "https://github.com/jhoel0521/bancofassil/blob/main/routes/api.php"
    click routesWeb "https://github.com/jhoel0521/bancofassil/blob/main/routes/web.php"
    click request "https://github.com/jhoel0521/bancofassil/blob/main/Core/Request.php"
    click response "https://github.com/jhoel0521/bancofassil/blob/main/Core/Response.php"
    click db "https://github.com/jhoel0521/bancofassil/blob/main/Core/DB.php"
    click querybuilder "https://github.com/jhoel0521/bancofassil/blob/main/Core/QueryBuilder.php"
    click modelFramework "https://github.com/jhoel0521/bancofassil/blob/main/Core/Model.php"
    click pdf "https://github.com/jhoel0521/bancofassil/tree/main/Core/fpdf"
    click controllers "https://github.com/jhoel0521/bancofassil/tree/main/App/Controllers"
    click middleware "https://github.com/jhoel0521/bancofassil/tree/main/App/Middleware"
    click models "https://github.com/jhoel0521/bancofassil/tree/main/App/Models"
    click views "https://github.com/jhoel0521/bancofassil/tree/main/resources/views"
    click staticAssets "https://github.com/jhoel0521/bancofassil/tree/main/public"
    click languages "https://github.com/jhoel0521/bancofassil/tree/main/langs"
    click migrations "https://github.com/jhoel0521/bancofassil/tree/main/database/migrations"
    click seeders "https://github.com/jhoel0521/bancofassil/tree/main/database/seeders"
```
