A comprehensive full-stack marketplace platform connecting farmers, vendors, and customers with advanced features including real-time chat, vendor verification system, location-based product discovery, and integrated M-Pesa payments.
Tech Stack: React + Vite (Frontend) β’ Rust + Actix-Web (Backend) β’ PostgreSQL (Database)
- JWT-based authentication with role-based access (Admin, Vendor, Customer)
- Username-based password reset system
- Vendor verification process with document upload
- Automatic verification rejection handling with user notifications
- Location-based product discovery using GPS coordinates
- Advanced shopping cart with persistent state
- Real-time inventory management
- Product search and filtering
- Integrated chatbot for customer support
- Real-time messaging between users
- Vendor-customer communication channels
- M-Pesa STK Push integration
- Secure payment processing
- Transaction history and receipts
- Order tracking and shipping management
- GPS-based vendor/customer matching
- Distance-based product filtering
- Manual location input for flexibility
- Node.js (v16+) - Download here
- Rust (latest stable) - Install via rustup
- PostgreSQL (v12+) - Installation guide
-
Clone the repository
git clone https://github.com/Wangscorp/Farmers-Market-Place.git cd Farmers-Market-Place -
Setup Backend
cd backend cargo build -
Setup Frontend
cd frontend npm install -
Database Setup
# Create PostgreSQL database createdb farmers_market # Set DATABASE_URL (optional - defaults to localhost) export DATABASE_URL="postgres://username:password@localhost/farmers_market"
Terminal 1 - Backend:
cd backend
cargo runServer starts at http://127.0.0.1:8080
Terminal 2 - Frontend:
cd frontend
npm run devApplication opens at http://localhost:5173
The application follows a modern three-tier architecture:
- Frontend (React + Vite): Modern SPA with responsive design and real-time updates
- Backend (Rust + Actix-Web): High-performance REST API with JWT authentication
- Database (PostgreSQL): Reliable data persistence with ACID compliance
- Communication: HTTP/HTTPS with JSON payloads (Frontend β Backend)
| Role | Username | Password | Description |
|---|---|---|---|
| Admin | admin |
admin123 |
Full system access |
| Vendor | farmer_john |
vendor123 |
Product management |
| Vendor | organic_mary |
vendor123 |
Alternative vendor |
| Customer | customer_alice |
customer123 |
Shopping features |
- Login as
customer_alice - Add products to cart
- Use phone number:
0712345678(test number) - Complete checkout flow with simulated M-Pesa response
- Login as a vendor account
- Upload verification documents (any image file)
- Admin can approve/reject from admin dashboard
- Rejected users see notification on next login
Backend (Railway):
- Connect GitHub repo to Railway
- Add PostgreSQL database service
- Deploy automatically on git push
Frontend (Vercel):
- Connect repo to Vercel
- Set root directory to
frontend - Add environment variable:
VITE_API_URL=https://your-backend-url
Backend Dockerfile:
FROM rust:1.70 as builder
WORKDIR /app
COPY backend/ .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates
COPY --from=builder /app/target/release/backend /usr/local/bin/backend
EXPOSE 8080
CMD ["backend"]Frontend Dockerfile:
FROM node:18 as builder
WORKDIR /app
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]DATABASE_URL=postgres://username:password@localhost/farmers_market
RUST_LOG=debug
JWT_SECRET=your-secret-key-here
SMTP_SERVER=smtp.gmail.com
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-passwordVITE_API_URL=http://localhost:8080
VITE_GEMINI_API_KEY=your-gemini-api-key| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /login |
User login with username/password | No |
| POST | /signup |
User registration | No |
| POST | /send-reset-code |
Initiate password reset | No |
| POST | /verify-reset-code |
Verify reset code | No |
| POST | /reset-password |
Complete password reset | No |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /products |
Get all products (location-filtered) | No |
| POST | /products |
Create new product | Vendor |
| PUT | /products/{id} |
Update product | Vendor |
| DELETE | /products/{id} |
Delete product | Vendor |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /cart |
Get user's cart items | Customer |
| POST | /cart |
Add item to cart | Customer |
| PUT | /cart/{id} |
Update cart item quantity | Customer |
| DELETE | /cart/{id} |
Remove item from cart | Customer |
| POST | /checkout |
Process M-Pesa payment | Customer |
| GET | /shipping |
Get user's orders | Customer |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /admin/users |
Get all users | Admin |
| GET | /admin/pending-verifications |
Get pending vendor verifications | Admin |
| POST | /admin/update-verification |
Approve/reject vendor verification | Admin |
main.rs- Application entry point and server setuproutes.rs- REST API endpoints and request handlersmodels.rs- Data structures and JWT handlingdb.rs- Database operations and queriesmpesa.rs- M-Pesa payment integrationemail.rs- Email notification systemgemini.rs- AI chatbot integration
Core Components:
UserContext.jsx- Global state managementAuth.jsx- Authentication forms with password resetProducts.jsx- Product catalog with location filteringCart.jsx- Shopping cart managementVendorDashboard.jsx- Vendor product managementAdminDashboard.jsx- Admin user/verification managementChat.jsx- Real-time messagingChatbot.jsx- AI customer support
Specialized Components:
VerificationUpload.jsx- Vendor document verificationMpesaTest.jsx- Payment testing interfaceShipping.jsx- Order tracking and management
cargo run # Start development server
cargo build # Build the project
cargo test # Run tests
cargo check # Check code without buildingnpm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint- JWT Authentication with role-based access control
- Password Hashing using bcrypt with salt
- CORS Protection configured for specific origins
- Input Validation on all API endpoints
- SQL Injection Prevention via parameterized queries
- XSS Protection through React's built-in escaping
- HTTPS Ready for production deployment
- Multi-role authentication (Admin/Vendor/Customer)
- Username-based password reset system
- Account verification with document upload
- Automatic cleanup of rejected verifications
- Location-based product discovery
- Shopping cart with persistent state
- M-Pesa payment integration
- Order tracking and management
- Real-time inventory updates
- AI-powered chatbot support
- Real-time messaging between users
- Email notifications for important events
- User management dashboard
- Vendor verification approval/rejection
- System-wide analytics and reporting
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes and commit:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/your-feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@farmersmarketplace.com
- Built with β€οΈ using Rust, React, and PostgreSQL
- M-Pesa integration for seamless African payments
- AI-powered features via Gemini API
- Modern web technologies for optimal performance