This is a backend application that provides a REST API for managing departments and users. It allows CRUD operations for departments and users, as well as retrieving the average salary per department. The API is secured with JWT token authentication.
- Java
- Spring Boot
- PostgreSQL (relational database)
- Jooq (database query library)
- Maven
To get started with the User Management API, follow these steps:
-
Clone the repository from GitHub:
git clone https://github.com/tolgaaksoy/expatrio-assignment.git
-
Make sure you have PostgreSQL installed and running.
-
Configure the database connection in the application properties file located at
src/main/resources/application.properties
. -
Build the project using Maven:
cd user-management-api mvn clean package
-
Run the application:
mvn spring-boot:run
The API will be accessible at
http://localhost:8080/api
.
The following API endpoints are available:
Swagger documentation is available at: http://localhost:8080/api/v3/api-docs/swagger-ui/index.html
There is a Postman collection available for the API. You can import the collection from the following link:
POST /auth/login
: Authenticates a user and returns a JWT token.POST /auth/register
: Registers a new user.PUT /auth/authInfo
: Updates user fields such as username and password.
GET /departments
: Retrieves all departments.GET /departments/{id}
: Retrieves a department by its ID.POST /departments
: Creates a new department.PUT /departments/{id}
: Updates a department.DELETE /departments/{id}
: Deletes a department.
GET /users
: Retrieves all users.GET /users/{id}
: Retrieves a user by their ID.POST /users
: Creates a new user.PUT /users/{id}
: Updates user fields such as first name, last name, and salary, department.DELETE /users/{id}
: Deletes a user.
GET /departments/averageSalary
: Retrieves the average salary per department.
The API endpoints are secured using JWT token authentication. To access the protected endpoints, you need to include the JWT token in the request headers.
The database schema includes the following tables:
department
: Stores department information.auth_user
: Stores user information.auth_role
: Stores user roles.auth_user_role
: Represents the many-to-many relationship between users and roles.
Unit tests are available for the application. To run the tests, execute the following command:
mvn test
For any inquiries or questions, please contact Tolga Aksoy.
This README provides a brief overview of the User Management API. For more detailed documentation, please refer to the codebase and API documentation generated by Swagger.
Swagger documentation is available at http://localhost:8080/api/v3/api-docs/swagger-ui/index.html
.