How halofie/knf works
Project type and purpose
• The “knft” folder contains the core business logic and CRUD endpoints; “public” holds all front-end assets; “login”, “admin”, “consumer”, “producer” folders contain role-specific views.
File structure
• Top-level folders:
• knft – PHP scripts (API endpoints, business logic).
• public – Static assets (CSS, JS, images).
• admin, consumer, producer – Role-specific HTML/PHP pages.
• login – Authentication UI.
• vendor – Composer packages.
• Key configuration: composer.json/composer.lock for dependencies.
• No separate “src” or microservices: it’s a single PHP codebase served by one web server (e.g., Apache/Nginx+PHP-FPM).
README
• Minimal content; no additional architecture notes. All architectural insight must come from file layout.
Diagramming the system architecture
a. Main components
1. Clients (Web Browsers)
2. Web Server (Apache/Nginx + PHP-FPM)
3. PHP Application
– Presentation layer: “public” assets + role views (login/, admin/, consumer/, producer/)
– Controller/Service layer: knft/*.php (authenticate.php, submitOrder.php, getCustomer.php, etc.)
– Data-access layer: knft scripts interacting with the Database
4. Database (MySQL/PostgreSQL)
5. External services/dependencies
– Composer/vendor libraries
– File transfer (knft/transferFile.php)
b. Relationships and interactions
• Browser → HTTP request for HTML or assets → Web Server
• Web Server routes static requests to “public” folder; PHP requests to dispatcher (e.g., index.php or direct script URLs)
• PHP scripts in “knft” handle business logic: read/write to Database, perform authentication, hash passwords, manage inventory/orders/customers/routes/suppliers.
• Responses (HTML, JSON, redirects) flow back to the browser.
• Composer/vendor code is autoloaded by PHP at runtime.
c. Architectural patterns/design principles
• Layered architecture: Presentation → Business logic → Data Access
• Role-based modules (Admin, Consumer, Producer) share common business logic in knft/
• Lightweight endpoint style (each PHP file is a single endpoint)
d. Key technologies
– PHP 7/8, Composer for dependency management
– HTML/CSS/JavaScript on the front end
– jQuery and custom JS scripts for dynamic UI
– MySQL or equivalent relational database