A Laravel 11 RESTful API backend for connecting food donors (supermarkets, restaurants) with receivers (charities, orphanages, low-income families) to minimize food waste and fight hunger in Uganda.
- Laravel Passport Authentication - OAuth2-based API authentication
- Role-Based Access Control - Donor, Receiver, and Admin and (Donor-Receiver) roles
- Donation Management - Create, update, and manage food donations
- Claiming System - Receivers can claim donations with approval workflow
- Location-Based Matching - Find nearby donations using geo-filtering (surplus to requirements)
- Campaign Management - Create and manage awareness campaigns (removed)
- Admin Analytics - Reports and statistics for monitoring activities
- PHP 8.2+
- Composer
- MySQL or PostgreSQL (SQLite for development)
- Laravel 11
- Clone the repository
git clone https://github.com/IsaacJM03/Year-3-Capstone-Project.git
cd Year-3-Capstone-Project- Install dependencies
composer install- Configure environment
cp .env.example .env
php artisan key:generate- Configure database
Edit
.envfile with your database credentials:
DB_CONNECTION=sqlite
# Or for MySQL/PostgreSQL
# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=dra
# DB_USERNAME=root
# DB_PASSWORD=- Run migrations
php artisan migrate- Install Passport
php artisan passport:keys
php artisan passport:client --personal --name="DRA Personal Access Client"- Seed the database (optional)
php artisan db:seedThis will create:
- 1 admin user
- 3 donor users
- 3 receiver users
- 5 sample donations
- 2 sample campaigns
After seeding, you can use these accounts:
Admin:
- Email: admin@dra.com
- Password: password
Donors:
- donor1@dra.com / password
- donor2@dra.com / password
- donor3@dra.com / password
Receivers:
- receiver1@dra.com / password
- receiver2@dra.com / password
- receiver3@dra.com / password
http://localhost:8000/api/v1
POST /api/v1/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"role": "donor",
"phone": "0700000000",
"address": "Kampala, Uganda",
"organization": "Supermarket Ltd"
}POST /api/v1/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "password123"
}GET /api/v1/user
Authorization: Bearer {token}POST /api/v1/logout
Authorization: Bearer {token}POST /api/v1/donations
Authorization: Bearer {token}
Content-Type: application/json
{
"title": "Fresh Bread",
"description": "End of day bread and pastries",
"category": "Bakery",
"quantity": 50,
"unit": "packs",
"expiry_date": "2025-10-20",
"pickup_location": "Kampala Road, Kampala",
"latitude": 0.3476,
"longitude": 32.5825,
"image_url": "https://example.com/image.jpg"
}GET /api/v1/donations
Authorization: Bearer {token}GET /api/v1/donations/{id}
Authorization: Bearer {token}PUT /api/v1/donations/{id}
Authorization: Bearer {token}
Content-Type: application/json
{
"status": "available",
"quantity": 40
}DELETE /api/v1/donations/{id}
Authorization: Bearer {token}GET /api/v1/donations/nearby?lat=0.3476&lng=32.5825&radius=5
Authorization: Bearer {token}POST /api/v1/claims
Authorization: Bearer {token}
Content-Type: application/json
{
"donation_id": 1,
"pickup_time": "2025-10-15 14:00:00",
"notes": "Will pick up in the afternoon"
}GET /api/v1/claims
Authorization: Bearer {token}PUT /api/v1/claims/{id}/approve
Authorization: Bearer {token}PUT /api/v1/claims/{id}/deliver
Authorization: Bearer {token}POST /api/v1/campaigns
Authorization: Bearer {token}
Content-Type: application/json
{
"title": "Feed 100 Families",
"description": "Help us raise funds to feed 100 families",
"goal_amount": 5000,
"deadline": "2025-12-31"
}GET /api/v1/campaigns
Authorization: Bearer {token}GET /api/v1/campaigns/{id}
Authorization: Bearer {token}POST /api/v1/campaigns/{id}/donate
Authorization: Bearer {token}
Content-Type: application/json
{
"amount": 100
}GET /api/v1/admin/reports/summary
Authorization: Bearer {admin-token}GET /api/v1/admin/reports/donations-per-category
Authorization: Bearer {admin-token}All API responses follow this standard format:
{
"success": true,
"message": "Operation successful",
"data": {}
}Run the test suite:
php artisan testRun specific tests:
php artisan test --filter AuthenticationTest
php artisan test --filter DonationTestapp/
βββ Http/
β βββ Controllers/
β β βββ API/
β β βββ V1/
β β βββ AuthController.php
β β βββ DonationController.php
β β βββ ClaimController.php
β β βββ CampaignController.php
β β βββ AdminController.php
β βββ Middleware/
β β βββ AdminMiddleware.php
β βββ Requests/
β βββ Resources/
βββ Models/
β βββ User.php
β βββ Donation.php
β βββ DonationClaim.php
β βββ Campaign.php
database/
βββ factories/
β βββ UserFactory.php
β βββ DonationFactory.php
β βββ DonationClaimFactory.php
β βββ CampaignFactory.php
βββ migrations/
β βββ *_create_users_table.php
β βββ *_add_role_and_fields_to_users_table.php
β βββ *_create_donations_table.php
β βββ *_create_donation_claims_table.php
β βββ *_create_campaigns_table.php
βββ seeders/
βββ DatabaseSeeder.php
routes/
βββ api.php
tests/
βββ Feature/
β βββ AuthenticationTest.php
β βββ DonationTest.php
βββ Unit/
- Framework: Laravel 11
- Authentication: Laravel Passport (OAuth2)
- Database: MySQL/PostgreSQL/SQLite
- ORM: Eloquent
- Testing: PHPUnit
- API: RESTful with JSON responses
- id, name, email, password
- role (donor, receiver, admin)
- phone, address, organization
- verified (boolean)
- id, donor_id, title, description
- category, quantity, unit
- expiry_date, status
- pickup_location, latitude, longitude
- image_url
- id, donation_id, receiver_id
- claim_status (pending, approved, rejected, delivered)
- pickup_time, notes
- id, title, description, creator_id
- goal_amount, raised_amount
- deadline, status
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is open-source and available under the MIT License.
For support, email support@dra.com or create an issue in the repository.