# Logistics operators: vendor portal using Django

## Summary
A vendor portal blueprint for logistics operators built with Django on Ample. Domain schema includes:
- **service_products** (sku, name, mode, transit_days, price_basis): shipping services as SKUs.
- **capacity_movements** (sku, lane, date, delta, reason): capacity as stock movements.
- **shipments** (shipment_no, lane, status, booked_at): shipments with status transitions.
- **shipment_lines** (shipment_no, sku, units): shipment contents.
- **document_access** (document_id, principal_reference, role, granted_at): who may read which document.

## Public Information
- Service products and transit times.
- Lanes served.
- Tracking entry point.

## Technical Basis
Verified on Django: a role-to-document access model with negative tests (401 without identity, 403 for the wrong role) and a private-bucket round-trip for the allowed role (private=ok).

## Resource Requirements
- **primitive:compute**
- **primitive:postgres**
- **primitive:s3-compatible-object-storage**

## Infrastructure Requirements
1. **Compute:** Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
2. **Postgres:** Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
3. **S3-compatible object storage:** Buckets are S3-compatible with issued credentials.

## Prerequisites
- A Django project (pip install into .ample/python from requirements.txt, then waitress serving project.wsgi from run.py reading PORT on the python-3.12 template).
- A PostgreSQL driver reading DATABASE_URL (auto-provisioned when omitted).
- Bucket credentials from `ample bucket create` passed as encrypted S3_* environment variables.
- A review of which logistics operators data classes may be handled at all; this blueprint models public information only.

## Workflow Steps
1. **Model the logistics operators domain**: Create tables for service_products, capacity_movements, shipments, shipment_lines, document_access.
2. **Model vendors**: Scoped to the agency with roles.
3. **Authorize document access**: By vendor and role (401, 403 negative tests).
4. **Store vendor documents**: In the private bucket.
5. **Deploy and verify**: Run the synchronous deploy once and read the result.

## Limitations
- The technical basis was verified with the pattern fixture; the logistics operators schema and workflow are an original design and were not executed as a separate application.
- No health, financial, privacy or other compliance claim is made.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Components**:
  - App server: 5.0
  - Managed PostgreSQL database: 5.0

## Success Checks
1. App responds on its public URL.
2. Private-document-library self-test from the example.

## Evidence Summary
- Django pattern fixture deployed on Ample. The private document library checks passed: a role-to-document access model with negative tests and a private-bucket round-trip.
