How phuclemon/vysoulcosmetic works
Project Overview
• This is a full-stack web application built in PHP using the MVC architecture pattern.
• Its purpose is to serve as an e-commerce website for cosmetics, with distinct interfaces and functionalities for Admin (management of products, orders, etc.) and User (browsing, cart, checkout).
• The project uses PHP for server-side logic, MySQL as its database (see the SQL file), and HTML/CSS/JavaScript for front-end interactions (with static assets stored in the Public folder).
Analyzing the File Structure
• Top-Level Files/Folders:
• Public: Contains static assets (CSS, JavaScript, images, fonts) which are rendered on the client side.
• index.php: Likely the main entry point for the application.
• mvc: Houses the core MVC architecture components:
▪ Controllers: Contains PHP files handling HTTP requests for Admin and User functionalities.
▪ Models: Contains business logic and database interactions (including separate sub-folders for Admin-related models and general models).
▪ Views: Contains the front-end HTML templates for both Admin and User, organized to clearly separate display blocks, layouts, and pages.
• Core: Contains essential components like App.php (application initialization), Controller.php (base controller), and Database.php.
• Other artifacts: SQL file for database schema and multiple README files for documentation.
Main System Components
A. Client Side:
• Web Browser: Renders HTML/CSS/JavaScript from the Public folder.
• Interaction Elements: Static UI assets (stylesheets, scripts), and user-initiated actions like searching, adding to cart, and navigating pages.
B. Web Server / PHP Application:
• Entry Point (index.php): Routes incoming requests.
• MVC Bridge (Bridge.php): Likely responsible for routing or initializing controllers.
• Controllers: Different controllers for both Admin (Bills, Branch, Customer, etc.) and User (TrangChu, SanPham, GioHang, etc.) that process user requests, manage sessions, and enforce action routing.
• Core Components: App, Controller, and Database which manage application bootstrapping and connection to MySQL.
C. Models:
• Data Access Layer: Handles business logic and CRUD operations for products, orders, user accounts, etc.
D. Views:
• Template Engine: Contains reusable blocks, layouts, and pages which render dynamic data from controllers.
E. Database (MySQL):
• Persist data related to users, products, orders, and sessions (schema provided by “u378271986_MyPham.sql”).
Relationships and Data Flow
• Requests originate from the client (browser) and are routed by the index.php entry point.
• An MVC Bridge then directs requests to the corresponding controller.
• Controllers invoke Models to retrieve/update data from the MySQL database.
• Once data is processed, controllers pass it to Views, which generate HTML/CSS/JavaScript responses.
• Public folder assets support styling and client-side interactions, including AJAX calls (handled by Public/js/ajax.js) for dynamic content updates.
• For administrative functionalities, separate directories in Controllers, Models, and Views (i.e., within /Admin) ensure proper role-based handling.
Architectural Patterns & Design Principles
• Clear MVC Separation: Models (business logic, database operations), Views (rendering), and Controllers (business process flow) are all separated.
• Role-based Access: Distinct Admin and User areas managed by different controllers and views.
• Modular Organization: Distinct folders for static content and dynamic PHP components to facilitate scalability and easier maintenance.
• The use of JavaScript (and libraries such as jQuery/Bootstrap) on the front-end to improve user interactions.