Inspired by the exercise from the SRE Bootcamp
The project is based on the Hexagonal Architecture organized with packaged not modules.
- Add a new student.
- Get all students.
- Get a student with an ID.
- Update existing student information.
- Delete a student record.
Before running this project, ensure that you have the following installed:
- Java 17
- Maven (for building and managing dependencies)
- Docker installed on your system. You can download and install Docker from here.
Follow these steps to get the project up and running on your local machine:
- Clone the Repository:
git clone https://github.com/jonamarkin/student-management-api.git cd student-management-api
- Build The Project
mvn clean install
- Run The Project
mvn spring-boot:run
Alternatively you can simply make use of the Makefile to start the project by running the following command in the root directory
make run
- You can access the Swagger documentation of the API Via
http://localhost:8080/swagger-ui/index.html
- Postman Documentation
This project uses PostgreSQL Database.
make migrate-db
To build the Docker image, run:
docker-compose up --build
Access the running application at http://localhost:8080
The project contains a Makefile which simplifies performing certain common tasks. Find below handy commands that may be helpful
make build
: Build all Docker imagesmake run-db
: Start only the PostgreSQL Databasemake migrate-db
: Run database migrationsmake build-app
: Build the API Docker Imagemake run-app
: Start the API container
With the available Makefile commands, another way of starting the application will be the run the command:
make run-app
This will ensure database is running and migrations are applied and start the application.
This project uses GitHub Actions for CI/CD to automate building, testing, and deploying the application.
- Checkout: Pulls the latest code from the main branch.
- Set up Java: Configures the Java environment using Temurin distribution.
- Build API: Compiles the API and packages it into a Docker container.
- Run Tests: Executes automated tests to ensure functionality.
- Login to Docker Hub: Authenticates to Docker Hub to push images.
- Build and Push Docker Image: Builds the Docker image and pushes it to Docker Hub using the
make docker-build-push
command.
The application requires the following environment variables to run:
SPRING_DATASOURCE_URL
: The URL to the database.SPRING_DATASOURCE_USERNAME
: The database username.SPRING_DATASOURCE_PASSWORD
: The database password.DOCKER_USERNAME
: Your Dockerhub usernameDOCKER_ACCESS_TOKEN
: Your Docker Access Token
You can set up these variables in Github for the workflow to complete successfully
Contributions are welcome! Feel free to open issues or submit pull requests to make improvements.