- Backend application demo using Spring Boot
- Application to manage Yoga classes
- Refactored of old version
- Docker
- PostgreSQL & pgAdmin
- Java & Spring boot
- Dependencies used:
- Spring Boot DevTools
- Spring Web
- JDBC API
- Spring Data JPA
- PostgreSQL Driver
- Validation
- Spring Boot Actuator
- Clone Repository and open project in IDE
- Set up database
- Run application
- Start docker daemon os unix based systems or docker desktop on windows based systems.
- Change directory to root of project using
cd /yoga-class-refactor/
then run Docker compose usingdocker compose up
- Open pgAdmin
- Set master password for pgAdmin
- Add a new server in pgAdmin:
- Set server name in general tab
- Set Host name/address in connection tab (get the address using command
docker inspect postgres_container | grep IPAddress
) - Set username =
mustafa
& password =123456789
in connection tab
- Create database with name
yoga-class-app
- Open Swagger to test CRUD operations
- Create operation
- Read operation
- Update operation
- Delete operation
- Enter body in POST request then execute
- Sample #1 Body
{
"firstName": "Ahmad",
"lastName": "Al-Deeb",
"phone": "01211223344",
"email": "[email protected]",
"nationality": "Egyptian",
"dateOfBirth": "2012-12-12",
"role": "STUDENT"
}
- Expected Response for Sample #1
- Sample #2 Body
{
"firstName": "Andrew",
"lastName": "Seif",
"phone": "01266778899",
"email": "[email protected]",
"nationality": "Egyptian",
"dateOfBirth": "2000-01-10",
"role": "INSTRUCTOR"
}
- Expected Response for Sample #2
- View results in database using below query in pgAdmin
SELECT id, first_name, last_name, role, email, phone, date_of_birth, nationality, created_by, created_date, last_modified_by, last_modified_date
FROM public.yoga_user;
id | first_name | last_name | role | phone | date_of_birth | nationality | created_by | created_date | last_modified_by | last_modified_date | |
---|---|---|---|---|---|---|---|---|---|---|---|
c65d94c8-0646-4803-98d6-dffdf122c824 | Ahmad | Al-Deeb | STUDENT | [email protected] | 01211223344 | 2012-12-12 02:00:00 | Egyptian | Test User | 2024-04-05 11:51:35.289056 | Test User | 2024-04-05 11:51:35.289056 |
914a4c5d-9916-4a07-a626-edc35dcc1226 | Andrew | Seif | INSTRUCTOR | [email protected] | 01266778899 | 2000-01-10 02:00:00 | Egyptian | Test User | 2024-04-05 11:52:17.970292 | Test User | 2024-04-05 11:52:17.970292 |
- Copy one user's id and use it to execute GET request
- Expected Response
- Just execute GET request
- Expected Response
- Copy one user's id and use it to execute PUT request
- Updating
lastName
&Role
fields
{
"lastName": "Deeb",
"role": "INSTRUCTOR"
}
- Expected Response
- View results in database using below query in pgAdmin
SELECT id, first_name, last_name, role, email, phone, date_of_birth, nationality, created_by, created_date, last_modified_by, last_modified_date
FROM public.yoga_user;
id | first_name | last_name | role | phone | date_of_birth | nationality | created_by | created_date | last_modified_by | last_modified_date | |
---|---|---|---|---|---|---|---|---|---|---|---|
914a4c5d-9916-4a07-a626-edc35dcc1226 | Andrew | Seif | INSTRUCTOR | [email protected] | 01266778899 | 2000-01-10 02:00:00 | Egyptian | Test User | 2024-04-05 11:52:17.970292 | Test User | 2024-04-05 11:52:17.970292 |
c65d94c8-0646-4803-98d6-dffdf122c824 | Ahmad | Deeb | INSTRUCTOR | [email protected] | 01211223344 | 2012-12-12 02:00:00 | Egyptian | Test User | 2024-04-05 11:51:35.289056 | Test User | 2024-04-05 11:56:21.676482 |
- Copy one user's id and use it to execute DELETE request
- Expected Response
- View results in database using below query in pgAdmin
SELECT id, first_name, last_name, role, email, phone, date_of_birth, nationality, created_by, created_date, last_modified_by, last_modified_date
FROM public.yoga_user;
id | first_name | last_name | role | phone | date_of_birth | nationality | created_by | created_date | last_modified_by | last_modified_date | |
---|---|---|---|---|---|---|---|---|---|---|---|
914a4c5d-9916-4a07-a626-edc35dcc1226 | Andrew | Seif | INSTRUCTOR | [email protected] | 01266778899 | 2000-01-10 02:00:00 | Egyptian | Test User | 2024-04-05 11:52:17.970292 | Test User | 2024-04-05 11:52:17.970292 |