# Delivery & Fleet Platform (Torbat Driver)

| Field | Value |
| --- | --- |
| Service | `delivery-service` |
| Database | `delivery_db` |
| Port | 8007 |
| Permission prefix | `delivery.*` |
| Version | 0.10.1.0 |
| Phase | 10.1 Driver Management |
| ADR | [ADR-015](../../../docs/architecture/adr/ADR-015.md) |

## Owns

- Delivery organizations, hubs, configuration/settings shells
- External provider / routing-engine **registrations** (adapters later)
- **Drivers**: profiles, lifecycle, credential/document refs, lifecycle history
- Delivery audit log + transactional outbox for driver events
- Health / capabilities / metrics discovery
- Publish-only `delivery.*` events

## Does not own

- Accounting journals / Posting Engine
- Communication SMS/email providers or message delivery timeline
- Loyalty ledger
- Vertical order aggregates (Hospitality, Marketplace, Store, Pharmacy, Clinic, Sports Center)
- Fleet / vehicles / dispatch / routing / tracking **engines** (later phases)
- Identity user admin / CRM contact master / Storage blobs
- Driver App / Dispatcher Panel UI (frontend)

## APIs

| Method | Path |
| --- | --- |
| GET | `/health` |
| GET | `/capabilities` |
| GET | `/metrics` |
| CRUD | `/api/v1/organizations` |
| CRUD | `/api/v1/hubs` |
| CRUD | `/api/v1/external-providers` |
| CRUD | `/api/v1/routing-engines` |
| CRUD | `/api/v1/configurations` |
| PUT/GET | `/api/v1/settings` |
| GET | `/api/v1/audit` |
| CRUD + lifecycle | `/api/v1/drivers` |
| GET | `/api/v1/permissions/catalog` |

## Run (dev)

```bash
export DELIVERY_DATABASE_URL=postgresql+asyncpg://...
export DELIVERY_DATABASE_URL_SYNC=postgresql+psycopg://...
python scripts/ensure_db.py
alembic upgrade head
uvicorn app.main:app --host 0.0.0.0 --port 8007 --reload
```

## Tests

```bash
pytest
```
