A complete web platform that connects food donors with NGOs and coordinates volunteers for pickup/delivery to reduce food wastage.
FoodShare/
βββ frontend/ # Next.js Frontend Application
β βββ app/ # Next.js pages
β βββ components/ # React components
β βββ lib/ # Utilities & API
β βββ public/ # Static assets
β βββ package.json
β
βββ backend/ # Node.js + Express + MongoDB Backend
β βββ src/
β β βββ models/ # Database models
β β βββ controllers/ # Business logic
β β βββ routes/ # API routes
β β βββ middleware/ # Auth & validation
β β βββ server.js # Main server
β βββ package.json
β
βββ FRONTEND_INTEGRATION.md # Frontend-Backend integration guide
βββ BACKEND_COMPLETE.md # Backend completion summary
βββ README.md # This file
- Node.js 18+ installed
- MongoDB installed (local) OR MongoDB Atlas account
- npm or pnpm package manager
cd backend
npm install
npm run seed # Create sample data
npm run dev # Start on port 5000Backend will run at: http://localhost:5000
cd frontend
npm install
npm run dev # Start on port 3000Frontend will run at: http://localhost:3000
After seeding the database, use these credentials:
| Role | Password | |
|---|---|---|
| Admin | admin@foodshare.com | admin123 |
| Donor | donor1@example.com | password123 |
| NGO | ngo1@example.com | password123 |
| Volunteer | volunteer1@example.com | password123 |
- Add food donations with expiry dates
- Manage donation listings
- Track donation history
- Receive notifications when claimed
- Browse available food donations
- Claim donations (first-come-first-served)
- View claim history
- Receive pickup notifications
- View available pickup requests
- Accept pickup tasks
- Update delivery status
- Track completed deliveries
- System dashboard with analytics
- User management
- Donation oversight
- Generate reports
- JWT-based authentication
- Password hashing (bcryptjs)
- Role-based access control
- Input validation & sanitization
- Rate limiting
- CORS protection
- β Automatic expiry validation
- β Duplicate claim prevention
- β Real-time notifications
- β Location tracking (Google Maps ready)
- β Multi-stage delivery tracking
- β Admin dashboard & reports
- Frontend Setup:
frontend/README.md - Backend Setup:
backend/README.md - Quick Start Guide:
backend/QUICKSTART.md - API Documentation:
backend/API_TESTING.md - Deployment Guide:
backend/DEPLOYMENT.md - Integration Guide:
FRONTEND_INTEGRATION.md - Backend Complete:
BACKEND_COMPLETE.md
Base URL: http://localhost:5000/api
POST /auth/register- Register new userPOST /auth/login- Login userGET /auth/me- Get current user
POST /donations- Create donation (Donor)GET /donations/available- Get available donationsGET /donations/my-donations/list- Get my donations (Donor)PUT /donations/:id- Update donation (Donor)DELETE /donations/:id- Delete donation (Donor)
POST /claims/claim/:donationId- Claim donation (NGO)GET /claims/my-claims- Get my claims (NGO)
GET /pickups/available- Get available pickups (Volunteer)POST /pickups/:id/accept- Accept pickup (Volunteer)PUT /pickups/:id/status- Update status (Volunteer)GET /pickups/my-pickups/list- Get my pickups (Volunteer)
GET /admin/stats- Dashboard statisticsGET /admin/users- Get all usersGET /admin/reports- Generate reports
GET /notifications- Get my notificationsPUT /notifications/:id/read- Mark as read
- Framework: Next.js 16.0 (React)
- UI Components: Radix UI
- Styling: Tailwind CSS
- Icons: Lucide React
- Theme: next-themes
- Forms: React Hook Form + Zod
- Runtime: Node.js
- Framework: Express.js 4.18
- Database: MongoDB with Mongoose 8.0
- Authentication: JWT + bcryptjs
- Security: Helmet, CORS, Rate Limiting
- Validation: express-validator
cd backend
npm run dev # Starts with nodemon (auto-reload)cd frontend
npm run dev # Starts Next.js dev servercd backend
npm run seed # Populates database with sample datacd backend
npm start # Production modecd frontend
npm run build # Build for production
npm start # Start production serverDeploy to Render, Railway, Heroku, DigitalOcean, or AWS EC2.
See backend/DEPLOYMENT.md for detailed guides.
Deploy to Vercel (recommended), Netlify, or any Node.js hosting.
Important: Update environment variables:
- Frontend:
NEXT_PUBLIC_API_URL=https://your-backend-url.com/api - Backend:
FRONTEND_URL=https://your-frontend-url.com
cd backend
# Import FoodShare_API.postman_collection.json in Postman
# Or use curl commands from API_TESTING.md- Start both backend and frontend
- Navigate to
http://localhost:3000 - Login with test credentials
- Test all user flows
- Users - User accounts with roles
- Donations - Food donations with expiry
- Claims - NGO claims on donations
- PickupRequests - Volunteer pickup tasks
- Notifications - User notifications
See backend/STRUCTURE.md for detailed schema.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License.
- Setup Issues: Check
backend/QUICKSTART.md - API Questions: See
backend/API_TESTING.md - Integration Help: Read
FRONTEND_INTEGRATION.md - Deployment: Refer to
backend/DEPLOYMENT.md
β
Four user roles (Donor, NGO, Volunteer, Admin)
β
Secure authentication with password hashing
β
Role-based access control
β
Donation management with expiry validation
β
First-come-first-served claim system
β
Automatic pickup request generation
β
Multi-stage delivery tracking
β
Real-time notifications
β
Admin dashboard with analytics
β
Location tracking support
β
Production-ready code
Status: β Complete & Production Ready
Both frontend and backend are fully functional with all required features implemented.
Create a .env file (or copy .env.example) and set the required variables before running the apps. A root-level .env.example has been added with common values for local development.
Example variables (in .env or backend/.env and frontend/.env):
# Backend
MONGO_URI=mongodb://localhost:27017/foodshare
PORT=5001
JWT_SECRET=your_jwt_secret_here
# Frontend
NEXT_PUBLIC_API_URL=http://localhost:5001/api
NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000
A basic CI workflow has been added at .github/workflows/ci.yml. It runs on push to main and performs the following steps on Ubuntu runners:
- Checks out the code
- Installs dependencies for
frontendandbackend(usingnpm ci) - Runs
npm run lintin each package if alintscript exists
If you want tests to run in CI, add a test script to frontend/package.json and/or backend/package.json and update the workflow accordingly.
Made with β€οΈ for reducing food wastage and helping communities