FarmLink is a full-stack web application designed to bridge the gap between local farmers and consumers. It allows farmers to manage inventory, track orders, and view financial analytics, while providing buyers with a marketplace to browse and purchase fresh produce.
The application follows a Client-Server architecture:
- Frontend: Built with HTML5, CSS3, and Vanilla JavaScript. It uses
fetchfor API communication andlocalStoragefor session management. - Backend: A RESTful API built with Node.js and Express.js.
- Database: MySQL relational database for persistent storage of users, products, and orders.
- Frontend: JavaScript (ES6+), Chart.js (for analytics), jsPDF (for receipts), FontAwesome.
- Backend: Node.js, Express, Multer (for image uploads), Dotenv.
- Database: MySQL (relational schema).
/Front_End: Contains the role-based dashboards for Farmers and Buyers./Back_End/controllers: Contains the logic for processing data (e.g.,orderController.js,marketplaceController.js)./Back_End/routes: Defines the API endpoints./Back_End/config/db.js: Database connection configuration.
- Role-Based Access: Specialized onboarding and login flows for Farmers and Buyers.
- Inventory Management: Farmers can upload products with images and monitor stock levels.
- Order Life-Cycle: Real-time status updates (Pending → Processing → Completed/Cancelled).
- Financial Dashboard: Visual representation of sales data and order counts using Chart.js.
- Global Search: Adaptive search logic based on the logged-in user's role.
- Database: Import the provided SQL schema into your MySQL Workbench.
- Environment Variables: Create a
.envfile in the/Back_Endfolder with your DB credentials:DB_HOST=localhost DB_USER=root DB_PASS=yourpassword DB_NAME=farmlink PORT=3001
- Install Dependencies:
cd Back_End npm install - Run Server:
node server.js
POST /api/users/login: Authenticates users and returns role data.GET /api/orders/latest/:userId: Fetches the most recent order for a specific farmer.POST /api/marketplace/add: Allows farmers to upload new products with images.GET /api/messages: Retrieves unread messages for the notification center.