Skip to content

mairohanhoon/Community-Fridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Community-Fridge App

Overview

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.

Project Structure

The project follows a client-server architecture:

  • Backend: Node.js with Express.js and MongoDB
  • Frontend: React.js with Vite build tool

Features

User Authentication

  • Secure signup and login system
  • Role-based access (NGO and Donor)
  • JWT-based authentication with secure HTTP-only cookies
  • Automatic session validation

Donor Features

  • Create food donation listings
  • View and manage personal donations
  • Track which NGOs have claimed donations
  • Update or remove active donation listings

NGO Features

  • Browse available food donations
  • Claim donations for pickup
  • Manage pickup schedule and history
  • View donor information for coordination

General Features

  • Responsive UI for mobile and desktop use
  • Real-time updates on donation status
  • Secure data handling and validation

Technology Stack

Backend

  • 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

Frontend

  • 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

Installation and Setup

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB account
  • Git

Backend Setup

  1. Clone the repository

    git clone https://github.com/mairohanhoon/Community-Fridge.git
    cd Community-Fridge/backend
  2. Install dependencies

    npm install
  3. Create a .env file in the backend directory with the following variables:

    MONGO_URL=your_mongodb_connection_string
    PORT=8080
    JWT_SECRET=your_jwt_secret
    
  4. Start the development server

    npm run dev

Frontend Setup

  1. Navigate to the frontend directory

    cd ../frontend
  2. Install dependencies

    npm install
  3. Create a .env file in the frontend directory with:

    VITE_API_URL=http://localhost:8080/api
    
  4. Start the development server

    npm run dev

API Routes

Authentication

  • POST /api/auth/signup - Register a new user
  • POST /api/auth/login - User login
  • GET /api/auth/userLoggedIn - Check if user is authenticated
  • POST /api/auth/logout - Logout user

Donations

  • POST /api/donor/donation - Create a new donation
  • GET /api/donor/donations - Get all donations
  • GET /api/donor/mydonations/:id - Get donations by donor ID
  • DELETE /api/donor/donation/:id - Delete a donation

Pickups

  • POST /api/pickups/claim - Claim a donation for pickup
  • GET /api/pickups/mypickups/:id - Get pickups by NGO ID

Deployment

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

Security Features

  • Password hashing with bcrypt
  • JWT authentication with secure cookies
  • Input validation with Joi
  • CORS protection
  • HTTP-only, secure cookies

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License.

Acknowledgements

  • MongoDB for the database service
  • Vercel for hosting
  • All contributors to this project

About

Sustainable Food Sharing Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published