# RideX

RideX is a hackathon MVP for the Africa's Talking Transport & Logistics Solutions Hackathon. It helps small logistics operators coordinate deliveries across customer, admin, rider, and tracking views while Africa's Talking SMS keeps customers informed.

## Winning Demo Angle

Small logistics teams often work with riders and customers who need simple status visibility. RideX presents the workflow as a real logistics story:

1. Customer creates a delivery request from Hotoro to Sabon Gari.
2. Admin sees the job in the dispatch queue and assigns a rider.
3. Rider accepts, marks pickup, and completes delivery.
4. Customer sees tracking progress and SMS logs.
5. Dashboard shows delivery status, timeline, and Africa's Talking balance.

## Hackathon API Coverage

- SMS API: automated customer and rider notifications, OTP alerts, and delivery-report callback.
- USSD API: offline rider workflow for accepting, picking up, and completing deliveries.
- Voice API: optional voice escalation route for urgent rider follow-up.
- Application Data API: live wallet balance on the dashboard.
- Insights API: optional SIM Swap risk check for rider/customer contact trust before sensitive itinerary updates.

Voice and Insights are disabled by default to avoid accidental paid calls/checks during practice. Enable them only when ready:

```ini
AT_VOICE_NUMBER=+234...
AT_ENABLE_PAID_ACTIONS=true
```

## Stack

- Laravel 13
- Vue 3
- Inertia.js
- Tailwind CSS
- MySQL
- Africa's Talking SMS, USSD callback, and Application Data API
- Optional Africa's Talking Voice and Insights hooks

## Setup

```bash
composer install
npm install
cp .env.example .env
php artisan key:generate
```

Create the database:

```bash
mysql -uroot --protocol=tcp -e "CREATE DATABASE IF NOT EXISTS dispatchtrack CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
```

Run migrations and seed demo data:

```bash
php artisan migrate:fresh --seed
```

Start the app:

```bash
php artisan serve --host=127.0.0.1 --port=8000
npm run dev -- --host 127.0.0.1 --port 5173
```

Open:

```text
http://127.0.0.1:8000
http://127.0.0.1:8000/customer
http://127.0.0.1:8000/rider
http://127.0.0.1:8000/track/KAN001
```

## Africa's Talking Config

Add these to `.env`:

```ini
AT_USERNAME=sandbox
AT_API_KEY=
AT_ENVIRONMENT=sandbox
AT_SENDER_ID=
AT_VOICE_NUMBER=
AT_ENABLE_PAID_ACTIONS=false
```

When `AT_API_KEY` is empty, SMS calls are logged instead of sent, so the dashboard can still be demoed locally.

## USSD Callback

Configure Africa's Talking USSD callback URL to:

```text
POST https://your-public-domain.test/ussd
```

Local test:

```bash
curl -X POST http://127.0.0.1:8000/ussd \
  -d "phoneNumber=+2348010000002&text=1"
```

Demo flow:

```text
text=""       -> Main menu
text="1"      -> Active deliveries
text="1*1"    -> Delivery actions
text="1*1*1"  -> Accept delivery
text="1*1*2"  -> Mark picked up and send OTP
text="1*1*3"  -> Prompt for OTP
text="1*1*3*123456" -> Complete delivery if OTP is valid
```

## Verification

```bash
npm run build
php artisan test
```
