Logo Lanfrica

ChrisOwuor/ase

Domain:

agriculturedigital infrastructure

Record type:

software
Creator:
Chr
Host:
Backend API for a farm e-commerce app with JWT auth, product/order management, and Mpesa payment integration using MongoDB. # FarmConnect API - Node.js Backend A backend REST API built with Node.js and Express to support the **FarmConnect** platformβ€”a system designed to eliminate middlemen in the agricultural supply chain. This platform empowers farmers by directly connecting them to verified buyers and managing logistics, payments, and withdrawals seamlessly. --- ## πŸš€ Purpose Many farmers are exploited by brokers who buy low and sell high. **FarmConnect** eliminates this by: - Allowing farmers to list their produce - Enabling buyers to directly place and pay for orders - Managing logistics centrally - Paying farmers directly via **M-PESA** --- ## 🧩 Features - βœ… Farmer and Buyer registration/login (JWT Auth) - βœ… Role-based access (Farmer / Buyer) - βœ… Product listing (Farmers) - βœ… Order placement (Buyers) - βœ… M-PESA payment integration (via STK push) - βœ… Order tracking for both parties - βœ… Farmer wallets and balance tracking - βœ… Withdrawal requests by farmers --- ## πŸ“ Folder Structure ```bash β”œβ”€β”€ controllers # Route logic β”œβ”€β”€ models # Mongoose schemas β”œβ”€β”€ routes # Express routes β”œβ”€β”€ middleware # Authentication & error handling β”œβ”€β”€ services # Mpesa & utility services β”œβ”€β”€ config # DB & environment config β”œβ”€β”€ app.js # Main app entry β”œβ”€β”€ server.js # Starts the server ``` --- ## πŸ” Authentication - Uses **JWT tokens** for secure route access - Protected routes based on user role (`farmer`, `buyer`) --- ## πŸ’³ M-PESA Integration - Buyers pay via **STK Push** - Payment validation handled via callback URL - Farmers’ wallet balance updated after successful payment - Farmers can **request withdrawals**, triggering M-PESA B2C payments --- ## πŸ› οΈ Tech Stack - **Node.js + Express** - **MongoDB + Mongoose** - **JWT** for Auth - **M-PESA Daraja API** for payments - **Dotenv** for environment management --- ## πŸ§ͺ API Endpoints | Method | Endpoint | Role | Description | | -- …

Languages