Pokédex At Home is a Spring Boot-based project that integrates with PokéAPI and FunTranslations to provide a different way of looking at your favorite Pokémon information.
- Pokédex At Home
- Retrieve details of Pokémon species from PokeAPI.
- Translate Pokémon descriptions using the FunTranslations API.
- Comprehensive exception handling for various error scenarios.
- Multi-stage Docker build for lightweight image creation.
- Automatically generated API documentation with Swagger for easy exploration and testing.
- Spring Boot: Provides RESTful services and dependency injection.
- RestClient: Manages API communication.
- Lombok: Reduces boilerplate code.
- JUnit: For unit testing.
- Mockito: For mocking dependencies in tests.
- Docker: For containerizing the application.
- Swagger: For generating and exploring API documentation.
- SpringDoc OpenAPI: To generate OpenAPI documentation for the REST API.
Ensure the following are installed on your machine:
- Java 21 or later
- Maven 3.8.1 or later
git clone https://github.com/mpellicc/pokedex-at-home.git
cd pokedex-at-home
mvn clean install
mvn spring-boot:run
The application will be available at http://localhost:8080.
mvn test
You can use Docker to build and run the application. Here’s how:
docker build -t pokedex-at-home -f Dockerfile .
docker run -p 8080:8080 pokedex-at-home
If you prefer Docker Compose (V2 compatible), use:
docker compose up --build
Alternatively, if using the older Docker Compose, run:
docker-compose up --build
This will build the Docker image and start the container, mapping port 8080 from the container to port 8080 on the host machine.
The project includes a multi-stage Dockerfile:
- Build Stage: Uses Maven to compile and package the application.
- Runtime Stage: Runs the packaged application using a lightweight Java runtime.
Feel free to modify the Dockerfile and Docker Compose file as needed.
To manage environment-specific configurations, use separate application-{environment}.yml
files.
-
Create Environment Configuration Files
- Place these files under
src/main/resources
:application-dev.yml
for developmentapplication-prod.yml
for production
- Place these files under
-
Define Environment Variables
-
In each configuration file, specify environment-specific properties. Example:
# application-dev.yml server: port: 8080 logging: level: root: DEBUG
-
-
Specify the Active Profile
-
For Docker
-
Run the container with the
SPRING_PROFILES_ACTIVE
environment variable to specify which profile to use:docker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE=dev pokedex-at-home
-
-
For Docker Compose
-
You need to set environment variables in the
docker-compose.yml
file. Add theSPRING_PROFILES_ACTIVE
environment variable under theenvironment
section. Example:version: "3.8" services: app: image: pokedex-at-home ports: - "8080:8080" environment: - SPRING_PROFILES_ACTIVE=dev
-
Then run:
docker compose up --build
-
-
-
Verify Configuration
- Ensure the application correctly picks up settings from the specified environment profile.
The application uses Swagger for documenting and exploring the API. After running the application, you can access the following:
-
Swagger UI: http://localhost:8080/swagger-ui.html
-
OpenAPI JSON: http://localhost:8080/v3/api-docs – for JSON format.
-
OpenAPI YAML: http://localhost:8080/v3/api-docs.yaml – for YAML format.
You can regenerate the openapi.json
file by running the following Maven command:
mvn verify
The generated openapi.json
file will be saved in the openapi
folder.