How yulito/sistema_ventas works
Main Components
• Frontend Components:
• Views: Represented by the resources/views directory (which contains various PHP view files, login pages, dashboards, modals, and layout/partials).
• Public assets: The public directory holding CSS, JS, images, and the entry point index.php.
• JavaScript functionality: Client-side scripts (e.g., login.js, product.js, generatorPDF.js) providing asynchronous calls to the backend and PDF generation.
• Backend Components:
• Controllers: In app/controllers, containing multiple controllers (AreaController, BrandController, UserController, etc.) that manage HTTP requests and user actions.
• Models: In app/models, with entities like Product, Sale, Client, etc., that encapsulate business logic and interact with the database.
• Helpers and Libraries: In app/helpers and lib, including CSRF, Session handling, routing, and utility functions to support both security and core functions.
• Routing: Defined in routes/web.php and supported by the lib/Route.php; these define how incoming requests map to controller actions.
• Configuration: The config directory (databases.php) and SQL script (db.sql) for database settings, essential for initializing the backend with MySQL.
• Database:
• MySQL as the storage engine, with the database script provided in config/db.sql.
• External Environment:
• Apache Server: The README details how to configure a virtual host and adjust the hosts file.
• Client Devices: Browsers (preferably Chrome) are used to access the system.
Relationships and Interactions
• That a browser (client) sends an HTTP request to Apache.
• Apache routes requests to the public/index.php file.
• The request is then handled by the routing system (from lib/Route.php and defined in routes/web.php) which dispatches the request to the appropriate controller.
• Controllers process input, interact with Models (business logic and database CRUD operations), and then pass the output to Views for rendering.
• Views (resources/views) generate HTML/CSS/JS that is sent back to the client.
• JavaScript on the client uses the fetch API for asynchronous calls, communicates with the server endpoints, and sometimes triggers PDF generation via JSPDF.
• Database interactions occur via models using queries configured through the databases.php file.
Architectural Patterns and Technologies
• MVC Pattern: Clearly separate concerns between controllers, models, and views.
• Asynchronous Data Communication: JavaScript’s fetch API calls to backend controllers.
• Security and Session Management: CSRF protection and Session handling provided by lib components.
• Dependency on External Libraries/Frameworks: Use of Bootstrap for styling, JSPDF for PDF generation.