Skip to content

laithse1/PokemonTournament-SpringBoot-Application

Repository files navigation

README.md file with complete details:

# Pokemon Tournament App

## Overview
The Pokemon Tournament App is a Java Spring Boot application designed to simulate Pokemon tournaments with customizable configurations. It includes both frontend and backend components, with a PostgreSQL database for data persistence. This project is containerized using Docker, allowing easy setup and execution.

## Features
- Manage Pokemon and tournament data.
- CRUD operations for Pokemon and tournaments.
- Secure data with encryption using secret keys.
- RESTful API for interacting with the application.
- Pre-configured database using PostgreSQL.

## Prerequisites
To run this application, you need:
- **Docker**: Make sure Docker is installed on your system. You can download Docker [here](https://www.docker.com/get-started).
- **Docker Compose**: This is usually included with Docker installations, but confirm it's available by running `docker-compose --version` in your terminal.
- Java JDK 21 and Node.js for local environment development.

## Project Structure
- **Dockerfile**: Defines the Docker image for the Spring Boot application.
- **docker-compose.yml**: Manages multi-container deployment, including the app and PostgreSQL database.
- **.env**: Stores environment variables required for database configuration and secret keys. **Ensure this file is in the project root directory**.

Getting Started

1. Run the Startup Shell Script

To launch the Pokémon Tournament application, simply run the following command in the root directory of this repository.

./start_pokemon_tournament.sh

Endpoints

Here are some key API endpoints available for testing:

Pokemon Endpoints

  • Get Pokemon by Name: GET /api/pokemon/name/{name}
    • Example: http://localhost:8081/api/pokemon/name/Pikachu
  • Get All Pokemon: GET /api/pokemon
  • Create a New Pokemon: POST /api/pokemon with JSON payload.

Tournament Endpoints

  • Create Tournament: POST /api/tournament with JSON payload.

Use Postman or curl to test the API endpoints. For example, to fetch a Pokemon by name:

curl -X GET http://localhost:8081/api/pokemon/name/Pikachu

Example Requests

Create Pokemon

POST /api/pokemon
Content-Type: application/json

{
  "name": "Charmander",
  "attack": 52,
  "defense": 43,
  "speed": 65,
  "max_hp": 100
}

Create Tournament

POST /api/tournament
Content-Type: application/json

{
  "tournamentName": "Kanto Championship",
  "pokemonIds": [1, 2, 3, 4]
}

User interface:

Example Image

Running as a Docker container:

Example Image

Database Access

To access the database within the Docker container:

  1. Run the following command to access the PostgreSQL database:
    docker-compose exec db psql -U $POSTGRES_USER -d $POSTGRES_DB

DB data Encryption:

Example Image

  1. You can then run SQL queries directly, e.g., SELECT * FROM pokemon;

DB tables:

Example Image

Common Issues and Troubleshooting

Docker Daemon Errors

If Docker isn’t running, start the Docker Desktop or Docker Daemon.

Secret Key Issues

Ensure the SECRET_KEY environment variable is properly set in the .env file.

Database Connection Issues

If the app fails to connect to the database, check if the environment variables in .env match those in docker-compose.yml.

Stopping the Application

To stop the application and remove all containers, networks, and volumes created by docker-compose up:

docker-compose down

Contributing

If you would like to contribute, please fork the repository and make changes as needed. Pull requests are welcome.

License

This project is licensed under the MIT License.


### Notes for Customization
1. **Environment Variables**: Ensure sensitive values are well-documented, especially for the `.env` file.
2. **API Documentation**: If you have more endpoints, you could consider adding Swagger for automatic documentation.
3. **Sample Data**: Add SQL scripts or instructions for adding initial data if required for testing.

---

This README provides a comprehensive guide for users to set up, run, and test the application with Docker.

About

Pokemon Tournament App is a Java Spring Boot application designed to simulate Pokémon tournaments with customizable configurations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors