This section explains how the Teams Service was built and how it fits into the TechCup platform architecture.


Teams Service

Dependencies

Parent

Runtime dependencies

Test dependencies

Build plugins

Dependency management


Diagrams & JPA

The class diagram used for the models is the following:

Class diagram

The entity-relation diagram used for JPA is the following:

Entity-relation diagram

The entities defined for this service are:

teams

Stores the general information and configuration of each football team.

Column Type Notes
id UUID PK Auto-generated
name VARCHAR(100) Unique team name
logo_url VARCHAR Optional team logo
description VARCHAR Optional team description
captain_id UUID Cross-service reference to Identity Service
created_at TIMESTAMP Automatically generated
updated_at TIMESTAMP Automatically updated

team_members

Stores the players that belong to a team.

Column Type Notes
id UUID PK Auto-generated
team_id UUID FK References teams.id
player_id UUID Cross-service reference to Users & Players Service
jersey_number INTEGER Optional jersey number
position ENUM GOALKEEPER · DEFENDER · MIDFIELDER · FORWARD
joined_at TIMESTAMP Date when the player joined the team

team_invitations

Stores invitations sent to players to join teams.

Column Type Notes
id UUID PK Auto-generated
team_id UUID FK References teams.id
player_id UUID Cross-service reference to Users & Players Service
status ENUM PENDING · ACCEPTED · REJECTED
sent_at TIMESTAMP Invitation creation timestamp
responded_at TIMESTAMP Optional response timestamp

team_requests

Stores requests sent by players asking to join a team.

Column Type Notes
id UUID PK Auto-generated
team_id UUID FK References teams.id
player_id UUID Cross-service reference to Users & Players Service
status ENUM PENDING · APPROVED · REJECTED
requested_at TIMESTAMP Request creation timestamp
reviewed_at TIMESTAMP Optional review timestamp

team_statistics

Stores accumulated statistics for each team.

Column Type Notes
id UUID PK Auto-generated
team_id UUID FK References teams.id
matches_played INTEGER Default 0
wins INTEGER Default 0
draws INTEGER Default 0
losses INTEGER Default 0
goals_scored INTEGER Default 0
goals_conceded INTEGER Default 0

Cross-service references (captain_id, player_id) are stored as primitive identifiers because the Teams Service does not own player or identity data. The real information lives in the Identity Service and Users & Players Service.


Endpoints

Team management

Method Path Auth required Description
POST /api/v1/teams Bearer (CAPTAIN) Creates a new team.
GET /api/v1/teams No Returns all teams.
GET /api/v1/teams/{id} No Returns a team by ID.
PUT /api/v1/teams/{id} Bearer (CAPTAIN) Updates team information.
DELETE /api/v1/teams/{id} Bearer (CAPTAIN) Deletes a team.

Team members

Method Path Auth required Description
POST /api/v1/teams/{id}/members Bearer (CAPTAIN) Adds a player to the team.
GET /api/v1/teams/{id}/members No Returns all players in a team.
DELETE /api/v1/teams/{id}/members/{playerId} Bearer (CAPTAIN) Removes a player from the team.

Invitations

Method Path Auth required Description
POST /api/v1/teams/{id}/invitations Bearer (CAPTAIN) Sends an invitation to a player.
PATCH /api/v1/teams/invitations/{invitationId}/accept Bearer (PLAYER) Accepts a team invitation.
PATCH /api/v1/teams/invitations/{invitationId}/reject Bearer (PLAYER) Rejects a team invitation.

Join requests

Method Path Auth required Description
POST /api/v1/teams/{id}/requests Bearer (PLAYER) Sends a request to join a team.
PATCH /api/v1/teams/requests/{requestId}/approve Bearer (CAPTAIN) Approves a join request.
PATCH /api/v1/teams/requests/{requestId}/reject Bearer (CAPTAIN) Rejects a join request.

Statistics

Method Path Auth required Description
GET /api/v1/teams/{id}/stats No Returns statistics for a team.
GET /api/v1/teams/ranking No Returns the global team ranking.

Inter-service communication

This service communicates directly with other microservices using OpenFeign instead of routing internal calls through the API Gateway.

Called service When Purpose
Identity Service During authenticated operations Validate user identity and roles
Users & Players Service When managing members Validate player existence and retrieve player information
Tournament Service During tournament registration flows Verify team eligibility and registration state

The API Gateway injects user information headers (X-User-Id, X-User-Role, X-User-Email) into forwarded requests. The Teams Service uses these headers to identify captains and players performing actions.


Team invitation state machine

text PENDING ──► ACCEPTED │ └──► REJECTED