I developed this API as a solution for the Player Control Challenge, which required implementing a comprehensive CRUD service to manage soccer players. The goal was to create an API that allows creating, viewing, updating, and deleting player records, along with additional functionality for searching, filtering, and pagination. The project also includes strict validation for player attributes, ensuring all data meets defined constraints.
- Node.js: JavaScript runtime for back-end development.
- Fastify: A fast and efficient web framework for Node.js.
- Prisma: ORM for managing the database with type safety.
- PostgreSQL: Relational database for data storage.
- Zod: Schema declaration and validation library for validating API inputs.
- Docker: Containerization to streamline the development environment.
- Swagger: Documentation tool for RESTful APIs.
Clone repository
git clone https://github.com/izacabral/PlayerManager.gitcd PlayerManager- In the root directory,create a
.envfile as following example:
DB_USER="player_manager_user"
DB_PASSWORD="dev12345"
DB_NAME="player_manager_db"
DB_PORT=5433make startThe API will be responding on port 3030 at: http://localhost:3030
GET /players -> List all players with optional pagination and search filters.
GET /players/:id -> Retrieve a specific player by ID.
POST /players -> Create a new player.
PUT /players/:id -> Update a player’s information.
DELETE /players/:id -> Delete a player.I used Swagger to document the API endpoints. You can access the documentation locally once the server is running at: http://localhost:3030/docs
/PlayerManager
├── prisma/
| ├── migrations/
| └── schema.prisma
├── src/
| ├── controllers/
| ├── docs/
| ├── lib/
| ├── routes/
| ├── schemas/
| ├── services/
| └── server.ts
├── Dockerfile
├── Makefile
├── README.md
├── docker-compose.yaml
├── eslint.config.mjs
├── package-lock.json
├── package.json
└── tsconfig.json
You can use the following make commands to manage the Docker containers, images, and volumes for the application:
- Build the application and database containers:
make build
- Start the containers:
make up
- Stop the containers:
make down
- Clean volumes and images (removes database data and all images):
make fclean
- Clean only volumes (preserves images):
make clean
- View logs:
make logs
- Restart the containers:
make restart
- Player Ranking: Implement a ranking feature based on player skills.
- Team Allocation: Develop functionality to divide players into balanced teams.
- Enhanced Error Messages: Improve error handling to provide more informative and user-friendly error messages, including specific details on validation failures and database issues.