How martincarreno/bienesraicesmvc works
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 Router · ActiveRecord.php ActiveRecord · LoginController.php Login · PaginasController.php Pages
Components 23
Runtime
Web entrypoint and request flow
- index.php · Web root bootstrap and request handoff
public/index.php
Core MVC
Routing, controllers, models, and persistence
- Router · Resolves URLs to controllers and actions
Router.php - Login · Admin authentication flow
controllers/LoginController.php - Pages · Public site page flow
controllers/PaginasController.php - Properties · Property CRUD and admin workflows
controllers/PropiedadController.php - Vendors · Vendor CRUD workflows
controllers/VendedorController.php - ActiveRecord · Shared CRUD and database abstraction
models/ActiveRecord.php - Admin · Admin credential lookup and validation
models/Admin.php - Propiedad · Property entity and persistence
models/Propiedad.php - Vendedor · Vendor entity and persistence
models/Vendedor.php - Database · MySQL connection configuration
includes/config/database.php - App bootstrap · Shared application setup
includes/app.php - Helpers · Shared helper functions
includes/funciones.php
Presentation
Views and shared templates
- Layout · Common page wrapper
views/layout.php - Login view · Admin login screen
views/auth/login.php - Pages views · Public site templates and content pages
views/paginas/index.php - Property views · Property admin screens and forms
views/propiedades/admin.php - Vendor views · Vendor admin screens and forms
views/vendedores/crear.php - Shared templates · Reusable UI fragments
includes/templates/header.php
Assets
Source assets and build output
- SCSS source · Authoring styles for base, layout, and admin sections
src/scss/app.scss - Frontend JS · Browser behavior and feature scripts
src/js/app.js - Built assets · Published CSS, JS, and images served at runtime
public/build/css/app.css - Gulp build · Bundles and compiles source assets
gulpfile.js
Connections 27
- 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