Video Demo: https://youtu.be/prTN5PxmBTs
Nijenge is a web application to allow users to create crowdfunding campaigns and track donations.
- User authentication (register, login, logout)
- Create and manage crowdfunding campaigns
- Track donations and contributions
- View campaign contribution reports
- PDF export for contribution reports
- Mobile-friendly responsive design
- Flask
- SQLAlchemy
- SQLite
- Bootstrap
- Jinja
fundraising-platform
├── app.py
├── models.py
├── forms.py
├── api.py
├── static/
│ ├── css/
│ │ └── styles.css
│ ├── js/
│ │ ├── scripts.js
│ │ └── Toastr.js
│ └── assets/
│ └── logo.png
├── templates/
│ ├── layout.html
│ ├── index.html
│ ├── login.html
│ ├── register.html
│ ├── fundraiser.html
│ ├── fundraiser_success.html
│ └── report.html
├── migrations/
│ ├── alembic.ini
│ ├── env.py
│ ├── README
│ ├── script.py.mako
│ └── versions/
├── requirements.txt
├── README.md
├── tests/
│ ├── conftest.py
│ ├── test_app.py
│ └── test_api.py
├── venv/
└── .gitignore
app.py- Flask application factory and routesmodels.py- Database modelsforms.py- WTForms for validationapi.py- REST API endpoints
static/- CSS, JS, imagestemplates/- Jinja templatesmigrations/- Schema migration config and scriptstests/- pytest unit testsvenv/- Python virtual environment
The frontend uses Bootstrap for styling and layout. Additional JS libraries used:
- jQuery - For AJAX requests and DOM manipulation
- Toastr - For notification messages
- JSPDF - For generating PDF exports
The main frontend files are:
static/css/styles.css- Custom CSSstatic/js/scripts.js- Custom JS codetemplates/layout.html- Base layouttemplates/index.html- Homepagetemplates/login.html- Login pagetemplates/register.html- Registration pagetemplates/error.html- Error page
Frontend code handles:
- Navigation and layout
- Form submission and validation
- Displaying success/error messages (with Toastr)
- Logging in and out
- PDF report generation
The app uses built-in Flask sessions for authentication. Users can:
- Register a new account
- Log in to an existing account
- Log out
Passwords are hashed using werkzeug.security before storing in the database.
The @login_required decorator is used to protect views that require authentication.
The /fundraiser page allows users to create a new crowdfunding campaign.
They can enter:
- Name
- Description
- End date
- Target funds amount
This information is submitted to the /fundraiser endpoint which handles creation and saving the new campaign.
Once created, users are redirected to the campaign page.
/fundraiser_success/<id> displays the created campaign and allows updating contributions.
It shows:
- Name
- Description
- End date
- Target funds
There is a form to enter a contribution message text. This is used to extract details like the contribution amount and contributor name.
The data is submitted to the save_contribution API endpoint.
The response from the API is used to display a success or error notification.
To manually test creating and updating campaigns:
- Register a new account
- Go to
/fundraiserand create a new campaign - Enter any test data for the fields
- You'll be redirected to the campaign page
- Try submitting a few test contribution messages and verify if they are saved correctly
Some example contribution messages:
You have received Ksh 1,000.00 from John Doe 0722333333 on 12/12/22 at 3:30 PM
You have received Ksh 2,345.67 from Jane Doe 0733444444 on 31/12/22 at 12:00 PM
The endpoint parses these messages to extract the relevant details.
SQLAlchemy is used as the ORM for the SQLite database. The main models are:
User- To represent a user accountFundraiser- Crowdfunding campaigns created by usersContribution- Donations made to a fundraiser
Database relationships, queries, inserts and updates are defined in models.py.
The database uses SQLite and SQLAlchemy ORM.
The main tables are:
Stores user accounts.
Columns:
id- Primary keyusername- Unique usernamepassword- Hashed password
Stores fundraising campaigns created by users.
Columns:
id- Primary keyuser_id- Foreign key to users tablename- Name of fundraiserdescription- Longer descriptionend_date- Campaign end datetarget_funds- Fundraising target amount
Stores donations made to fundraisers.
Columns:
contribution_id- Primary keyfundraiser_id- Foreign key to fundraisers tablecontribution_reference- Payment reference codecontributor_name- Name of donorphone_number- Donor phone numberamount- Donation amountcontribution_date- Date of donationcontribution_time- Time of donationtimestamp- Timestamp of insertion
Schema migrations are handled using Alembic.
To run migrations:
# Initialize migration config
alembic init migrations
# Generate a new migration
alembic revision --autogenerate -m "Create user table"
# Run migrations
alembic upgrade head
This allows safely making schema changes and deploying updates.
The save_contribution endpoint provides a REST API to submit and save a new contribution via AJAX.
The response returns:
successorerrorstatus- message
- contribution data (if successful)
Frontend JS code handles calling this endpoint and displaying the response.
- Clone the repository
git clone https://github.com/Mur1thi/Nijenge.git
- Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Run the application
flask run
The app will be served at http://127.0.0.1:5000/
Register a new user account
Go to /register and enter a username and password.
Login
Go to /login and enter your credentials.
Create a campaign
Go to /fundraiser, fill out the form and submit.
View campaign contributions
Go to /report to see a paginated list of contributions.
Download contribution report
Click the "Download PDF" button on the /report page.
Automated tests using pytest.
Run tests:
pytest
requirements.txt- Python package dependencies.gitignore- Exclude files from GitREADME.md- Documentation