How haviwijayalath/farmlink works
Project type and purpose
• FarmLink is a full-stack, PHP-based MVC web application that connects farmers and buyers in a wholesale market.
• Built from scratch (no framework) using PHP for backend logic, HTML/CSS for presentation, and JavaScript for client-side behavior.
File structure
• Top-level “app” directory implements the MVC layers:
– app/config: configuration (database credentials, environment)
– app/bootstrap.php: application entry setup
– app/libraries: Core router, base Controller, Database class
– app/helpers: cross-cutting utilities (mailer, sessions, flash messages, notifications, URL)
– app/controllers: one controller per resource (Admin, Buyers, Farmers, etc.)
– app/models: domain objects matching controllers (User, Order, Appointment, Complaint…)
– app/views: view templates organized by module (admin, buyer, consultant, d_person, farmers, forum, home, users)
• “public” directory is the document root:
– public/index.php: front controller
– public/css, js, images: static assets
– .htaccess files for URL rewriting
• composer.json for dependency metadata (even if no external PHP packages are used)
README
• Confirms MVC architecture and tech stack (PHP, HTML, CSS, JS)
Components
a. Main components
1. Client (Browser)
2. Web Server / PHP-FPM (serving public/index.php + .htaccess rewrites)
3. Front Controller (public/index.php)
4. Router (app/libraries/Core)
5. Controllers (app/controllers)
6. Models & Data Access (app/models + app/libraries/Database)
7. Views (app/views)
8. Configuration & Bootstrap (app/bootstrap.php + app/config)
9. Helpers & Libraries (mailer_config, session_helper, notification_helper…)
10. Relational Database (MySQL or PostgreSQL)
11. External Services (SMTP/email provider via mailer_config)
b. Relationships & data flow
– Browser → HTTP Request → Web Server
– Web Server → public/index.php → Router
– Router → Appropriate Controller
– Controller → Models → Database
– Database → Query Results → Model
– Controller → View (passing model data)
– View → Render HTML → Response to Browser
– Controller → Helpers → External Services (e.g., send email via SMTP)
– Static assets (CSS/JS/images) served directly by Web Server to Browser
c. Architectural patterns & design principles
– MVC: separation of concerns between models, views, controllers
– Front-controller & router pattern for clean URLs
– Layered architecture: presentation → application logic → data access
– Dependency inversion in helper/libraries for cross-cutting concerns
d. Key technologies, frameworks, libraries
– PHP (7.x or 8.x)
– Apache or Nginx + PHP-FPM
– MySQL/PostgreSQL (via app/libraries/Database)
– HTML5, CSS3, JavaScript (notifications.js, client validation)
– .htaccess for URL rewriting
Elements
– Clear, concise labels for every component (e.g., “Router (app/libraries/Core)”)
• Green for helpers/external services
• Orange for static asset delivery