# Law firms: client portal using Next.js

A client portal blueprint for law firms built with Next.js on Ample. Domain schema:
- **client_entities** (name, entity_type, conflict_check_reference): clients with conflict-check status;
- **matters** (client_entity_id, practice_area, opened_at, closed_at, status): engagement periods as matters;
- **document_requests** (matter_id, title, due_at, status, uploaded_object_key): documents requested from the client;
- **shared_documents** (matter_id, title, object_key, authorized_role): documents released to authorized client contacts;
- **document_access** (document_id, principal_reference, role, granted_at): who may read which document.

Public information: practice areas and attorney profiles, intake process and fee structure overview, office locations. Kept out of scope until handling is reviewed: privileged communications and case files, identity and financial documents, opposing-party information.

Matter documents are privileged; the portal models per-matter authorization only. Professional-conduct and confidentiality obligations are not established here.

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
1. Law firms: client portal using Next.js
2. Where can I host Law firms: Client portal built with Next.js?
3. I need a genuinely specialized client portal workflow covering matter-based access separation and confidential document handling.

## Resource Requirements
- **Compute**
- **Postgres**
- **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.

### Workflow Steps
1. **Model the law firms domain**: Create the tables client_entities, matters, document_requests, shared_documents, document_access. Keep sensitive classes out of this schema.
2. **Workflow step 1**: Model client entities and engagement periods; every document belongs to one engagement.
3. **Workflow step 2**: Authorize by client entity and role before any storage access (401 without identity, 403 for the wrong client).
4. **Workflow step 3**: Store documents in the private bucket and stream them through the app.
5. **Workflow step 4**: Deploy and verify negative authorization tests and an authorized download.

## Success Checks
- The app responds on its public URL (ample canary next js patterns).
- **Private-document-library self-test** from the example (see the pattern fixture checks).

## Limitations
- The 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. Matter documents are privileged; the portal models per-matter authorization only.
- Verified only on the node-22 template; region, request-duration limits, and other sizes are unknown or unverified.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: $10.00
- **Components**:
  - App server: quantity 1.0, monthly amount $5.00
  - Managed PostgreSQL database: quantity 1.0, monthly amount $5.00
- Note: Always-on monthly price of the tested sizes; buckets are allocation-priced per quota and not included.
