A tennis ranking management API built with NestJS, Mongoose, and MongoDB. This system allows for managing players, categories, challenges, and match results.
- Players Management: CRUD operations for players.
- Categories: Group players into categories and assign them to specific events.
- Challenges: Create challenges between players within the same category.
- Matches: Record match results, which automatically updates challenge statuses.
- Observability: Integrated NestJS Logger across all services.
- Validation: Strict data validation using
class-validatorand custom pipes.
- Framework: NestJS
- Database: MongoDB with Mongoose
- Language: TypeScript
- Validation: class-validator & class-transformer
- Node.js (v18 or higher)
- Docker & Docker Compose (for running MongoDB)
-
Clone the repository:
git clone <repository-url> cd api-smartranking
-
Install dependencies:
npm install
-
Environment Setup: Copy
.env.exampleto.envand configure your MongoDB URI.cp .env.example .env
-
Run MongoDB:
docker-compose up -d
-
Run the API:
# Development npm run start:dev # Production build npm run build npm run start:prod
POST /api/v1/players: Create a new player.GET /api/v1/players: List all players.GET /api/v1/players/:id: Get player details.PUT /api/v1/players/:id: Update player info.DELETE /api/v1/players/:id: Remove a player.
POST /api/v1/categories: Create a category.GET /api/v1/categories: List all categories.POST /api/v1/categories/:category/players/:playerId: Assign a player to a category.
POST /api/v1/challengers: Request a new challenge.GET /api/v1/challengers: List all challenges (supports?playerId=filter).PUT /api/v1/challengers/:id: Update challenge status (ACCEPTED, DENIED, CANCELED).DELETE /api/v1/challengers/:id: Delete a challenge.
POST /api/v1/challengers/:challengeId/match: Register a match result for a challenge.
You can find request examples in the requests.http file. If you use VS Code, the REST Client extension is recommended to run them directly.
# Run unit tests
npm run test
# Run e2e tests
npm run test:e2eThe project follows the standard NestJS modular architecture:
src/players: Player logic and schema.src/categories: Category logic and player assignments.src/challengers: Logic for challenges and match results.src/shared: Database providers and global filters/pipes.