How ryan-menezes/loja-virtual works
Project type and purpose
• This is a monolithic, full-stack PHP e-commerce web application (“Loja Virtual”) built on a custom lightweight MVC framework.
• It provides a public shopping site, an administration panel, database persistence, file storage, and integrates with external shipping (Correios) and payment gateways (MercadoPago, PagSeguro, PicPay).
File structure
• Top‐level “public/” serves static assets (CSS, JS, images) and routes all requests through “public/index.php.”
• “routes/web.php” defines URL → controller mappings.
• “src/Classes” houses framework core (Router, Request, Controller, View, Database, Session, Mail, Validator, Storage, etc.).
• “app/Controllers” separates admin (Panel) and public (Site) controllers.
• “app/Models” represents database entities (Product, Category, User, Request, etc.).
• “app/Classes” contains domain services (Cart, shipping under Correios, payment gateway wrappers).
• “app/Middlewares” handles cross-cutting concerns (auth, maintenance, LGPD).
• “config/” holds environment and service configurations.
• “resource/views” contains Blade-style templates for public site, admin panel, emails, and components.
• “storage/” persists user‐uploaded files (banners, products, policies) and local database dumps.
• Node and Webpack config build front-end assets under “public/assets.”
Review README for additional insights
• Requires Composer + NPM.
• Uses a blade-like templating system; assets must be rebuilt via npm scripts.
• External integrations (PagSeguro, MercadoPago, PicPay) are disabled by default and configured via admin panel.
Main components and interactions
a. Web & Static Asset Layer (public/)
• Web server (Apache/Nginx) → serves static files (CSS/JS/images) and forwards dynamic requests to index.php
b. HTTP Routing & Framework Core (src/Classes + routes/web.php)
• Request enters Router → dispatched to Middleware chain → Controller
c. Controllers (app/Controllers)
• “Site” controllers for public pages and checkout.
• “Panel” controllers for admin dashboard and configuration.
d. Business Logic & Services
• Cart service, shipping calculators (Correios classes), payment service wrappers (Pago, MercadoPago, PicPay)
e. Models & Database (app/Models + config/database.php)
• ORM/Active-Record or simple Query Builder → MySQL/PostgreSQL
f. Templating & Views (resource/views)
• Controllers pass data to Blade templates for HTML rendering.
g. File Storage (storage/app/public)
• Uploaded images/documents managed by Storage/File class and publicly accessible via symbolic link or web server alias
h. External Services
• Correios API (via FreteWsCorreios)
• Payment gateways (pagseguro, mercadopago, picpay) via REST/SDK calls
Architectural patterns & design principles
• MVC (Model-View-Controller) layered architecture
• Single-entry point / Front Controller in public/index.php
• Dependency injection limited – services instantiated in controllers or factory classes under app/Classes
• Middlewares for cross-cutting concerns (Authentication, Maintenance mode, LGPD compliance)
• Service wrappers for external APIs isolate HTTP logic
Elements
• Configuration store (config files) indicating where credentials and environment settings live
• Build step: npm/webpack compiles assets into public/assets
• Confirm MVC layers are distinct and labeled
• Services (shipping, payment) as dedicated components
• Middleware chain before controllers
• Where templating fits (Controllers → View → HTML)
• Differentiate internal data stores vs. external APIs
• Critical interactions for clarity (e.g., “Session start,” “CSRF check,” “ORM save”)