A role-based web platform where donors can post surplus food and NGOs can claim and collect it.
- Frontend: HTML, Tailwind CSS, Vanilla JavaScript
- Backend: Flask (Python)
- Database: MongoDB (PyMongo)
- Template Engine: Jinja2
- Web-based platform (currently no Android/iOS app)
- Username/password authentication with hashed passwords
- Role-based registration (
donororngo) - Session-based login management
- Protected routes with role checks
- Donor food listing CRUD and status workflow
- NGO filtering, claim flow, and receive confirmation
- Configurable billing workflow with invoice generation for claimed/collected listings
- Donor and NGO invoice view + print pages with access control
- Configurable donation pricing rule (
> 0by default, optional>= 0) - Two-way in-app messaging between donor and NGO
- Project-only chatbot with API key auto-rotation
- Flash messages for success/error feedback
- Responsive UI with donor (green) and NGO (blue) themes
.
├── app.py
├── config.py
├── requirements.txt
├── .env
├── static/
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── app.js
└── templates/
├── base.html
├── auth/
│ ├── login.html
│ └── register.html
├── donor/
│ ├── dashboard.html
│ └── add_food.html
└── ngo/
├── dashboard.html
└── claim_food.html
usernamepassword(hashed)roleorganization_namelocationcontactcreated_at
donor_idfood_namequantitydonation_price(required, low-cost donation rate per unit)expirylocationdescriptioncategorystatus(available,claimed,collected)claimed_bycreated_at
sender_idrecipient_idsender_rolerecipient_rolelisting_id(optional)messageis_readcreated_at
invoice_number(unique)listing_iddonor_idngo_idfood_namequantityunit_pricesubtotaltaxtotalcurrencystatuscreated_at
- Open terminal and move to project folder:
cd E:\folder\peanuts\ceosus\fwd
- Create and activate virtual environment:
python -m venv .venv # Windows PowerShell .\.venv\Scripts\Activate.ps1
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables in
.env:SECRET_KEY=replace-with-a-strong-secret-key # Option A: Full URI MONGO_URI=mongodb://localhost:27017 MONGO_DB_NAME=foodwaste_db # Option B: Split Mongo Atlas values MONGO_USERNAME=your_username MONGO_PASSWORD=your_password MONGO_CLUSTER=cluster0.xxxxx.mongodb.net MONGO_DATABASE=foodwaste_db # Billing feature toggle BILLING_ENABLED=true # Donation price business rule # false (default): price must be > 0 # true: price can be 0 or greater DONATION_PRICE_ALLOW_ZERO=false # Chatbot keys (any of these names are supported) FWD_API_KEY_1=your_key_1 FWD_API_KEY_2=your_key_2 FWD_API_KEY_3=your_key_3 # Alternate key names also supported fwd_1_api=your_key_1 fwd_2_api=your_key_2 fwd_3_api=your_key_3
- Ensure MongoDB is running locally (Option A) or configure Atlas credentials (Option B).
- Run the Flask app:
python app.py
- Open in browser:
http://127.0.0.1:5000
/register-> Create donor or NGO account/login-> Authenticate user- Donor ->
/donor/dashboard - NGO ->
/ngo/dashboard - Billing -> NGO can generate from claimed/collected listing; donor and NGO can open
/invoices/<invoice_id> - Authenticated users ->
/chatbotfor project-restricted Q&A
- Turn on with
BILLING_ENABLED=true. - NGO users can generate invoices only for their claimed/collected listings.
- Invoice actions appear in NGO dashboard/claim pages and donor dashboard when invoice exists.
- Both linked donor and NGO can view and print invoice pages.
- Billing routes:
POST /ngo/food/<listing_id>/invoiceGET /invoices/<invoice_id>GET /invoices/<invoice_id>/print
The project now includes test coverage at four levels using pytest and an in-memory Mongo mock.
pip install -r requirements-test.txtValidates pure functions and small isolated logic.
pytest tests/unitValidates module interactions such as auth flow and session behavior.
pytest tests/integrationValidates full workflow across major modules (donor listing -> NGO claim -> received).
pytest tests/systemValidates user-story behavior from an end-user point of view.
pytest tests/acceptancepytest- Passwords are hashed using Werkzeug.
- Sessions use Flask secret key.
- Route decorators enforce authentication and role authorization.
The chatbot is now grounded with an FWD-relevant dataset stored at data/fwd_chatbot_dataset.json.
This dataset is used as runtime knowledge context so responses stay aligned with the current FWD web application.
| Intent | What it teaches the chatbot |
|---|---|
| Platform Scope | FWD is web-based only, no app-store flow |
| Account Creation | Register flow and role selection |
| Login | Username/password web login and dashboard redirect |
| Registration Fields | Required registration fields in current build |
| Donor Listing | How donors create listings |
| Donation Pricing | Low-cost donation model (not free) |
| Billing Availability | Billing depends on feature toggle |
| Invoice Generation | NGO can generate bill for eligible listings |
| Invoice Access | Donor and NGO access rules for invoice pages |
| Invoice Navigation | Where to find generate/view/print actions |
| Invoice Contents | What fields are included in invoice |
| NGO Claim Flow | NGO claim steps and availability workflow |
| Collection Status | Status transitions (available -> claimed -> collected) |
| Messaging | In-app donor/NGO conversation support |
| Map and Distance | Address search, map pinning, distance guidance |
| Chatbot Scope | Project-only support behavior |
| Notifications | Current web limitations for push/email app notifications |
| Acknowledgement Handling | Context-aware replies for short turns like okay/thanks |
| Greeting Handling | FWD-specific welcome replies (not generic resets) |
- Platform Scope: "FWD is currently web-based only..."
- Account Creation: "Register page -> role -> username/password/org/location/contact"
- Login: "Username/password login routes to role dashboard"
- Registration Fields: "Current required fields and no app-download step"
- Donor Listing: "Add food with quantity, price, expiry, location"
- Donation Pricing: "Low-cost donation pricing (default > 0, optional config allows 0)"
- Billing Availability: "Billing works when BILLING_ENABLED is enabled"
- Invoice Generation: "NGO can generate invoices for claimed/collected listings"
- Invoice Access: "Donor and NGO can open linked invoices only"
- Invoice Navigation: "Dashboards expose generate/view/print bill actions"
- Invoice Contents: "Invoice includes number, quantities, pricing totals, and party details"
- NGO Claim Flow: "Browse available listings and claim"
- Collection Status: "available -> claimed -> collected"
- Messaging: "Two-way in-app donor/NGO messaging"
- Map and Distance: "Map pin, address suggestions, distance/ETA guidance"
- Chatbot Scope: "FWD-only questions"
- Notifications: "No native app push in current web build"
- Acknowledgement Handling: "Short acknowledgements return FWD-specific next-help options"
- Greeting Handling: "Greetings return FWD workflow-focused support guidance"
- Current implementation uses grounding (dataset-backed context injection) per question.
- This avoids hallucinations like app-store/email-login instructions that do not match FWD.
- If you want full model fine-tuning later, this same dataset can be exported to JSONL instruction format.
- Add CSRF protection with Flask-WTF
- Add pagination and richer analytics
- Add SMS or WhatsApp notifications for claims
- Add expiry alerts and scheduled cleanup jobs
You can temporarily show a "Coming Soon" page for the deployed site while backend updates are in progress.
Set this environment variable in deployment:
MAINTENANCE_MODE=trueWhen enabled:
- Most routes return the maintenance page.
- Static assets and legal/contact pages stay reachable.
- You can also open
/coming-soondirectly.
To restore normal site behavior, set:
MAINTENANCE_MODE=false