A WiFi billing system that allows users to purchase internet access via MPesa payments (STK Push). Ideal for cybercafés, small businesses, and public WiFi hotspots.
# Mpesa_Based-WiFi-Billing-System
A WiFi billing system that allows users to purchase internet access via MPesa payments (STK Push). Ideal for cybercafés, small businesses, and public WiFi hotspots.
**📌 FEATURES**
✅ MPesa STK Push Integration – Users pay directly from their phone via STK Push.
✅ Time-Based Access.
✅ Admin Dashboard – Track payments and manage users.
✅ MAC Address Whitelisting – Secure WiFi access via MikroTik integration.
**🛠️ TECH STACK**
Frontend: React + Tailwind CSS
Backend: Node.js + Express
Database: MySQL
Router Integration: MikroTik (MAC Address Whitelisting)
**🔧 INSTALLATION & SETUP**
1️⃣ Clone the repository
```bash
git clone
github.com
cd PROJECT_FOLDER
```
2️⃣ Install backend dependencies
```bash
npm install
```
3️⃣ Configure environment variables
Copy the template and edit the values for your local setup:
```bash
copy env.template .env
```
Then update `.env` with your database and API credentials. At minimum, set:
```env
DATABASE_URL="mysql:// : @localhost:3306/ "
JWT_SECRET=your_super_secret_jwt_key_here_minimum_32_chars
MPESA_ENV=sandbox
MPESA_CONSUMER_KEY=your_mpesa_consumer_key
MPESA_CONSUMER_SECRET=your_mpesa_consumer_secret
MPESA_SHORTCODE=your_mpesa_shortcode
MPESA_PASSKEY=your_mpesa_passkey
MPESA_CALLBACK_URL=
your-callback-url.ngrok.io
NEXT_PUBLIC_API_URL=
localhost
FRONTEND_ORIGIN=
localhost
```
> `DATABASE_URL` must point to your MySQL database. Example:
> `DATABASE_URL="mysql://root:password@localhost:3306/wifi_billing"`
## Fresh Database Setup (Crucial)
This project uses Prisma and requires the schema to be pushed to your MySQL database before use.
1. Ensure your MySQL database exists.
2. From the project root, run:
```bash
npx prisma db push
```
If you prefer migrations instead, you can also run:
```bash
npx prisma migrate dev --name init
```
### Admin users are NOT seeded automatically
A fresh d …