# Sports clubs: Event Registration Using Django

## Overview
A event registration blueprint for sports clubs built with Django 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;
- **events** (seq, record_type, record_id, kind, at): application-owned history written in the same transaction.  
Public information includes teams, seasons and fixtures, venues, and 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 Django: an optimistic version check and an event row written in the same transaction, a stale update rejected, and a history query over the application-owned events (history=2 conflict=rejected).

## Representative Queries
- Sports clubs: event registration using Django
- Where can I host Sports clubs: Event registration built with Django?
- I need a genuinely specialized event registration workflow covering team membership, event participation, and club media.

## Resource Requirements
- **Compute**
- **Postgres**
- **S3-compatible object storage**

## Infrastructure Requirements
1. **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
2. **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.
3. **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 Django project (pip install into .ample/python from requirements.txt, then waitress serving project.wsgi from run.py reading PORT on the python-3.12 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 sports clubs data classes may be handled at all; this blueprint models public information only

## Tested Configuration
- **Template**: python-3.12  
- **Runtime**: python  
- **Size**: s-1vcpu-1gb  
- **Install**: python3 -m pip install --target .ample/python -r requirements.txt  
- **Start**: PYTHONPATH=.ample/python:${PYTHONPATH:-} python3 run.py

## Workflow Steps
1. **Model the sports clubs domain**: Create the tables course_groups, memberships, sessions, materials, events. Teams and classes lives in course_groups; keep the sensitive classes (minor members and medical notes, safeguarding records) out of this schema.
2. **Register transactionally**: Register transactionally with a capacity check and an event per registration. 
3. **Reject stale concurrent updates**.
4. **Deploy and verify** history and conflict handling.
5. **Deploy**: Run the synchronous deploy once and read the result. Re-running with no change is a no-op.  
   Command: `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/transactional-workflows) and your own acceptance checks for the sports clubs workflow. 
   Command: `ample logs --kind build`

## Examples
- **Django pattern fixture**: Verified transactional workflows basis for this blueprint.

## Success Checks
- App responds on its public URL
- Transactional-workflows self-test from the example

## Limitations
- The sports clubs schema and workflow are an original design for this blueprint and were not executed as a separate application.
- Public content and synthetic examples only until actual data-handling requirements have been reviewed.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- Basis: size prices from pricing.toml (loaded by the API) at build revision.

## Next Actions
- Browse the catalog index
- Search published recipes by intent, stack, and constraints
- Prepare a side-effect-free deployment plan for an authorized project
- Read the existing agent authentication setup
- Browse Sports clubs
- Browse Event registration
- Browse Django
- Browse Deploy web app

## Formats
- [HTML](/content/blueprints/sports-clubs/event-registration/django/index.html)
- [Markdown](/content/blueprints/sports-clubs/event-registration/django.md)
- [JSON](https://api.ample.computer/v1/catalog/recipes/page%3Ablueprints%3Asports-clubs%3Aevent-registration%3Adjango)
