This README provides information about the project, its dependencies, and documentation for the service endpoints.
The project consists of an Angular frontend application and a Spring Boot backend service. The Angular application is responsible for the user interface, while the Spring Boot service handles the backend logic and data storage.
The project follows the principles of Object-Oriented Programming (OOP) and adheres to the SOLID principles.
- Object-Oriented Programming: The codebase is organized into packages representing different layers of the application, such as
application
,domain
, andinfrastructure
. These packages contain classes that encapsulate related functionality using objects, classes, and inheritance. - SOLID Principles: The project applies SOLID principles to enhance maintainability, testability, and extensibility.
- Single Responsibility Principle (SRP): Each class has a single responsibility, ensuring that it has only one reason to change.
- Open/Closed Principle (OCP): The code is open for extension but closed for modification, allowing new features to be added without modifying existing code.
- Liskov Substitution Principle (LSP): Subtypes can be substituted for their base types, ensuring that inheritance and polymorphism are used correctly.
- Interface Segregation Principle (ISP): Clients should not be forced to depend on interfaces they do not use. Interfaces are tailored to specific clients to avoid unnecessary dependencies.
- Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules. Both should depend on abstractions, allowing for loose coupling and easier testing.
The project includes unit tests implemented using Mockito and JUnit 5. The tests focus on verifying the behavior and correctness of individual components, such as controller and service classes.
The use of unit testing helps ensure that each unit of code functions as expected and facilitates the identification and resolution of issues during development.
The tests are located in the test
directory and follow a similar package structure as the main source code.
- @angular/animations: ^15.2.0
- @angular/cdk: ^15.2.9
- @angular/common: ^15.2.0
- @angular/compiler: ^15.2.0
- @angular/core: ^15.2.0
- @angular/forms: ^15.2.0
- @angular/material: ^15.2.9
- @angular/platform-browser: ^15.2.0
- @angular/platform-browser-dynamic: ^15.2.0
- @angular/router: ^15.2.0
- ngx-pagination: ^6.0.3
- rxjs: ~7.8.0
- tslib: ^2.3.0
- zone.js: ~0.12.0
- Spring Boot: 2.7.11
- Spring Boot Starter Data JPA
- Spring Boot Starter Web
- Spring Boot Starter Undertow (provided scope)
- Spring Boot Starter Validation
- H2 Database (runtime scope)
- Project Lombok
- Spring Boot Starter Test (test scope)
- JBoss XNIO API: 3.8.8.Final
To run the project, you need to have the following dependencies installed:
- Node.js 18
- Angular CLI 15
- Java 8 or higher
- Maven
- WildFly 24
Make sure to set up a H2 database datasource named java:/test
in your WildFly server.
The Angular frontend application is responsible for the user interface and interaction with the backend service.
- Clone the project repository.
- Navigate to the
frontend
directory. - Run
npm install
to install the project dependencies.
To start the development server, run npm start
or ng serve
from the frontend
directory. The application will be accessible at http://localhost:4200
.
To build the application, run npm run build
or ng build
. The build artifacts will be stored in the frontend/dist
directory.
The Spring Boot backend service provides the RESTful APIs for managing employees.
To start the development server, run mvn spring-boot:run -Pdev
from the backend
directory. The application will be accessible at http://localhost:8080
.
To build the Spring Boot application, run mvn clean package -Pprod test -Pdev
from the project's backend
directory. This will create a WAR file in the target
directory.
Deploy the generated WAR file to your WildFly server. Make sure the server is running and has the H2 datasource configured.
The backend service exposes the following endpoints:
-
GET /api/v1/employees: Retrieves a paginated list of all employees. Accepts optional pagination parameters:
page
,size
, andsort
. -
GET /api/v1/employee/{employeeId}: Retrieves a specific employee by ID.
-
POST /api/v1/employee: Creates a new employee. Requires a JSON payload with the employee data.
-
PUT /api/v1/employee: Updates an existing employee. Requires a JSON payload with the updated employee data.
-
DELETE /api/v1/employee/{employeeId}: Deletes a specific employee by ID.
Make HTTP requests to the respective endpoints to interact with the employee management system.
{
"id": 1,
"firstName": "Michael",
"lastName": "Scott",
"position": "Regional Manager",
"salary": 5000.0,
"annualSalary": 60000.0
}
{
"content": [
{
"id": 1,
"firstName": "Michael",
"lastName": "Scott",
"position": "Regional Manager",
"salary": 5000.0,
"annualSalary": 60000.0
},
{
"id": 2,
"firstName": "Jim",
"lastName": "Halpert",
"position": "Sales Representative",
"salary": 4000.0,
"annualSalary": 48000.0
},
{
"id": 3,
"firstName": "Dwight",
"lastName": "Schrute",
"position": "Assistant to the Regional Manager",
"salary": 3800.0,
"annualSalary": 45600.0
},
{
"id": 4,
"firstName": "Pam",
"lastName": "Beesly",
"position": "Receptionist",
"salary": 3500.0,
"annualSalary": 42000.0
},
{
"id": 5,
"firstName": "Angela",
"lastName": "Martin",
"position": "Senior Accountant",
"salary": 4500.0,
"annualSalary": 54000.0
},
{
"id": 6,
"firstName": "Ryan",
"lastName": "Howard",
"position": "Temp",
"salary": 3000.0,
"annualSalary": 36000.0
},
{
"id": 7,
"firstName": "Oscar",
"lastName": "Martinez",
"position": "Accountant",
"salary": 3900.0,
"annualSalary": 46800.0
},
{
"id": 8,
"firstName": "Kelly",
"lastName": "Kapoor",
"position": "Customer Service Representative",
"salary": 3200.0,
"annualSalary": 38400.0
},
{
"id": 9,
"firstName": "Kevin",
"lastName": "Malone",
"position": "Accountant",
"salary": 4200.0,
"annualSalary": 50400.0
},
{
"id": 10,
"firstName": "Stanley",
"lastName": "Hudson",
"position": "Sales Representative",
"salary": 4100.0,
"annualSalary": 49200.0
}
],
"pageable": {
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"offset": 0,
"pageSize": 20,
"pageNumber": 0,
"paged": true,
"unpaged": false
},
"last": true,
"totalElements": 10,
"totalPages": 1,
"size": 20,
"number": 0,
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"numberOfElements": 10,
"first": true,
"empty": false
}
This README provides an overview of the project, its dependencies, and instructions for running the frontend and backend components. Refer to the specific sections for detailed information on installation, configuration, building, and running the application.