A comprehensive moving and logistics application with integrated M-Pesa payments.
- π Driver Booking System: Book drivers for moving services
- π° M-Pesa Integration: Pay securely via M-Pesa Daraja API
- π€ User Dashboard: Track orders, manage wallet, view history
- π Driver Dashboard: Accept orders, manage earnings, track deliveries
- π¨βπΌ Admin Panel: Manage users, drivers, and support tickets
- π± Real-time Tracking: Monitor driver location and order status
- π³ Wallet System: Deposit, withdraw, and manage funds
- Python 3.8+ installed
- Node.js and npm installed
- M-Pesa Daraja API credentials (see setup guide below)
-
Install dependencies:
pip install flask flask-sqlalchemy flask-cors requests python-dotenv
-
Configure M-Pesa credentials:
- Copy
.env.exampleto.env - Add your Daraja API credentials (see DARAJA_SETUP_GUIDE.md)
- Copy
-
Start the backend:
python3 movers.py
Or:
python movers.py
-
Navigate to frontend directory:
cd moving-app-frontend -
Install dependencies:
npm install
-
Start the frontend:
npm start
The application will open at http://localhost:3000
This application uses the official Safaricom Daraja API for M-Pesa payments.
- Create Daraja Account: developer.safaricom.co.ke
- Get API Credentials: Consumer Key and Consumer Secret
- Configure
.env: Add your credentials - Set up Callback URL: Use ngrok for local testing
π Detailed Instructions: See DARAJA_SETUP_GUIDE.md
π Full Documentation: See MPESA_INTEGRATION.md
moving-app/
βββ movers.py # Backend Flask application
βββ instance/ # SQLite database
βββ .env # Environment variables (create from .env.example)
βββ .env.example # Environment variables template
βββ DARAJA_SETUP_GUIDE.md # Quick start guide for M-Pesa
βββ MPESA_INTEGRATION.md # Complete M-Pesa documentation
βββ moving-app-frontend/ # React frontend
βββ src/
β βββ components/ # React components
β β βββ user/ # User components (wallet, booking, etc.)
β β βββ driver/ # Driver components
β β βββ admin/ # Admin components
β β βββ auth/ # Authentication components
β βββ context/ # React context (auth, etc.)
βββ public/ # Static files
POST /api/register- Register new userPOST /api/login- User login
POST /api/mpesa/stk-push- Initiate M-Pesa paymentPOST /api/mpesa/callback- Handle M-Pesa callbackGET /api/mpesa/check-status/<transaction_id>- Check payment status
GET /api/user/<user_id>- Get user detailsGET /api/user/payment-history/<user_id>- Get transaction historyGET /api/user/order-history/<user_id>- Get order history
GET /api/driver/order-history/<driver_id>- Get driver ordersPOST /api/driver/toggle-availability- Toggle driver availability
POST /api/book-driver- Create new bookingPOST /api/driver/accept-order- Accept booking
- Use sandbox credentials from Daraja portal
- Test phone number: Any Kenyan number (e.g.,
0712345678) - Test amount: Any amount between KES 1 - 150,000
- The sandbox simulates STK Push without real money
# Start backend
python movers.py
# In another terminal, start ngrok
ngrok http 5000
# Copy the https URL and update MPESA_CALLBACK_URL in .envThe application creates a default admin account on first run:
- Email: admin@moving.com
- Password: admin123
- Flask: Python web framework
- SQLAlchemy: Database ORM
- SQLite: Database
- M-Pesa Daraja API: Payment processing
- Flask-CORS: Cross-origin resource sharing
- React: UI framework
- React Router: Navigation
- Axios: HTTP client
- Leaflet: Map integration
- React-Toastify: Notifications
Port already in use:
# Kill process on port 5000
lsof -ti:5000 | xargs kill -9Database errors:
# Recreate database
rm instance/moving_app.db
python movers.py"Failed to authenticate with M-Pesa API":
- Check Consumer Key and Secret in
.env - Ensure credentials are from the same app
"Callback not received":
- Verify ngrok is running
- Check callback URL is HTTPS
- Ensure URL is registered in Daraja portal
See MPESA_INTEGRATION.md for more troubleshooting tips.
Before deploying to production:
- β Get production Daraja credentials
- β Set up HTTPS domain
- β Configure production callback URL
- β Update environment variables
- β Set up database backups
- β Configure error monitoring
- β Add rate limiting
- β Test with real transactions
See production checklist in MPESA_INTEGRATION.md
- π M-Pesa Integration Guide
- π Daraja Setup Guide
- π Daraja API Docs
- π¬ Contact: digitalapi@safaricom.co.ke
This project is for educational purposes.
Contributions are welcome! Please create a pull request with your changes.
Enjoy using the Moving App! π