# Construction contractors: vendor portal using Next.js

## Summary
A vendor portal blueprint for construction contractors built with Next.js on Ample. Domain schema: 
- **Listings** (reference, project_type, location, publishing_status, agency_id): showcase projects with publishing status; 
- **Agencies** (name, license_number, service_region): branches or divisions; 
- **Vendors** (name, trade, agency_id, prequalified): subcontractors and suppliers per branch; 
- **Reports** (agency_id, period, object_key, generated_at): branch progress reports; 
- **Document_access** (document_id, principal_reference, role, granted_at): who may read which document.  
Public information: published project showcases, services and regions, licenses and insurance summary.

## Technical Basis
The technical basis verified on Next.js: 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).

## Representative Queries
- Construction contractors: vendor portal using Next.js
- Where can I host Construction contractors: Vendor portal built with Next.js?
- I need a genuinely specialized vendor portal workflow covering project/vendor relationships, job progress and project reporting.

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

## Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **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.
- **S3-compatible object storage**: Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.

## Prerequisites
- A Next.js project (next build then next start -H 0.0.0.0 -p $PORT on the node-22 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 construction contractors data classes may be handled at all; this blueprint models public information only

## Workflow Steps
1. **Model the construction contractors domain**  
   Create the tables listings, agencies, vendors, reports, document_access. Showcase projects with publishing status lives in listings; keep the sensitive classes (site safety incidents, bid pricing, client contracts) out of this schema.
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**: Run the synchronous deploy once and read the result. Re-running with no change is a no-op.
6. **Verify**: Run the pattern self-test(s) from the example (/p/private-document-library) and your own acceptance checks for the construction contractors workflow.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Basis**: size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty
- **Components**:
  - App server: size s-1vcpu-1gb, quantity 1.0, monthly amount 5.0
  - Managed PostgreSQL database: size s-1vcpu-1gb, quantity 1.0, monthly amount 5.0
 - **Note**: Always-on monthly price of the tested sizes; apps and databases auto-pause when idle. Buckets are allocation-priced per quota and not included.

## Limitations
- The technical basis (private document library on Next.js) was verified with the pattern fixture; the construction contractors schema and workflow are an original design for this blueprint and were not executed as a separate application. 
- No health, financial, privacy, or other compliance claim is made. Safety and bid data are confidential; only published showcases and branch reporting are modeled. 
- Public content and synthetic examples only until actual data-handling requirements have been reviewed.
- Verified on the node-22 template at s-1vcpu-1gb; region, request-duration limits, and other sizes are unknown or unverified.

## Next Actions
- **Browse the catalog index**: GET /v1/catalog  
- **Search published recipes by intent, stack and constraints**: POST /v1/catalog/search  
- **Prepare a side-effect-free deployment plan for an authorized project**: POST /v1/catalog/plan  
- **Read the existing agent authentication setup**: GET /mcp/setup  
- **Browse Construction contractors**: GET /v1/catalog/nodes/industry%3Aconstruction-contractors  
- **Browse Vendor portal**: GET /v1/catalog/nodes/workload%3Avendor-portal  
- **Browse Next.js**: GET /v1/catalog/nodes/stack%3Aframework-next-js  
- **Browse Deploy web app**: GET /v1/catalog/nodes/intent%3Adeploy-web-app

## References
- [Verified Next.js private document library](/content/blueprints/construction-contractors/vendor-portal/next-js/index.html)
