The Community Fridge App is a platform that connects food donors with NGOs to reduce food waste and help those in need. The application allows donors to post available food items and NGOs to claim these donations for distribution.
The project follows a client-server architecture:
- Backend: Node.js with Express.js and MongoDB
- Frontend: React.js with Vite build tool
- Secure signup and login system
- Role-based access (NGO and Donor)
- JWT-based authentication with secure HTTP-only cookies
- Automatic session validation
- Create food donation listings
- View and manage personal donations
- Track which NGOs have claimed donations
- Update or remove active donation listings
- Browse available food donations
- Claim donations for pickup
- Manage pickup schedule and history
- View donor information for coordination
- Responsive UI for mobile and desktop use
- Real-time updates on donation status
- Secure data handling and validation
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ORM
- Authentication: JWT with bcrypt password hashing
- Validation: Joi schema validation
- Deployment: Vercel Serverless Functions
- Library: React.js
- Build Tool: Vite
- Routing: React Router
- State Management: Context API with React Hooks
- UI Components: Custom components with CSS
- Special Effects: Custom animations and UI effects
- Path Aliasing:
@for src directory
- Node.js (v16 or higher)
- MongoDB account
- Git
-
Clone the repository
git clone https://github.com/mairohanhoon/Community-Fridge.git cd Community-Fridge/backend -
Install dependencies
npm install
-
Create a
.envfile in the backend directory with the following variables:MONGO_URL=your_mongodb_connection_string PORT=8080 JWT_SECRET=your_jwt_secret -
Start the development server
npm run dev
-
Navigate to the frontend directory
cd ../frontend -
Install dependencies
npm install
-
Create a
.envfile in the frontend directory with:VITE_API_URL=http://localhost:8080/api -
Start the development server
npm run dev
POST /api/auth/signup- Register a new userPOST /api/auth/login- User loginGET /api/auth/userLoggedIn- Check if user is authenticatedPOST /api/auth/logout- Logout user
POST /api/donor/donation- Create a new donationGET /api/donor/donations- Get all donationsGET /api/donor/mydonations/:id- Get donations by donor IDDELETE /api/donor/donation/:id- Delete a donation
POST /api/pickups/claim- Claim a donation for pickupGET /api/pickups/mypickups/:id- Get pickups by NGO ID
The application is configured for deployment on Vercel:
- Backend is deployed as serverless functions
- Frontend is deployed as a static site
- MongoDB Atlas is used for the database
- Password hashing with bcrypt
- JWT authentication with secure cookies
- Input validation with Joi
- CORS protection
- HTTP-only, secure cookies
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
- MongoDB for the database service
- Vercel for hosting
- All contributors to this project