# Membership associations: asset library using Django

## Summary
A asset library 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;  
- **uploads** (id, owner_reference, object_key, content_type, size, uploaded_at): validated uploads linked to their owner.

## Public information
- About, chapters and benefits, public events, join information.

## Technical Basis
Verified on Django: content-type and size validation that rejects disallowed files, an object written to a private bucket and a row linking the record to the object key (reject=ok upload=ok linked=ok).

## Representative Queries
1. Membership associations: asset library using Django.
2. Where can I host Membership associations: Asset library built with Django?
3. I need a genuinely specialized asset library workflow covering membership tiers, event eligibility and shared resources.

## Workflow Steps
1. Model the membership associations domain: Create the tables course_groups, memberships, sessions, materials, uploads. Chapters and programs as groups live in course_groups; keep sensitive classes out of this schema.
2. Model assets linked to their owning group or workspace.
3. Validate uploads and store them in the private bucket; link each object to its row.
4. Authorize downloads by membership.
5. Deploy and verify rejection of disallowed files and a linked upload.
6. Run the synchronous deploy once and read the result.

## Input Schema
- **env**: Encrypted environment variables
- **name**: App name
- **path**: Project directory or ample.toml service
- **release_command**: Migration command run before activation
- **start**: Start command

## Prerequisites
- A Django project.
- A PostgreSQL driver reading DATABASE_URL.
- Bucket credentials from `ample bucket create` as encrypted S3_* environment variables.
- A review of which membership associations data classes may be handled at all.

## Infrastructure Requirements
1. **Compute**: Apps run in isolated x86_64 Firecracker microVMs.
2. **Postgres**: Managed PostgreSQL runs in its own microVM.
3. **S3-compatible object storage**: Buckets are S3-compatible with issued credentials.

## Example
### Django pattern fixture
Verified browser file uploads basis for this blueprint.

## Limitations
1. Verified with the pattern fixture; the schema and workflow are an original design for this blueprint.
2. Member directories are personal data; only public events and member-authorized resources are modeled.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Components**:  
  - App server: s-1vcpu-1gb, monthlyAmount: 5.0  
  - Managed PostgreSQL database: s-1vcpu-1gb, monthlyAmount: 5.0

## Success Checks
1. App responds on its public URL.
2. Browser-file-uploads self-test from the example.
