Backend API for Agric Connect, a platform that connects farmers and buyers across East Africa. Built with Node.js, Express, MongoDB, and JWT authentication.
# π± Agric-Connect Backend
The backend API for **Agric-Connect**, a web platform designed to connect farmers and buyers across East Africa.
Agric-Connect provides a secure and scalable REST API for user authentication, farmer product management, product discovery, and role-based access control.
## π Features
* π JWT-based authentication
* π₯ Role-based access control (RBAC)
* π¨βπΎ Farmer and buyer user roles
* π¦ Product management
* πΌοΈ Product image uploads using Multer
* π Product retrieval and filtering
* ποΈ MongoDB database with Mongoose
* β‘ Redis caching for improved API performance
* π Password hashing with bcrypt
* π‘οΈ Helmet security middleware
* π CORS configuration
* π Structured controllers, services, models, and routes
* π Protected API endpoints
* βοΈ Environment-based configuration
## π οΈ Tech Stack
| Technology | Purpose |
| ---------- | ----------------------------- |
| Node.js | Backend runtime |
| Express.js | REST API framework |
| MongoDB | Database |
| Mongoose | MongoDB ODM |
| Redis | Caching |
| JWT | Authentication |
| bcrypt | Password hashing |
| Multer | Image uploads |
| Helmet | HTTP security |
| CORS | Cross-origin resource sharing |
| Postman | API testing |
## π Project Structure
```text
src/
βββ config/
β βββ db.js
β βββ redis.js
β
βββ controllers/
β βββ auth.controller.js
β βββ product.controller.js
β
βββ middleware/
β βββ auth.middleware.js
β βββ upload.middleware.js
β βββ ...
β
βββ models/
β βββ user.model.js
β βββ product.model.js
β βββ role.model.js
β βββ permission.model.js
β
βββ routes/
β βββ auth.route.js
β βββ product.route.js
β
βββ services/
β βββ auth.service.js
β βββ product.service.js
β
βββ app.js
βββ server.js
uploads/
.env
.gitignore
package.json
README.md
```
## β¦