A comprehensive RESTful Web API for managing football leagues, teams, players, coaches, and matches. Built with .NET 9 and following Clean Architecture principles with a focus on security, scalability, and maintainability.
- League Management - Create and manage football leagues with seasons
- Team Management - Handle team information, stadiums, and league associations
- Player Management - Manage player profiles, positions, and team assignments
- Coach Management - Track coaching staff and team associations
- Match Management - Schedule and record match results between teams
- JWT Authentication - Secure token-based authentication system
- Role-Based Authorization - User and Admin roles with different permissions
- Refresh Token Support - Automatic token renewal for seamless user experience
- Password Hashing - Secure password storage using ASP.NET Core Identity
- Clean Architecture - Separation of concerns across Domain, Application, Infrastructure, and API layers
- Entity Framework Core - Code-first approach with SQL Server integration
- AutoMapper - Automatic object-to-object mapping between entities and DTOs
- Audit Trail - Automatic tracking of creation and modification timestamps
- API Documentation - Interactive Swagger/OpenAPI documentation with Scalar UI
- .NET 9 - Latest .NET framework
- C# 13 - Modern C# language features
- ASP.NET Core Web API - RESTful API framework
- Entity Framework Core - ORM for database operations
- SQL Server - Primary database
- JWT Bearer Authentication - Security implementation
- AutoMapper - Object mapping
- Swagger/OpenAPI - API documentation
- Scalar - Enhanced API documentation UI
The API is documented using Swagger/OpenAPI and Scalar, providing an interactive interface for testing endpoints.
Access the API documentation at: https://localhost:{port}/swagger or https://localhost:{port}/scalar
The solution follows Clean Architecture principles with clear separation of concerns:
LeagueMaster.sln
ββ LeagueMaster.Domain/ # Core business entities and enums
β ββ Entities/ # League, Team, Player, Coach, Match, User
β ββ Enums/ # PlayerPosition, UserRole
β ββ BaseDomainObject.cs # Base entity with audit fields
ββ LeagueMaster.Application/ # Business logic and use cases
β ββ DTOs/ # Data transfer objects
β ββ Interfaces/ # Service and repository abstractions
β ββ Services/ # Business logic implementation
β ββ Mappings/ # AutoMapper profiles
ββ LeagueMaster.Infrastructure/ # Data access and external concerns
β ββ Persistence/ # DbContext and configurations
β ββ Repositories/ # Data access implementations
β ββ Migrations/ # EF Core migrations
ββ LeagueMaster.API/ # HTTP layer and configuration
ββ Controllers/ # API endpoints
ββ Program.cs # Application startup
ββ appsettings.json # Configuration
The API uses JWT authentication with role-based authorization:
- User - Can view leagues, teams, players, coaches, and matches
- Admin - Full CRUD operations on all resources
- Register -
POST /api/users/register - Login -
POST /api/users/login(returns access token and refresh token) - Use Token - Include
Authorization: Bearer {token}header - Refresh -
POST /api/users/refreshwhen token expires
POST /api/users/register- Register new userPOST /api/users/login- User loginPOST /api/users/refresh- Refresh access token
GET /api/leagues- Get all leagues (User/Admin)GET /api/leagues/{id}- Get league by ID (User/Admin)POST /api/leagues- Create league (Admin only)PUT /api/leagues/{id}- Update league (Admin only)DELETE /api/leagues/{id}- Delete league (Admin only)
Similar CRUD patterns with appropriate role restrictions.
Test the API using the provided HTTP file:
LeagueMaster.API/LeagueMaster.API.http- Sample requests for all endpoints
The database includes the following main entities:
- Leagues - Competition information
- Teams - Team details and league associations
- Players - Player profiles with team assignments
- Coaches - Coaching staff information
- Matches - Game results between teams
- Users - Authentication and authorization
All entities inherit from BaseDomainObject providing automatic audit trails.




