A Flask web application for managing youth delegate registrations with M-Pesa payment integration.
- Authentication System - Login for Chairs, Finance, and Admins
- Delegate Registration - Register delegates with church details
- M-Pesa Integration - Daraja API for seamless payments via STK Push
- Admin Dashboard - Overview with statistics, reports, and exports
- Export Reports - Excel and PDF export functionality Responsive Design - Bootstrap 5 for mobile-friendly interface
- Backend: Flask (Python)
- Database: SQLAlchemy (SQLite/PostgreSQL)
- Frontend: Bootstrap 5, Jinja2 Templates
- Payment: M-Pesa Daraja API
- Authentication: Flask-Login
KAYO/
├── app/
│ ├── __init__.py # Flask app factory
│ ├── forms.py # WTForms definitions
│ ├── models/
│ │ ├── __init__.py
│ │ ├── user.py # User model
│ │ ├── delegate.py # Delegate model
│ │ └── payment.py # Payment model
│ ├── routes/
│ │ ├── __init__.py
│ │ ├── auth.py # Authentication routes
│ │ ├── main.py # Main dashboard routes
│ │ ├── delegates.py # Delegate management
│ │ ├── payments.py # Payment processing
│ │ └── admin.py # Admin routes
│ ├── services/
│ │ ├── __init__.py
│ │ └── mpesa.py # M-Pesa Daraja API
│ └── templates/
│ ├── base.html
│ ├── dashboard.html
│ ├── auth/
│ ├── delegates/
│ ├── payments/
│ └── admin/
├── config.py # Configuration
├── run.py # Entry point
├── init_db.py # Database initialization
├── requirements.txt
├── .env.example # Environment template
└── README.md
-
Clone the repository
git clone https://github.com/yourusername/KAYO.git cd KAYO -
Create a virtual environment
python -m venv venv # Windows venv\Scripts\activate # Linux/Mac source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env with your settings -
Initialize the database
python init_db.py
-
Run the application
python run.py
-
Open in browser
http://localhost:5000
- contact for deatils
- Register at Safaricom Developer Portal
- Create an app and get your credentials
- Update
.envwith your M-Pesa credentials:MPESA_CONSUMER_KEY=your-consumer-key MPESA_CONSUMER_SECRET=your-consumer-secret MPESA_SHORTCODE=your-paybill-number MPESA_PASSKEY=your-passkey MPESA_CALLBACK_URL=https://yourdomain.com/payments/callback MPESA_ENV=sandbox # or 'production'
For production with PostgreSQL:
-
Update
DATABASE_URLin.env:DATABASE_URL=postgresql://username:password@localhost/kayo_db -
Initialize migrations:
flask db init flask db migrate -m "Initial migration" flask db upgrade
- Upload project to PythonAnywhere
- Set up virtual environment
- Configure WSGI file to point to
run.py - Set environment variables in PythonAnywhere console
- Ensure M-Pesa callback URL is accessible
- Register an account with your church details
- Log in to access your dashboard
- Register delegates using the form
- Once done, initiate payment for all unpaid delegates
- Complete M-Pesa payment via STK Push
- Log in with admin credentials
- View overall statistics on dashboard
- Manage users (create, edit, deactivate)
- View all delegates with filters
- Export reports to Excel or PDF
- Monitor payment status
| Endpoint | Method | Description |
|---|---|---|
/login |
GET, POST | User login |
/register |
GET, POST | User registration |
/dashboard |
GET | User dashboard |
/delegates/register |
GET, POST | Register delegate |
/delegates/ |
GET | List delegates |
/payments/ |
GET | Payment page |
/payments/initiate |
POST | Initiate M-Pesa payment |
/payments/callback |
POST | M-Pesa callback |
/admin/ |
GET | Admin dashboard |
/admin/export/delegates |
GET | Export to Excel |
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License.
For support, email monsieuraloo@gmail.com or create an issue on GitHub.