# richardues/sarc-too architecture

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

- Interactive diagram: https://gitdiagram.com/richardues/sarc-too
- Repository: https://github.com/richardues/sarc-too

## Overview

##### Project type and purpose
- From the README title “Sistema de Atención y Resolución de Clientes (SARC)” and the file tree, this is a monolithic, full-stack PHP MVC web application.
- It implements user authentication, dashboards, error pages, and CRUD operations via its modules.

##### File structure
- App/Config: database connection and global configuration.
- App/Core: central Router and base Controller logic.
- App/Helpers: reusable PHP functions.
- App/Models: ORM-like classes mapping to DB tables (Cliente, Usuario, Rol, UserTypes).
- App/Modules: feature modules (Auth, Dashboard, Errors, Home) each with Controller, Service/Repository, optional GenericCrud.
- public/: entry point (index.php), static assets (CSS, JS, fonts).
- resources/views/: view templates organized by feature.
- composer.json: dependency management.
- dataset.sql, scrips_tables.sql: initial schema and data.

##### README for additional insights
- Although sections aren’t filled out here, the headings hint at:
– Host virtual configuration (Apache/nginx + .htaccess)
– Local DB connection via App/Config/Database.php
– PHP dependencies (managed by Composer)

a. Main components
1. Client Browser (UI)
2. Web Server (Apache or nginx + .htaccess)
3. PHP Runtime / Front Controller (public/index.php)
4. Router (App/Core/Router.php)
5. Controllers (App/Modules/*/*Controller.php)
6. Services & Repositories (AuthService, AuthRepository, GenericCrud)
7. Models (App/Models/*.php)
8. Database (MySQL/PostgreSQL as per dataset.sql)
9. Static Assets (CSS/JS under public/assets, public/styles, public/scripts)

b. Relationships & interactions
- Browser → HTTP Request → Web Server → index.php
- index.php invokes Router → dispatches to appropriate Controller
- Controller uses Services (AuthService, Dashboard logic)
- Services call Repositories or GenericCrud → Models → Database
- Database returns data → Models → Repositories → Services → Controller
- Controller loads a View template (resources/views/…) → HTML response → Browser
- Static assets (CSS/JS) served directly by Web Server on client requests

c. Architectural patterns & design principles
- MVC (Model-View-Controller)
- Front-Controller pattern (single entry point + Router)
- Layered architecture (Presentation, Application, Data)
- Separation of concerns (Controllers vs. Services/Repositories vs. Models)
- Module-based organization (each feature in its own folder under App/Modules)

d. Key technologies & frameworks
- PHP 7+ (Composer for autoloading)
- MySQL (or compatible) via App/Config/Database.php
- Vanilla JS, Bootstrap CSS (public/scripts + public/styles/bootstrap)
- .htaccess for URL rewriting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        Browser["Client Browser"]:::client
        StaticAssets["Static Assets\n(public/styles/, public/scripts/, public/assets/)"]:::static
    end

    %% Server Side
    subgraph "Server Side"
        WebServer["Web Server\n(Apache/nginx)"]:::server
        HTAccess[".htaccess"]:::config
        Composer["composer.json"]:::config
        FrontController["Front Controller\npublic/index.php"]:::server
        Router["Router\nApp/Core/Router.php"]:::server
        BaseController["Base Controller\nApp/Core/Controller.php"]:::server
        Helpers["Global Helpers\nApp/Helpers/functions.php"]:::server
        DBConfig["Database Config\nApp/Config/Database.php"]:::config

        subgraph "Modules"
            AuthController["AuthController\nApp/Modules/Auth/AuthController.php"]:::server
            AuthService["AuthService\nApp/Modules/Auth/AuthService.php"]:::server
            AuthRepo["AuthRepository\nApp/Modules/Auth/AuthRepository.php"]:::server
            GenericCrud["GenericCrud\nApp/Modules/Auth/GenericCrud.php"]:::server
            DashboardController["DashboardController\nApp/Modules/Dashboard/DashboardController.php"]:::server
            HomeController["HomeController\nApp/Modules/Home/HomeController.php"]:::server
            ErrorsController["ErrorsController\nApp/Modules/Errors/ErrorsController.php"]:::server
        end

        subgraph "Models"
            Cliente["Cliente\nApp/Models/Cliente.php"]:::model
            Usuario["Usuario\nApp/Models/Usuario.php"]:::model
            Rol["Rol\nApp/Models/Rol.php"]:::model
            UserTypes["UserTypes\nApp/Models/UserTypes.php"]:::model
        end
    end

    %% Database
    subgraph "Database"
        DB["Database\n(MySQL/PostgreSQL)"]:::db
        Dataset["dataset.sql\nscrips_tables.sql"]:::dbscript
    end

    %% Views
    subgraph "Views"
        AuthViews["Auth Views\nresources/views/auth/login.php"]:::view
        DashboardViews["Dashboard Views\nresources/views/dashboard/"]:::view
        ErrorViews["Error Pages\nresources/views/errors/401.php,404.php,500.php"]:::view
        HomeViews["Home & Static Pages\nresources/views/home.php,about.php,contact.php"]:::view
        Layouts["Global Layouts\nresources/views/layouts/"]:::view
    end

    %% Connections
    Browser -->|"HTTP Request"| WebServer
    Browser -->|"GET /assets"| StaticAssets
    StaticAssets -->|Served Directly| WebServer

    WebServer -->|Rewrite| HTAccess
    HTAccess -->|Entry| FrontController
    Composer -->|Autoload| FrontController
    FrontController -->|dispatch| Router
    Router -->|instantiates| BaseController
    BaseController -->|uses| Helpers
    BaseController -->|loads DB config| DBConfig

    Router -->|routes to| AuthController
    Router -->|routes to| DashboardController
    Router -->|routes to| HomeController
    Router -->|routes to| ErrorsController

    AuthController -->|calls| AuthService
    DashboardController -->|calls| AuthService
    HomeController -->|calls| GenericCrud
    ErrorsController -->|calls| GenericCrud

    AuthService -->|uses| AuthRepo
    AuthService -->|uses| GenericCrud
    GenericCrud -->|accesses| Models
    AuthRepo -->|accesses| Usuario
    AuthRepo -->|accesses| Cliente
    AuthRepo -->|accesses| Rol
    AuthRepo -->|accesses| UserTypes

    Models -->|queries| DB
    DB -->|returns data| Models

    AuthController -->|renders| AuthViews
    DashboardController -->|renders| DashboardViews
    HomeController -->|renders| HomeViews
    ErrorsController -->|renders| ErrorViews
    BaseController -->|wraps| Layouts

    DB -->|initialized via| Dataset

    %% Click Events
    click FrontController "https://github.com/richardues/sarc-too/blob/main/public/index.php"
    click Router "https://github.com/richardues/sarc-too/blob/main/App/Core/Router.php"
    click BaseController "https://github.com/richardues/sarc-too/blob/main/App/Core/Controller.php"
    click DBConfig "https://github.com/richardues/sarc-too/blob/main/App/Config/Database.php"
    click Helpers "https://github.com/richardues/sarc-too/blob/main/App/Helpers/functions.php"
    click AuthController "https://github.com/richardues/sarc-too/blob/main/App/Modules/Auth/AuthController.php"
    click AuthService "https://github.com/richardues/sarc-too/blob/main/App/Modules/Auth/AuthService.php"
    click AuthRepo "https://github.com/richardues/sarc-too/blob/main/App/Modules/Auth/AuthRepository.php"
    click GenericCrud "https://github.com/richardues/sarc-too/blob/main/App/Modules/Auth/GenericCrud.php"
    click DashboardController "https://github.com/richardues/sarc-too/blob/main/App/Modules/Dashboard/DashboardController.php"
    click HomeController "https://github.com/richardues/sarc-too/blob/main/App/Modules/Home/HomeController.php"
    click ErrorsController "https://github.com/richardues/sarc-too/blob/main/App/Modules/Errors/ErrorsController.php"
    click Cliente "https://github.com/richardues/sarc-too/blob/main/App/Models/Cliente.php"
    click Usuario "https://github.com/richardues/sarc-too/blob/main/App/Models/Usuario.php"
    click Rol "https://github.com/richardues/sarc-too/blob/main/App/Models/Rol.php"
    click UserTypes "https://github.com/richardues/sarc-too/blob/main/App/Models/UserTypes.php"
    click AuthViews "https://github.com/richardues/sarc-too/blob/main/resources/views/auth/login.php"
    click DashboardViews "https://github.com/richardues/sarc-too/tree/main/resources/views/dashboard/"
    click ErrorViews "https://github.com/richardues/sarc-too/blob/main/resources/views/errors/401.php"
    click ErrorViews "https://github.com/richardues/sarc-too/blob/main/resources/views/errors/404.php"
    click ErrorViews "https://github.com/richardues/sarc-too/blob/main/resources/views/errors/500.php"
    click HomeViews "https://github.com/richardues/sarc-too/blob/main/resources/views/home.php"
    click Layouts "https://github.com/richardues/sarc-too/tree/main/resources/views/layouts/"
    click Dataset "https://github.com/richardues/sarc-too/blob/main/dataset.sql"
    click Dataset "https://github.com/richardues/sarc-too/blob/main/scrips_tables.sql"
    click Composer "https://github.com/richardues/sarc-too/blob/main/composer.json"
    click HTAccess "https://github.com/richardues/sarc-too/blob/main/.htaccess"

    %% Styles
    classDef client fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef static fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef server fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef config fill:#d9edf7,stroke:#333,stroke-width:1px
    classDef model fill:#b3ffb3,stroke:#333,stroke-width:1px
    classDef db fill:#d5f5e3,stroke:#333,stroke-width:1px
    classDef dbscript fill:#f2dede,stroke:#333,stroke-width:1px
    classDef view fill:#fcf8e3,stroke:#333,stroke-width:1px
```
