# martincarreno/bienesraicesmvc architecture

> Architecture diagram of the GitHub repository martincarreno/bienesraicesmvc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martincarreno/bienesraicesmvc
- Repository: https://github.com/martincarreno/bienesraicesmvc

## Overview

1. **Overall shape**
   - This is a classic server-rendered PHP application with a custom MVC structure.
   - The main runtime boundary is the **public/** directory, which acts as the web root and entry point for all requests.

2. **Request entry and routing**
   - Requests land in **public/index.php**, which bootstraps the app and hands control to the custom **Router.php**.
   - The router resolves the URL to the appropriate controller/action instead of exposing files directly, keeping the app organized around routes.

3. **Controller layer**
   - Business flow is split across controllers in **controllers/**:
     - **LoginController.php** for authentication.
     - **PaginasController.php** for public pages.
     - **PropiedadController.php** for property CRUD and admin flows.
     - **VendedorController.php** for vendor CRUD.
   - Controllers coordinate input, model calls, and view rendering; they do not appear to contain persistence logic themselves.

4. **Model / domain layer**
   - Domain objects live in **models/**:
     - **Propiedad**, **Vendedor**, and **Admin** represent the main data entities.
     - **ActiveRecord.php** provides the shared persistence pattern and likely abstracts CRUD operations against MySQL.
   - The architecture suggests a lightweight ORM/Active Record approach rather than a separate service layer.

5. **Database boundary**
   - Database access is configured in **includes/config/database.php**.
   - The app uses **MySQL** as its system of record for properties, vendors, and admin users.
   - The main data flow is: controller → model/ActiveRecord → database → model → view.

6. **Authentication subsystem**
   - Admin login is isolated in **controllers/LoginController.php** and **views/auth/login.php**.
   - **models/Admin.php** backs credential lookup / validation.
   - This creates a protected admin boundary separate from the public site pages.

7. **Public site pages**
   - The user-facing content is rendered from **views/paginas/**, including home, about, blog, contact, property listing, and property detail pages.
   - **controllers/PaginasController.php** likely supplies these pages with content fetched from models and then renders the corresponding view templates.

8. **Admin CRUD subsystem**
   - Admin management screens live under **views/propiedades/** and **views/vendedores/**.
   - These views support create/update/list workflows, while the controllers orchestrate persistence and form handling.
   - Property management is the richer subsystem because it includes image handling and record relationships.

9. **Reusable view composition**
   - Shared UI pieces are centralized under **includes/templates/** and **views/layout.php**.
   - Typical structure is header/footer + page-specific content, which keeps the presentation layer consistent across public and admin pages.

10. **Configuration and shared helpers**
   - **includes/app.php** and **includes/funciones.php** act as bootstrap/shared utility files.
   - The **includes/** boundary separates application setup, helpers, and templates from the domain models and controllers.

11. **Static assets and build pipeline**
   - Source assets live in **src/** with SCSS, JS, and image sources.
   - Compiled assets are published to **public/build/**, which is what the application serves at runtime.
   - **gulpfile.js**, **package.json**, and **package-lock.json** indicate a Node/Gulp build step for bundling/minifying styles and scripts.

12. **Frontend styling and UI behavior**
   - SCSS is organized by concern: base styles, layout components, and internal/admin sections.
   - The README notes **dark mode/light mode** support and responsive design, so the front-end architecture is componentized around reusable style partials rather than a monolithic stylesheet.

13. **Image handling**
   - The repo separates source imagery from runtime/public imagery: **src/img**, **public/imagenes**, and **imagenesApp**.
   - This suggests a build/deployment boundary where optimized assets are served from public paths while design/demo assets remain outside the runtime flow.

14. **Key architectural flow to diagram**
   - User/browser → **public/index.php** → **Router.php** → controller → model/ActiveRecord → MySQL → controller → view/layout → browser.
   - Admin flows follow the same path, but pass through authentication first and then into CRUD views/controllers for properties and vendors.

15. **What makes this repo distinct**
   - The project is not framework-based; it implements its own MVC, routing, and Active Record layer on top of PHP.
   - That means the important diagram boundaries are the custom routing/bootstrap layer, the controller/model separation, the MySQL persistence layer, and the asset build pipeline feeding the public web root.

Main entry points: [`Router.php`](https://github.com/martincarreno/bienesraicesmvc/blob/master/Router.php) (Router), [`models/ActiveRecord.php`](https://github.com/martincarreno/bienesraicesmvc/blob/master/models/ActiveRecord.php) (ActiveRecord), [`controllers/LoginController.php`](https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/LoginController.php) (Login), [`controllers/PaginasController.php`](https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/PaginasController.php) (Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_public_index["index.php<br/>web entrypoint<br/>[index.php]"]
end

subgraph group_core["Core MVC"]
  node_router{{"Router<br/>[Router.php]"}}
  node_login_controller["Login<br/>controller"]
  node_paginas_controller["Pages<br/>controller"]
  node_propiedad_controller["Properties<br/>controller"]
  node_vendedor_controller["Vendors<br/>controller"]
  node_active_record[("ActiveRecord<br/>persistence base<br/>[ActiveRecord.php]")]
  node_admin_model["Admin<br/>auth model<br/>[Admin.php]"]
  node_propiedad_model["Propiedad<br/>domain model<br/>[Propiedad.php]"]
  node_vendedor_model["Vendedor<br/>domain model<br/>[Vendedor.php]"]
  node_db_config[("Database<br/>mysql config<br/>[database.php]")]
  node_app_bootstrap["App bootstrap<br/>[app.php]"]
  node_helpers["Helpers<br/>[funciones.php]"]
end

subgraph group_presentation["Presentation"]
  node_layout["Layout<br/>view shell<br/>[layout.php]"]
  node_auth_view["Login view<br/>auth view<br/>[login.php]"]
  node_pages_views["Pages views<br/>page templates<br/>[index.php]"]
  node_propiedades_views["Property views<br/>admin templates<br/>[admin.php]"]
  node_vendedores_views["Vendor views<br/>admin templates<br/>[crear.php]"]
  node_templates["Shared templates<br/>partials<br/>[header.php]"]
end

subgraph group_assets["Assets"]
  node_src_scss["SCSS source<br/>frontend styles<br/>[app.scss]"]
  node_src_js["Frontend JS<br/>frontend scripts<br/>[app.js]"]
  node_public_build["Built assets<br/>compiled assets<br/>[app.css]"]
  node_gulp{{"Gulp build<br/>build pipeline<br/>[gulpfile.js]"}}
end

node_public_index -->|"bootstraps"| node_app_bootstrap
node_public_index -->|"dispatches"| node_router
node_router -->|"routes to"| node_login_controller
node_router -->|"routes to"| node_paginas_controller
node_router -->|"routes to"| node_propiedad_controller
node_router -->|"routes to"| node_vendedor_controller
node_login_controller -->|"uses"| node_admin_model
node_paginas_controller -->|"reads"| node_propiedad_model
node_propiedad_controller -->|"uses"| node_propiedad_model
node_vendedor_controller -->|"uses"| node_vendedor_model
node_admin_model -->|"extends"| node_active_record
node_propiedad_model -->|"extends"| node_active_record
node_vendedor_model -->|"extends"| node_active_record
node_active_record -->|"connects to"| node_db_config
node_login_controller -->|"renders"| node_auth_view
node_paginas_controller -->|"renders"| node_pages_views
node_propiedad_controller -->|"renders"| node_propiedades_views
node_vendedor_controller -->|"renders"| node_vendedores_views
node_pages_views -->|"wrapped by"| node_layout
node_auth_view -->|"wrapped by"| node_layout
node_propiedades_views -->|"uses"| node_templates
node_vendedores_views -->|"uses"| node_templates
node_src_scss -->|"compiled by"| node_gulp
node_src_js -->|"bundled by"| node_gulp
node_gulp -->|"publishes"| node_public_build
node_layout -->|"loads"| node_public_build
node_templates -.->|"styles with"| node_public_build

click node_public_index "https://github.com/martincarreno/bienesraicesmvc/blob/master/public/index.php"
click node_router "https://github.com/martincarreno/bienesraicesmvc/blob/master/Router.php"
click node_login_controller "https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/LoginController.php"
click node_paginas_controller "https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/PaginasController.php"
click node_propiedad_controller "https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/PropiedadController.php"
click node_vendedor_controller "https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/VendedorController.php"
click node_active_record "https://github.com/martincarreno/bienesraicesmvc/blob/master/models/ActiveRecord.php"
click node_admin_model "https://github.com/martincarreno/bienesraicesmvc/blob/master/models/Admin.php"
click node_propiedad_model "https://github.com/martincarreno/bienesraicesmvc/blob/master/models/Propiedad.php"
click node_vendedor_model "https://github.com/martincarreno/bienesraicesmvc/blob/master/models/Vendedor.php"
click node_db_config "https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/config/database.php"
click node_app_bootstrap "https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/app.php"
click node_helpers "https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/funciones.php"
click node_layout "https://github.com/martincarreno/bienesraicesmvc/blob/master/views/layout.php"
click node_auth_view "https://github.com/martincarreno/bienesraicesmvc/blob/master/views/auth/login.php"
click node_pages_views "https://github.com/martincarreno/bienesraicesmvc/blob/master/views/paginas/index.php"
click node_propiedades_views "https://github.com/martincarreno/bienesraicesmvc/blob/master/views/propiedades/admin.php"
click node_vendedores_views "https://github.com/martincarreno/bienesraicesmvc/blob/master/views/vendedores/crear.php"
click node_templates "https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/templates/header.php"
click node_src_scss "https://github.com/martincarreno/bienesraicesmvc/blob/master/src/scss/app.scss"
click node_src_js "https://github.com/martincarreno/bienesraicesmvc/blob/master/src/js/app.js"
click node_public_build "https://github.com/martincarreno/bienesraicesmvc/blob/master/public/build/css/app.css"
click node_gulp "https://github.com/martincarreno/bienesraicesmvc/blob/master/gulpfile.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_index toneBlue
class node_router,node_login_controller,node_paginas_controller,node_propiedad_controller,node_vendedor_controller,node_active_record,node_admin_model,node_propiedad_model,node_vendedor_model,node_db_config,node_app_bootstrap,node_helpers toneAmber
class node_layout,node_auth_view,node_pages_views,node_propiedades_views,node_vendedores_views,node_templates toneMint
class node_src_scss,node_src_js,node_public_build,node_gulp toneRose
```

## Components

### Runtime

Web entrypoint and request flow

- [index.php](https://github.com/martincarreno/bienesraicesmvc/blob/master/public/index.php): web entrypoint · Web root bootstrap and request handoff · `public/index.php`

### Core MVC

Routing, controllers, models, and persistence

- [Router](https://github.com/martincarreno/bienesraicesmvc/blob/master/Router.php): request router · Resolves URLs to controllers and actions · `Router.php`
- [Login](https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/LoginController.php): controller · Admin authentication flow · `controllers/LoginController.php`
- [Pages](https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/PaginasController.php): controller · Public site page flow · `controllers/PaginasController.php`
- [Properties](https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/PropiedadController.php): controller · Property CRUD and admin workflows · `controllers/PropiedadController.php`
- [Vendors](https://github.com/martincarreno/bienesraicesmvc/blob/master/controllers/VendedorController.php): controller · Vendor CRUD workflows · `controllers/VendedorController.php`
- [ActiveRecord](https://github.com/martincarreno/bienesraicesmvc/blob/master/models/ActiveRecord.php): persistence base · Shared CRUD and database abstraction · `models/ActiveRecord.php`
- [Admin](https://github.com/martincarreno/bienesraicesmvc/blob/master/models/Admin.php): auth model · Admin credential lookup and validation · `models/Admin.php`
- [Propiedad](https://github.com/martincarreno/bienesraicesmvc/blob/master/models/Propiedad.php): domain model · Property entity and persistence · `models/Propiedad.php`
- [Vendedor](https://github.com/martincarreno/bienesraicesmvc/blob/master/models/Vendedor.php): domain model · Vendor entity and persistence · `models/Vendedor.php`
- [Database](https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/config/database.php): mysql config · MySQL connection configuration · `includes/config/database.php`
- [App bootstrap](https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/app.php): bootstrap · Shared application setup · `includes/app.php`
- [Helpers](https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/funciones.php): utility · Shared helper functions · `includes/funciones.php`

### Presentation

Views and shared templates

- [Layout](https://github.com/martincarreno/bienesraicesmvc/blob/master/views/layout.php): view shell · Common page wrapper · `views/layout.php`
- [Login view](https://github.com/martincarreno/bienesraicesmvc/blob/master/views/auth/login.php): auth view · Admin login screen · `views/auth/login.php`
- [Pages views](https://github.com/martincarreno/bienesraicesmvc/blob/master/views/paginas/index.php): page templates · Public site templates and content pages · `views/paginas/index.php`
- [Property views](https://github.com/martincarreno/bienesraicesmvc/blob/master/views/propiedades/admin.php): admin templates · Property admin screens and forms · `views/propiedades/admin.php`
- [Vendor views](https://github.com/martincarreno/bienesraicesmvc/blob/master/views/vendedores/crear.php): admin templates · Vendor admin screens and forms · `views/vendedores/crear.php`
- [Shared templates](https://github.com/martincarreno/bienesraicesmvc/blob/master/includes/templates/header.php): partials · Reusable UI fragments · `includes/templates/header.php`

### Assets

Source assets and build output

- [SCSS source](https://github.com/martincarreno/bienesraicesmvc/blob/master/src/scss/app.scss): frontend styles · Authoring styles for base, layout, and admin sections · `src/scss/app.scss`
- [Frontend JS](https://github.com/martincarreno/bienesraicesmvc/blob/master/src/js/app.js): frontend scripts · Browser behavior and feature scripts · `src/js/app.js`
- [Built assets](https://github.com/martincarreno/bienesraicesmvc/blob/master/public/build/css/app.css): compiled assets · Published CSS, JS, and images served at runtime · `public/build/css/app.css`
- [Gulp build](https://github.com/martincarreno/bienesraicesmvc/blob/master/gulpfile.js): build pipeline · Bundles and compiles source assets · `gulpfile.js`

## Connections

- index.php → App bootstrap: bootstraps · Initial application setup
- index.php → Router: dispatches · Hands request handling to router
- Router → Login: routes to · Authentication requests
- Router → Pages: routes to · Public pages
- Router → Properties: routes to · Property admin flows
- Router → Vendors: routes to · Vendor admin flows
- Login → Admin: uses · Validates credentials through model
- Pages → Propiedad: reads · Fetches properties for public pages
- Properties → Propiedad: uses · CRUD operations on properties
- Vendors → Vendedor: uses · CRUD operations on vendors
- Admin → ActiveRecord: extends · Shares persistence behavior
- Propiedad → ActiveRecord: extends · Shares persistence behavior
- Vendedor → ActiveRecord: extends · Shares persistence behavior
- ActiveRecord → Database: connects to · Uses MySQL configuration
- Login → Login view: renders · Login page template
- Pages → Pages views: renders · Public page templates
- Properties → Property views: renders · Property admin screens
- Vendors → Vendor views: renders · Vendor admin screens
- Pages views → Layout: wrapped by · Shared site shell
- Login view → Layout: wrapped by · Shared site shell
- Property views → Shared templates: uses · Reusable form and page fragments
- Vendor views → Shared templates: uses · Reusable form and page fragments
- SCSS source → Gulp build: compiled by · Styles are built into public assets
- Frontend JS → Gulp build: bundled by · Scripts are built into public assets
- Gulp build → Built assets: publishes · Outputs runtime-ready assets
- Layout → Built assets: loads · Uses compiled CSS and JS
- Shared templates → Built assets: styles with · Presentation assets are consumed at runtime
