feat: Team model + assignment endpoints (Phase 10a) #81
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api#81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lineage
plan-2026-03-08-tryout-prep→ Phase 10 (Team Placement) → Phase 10a (Backend)Repo
forgejo_admin/basketball-apiUser Story
As an admin
I want to create teams, assign players to them, and assign coaches to teams
So that coaches see only their team's roster and players know which team they're on
Context
Tryouts are done (53 players, 45 ready). Auth is live (Keycloak IdP, Phase 5 COMPLETED). Now Marcus needs to assign players to teams before the season starts. Currently there is no Team model — Player and Coach exist but have no relationship to each other. This phase adds the Team entity as the bridge between players and coaches.
Key decisions from planning:
File Targets
Files the agent should modify or create:
src/basketball_api/models.py— add Team model, addteam_idFK to Player modelalembic/versions/xxx_add_team_model.py— new migration: Team table + Player.team_id FKsrc/basketball_api/routes/teams.py— new route file: CRUD, assignment, overview, coach-filtered endpointssrc/basketball_api/main.py— register the teams routertests/test_teams.py— new test file for all team endpointsFiles the agent should NOT touch:
src/basketball_api/routes/register.py— registration flow is separatesrc/basketball_api/routes/webhooks.py— Stripe webhooks are separatesrc/basketball_api/auth.py— auth is already working, use existingrequire_role()patternAcceptance Criteria
POST /api/teamscreates a team (admin only)GET /api/teamslists all teams with player counts and coach name (admin only)GET /api/teams/{team_id}returns team detail with full player roster (admin only)PATCH /api/teams/{team_id}updates team fields (admin only)DELETE /api/teams/{team_id}deletes team, unassigns players (admin only)POST /api/teams/{team_id}/playersassigns player(s) to team via{"player_ids": [...]}(admin only)DELETE /api/teams/{team_id}/players/{player_id}unassigns player (admin only)GET /api/teams/minereturns team(s) for authenticated coach (matches Keycloak email to Coach.email)GET /api/teams/overviewreturns admin summary: all teams, player counts, unassigned count, coach infoTest Expectations
pytest tests/test_teams.py -vConstraints
require_role("admin")fromsrc/basketball_api/auth.pysrc/basketball_api/routes/admin.pyandroster.py)models.py)tenant_id(multi-tenant)e09c9e678004(add division column) — chain from thatruff formatbefore committingChecklist
Related
westside-basketball— project