This is a Flask-based web application for managing user donations and articles. It allows users to create accounts, make cash or food donations, write articles, and view their donation and article history. The application uses SQLAlchemy to interact with a SQLite database.
Follow these steps to get the Flask application up and running:
-
Clone the repository to your local machine:
git clone git@github.com:kipngenohaaron/Python_NourishNow_Project.git cd Python_NourishNow_Project
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use "venv\Scripts\activate"
-
Install the required dependencies:
pip install -r requirements.txt
-
Initialize the SQLite database:
flask db init flask db migrate flask db upgrade
-
Start the Flask application:
flask run
-
Access the application in your web browser at
http://localhost:5000
.
- User registration and authentication.
- Cash and food donation functionality.
- Article creation and retrieval.
- Viewing user donation and article history.
- A simple home page.
/
(Home Page)/signUp
(User Registration)/signIn
(User Authentication)/donateFunds/<int:id>
(Add Cash Donation)/donateFood/<int:id>
(Add Food Donation)/userDonations/<int:id>
(View User's Donations)/articles
(Create Article)/articles/user/<int:user_id>
(View User's Articles)/articles/<int:article_id>
(View Specific Article)
id
(Primary key and unique identifier)name
(User's name)email
(User's email address, unique)password
(User's password)- Relationships:
donations
(One-to-many relationship withDonation
model)articles
(One-to-many relationship withArticle
model)
id
(Primary key and unique identifier)user_id
(Foreign key referencing theUser
model)type
(Type of donation, e.g., "Cash" or "Food")amount
(Donation amount or quantity)date
(Date and time of the donation, defaulting to the current UTC time)
id
(Primary key and unique identifier)user_id
(Foreign key referencing theUser
model)author
(Author's name, can be the same as the user's name)title
(Title of the article)body
(Content of the article as text)
To add a user to your Flask application, send a POST request to the /signUp
endpoint. Here's an example using Postman:
-
Open Postman.
-
Create a new request by clicking the "New" button.
-
Choose the HTTP request type as "POST."
-
Set the request URL to
http://localhost:5000/signUp
. -
Add a request header:
- Key:
Content-Type
- Value:
application/json
- Key:
-
In the request body, provide JSON data with the user's registration information. For example:
{ "name": "Kipngenoh", "email": "kipngenohaaron@gmail.com", "password": "secret_password" }
-
Click the "Send" button.
-
Postman will display the response from your Flask application, including details of the newly registered user, such as the user ID, name, and email.
To add a cash donation to your Flask application, send a POST request to the /donateFunds/<int:id>
endpoint. Here's an example using Postman:
-
Open Postman.
-
Create a new request by clicking the "New" button.
-
Choose the HTTP request type as "POST."
-
Set the request URL to an appropriate endpoint for adding cash donations, such as
http://localhost:5000/donateFunds/1
(Replace1
with the desired user ID). -
Add a request header:
- Key:
Content-Type
- Value:
application/json
- Key:
-
In the request body, provide JSON data with the cash donation amount. For example:
{ "amount": 100 }
-
Click the "Send" button.
-
Postman will display the response from your Flask application, including details of the cash donation, such as the donation ID, user ID, type (Cash), donation amount, and date.
To add a food donation to your Flask application, send a POST request to the /donateFood/<int:id>
endpoint. Here's an example using Postman:
-
Open Postman.
-
Create a new request by clicking the
"New" button.
-
Choose the HTTP request type as "POST."
-
Set the request URL to an appropriate endpoint for adding food donations, such as
http://localhost:5000/donateFood/2
(Replace2
with the desired user ID). -
Add a request header:
- Key:
Content-Type
- Value:
application/json
- Key:
-
In the request body, provide JSON data with the food donation details, including the number of food items. For example:
{ "amount": 10 }
-
Click the "Send" button.
-
Postman will display the response from your Flask application, including details of the food donation, such as the donation ID, user ID, type (Food), donation amount (number of food items), and date.
You can use Postman to simulate user interactions with your Flask application's donation features by sending POST requests with different user IDs and donation amounts as needed.
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or create a pull request.
Email Address: kipngenohaaron@gmail.com
This project is licensed under the MIT License - see the LICENSE file for details.