# Sports clubs: member portal using Next.js

## Summary  
A member portal blueprint for sports clubs built with Next.js on Ample. Domain schema:  
- **course_groups** (team_or_class, season, age_group): teams and classes  
- **memberships** (course_group_id, member_reference, guardian_reference, role): players, guardians, and coaches  
- **sessions** (course_group_id, starts_at, venue, type): training and fixtures  
- **materials** (course_group_id, title, object_key, visibility): schedules and coaching resources  
- **document_access** (document_id, principal_reference, role, granted_at): who may read which document.  
  
Public information: teams, seasons and fixtures, venues, membership fees. Kept out of scope until handling is reviewed: minor members and medical notes, safeguarding records. Medical and safeguarding records are sensitive; only schedules and coaching materials are modeled.  
  
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).

## Framework  
- **Framework**: Next.js  
- **Workload**: Member portal  
- **Industry**: Sports clubs

## Resource Requirements  
- **Compute:** (verified) Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request.  
- **Postgres:** (verified) Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database.  
- **S3-compatible object storage:** (verified) Buckets are S3-compatible with issued credentials.

## 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

## Limitations  
- The technical basis (private document library on Next.js) was verified with the pattern fixture; the sports clubs schema and workflow are an original design for this blueprint and were not executed as a separate application.  
- **Public content:** Verified only until actual data-handling requirements have been reviewed.  
- Managed PostgreSQL 16 only; extensions, connection limits, and backup or restore procedures are not verified.

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