The Food Sharing Platform is a web application that aims to connect individuals and businesses with surplus food to those in need. The platform provides a convenient way for users to donate excess food items or request meals, facilitating the coordination, pickup, and delivery of the food. It also incorporates features like nutritional information and allergy alerts to ensure the safety and suitability of the donated food!
- Donation: Users can easily create listings for surplus food items they wish to donate. They can provide details such as the type of food, quantity, expiration date, and pickup location.
- Request: Users in need of meals can create requests specifying their dietary preferences, allergies, and location.
- Coordination: The platform provides a messaging system to facilitate communication between donors and recipients. Users can arrange pickup details, clarify any questions, and coordinate the delivery of food.
- Nutritional Information: Donors can provide nutritional information for their food items, enabling recipients to make informed decisions based on their dietary requirements.
- Allergy Alerts: Users can specify their allergies or dietary restrictions, and the platform will notify them if a donation or request contains any potential allergens.
- User Profiles: Users can create and manage their profiles, providing information such as their location, dietary preferences, and allergies. This helps personalize the donation and request matching process.
- Backend: Django, Django REST Framework
- Frontend: React
- Database: MySQL
- Other Technologies: HTML, CSS, JavaScript, Axios (for API requests)
The step-by-step process to create a folder, set up the project, and execute it using pnpm.
Step 1: Create a Folder and Set Up the Django Project
- Create a new folder for your project:
mkdir food-sharing-platform
- Change into the project directory:
cd food-sharing-platform
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
- For Windows:
venv\Scripts\activate
- For macOS/Linux:
source venv/bin/activate
- For Windows:
- Install Django and Django REST Framework:
pip install django djangorestframework
- Start a new Django project:
django-admin startproject backend .
- Create a new Django app:
python manage.py startapp api
- Update the
backend/settings.py
file:- Add
'api'
to theINSTALLED_APPS
list. - Update the
DATABASES
configuration to use MySQL.
- Add
Step 2: Set Up the React Frontend
- Open a new terminal window and navigate to the project folder (
food-sharing-platform
). - Initialize a new React project:
npx create-react-app frontend
- Change into the frontend directory:
cd frontend
- Install the required packages:
- React Router:
pnpm install react-router-dom
- Axios:
pnpm install axios
- Tailwind CSS:
pnpm install tailwindcss
- React Router:
- Replace the content of the
src/App.js
file with the updated code provided below. - Replace the content of the
src/index.js
file with the updated code provided below. - Replace the content of the
src/index.css
file with the updated code provided below. - Create a new file
src/tailwind.css
with the following content:
@import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities';
- Update the
src/index.js
file to include the import statement for thetailwind.css
file:
import './index.css'; import './tailwind.css';
Step 3: Update the Django Backend Code
- Replace the content of the
backend/models.py
file with the updated code provided below. - Replace the content of the
backend/serializers.py
file with the updated code provided below. - Replace the content of the
backend/views.py
file with the updated code provided below.
Step 4: Create the React Components
- Replace the content of the
src/App.js
file with the updated code provided below.
Step 5: Run the Development Servers
- In one terminal window, navigate to the project folder (
food-sharing-platform
). - Activate the virtual environment:
- For Windows:
venv\Scripts\activate
- For macOS/Linux:
source venv/bin/activate
- For Windows:
- Start the Django development server:
python manage.py runserver
- In another terminal window, navigate to the frontend folder (
food-sharing-platform/frontend
). - Start the React development server:
pnpm start
Now you can access the Food Sharing Platform application in your browser at http://localhost:3000
.
- Clone the repository:
git clone https://github.com/THARAGESHWARAN-SATHYAMOORTHY/foodsharing-platform
- Install the necessary dependencies for the backend and frontend.
- Set up the PostgreSQL database and configure the database settings.
- Run the backend server:
python manage.py runserver
- Run the frontend development server:
pnpm start
- Access the application in your browser at
http://localhost:3000
-
React Configuration: Configuring React and its dependencies correctly can be a challenge, especially when dealing with conflicting packages or outdated versions. It's important to ensure that the required dependencies are installed and properly configured.
-
React Router: Setting up routes and handling navigation within the React application can be tricky. Common issues include incorrect route configuration, rendering components outside of
<Routes>
, or using<Route>
directly instead of wrapping it within<Routes>
. -
React Components: Errors related to rendering components, such as the
Route
component, can occur due to incorrect usage or improper nesting within the component tree. It's important to follow the correct structure and hierarchy while rendering components. -
Module Dependencies: Errors related to missing or conflicting module dependencies can occur during both frontend (React) and backend (Django) development. These issues can be resolved by ensuring that the required packages are installed and configured correctly, and that there are no conflicting versions or dependencies.
-
Backend Configuration: Configuring the backend (in this case, Django) properly is crucial for the overall functionality of the food sharing platform. Common issues include database configuration errors, missing or incorrect module installations, and improper API endpoint setup.
-
Server-Side Errors: Server-side errors can occur when handling requests and processing data. These errors can be related to database connectivity, improper API endpoint setup, or missing libraries such as
mysqlclient
in the case of MySQL database integration. -
Network Requests: Errors related to network requests, such as failed resource loading or 404 responses, can occur when interacting with APIs or fetching data from the server. These errors can be caused by incorrect URLs, missing or incorrect request parameters, or server-side issues.
When creating a food sharing platform, it's important to thoroughly test the application, handle errors gracefully, and troubleshoot any issues that arise. This may involve checking logs, debugging code, and ensuring proper configuration and dependencies on both the frontend and backend sides.
Youtube : https://youtu.be/d1FUS0wDLr0
- Integration with third-party delivery services for seamless pickup and delivery.
- Implementing a rating and review system to establish trust and reputation among users.
- Social media sharing features to raise awareness and encourage more donations.
- Gamification elements to incentivize and reward users for their contributions to reducing food waste.
email : [email protected]
Feel free to customize and expand this project.