How thnhtai19/bkstore works
Main Components
a. Clients
• Public users browsing/catalog (/views/public, /views/client)
• Authenticated customers (account pages, cart, checkout)
• Admin users (/views/admin)
b. Web Server & Application Layer
• Apache/nginx + PHP runtime serving files under public/
• MVC components in app/
• Controllers (app/controllers/*)
• Service layer / Models (app/models/*)
• Views (app/views/*)
c. Data Layer
• MySQL database (schemas from config/create_database.sql, sample data)
d. Static Asset Storage
• Image files on disk under public/image/…
• CSS and JS under public/css, public/js
e. External Service
• Payment provider integration (app/controllers/payment/*, PayOsService)
Relationships & Data Flows
• User browsers ➞ HTTP requests to Web Server
• Web Server routes requests to specific Controller (by URL pattern)
• Controller invokes Service/Model methods for business logic & DB access
• Service layer executes SQL queries on MySQL, returns domain objects/data
• Controller selects a View template, passes data for rendering HTML
• Web Server returns HTML + static assets (CSS/JS/images) to browser
• For payment operations: Controller calls external Payment Gateway API, processes callbacks
• File uploads (e.g. product images, user avatars) flow through Controller → stored in public/image/…
Architectural Patterns & Principles
• MVC separation:
• “View” templates are purely presentation
• “Controllers” handle routing, request/response, validation
• “Models” encapsulate database access (one Service class per domain)
• Layered architecture: Presentation ↔ Business Logic ↔ Data Access
• Modular controllers organized by feature (auth, admin, product, cart, order, system, etc.)
• Single monolithic codebase, no microservices
Relevant Technologies & Frameworks
• PHP 7/8, built-in web server or Apache/nginx (.htaccess for rewrites)
• MySQL (connect details in config/db.php)
• Front-end: HTML5, CSS3, Tailwind, vanilla JS (files under public/js)
• SQL scripts for schema and seed data
Tool Recommendations & Detail Level
• Aim for readability: group related controllers as a package, but don’t omit any major feature (auth, cart, order, product, admin)
• Five layers/components, but avoid over-fragmenting identical services