A modern, responsive donation platform built with SvelteKit that enables well-wishers to donate anonymously to various social projects through M-Pesa mobile money integration. The platform includes a secure admin interface to track donations and manage projects.
Clone the repository:
git clone <repository-url>
cd svelte-donation-platform
Install dependencies:
npm install
Create a .env
file in the root directory:
```env
MONGODB_URI=mongodb://localhost:27017/donation-platform
MPESA_CONSUMER_KEY=your_mpesa_consumer_key MPESA_CONSUMER_SECRET=your_mpesa_consumer_secret MPESA_PASSKEY=your_mpesa_passkey MPESA_SHORTCODE=174379 MPESA_CALLBACK_URL=https://yourdomain.com/api/mpesa/callback
JWT_SECRET=your_jwt_secret_key ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=your_admin_password
NODE_ENV=development
4. Seed the database with sample projects:
```bash
npm run seed
Start the development server:
npm run dev
Visit http://localhost:5173
in your browser
Method | Endpoint | Description |
---|---|---|
GET | /api/projects |
Fetch all projects |
POST | /api/projects |
Create new project (admin only) |
POST | /api/mpesa/stk-push |
Initiate M-Pesa payment |
POST | /api/mpesa/callback |
Handle M-Pesa confirmation |
GET | /api/donations |
Get donations (admin only) |
POST | /api/admin/login |
Admin login |
POST | /api/admin/logout |
Admin logout |
GET | /api/admin/stats |
Get dashboard statistics |
/admin/login
.env
filesrc/
|-- routes/
| |-- +layout.svelte # Main layout
| |-- +page.svelte # Homepage with projects
| |-- donate/+page.svelte # Donation form
| |-- admin/ # Admin interface
| |-- api/ # API endpoints
|-- lib/
| |-- components/ # Reusable components
| |-- db/ # Database configuration
| |-- models/ # Database models
| |-- utils/ # Utility functions
| |-- scripts/ # Seed scripts
|-- app.html # App template
Make sure to set all required environment variables in your deployment platform:
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions, please open an issue in the repository or contact the maintainers.