Work in Progress
Django REST Framework backend for the internal management of a Sports Association. This is not an e-commerce or SaaS platform — it is a management tool used by ASD staff and members to handle registrations, documentation, and athlete data.
Stack:
- Python 3.13+
- Django 6.0+
- Django REST Framework 3.17+
- PostgreSQL (SQLite for local development)
- JWT authentication (djangorestframework-simplejwt)
- API documentation via drf-spectacular (Swagger UI)
git clone https://github.com/aleattene/asd-management-backend.git
cd asd-management-backendpython3.13 -m venv .venv
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windowspip install --upgrade pip
pip install -r requirements.txtFor development (includes pytest, coverage, ruff):
pip install -r requirements_dev.txtDependency management: this project uses pip-tools. The
requirements*.txtfiles are compiled fromrequirements*.inand should not be edited directly. To add or update a dependency, edit the relevant.infile and recompile:pip-compile requirements.in pip-compile requirements_dev.in
The project reads configuration from environment variables. Create a .env file
in the project root with the following variables:
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000
# PostgreSQL (production only)
POSTGRES_DATABASE=asd_management
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432python manage.py migratepython manage.py createsuperuserpython manage.py runserverThe API will be available at http://localhost:8000/api/v1/.
Swagger UI is available at:
http://localhost:8000/api/schema/swagger-ui/
OpenAPI schema (JSON) at:
http://localhost:8000/api/schema/
| Method | Endpoint | Description | Permission |
|---|---|---|---|
| POST | /api/v1/auth/token/ |
Obtain JWT token pair | Public |
| POST | /api/v1/auth/token/refresh/ |
Refresh access token | Public |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
| GET/PATCH | /api/v1/users/me/ |
Own profile | Authenticated (non-external) |
| GET/POST | /api/v1/users/ |
List/create users | Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/users/{id}/ |
User detail | Admin/Operator/Superadmin |
| PATCH | /api/v1/users/{id}/set_role/ |
Change user role | Superadmin only |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
| GET/POST | /api/v1/athletes/ |
List/create athletes | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/athletes/{id}/ |
Athlete detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/POST | /api/v1/categories/ |
List/create categories | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/categories/{id}/ |
Category detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/POST | /api/v1/trainers/ |
List/create trainers | Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/trainers/{id}/ |
Trainer detail | Admin/Operator/Superadmin |
| GET/POST | /api/v1/doctors/ |
List/create sport doctors | Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/doctors/{id}/ |
Doctor detail | Admin/Operator/Superadmin |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
| GET/POST | /api/v1/enrollments/ |
List/create season enrollments | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/enrollments/{id}/ |
Enrollment detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/POST | /api/v1/certificates/ |
List/create sport medical certificates | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/certificates/{id}/ |
Certificate detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
| GET/POST | /api/v1/countries/ |
List/create countries | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/countries/{id}/ |
Country detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/POST | /api/v1/provinces/ |
List/create Italian provinces | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/provinces/{id}/ |
Province detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/POST | /api/v1/municipalities/ |
List/create municipalities (?province=<id>) |
Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/municipalities/{id}/ |
Municipality detail | Read: authenticated (non-external); Write: Admin/Operator/Superadmin |
| Method | Endpoint | Description | Permission |
|---|---|---|---|
| GET/POST | /api/v1/companies/ |
List/create companies | Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/companies/{id}/ |
Company detail | Admin/Operator/Superadmin |
| GET/POST | /api/v1/payment-methods/ |
List/create payment methods | Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/payment-methods/{id}/ |
Payment method detail | Admin/Operator/Superadmin |
| GET/POST | /api/v1/invoices/ |
List/create invoices (direction=purchase or direction=sale) |
Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/invoices/{id}/ |
Invoice detail | Admin/Operator/Superadmin |
| GET/POST | /api/v1/receipts/ |
List/create receipts | Admin/Operator/Superadmin |
| GET/PATCH/DELETE | /api/v1/receipts/{id}/ |
Receipt detail | Admin/Operator/Superadmin |
To populate the local database with realistic seed data (users, athletes, enrollments, invoices, etc.),
the following environment variables must be set in your .env file (see .env.example):
SEED_SUPERADMIN_USERNAME=
SEED_SUPERADMIN_EMAIL=
SEED_SUPERADMIN_PASSWORD=
SEED_ADMIN_USERNAME=
SEED_ADMIN_EMAIL=
SEED_ADMIN_PASSWORD=Requires DEBUG=True and dev dependencies installed (pip install -r requirements_dev.txt).
python manage.py seed_dbTo reset and re-seed from scratch (preserves existing superusers):
python manage.py seed_db --flushpython manage.py test --settings=config.settings.testWith coverage:
coverage run manage.py test --settings=config.settings.test
coverage report --show-missingconfig/
settings/ # base / development / production / test
urls.py # API-only routing + Django Admin
permissions.py # Role-based permission classes
pagination.py # Standard pagination
users/ # Custom user model with roles + JWT
athletes/ # Athlete registry + categories
staff/ # Trainers (internal ASD staff)
doctors/ # Sport doctors (external professionals)
enrollments/ # Season enrollments
certificates/ # Sport medical certificates
geography/ # Reference data: countries, provinces, municipalities
companies/ # External companies (invoicing counterparts)
payment_methods/ # Configurable payment methods
invoices/ # Purchase and sale invoices
receipts/ # Fiscal receipts (member payments + staff compensations)
docs/ # Additional project documentation
- Fork the repository
- Create a feature branch:
git checkout -b feat/your-feature - Commit following Conventional Commits
- Open a pull request to
main
This project is licensed under the MIT License.