## Membership associations: member portal using Django

### Summary
A member portal blueprint for membership associations built with Django on Ample.  
Domain schema:  
- **course_groups** (chapter_or_program, start_at, end_at): chapters and programs as groups;  
- **memberships** (course_group_id, member_email, tier, role, renewed_at): members and roles;  
- **sessions** (course_group_id, starts_at, title, venue): meetings and events;  
- **materials** (course_group_id, title, object_key, visibility): member resources;  
- **document_access** (document_id, principal_reference, role, granted_at): who may read which document.  
Public information: about, chapters and benefits, public events, join information.  
Kept out of scope until handling is reviewed: member directory details, dues and payment records. Member directories are personal data; only public events and member-authorized resources are modeled.

### Representative Queries
- Membership associations: member portal using Django  
- Where can I host Membership associations: Member portal built with Django?  
- I need a genuinely specialized member portal workflow covering membership tiers, event eligibility and shared resources.

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

### Workflow Steps
1. **Model the membership associations domain**  
   Create the tables course_groups, memberships, sessions, materials, document_access. Chapters and programs as groups live in course_groups; keep the sensitive classes (member directory details, dues and payment records) out of this schema.  
2. **Model groups, memberships and roles**  
3. **Authorize access to materials** by membership and role (401, 403 negative tests)  
4. **Store materials in the private bucket** and stream them through the app  
5. **Deploy**  
   Run the synchronous deploy once and read the result. Re-running with no change is a no-op.  
   ```bash  
   ample deploy . --name --public --start "python3 run.py" --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...  
   ```  
6. **Verify**  
   Run the pattern self-test(s) from the example (/p/private-document-library) and your own acceptance checks for the membership associations workflow.  
   ```bash  
   ample logs --kind build  
   ```

### Limitations
- The technical basis (private document library on Django) was verified with the pattern fixture; the membership associations 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. Member directories are personal data; only public events and member-authorized resources are modeled.  
- Verified on the python-3.12 template at s-1vcpu-1gb; region, request-duration limits and other sizes are unknown or unverified.

### 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**: 1.0 (s-1vcpu-1gb) - 5.0  
  - **managed PostgreSQL database**: 1.0 (s-1vcpu-1gb) - 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.

### Examples
- **Django pattern fixture**: Verified private document library basis for this blueprint.
  - Source Ref: tests/deploy-canaries/django-patterns

### Success Checks
- **App responds** on its public URL: `ample canary django patterns`  
- **private-document-library self-test** from the example: see the pattern fixture checks.
