Finish PHV Rental Marketplace Backend

Job ID: 40444918

Budget: £20 – £250 GBP

PROJECT: ANI MOTORS – PRIVATE HIRE VEHICLE RENTAL MARKETPLACE + FLEET MANAGEMENT BACKEND

IMPORTANT:
This is NOT taxi dispatch.
This is NOT chauffeur booking.
This is NOT ride hailing.

This module is ONLY for private hire drivers renting PHV-ready vehicles weekly/monthly (Uber/Bolt style rental marketplace).

Frontend UI is already ~90% completed in Next.js from existing Figma implementation.

You MUST work with our existing internal team (frontend + backend developers) and continue on EXISTING codebase.

Tech stack:

* Next.js (App Router)
* MongoDB + Mongoose
* NextAuth
* Existing APIs partially started

DO NOT rebuild from scratch.

YOUR RESPONSIBILITY:
Complete backend architecture, APIs, business logic, MongoDB models, integrations, and frontend API connection.

CORE BUSINESS FLOW:
Pending driver:
Browse listings → Enquiry only

Approved driver:
Browse → Reserve → Deposit → Contract → Check-out → Active rental → Payments → PCNs → Return → Settlement

MODULES REQUIRED:

1. MASTER DATA
Configurable system masters:
vehicle categories, contract types, mileage packages, deposit types, document types, charge types, PCN types, payment statuses, compliance rules, licensing authorities, regions.

No hardcoding.

2. SUPPLIER MODULE
Supplier:

* company profile
* branches
* pickup locations
* vehicle management
* pricing
* documents
* contracts
* PCNs
* fleet dashboard

Admin:
approve/suspend suppliers.

3. VEHICLE / FLEET MANAGEMENT
Full PHV vehicle lifecycle:

* registration
* make/model
* VIN
* mileage
* MOT
* insurance
* PHV licence
* road tax
* service history
* photos
* assigned supplier
* assigned driver

Statuses:
draft / pending / available / reserved / on hire / maintenance / off-road / compliance hold / accident / inactive

Fleet tools:
availability calendar
maintenance records
damage history
contract history
PCNs
payments
check-in/out history

4. MARKETPLACE LISTINGS
Drivers browse PHV rental vehicles with filters:
price
deposit
licensing authority
location
vehicle type
insurance included
maintenance included
availability
mileage package

Pending drivers:
Enquiry only

Approved drivers:
Reserve/book

5. DRIVER ELIGIBILITY ENGINE
Match driver:
licence authority
age
experience
document validity
approval status

Example:
TfL driver only sees TfL compatible vehicles.

6. ENQUIRY MODULE
Pending drivers submit enquiry.
Fields:
name
phone
experience
start date
notes

Supplier receives masked contact details.
Super admin sees full details.

Statuses:
submitted / reviewing / supplier interested / approved / rejected / converted

7. BOOKING / RESERVATION
Approved drivers only.

Flow:
eligibility check
reserve vehicle
temporary lock
deposit payment
contract generation
supplier notification
admin notification

8. CONTRACT MANAGEMENT
Full rental lifecycle.

Contract states:
draft
generated
sent
signed
active
paused
upgraded
swapped
terminated
completed
defaulted

Must include:
rent
deposit
mileage
insurance
maintenance
late fees
PCN liability
damage liability
termination fees

Admin can edit/cancel/amend.

9. CHECK-IN / CHECK-OUT
Vehicle handover + return.

Capture:
mileage
fuel/battery
photos
existing damage
new damage
accessories
keys
cleanliness
driver signature
staff signature

System calculates:
damage
cleaning
missing keys
late return
excess mileage
deposit deductions

10. DAMAGE MANAGEMENT
damage reports
photos
estimates
liability
repair status
deposit deductions

11. MAINTENANCE / REPAIRS
service records
MOT due
tyres
breakdowns
bodywork
downtime
replacement vehicle logic

KwikBooking integration ready.

12. PCN MANAGEMENT
Critical module.

Track:
PCN ref
vehicle
driver
contract
authority
dates
amount
discount
deadline
appeal
status
admin fee

Logic:
If PCN happened during active rental → assign to driver.

13. PAYMENTS
Track:
deposit
weekly rent
monthly rent
insurance
maintenance
damage
PCNs
admin fees
refunds
termination fees

Statuses:
pending
paid
failed
overdue
partial
refunded

Driver dashboard:
due payments
history
receipts
disputes

14. RENT SCHEDULE / INVOICING
Auto create payment schedule from contract.

Example:
12 weeks @ £265
generate 12 invoices.

Early termination must cancel future invoices.

15. DEPOSIT LEDGER
Track:
paid
held
deductions
refund
forfeiture

16. VEHICLE SWAP / UPGRADE
Close old contract
check-in old car
check-out new car
recalculate rent
transfer deposit if approved

17. COMPLIANCE
Driver docs:
licence
PHV badge
proof of address

Vehicle docs:
insurance
MOT
PHV licence
V5C

Expiry alerts:
30/14/7 days

Expired docs = block booking/use.

18. SUPPLIER SETTLEMENTS
Revenue split:
supplier earnings
platform commission
deductions
refunds

19. NOTIFICATIONS
email + in-app
Events:
enquiry
approval
deposit
contract
payment due
payment failed
PCN
document expiry
contract ending

20. REPORTS
Admin:
fleet utilisation
arrears
supplier earnings
PCNs
damage
deposits
revenue
compliance risks

21. AUDIT LOGS
Track all actions:
bookings
payments
approvals
document changes
contracts
PCNs
check-ins

TECHNICAL EXPECTATIONS:

* clean architecture
* RBAC
* MongoDB models
* API validation
* audit middleware
* reusable service layer
* proper error handling
* standard API response structure
* work with existing Next.js codebase
* integrate with existing frontend
* Postman tested APIs

SUCCESS CRITERIA:
Working PHV marketplace + fleet management system end-to-end.

This is enterprise-grade, NOT basic CRUD.