# Jobnixy Admin Modules

The admin portal implements the Jobnixy vision document (phases 1–8). It has two kinds of modules:

1. **Hand-built modules** in `app/Modules/{Module}` for screens with bespoke UX.
2. **Resource modules** declared in `app/Admin/Resources/*Resource.php` and served by one generic
   controller (`App\Modules\Core\Controllers\ResourceController`) with shared views in
   `resources/views/admin/resource`.

```
app/Modules/
├── Auth/        Staff authentication
├── Dashboard/   Command Center
├── Reports/     Skill Demand Map (demand vs verified supply per city & skill)
├── Users/       Platform users
├── Skills/      Skills
├── Categories/  Skill categories
├── Jobs/        Job operations + GeoMatch + fair-price estimate
├── Reviews/     Ratings moderation (star ratings)
├── Staff/       RBAC staff management
├── Audit/       Immutable audit trail
├── Settings/    Platform settings
└── Core/        Generic ResourceController
```

## Resource modules (`App\Admin\ResourceRegistry`)

| Sidebar section | Modules |
| --- | --- |
| People | Identity / KYC, Professionals (Career Passport), Agents, Agent ↔ Worker splits, Agencies, Addresses |
| Operations | Match candidates, Bids, Offers, Contracts, Milestones, Change orders, Job sessions (GPS), Evidence, Disputes |
| Protection | Warranty claims, Safety / SOS incidents, Support cases, Notifications (SMS/push/USSD) |
| Finance | Wallets, Ledger, Escrow, Payments, Payouts (risk-assessed), Commissions, WorkCards |
| Trust & Security | Risk Center, Trust Scores, Device trust, Security events |
| Professional Economy | Certifications, Portfolio, Academy courses, Enrollments, Apprenticeships |
| Trade | Suppliers, Storefronts, Products, Trade orders, Material requests |
| Enterprise | Projects, Workforce plan, Assignments, Attendance |
| Expansion | Countries, Identity documents per country, Integration providers |

Every resource gets: filtered/searchable list, add, edit, view, delete, related panels, domain actions
(e.g. *Release funds*, *Resolve dispute*, *Grade & issue credential*, *Auto-staff from plan*) and audit logging.

## Engines (`app/Services`)

- `WalletService` – double-entry, idempotent ledger postings with row locks.
- `EscrowService` – release / refund / freeze with worker · agent · platform commission split.
- `GeoMatchService` – ranks professionals by skill, distance, availability, rating, experience,
  completion, verification and warranty; dispatches in radius waves.
- `PriceEstimator` – fair price range from comparable contracts (25th–75th percentile × urgency).
- `TrustScoreService` – trust score + objective career level (never demographic data).
- `RiskEngine` – payout risk scoring; high-risk payouts are placed on hold.
- `AutoReleaseService` – releases escrow after the inspection window (`jobnixy:auto-release`, hourly).

## Adding a resource module

1. Create the model in `app/Models` and a migration.
2. Create `app/Admin/Resources/YourResource.php` extending `App\Admin\Resource`
   (define `$model`, `$slug`, `$label`, `$singular`, `$section`, `$permission`, `fields()`, `columns()`;
   optionally `filters()`, `panels()`, `actions()`, `indexActions()`, `mutate()`, `afterSave()`, `beforeDelete()`).
3. Register it in `App\Admin\ResourceRegistry::all()`.

Routes (`admin.{slug}.index|create|store|show|edit|update|destroy|action|index-action`) and the
sidebar entry are generated automatically. Sensitive operations are written to the audit log.
