diff --git a/.gitattributes b/.gitattributes
index b5cdfa27b762ffc45b54f99b1c13c8b53159502c..5d3ffc5a953e83b23458c681a9783365e24b12c9 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -129,3 +129,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/009[[:space:]]Object,[[:space:]]JNI[[:space:]]and[[:space:]]Object[[:space:]]class[[:space:]]overview.mp4 filter=lfs diff=lfs merge=lfs -text
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/013[[:space:]]Liskov[[:space:]]Substitution[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/014[[:space:]]Interface[[:space:]]Segregation[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
+13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/015[[:space:]]Dependency[[:space:]]Inversion[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/001[[:space:]]Version[[:space:]]Control[[:space:]]Systems[[:space:]]&[[:space:]]Git[[:space:]]-[[:space:]]Overview.mp4 filter=lfs diff=lfs merge=lfs -text
+16[[:space:]]-[[:space:]]===[[:space:]]EXAM[[:space:]]OOP[[:space:]]&[[:space:]]Object[[:space:]]Oriented[[:space:]]e-Commerce[[:space:]]console[[:space:]]applications[[:space:]]===/001[[:space:]]Exam[[:space:]]and[[:space:]]homework[[:space:]]for[[:space:]]OOP[[:space:]]topic.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/004[[:space:]]Git[[:space:]]repo[[:space:]]init,[[:space:]]First[[:space:]]commit[[:space:]]and[[:space:]]main[[:space:]]bracnh.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/005[[:space:]]Git[[:space:]]ignoring[[:space:]]&[[:space:]]Git[[:space:]]log.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/002[[:space:]]How[[:space:]]to[[:space:]]Install[[:space:]]Git[[:space:]]and[[:space:]]Basic[[:space:]]Git[[:space:]]Configuration.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/006[[:space:]]Git[[:space:]]undoing[[:space:]]things[[:space:]]&[[:space:]]Vi[[:space:]]text[[:space:]]editor.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/007[[:space:]]Git[[:space:]]remote[[:space:]]repositories.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/008[[:space:]]SSH[[:space:]]Connection.mp4 filter=lfs diff=lfs merge=lfs -text
+17[[:space:]]-[[:space:]]GIT/010[[:space:]]Pull[[:space:]]Requests[[:space:]]&[[:space:]]Merge[[:space:]]Requests.mp4 filter=lfs diff=lfs merge=lfs -text
diff --git a/13 - Object-oriented programming/015 Dependency Inversion Principle.mp4 b/13 - Object-oriented programming/015 Dependency Inversion Principle.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..930331b4089389f525e2434241b7dd0fdd8eb273
--- /dev/null
+++ b/13 - Object-oriented programming/015 Dependency Inversion Principle.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4839fd3d0b1411e30add8cf0f50a648927c520582c774aa9487fa2cced8add20
+size 97920838
diff --git a/16 - === EXAM OOP & Object Oriented e-Commerce console applications ===/001 Exam and homework for OOP topic.mp4 b/16 - === EXAM OOP & Object Oriented e-Commerce console applications ===/001 Exam and homework for OOP topic.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..e966d2939d321430e989d88a2af484430888c375
--- /dev/null
+++ b/16 - === EXAM OOP & Object Oriented e-Commerce console applications ===/001 Exam and homework for OOP topic.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:10683a9dfc1d5f7fb211f447a48dab53b3f98038444979089255d4ee0a180ce6
+size 153802800
diff --git a/17 - GIT/001 Version Control Systems & Git - Overview.mp4 b/17 - GIT/001 Version Control Systems & Git - Overview.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..dce253b1587b5ecd255054f41ff1ffd5e63c67fe
--- /dev/null
+++ b/17 - GIT/001 Version Control Systems & Git - Overview.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3fee90b68e09558b6d846df640bad96f49f8d3f2b2baadaa9d61f3210b43d5bb
+size 57399220
diff --git a/17 - GIT/002 How to Install Git and Basic Git Configuration.mp4 b/17 - GIT/002 How to Install Git and Basic Git Configuration.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..82fe71f0c2603bee529bc2ccfbeb53095a9ff761
--- /dev/null
+++ b/17 - GIT/002 How to Install Git and Basic Git Configuration.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c8ada8b8b5e0e12969640b928bd897baa5209608777aecf750847b3ccf974ee4
+size 158468542
diff --git a/17 - GIT/004 Git repo init, First commit and main bracnh.mp4 b/17 - GIT/004 Git repo init, First commit and main bracnh.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..14acde0b356c156962fbf6d41a22b542239f74e3
--- /dev/null
+++ b/17 - GIT/004 Git repo init, First commit and main bracnh.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c13262001a8309cdd0954965676b57ea401c0758db2a02b3d2eaae49c6e391d1
+size 38282816
diff --git a/17 - GIT/005 Git ignoring & Git log.mp4 b/17 - GIT/005 Git ignoring & Git log.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..4c3b279385b3b66ed72b19cf391f18f2132a1e59
--- /dev/null
+++ b/17 - GIT/005 Git ignoring & Git log.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a1be93c5595bd47cb49c7079acfb695a6c90941d35f21b52f5adb6a1c148a1e0
+size 133419159
diff --git a/17 - GIT/006 Git undoing things & Vi text editor.mp4 b/17 - GIT/006 Git undoing things & Vi text editor.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..d13c4050ec3618065d9d5a4346284192302266e3
--- /dev/null
+++ b/17 - GIT/006 Git undoing things & Vi text editor.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a7de076f8653cd0d370273844dab3154041cb461d1521c2c9f9354731f57daf6
+size 147540639
diff --git a/17 - GIT/007 Git remote repositories.mp4 b/17 - GIT/007 Git remote repositories.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..6aba5a5da079e655a4c6c80f24b6716c1a8cee8c
--- /dev/null
+++ b/17 - GIT/007 Git remote repositories.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d1eba26a36847641bc5071a7daa9bca13ed5ebae58553a9b23607abd89ffa61a
+size 105054427
diff --git a/17 - GIT/008 SSH Connection.mp4 b/17 - GIT/008 SSH Connection.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..260eee2bf07a67a2a50bd7f6c84bd2e0a7ee180f
--- /dev/null
+++ b/17 - GIT/008 SSH Connection.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b09ac33aaf19880dba5d977f30da4c0eb7b0ac7be1670dab5c17433b34bae49e
+size 108866715
diff --git a/17 - GIT/010 Pull Requests & Merge Requests.mp4 b/17 - GIT/010 Pull Requests & Merge Requests.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..66674fb8d5e41c55c6556aa38b9811c00d9cccf8
--- /dev/null
+++ b/17 - GIT/010 Pull Requests & Merge Requests.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9f270121a98d4f62d1be9c2a62ecd828eac4ed9ce45f4377b8bf9e40e0a7aae4
+size 140071769
diff --git a/84 - Spring Security/external-links.txt b/84 - Spring Security/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..21f90a9b65783d772fc5138811aef0ea59036f97
--- /dev/null
+++ b/84 - Spring Security/external-links.txt
@@ -0,0 +1,12 @@
+
+002 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/fa1f32b831ae40f681525076f3c8bd8928807f48
+
+003 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/54608d3a38dc7bf0ec826a5210082f931bcf4ce4
+
+004 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/9c0322078c8402104870492f91fc9713fc5f615a
+
+005 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/8dddc2feb47bce4664713763e10e3fd9fda9648b
diff --git a/85 - ===== EXAM Spring Security - Online Shop =====/001 EXAM Spring Security - Online Shop_en.srt b/85 - ===== EXAM Spring Security - Online Shop =====/001 EXAM Spring Security - Online Shop_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..25c8a3d4a2da6efeb5450f229e5f168e2b2b259e
--- /dev/null
+++ b/85 - ===== EXAM Spring Security - Online Shop =====/001 EXAM Spring Security - Online Shop_en.srt
@@ -0,0 +1,1240 @@
+1
+00:00:06,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:13,000
+We have learned a lot about spring security and now it is time for you to practice your skills and realize
+
+3
+00:00:13,000 --> 00:00:16,000
+how much you already learned in the course.
+
+4
+00:00:16,000 --> 00:00:22,000
+As you know, with all my students during the whole course Java from zero to first job, we develop
+
+5
+00:00:22,000 --> 00:00:25,000
+our online shop from scratch.
+
+6
+00:00:25,000 --> 00:00:32,000
+I truly believe that real business case will help you to understand how to apply gained knowledge on
+
+7
+00:00:32,000 --> 00:00:33,000
+practice.
+
+8
+00:00:33,000 --> 00:00:39,000
+And in this exam task we are going to improve our existing web application by adding spring security
+
+9
+00:00:39,000 --> 00:00:40,000
+features to it.
+
+10
+00:00:40,000 --> 00:00:44,000
+Let's review this document with the exam task description.
+
+11
+00:00:44,000 --> 00:00:48,000
+We'll make sure that you understand the task.
+
+12
+00:00:48,000 --> 00:00:51,000
+After that, you will try to implement the task.
+
+13
+00:00:51,000 --> 00:00:56,000
+And at the end of the video lesson, I am going to share with you my solution, and we are going to
+
+14
+00:00:56,000 --> 00:00:57,000
+discuss it.
+
+15
+00:00:57,000 --> 00:01:01,000
+So let's start with the review of the exam task.
+
+16
+00:01:02,000 --> 00:01:07,000
+The first thing that you need to do is to clone repository with our online shop.
+
+17
+00:01:07,000 --> 00:01:13,000
+In my course, Java from zero to first job will develop online shop from scratch and usually during
+
+18
+00:01:13,000 --> 00:01:19,000
+each following exam task, we continue from the point where we stopped last time.
+
+19
+00:01:20,000 --> 00:01:23,000
+So here is the link to the repository.
+
+20
+00:01:23,000 --> 00:01:24,000
+It is solution.
+
+21
+00:01:24,000 --> 00:01:30,000
+After completion of the previous exam task, when we finished integration of the Spring core and spring
+
+22
+00:01:30,000 --> 00:01:32,000
+MVC into our solution.
+
+23
+00:01:33,000 --> 00:01:38,000
+And now it is time to add spring security features into our application.
+
+24
+00:01:38,000 --> 00:01:46,000
+So once you clone the repository, try to run the application and make sure that you don't have errors
+
+25
+00:01:46,000 --> 00:01:47,000
+during the startup.
+
+26
+00:01:47,000 --> 00:01:51,000
+It would also require you to configure database.
+
+27
+00:01:51,000 --> 00:01:57,000
+Basically, you can refer to the README inside the repository and follow simple steps.
+
+28
+00:01:57,000 --> 00:02:04,000
+The main thing is to configure the database server, create schema, configure the schema inside the
+
+29
+00:02:04,000 --> 00:02:09,000
+application, and after that you can let hibernate, create all necessary tables.
+
+30
+00:02:09,000 --> 00:02:16,000
+But after that, in order to bring life to the application, you need to insert some data manually.
+
+31
+00:02:16,000 --> 00:02:21,000
+For example, information about products, about orders and things like that.
+
+32
+00:02:22,000 --> 00:02:23,000
+Everything is prepared for you.
+
+33
+00:02:23,000 --> 00:02:27,000
+You just need to follow the steps described in the README file.
+
+34
+00:02:27,000 --> 00:02:31,000
+You can find the folder with data to insert into the database.
+
+35
+00:02:31,000 --> 00:02:38,000
+Once you configure it application and manage to start it successfully, just navigate between pages,
+
+36
+00:02:38,000 --> 00:02:42,000
+Try to understand how it works just in case.
+
+37
+00:02:42,000 --> 00:02:48,000
+All business requirements that we implemented in the online shop are located in this file.
+
+38
+00:02:48,000 --> 00:02:54,000
+Feel free to look through it to understand the functionality of the application better.
+
+39
+00:02:54,000 --> 00:03:00,000
+It is recommended to make this overview of the functionality in order you can make sure that nothing
+
+40
+00:03:00,000 --> 00:03:03,000
+is broken Once you completed the home task.
+
+41
+00:03:03,000 --> 00:03:08,000
+And now you can start with the integration of the spring security with our application.
+
+42
+00:03:08,000 --> 00:03:15,000
+The first thing that you need to do is to configure authentication and security filter in the application.
+
+43
+00:03:15,000 --> 00:03:22,000
+We already have login page, So like we already learned in one of the lessons we need to configure spring
+
+44
+00:03:22,000 --> 00:03:25,000
+security with the custom login page.
+
+45
+00:03:25,000 --> 00:03:26,000
+Be attentive.
+
+46
+00:03:26,000 --> 00:03:32,000
+During the integration we learned everything you need to know to complete this part of the task.
+
+47
+00:03:32,000 --> 00:03:37,000
+So in case you need to refresh your knowledge, feel free to get back to the lessons that we already
+
+48
+00:03:37,000 --> 00:03:38,000
+watched.
+
+49
+00:03:38,000 --> 00:03:40,000
+Secure Protected Resources.
+
+50
+00:03:40,000 --> 00:03:47,000
+You need to secure order management resources to be accessible only to users with the admin and manager
+
+51
+00:03:47,000 --> 00:03:53,000
+roles and make admin resource available only for users with admin role.
+
+52
+00:03:53,000 --> 00:03:59,000
+Just remember that we don't have to store passwords in the database in the raw format.
+
+53
+00:04:00,000 --> 00:04:05,000
+Always encode passwords before putting them into the database.
+
+54
+00:04:05,000 --> 00:04:12,000
+Our current solution uses custom encoder, but within the task I want to use password encoder been to
+
+55
+00:04:12,000 --> 00:04:19,000
+encode passwords and too much raw password and encoded version of the password when needed.
+
+56
+00:04:20,000 --> 00:04:27,000
+I want you to implement application in the way where we can assign user to multiple roles.
+
+57
+00:04:27,000 --> 00:04:33,000
+In simple words, you need to be able to store array of roles inside the user.
+
+58
+00:04:33,000 --> 00:04:36,000
+Your user can have manager and admin role simultaneously.
+
+59
+00:04:36,000 --> 00:04:37,000
+For example.
+
+60
+00:04:38,000 --> 00:04:41,000
+Each role in turn can have multiple privileges.
+
+61
+00:04:41,000 --> 00:04:48,000
+For example, admin role can have read, write and delete privilege and manager user can have only read
+
+62
+00:04:48,000 --> 00:04:49,000
+and write privilege.
+
+63
+00:04:50,000 --> 00:04:57,000
+This is just an example, but I believe that you understood that role may contain multiple privileges
+
+64
+00:04:57,000 --> 00:05:00,000
+and each privilege can have multiple roles.
+
+65
+00:05:01,000 --> 00:05:02,000
+There will be many to many relation.
+
+66
+00:05:02,000 --> 00:05:03,000
+ActionScript.
+
+67
+00:05:04,000 --> 00:05:08,000
+Also want to implement Remember me functionality.
+
+68
+00:05:08,000 --> 00:05:15,000
+Be attentive because this would also require you to put authenticated user into the session when needed
+
+69
+00:05:15,000 --> 00:05:24,000
+because such element as header in our online shop relies on the user that is stored in the session taking
+
+70
+00:05:24,000 --> 00:05:25,000
+into account user.
+
+71
+00:05:25,000 --> 00:05:31,000
+In the session we show username and we change button in the header.
+
+72
+00:05:31,000 --> 00:05:39,000
+Namely when the user is logged in, we don't need to show button sign in and sign up, we just need
+
+73
+00:05:39,000 --> 00:05:41,000
+to show sign out button.
+
+74
+00:05:41,000 --> 00:05:44,000
+Think about how you will implement this.
+
+75
+00:05:44,000 --> 00:05:49,000
+For users who just registered, we need to set customer role by default.
+
+76
+00:05:49,000 --> 00:05:56,000
+Make sure that the registration login logout remember me and access restrictions functionality works
+
+77
+00:05:56,000 --> 00:05:57,000
+as expected.
+
+78
+00:05:58,000 --> 00:06:03,000
+I believe you can easily complete this task because there is nothing what we didn't discuss during the
+
+79
+00:06:04,000 --> 00:06:05,000
+learning course.
+
+80
+00:06:05,000 --> 00:06:11,000
+So now I recommend you to put on pause the video and proceed with the implementation.
+
+81
+00:06:11,000 --> 00:06:19,000
+And once you are done we are going to review my solution and changes that I did to compare yours and
+
+82
+00:06:19,000 --> 00:06:20,000
+my solution.
+
+83
+00:06:20,000 --> 00:06:27,000
+As you see all conditions and development environment is super close to the reality when you will get
+
+84
+00:06:27,000 --> 00:06:31,000
+new task assigned on you in real life.
+
+85
+00:06:31,000 --> 00:06:37,000
+Because in real life nobody would specify what files you need to fix or change.
+
+86
+00:06:38,000 --> 00:06:45,000
+You need to find the files that are needed to be changed in order to meet the requirements of the task.
+
+87
+00:06:45,000 --> 00:06:50,000
+And this is also part of your education in this course to be ready for real life.
+
+88
+00:06:51,000 --> 00:06:57,000
+So I bet that you completed the home task and now you're ready to review the solution together with
+
+89
+00:06:57,000 --> 00:06:58,000
+me.
+
+90
+00:06:58,000 --> 00:07:04,000
+First of all, I want to highlight that completely working solution is located in the separate repository.
+
+91
+00:07:04,000 --> 00:07:07,000
+You can find link here.
+
+92
+00:07:07,000 --> 00:07:13,000
+Feel free to clone it on your local computer to run it and explore it better.
+
+93
+00:07:14,000 --> 00:07:21,000
+In case you want to explore only changes, here is a commit with all changes that I did to implement
+
+94
+00:07:21,000 --> 00:07:22,000
+this coding exercise.
+
+95
+00:07:23,000 --> 00:07:28,000
+Let's review it together and I will give you my comments as we will go over.
+
+96
+00:07:28,000 --> 00:07:31,000
+I opened the commit with changes.
+
+97
+00:07:31,000 --> 00:07:33,000
+Let's review each file.
+
+98
+00:07:33,000 --> 00:07:41,000
+I introduced Ralph Facade in my business layer, just to remind you that when we learned layered architecture,
+
+99
+00:07:41,000 --> 00:07:45,000
+we made a decision to follow layered architecture pattern.
+
+100
+00:07:45,000 --> 00:07:51,000
+And in the solution we have strict separation between business layer and persistence layer.
+
+101
+00:07:51,000 --> 00:07:55,000
+So you can see that row facade is in our core module.
+
+102
+00:07:55,000 --> 00:07:57,000
+In the business layer.
+
+103
+00:07:57,000 --> 00:08:00,000
+We need to be able to extract role by name.
+
+104
+00:08:01,000 --> 00:08:05,000
+The implementation of the role facade is default role facade.
+
+105
+00:08:06,000 --> 00:08:13,000
+Inject role DAO into this class and role to roll converter.
+
+106
+00:08:13,000 --> 00:08:14,000
+On the business layer.
+
+107
+00:08:14,000 --> 00:08:18,000
+We operate with the business models on the persistence layer.
+
+108
+00:08:18,000 --> 00:08:21,000
+We work with the data transfer objects.
+
+109
+00:08:21,000 --> 00:08:27,000
+That's why we need converters to convert from object to the business model.
+
+110
+00:08:27,000 --> 00:08:34,000
+Moreover, this architecture in the future will allow you to add any business behavior to your business
+
+111
+00:08:34,000 --> 00:08:41,000
+model because methods with business logic, it is not something what you have to store in the objects
+
+112
+00:08:41,000 --> 00:08:42,000
+on the persistence layer.
+
+113
+00:08:42,000 --> 00:08:48,000
+That's why from one side this architecture gives you better scalability.
+
+114
+00:08:48,000 --> 00:08:55,000
+But at the same time, this architecture adds code complexity because of the additional classes.
+
+115
+00:08:55,000 --> 00:09:00,000
+This challenge is addressed in different frameworks in different way.
+
+116
+00:09:00,000 --> 00:09:07,000
+For example, there are already invented code generation tools that generates code automatically, taking
+
+117
+00:09:07,000 --> 00:09:10,000
+into account the structure of the data.
+
+118
+00:09:10,000 --> 00:09:18,000
+Object and converter is easy to define, and you can also create a code that will generate source code
+
+119
+00:09:18,000 --> 00:09:23,000
+of dtos and converters based on the XML configuration by yourself.
+
+120
+00:09:23,000 --> 00:09:31,000
+In other words, you can define your data types in the XML file, for example, and generate all required
+
+121
+00:09:31,000 --> 00:09:32,000
+details automatically.
+
+122
+00:09:32,000 --> 00:09:39,000
+This is just an additional food for thought for you in case you are interested about software architecture.
+
+123
+00:09:39,000 --> 00:09:44,000
+So the implementation of the default rule facade is pretty straightforward.
+
+124
+00:09:44,000 --> 00:09:49,000
+The next file that we updated is default user facade.
+
+125
+00:09:49,000 --> 00:09:58,000
+I've removed setting role name here and instead I added setting array of roles, taking into account
+
+126
+00:09:58,000 --> 00:10:01,000
+that we can register only user with a customer role.
+
+127
+00:10:01,000 --> 00:10:07,000
+You can see here that I passed the array of roles that contains only one element.
+
+128
+00:10:07,000 --> 00:10:08,000
+Customer role.
+
+129
+00:10:09,000 --> 00:10:16,000
+I added spring security core dependency in order to use password encoder in persistence module.
+
+130
+00:10:17,000 --> 00:10:21,000
+The next file that you can see here in the list is the setup data loader.
+
+131
+00:10:21,000 --> 00:10:27,000
+If you watched our lessons attentively, we already had this similar file in our code examples during
+
+132
+00:10:27,000 --> 00:10:28,000
+the previous lessons.
+
+133
+00:10:28,000 --> 00:10:33,000
+We are using it to configure privileges admin and manager users.
+
+134
+00:10:33,000 --> 00:10:39,000
+I will not make a detailed overview of this file because we already did the detailed overview of this
+
+135
+00:10:39,000 --> 00:10:47,000
+file during one of the coding exercises in the lesson, when we learned how to work with roles and privileges.
+
+136
+00:10:47,000 --> 00:10:54,000
+Basically just create or just check that all required roles, privileges and admin users exist in the
+
+137
+00:10:54,000 --> 00:11:01,000
+system and you can see that this class implements application listener of context refreshed event.
+
+138
+00:11:01,000 --> 00:11:06,000
+That means that mass will be triggered on the event of the context refresh.
+
+139
+00:11:07,000 --> 00:11:11,000
+In this solution I introduced new entity privilege.
+
+140
+00:11:11,000 --> 00:11:17,000
+That means that I need to create and implement all the related classes to support operations with this
+
+141
+00:11:17,000 --> 00:11:18,000
+entity.
+
+142
+00:11:18,000 --> 00:11:25,000
+This includes privilege, DAO, privilege, DTO privilege, business entity and privilege detail to
+
+143
+00:11:25,000 --> 00:11:27,000
+privilege business model converter.
+
+144
+00:11:27,000 --> 00:11:34,000
+Here you can see I declared two masses in the privilege DAO interface in the role Dao.
+
+145
+00:11:34,000 --> 00:11:37,000
+I declared one more method safe.
+
+146
+00:11:37,000 --> 00:11:43,000
+It is required for us to create all required roles from the setup data loader class.
+
+147
+00:11:43,000 --> 00:11:48,000
+The next thing here in the list is the implementation of the privilege.
+
+148
+00:11:48,000 --> 00:11:50,000
+Dao privilege.
+
+149
+00:11:50,000 --> 00:11:55,000
+Dao implements a contract using the entity manager factory and entity manager.
+
+150
+00:11:56,000 --> 00:11:58,000
+Also we slightly updated role DAO.
+
+151
+00:11:59,000 --> 00:12:06,000
+I fixed a typo in the class name changed role name attribute and implemented safe method.
+
+152
+00:12:06,000 --> 00:12:12,000
+Again, this is something that you have to be familiar with because we learned literally the similar
+
+153
+00:12:12,000 --> 00:12:15,000
+examples in lessons about GPA.
+
+154
+00:12:15,000 --> 00:12:21,000
+In case you want to refresh your knowledge, feel free to check my course Java from zero to first job
+
+155
+00:12:21,000 --> 00:12:24,000
+and name the section about GPA Hibernate.
+
+156
+00:12:24,000 --> 00:12:26,000
+Let's move on.
+
+157
+00:12:26,000 --> 00:12:29,000
+Here you can see privileged class.
+
+158
+00:12:29,000 --> 00:12:37,000
+And again, I just use the examples that I have shared with you in one of our lessons from this course.
+
+159
+00:12:37,000 --> 00:12:43,000
+So it contains ID, name and list of roles in the role detail.
+
+160
+00:12:43,000 --> 00:12:45,000
+I added privileges property.
+
+161
+00:12:45,000 --> 00:12:50,000
+It is many to many relation and you can see list of privileges here.
+
+162
+00:12:50,000 --> 00:12:53,000
+The rest is just getters and setters.
+
+163
+00:12:54,000 --> 00:13:02,000
+Also, I made changes in the user class configure it many to many relationship with the roles.
+
+164
+00:13:02,000 --> 00:13:05,000
+Also I added is enabled flag.
+
+165
+00:13:05,000 --> 00:13:11,000
+It is not mandatory according to the task requirements, but I just decided to add it for the future.
+
+166
+00:13:11,000 --> 00:13:18,000
+Probably we will implement with you security from the brute force and will disable account in case of
+
+167
+00:13:18,000 --> 00:13:22,000
+multiple failed login attempts or things like that.
+
+168
+00:13:22,000 --> 00:13:28,000
+Anyway, you can just turn on your imagination and come up with different similar business requirements.
+
+169
+00:13:29,000 --> 00:13:30,000
+I leave it here.
+
+170
+00:13:31,000 --> 00:13:35,000
+The next class here in the list is a converter class.
+
+171
+00:13:35,000 --> 00:13:40,000
+It is required to convert privilege to privilege business model.
+
+172
+00:13:40,000 --> 00:13:48,000
+Also based on the changes that we did in the raw entity, I also need to update row to row converter
+
+173
+00:13:48,000 --> 00:13:51,000
+and user to user converter.
+
+174
+00:13:52,000 --> 00:13:57,000
+The next thing here in the list is privileged role and user types.
+
+175
+00:13:57,000 --> 00:14:04,000
+And again, we just need to make proper changes to reflect changes in the relationships that we did
+
+176
+00:14:04,000 --> 00:14:05,000
+in our architecture.
+
+177
+00:14:05,000 --> 00:14:12,000
+Just to remind you that in this task we configured many to many relationships between role and privilege
+
+178
+00:14:12,000 --> 00:14:15,000
+and between user and role entities.
+
+179
+00:14:16,000 --> 00:14:22,000
+And after that goes implementation of these types namely default village.
+
+180
+00:14:22,000 --> 00:14:24,000
+Default role and default user.
+
+181
+00:14:25,000 --> 00:14:31,000
+This is exactly our business entities where we can put any business related behavior associated with
+
+182
+00:14:31,000 --> 00:14:33,000
+these entities.
+
+183
+00:14:33,000 --> 00:14:39,000
+In Pom.xml I added all necessary dependencies to work with spring security.
+
+184
+00:14:40,000 --> 00:14:46,000
+And the web application initializer add spring security filter to the select context.
+
+185
+00:14:46,000 --> 00:14:53,000
+In the next file in the web.config, I created all necessary beans required for implementation of our
+
+186
+00:14:53,000 --> 00:14:54,000
+task.
+
+187
+00:14:54,000 --> 00:15:01,000
+First of all, this is password encoder that we are going to use for password encoding and verification
+
+188
+00:15:01,000 --> 00:15:06,000
+of the raw password with its encoded version during the login.
+
+189
+00:15:06,000 --> 00:15:10,000
+The next bin is the authentication success handler.
+
+190
+00:15:10,000 --> 00:15:13,000
+We are going to review implementation a little bit later.
+
+191
+00:15:13,000 --> 00:15:20,000
+In short, I will use it for putting user into session and configuring redirection based on the roles
+
+192
+00:15:20,000 --> 00:15:21,000
+assigned.
+
+193
+00:15:22,000 --> 00:15:30,000
+Then we have configuration of the security filter chain authorization of requests, custom login form.
+
+194
+00:15:30,000 --> 00:15:31,000
+Pay attention.
+
+195
+00:15:31,000 --> 00:15:34,000
+I change the name of the username parameter.
+
+196
+00:15:34,000 --> 00:15:41,000
+As you remember, in case you use custom attribute name for username in the login form, you need to
+
+197
+00:15:41,000 --> 00:15:44,000
+specify it in the configuration.
+
+198
+00:15:44,000 --> 00:15:49,000
+And in my case I decided not to change existing login form.
+
+199
+00:15:49,000 --> 00:15:53,000
+An existing form uses email name parameter.
+
+200
+00:15:54,000 --> 00:15:58,000
+I said success handler and failure handler.
+
+201
+00:15:58,000 --> 00:16:04,000
+Failure handler is used to limit failed amount of the attempts to login with the same period of time.
+
+202
+00:16:04,000 --> 00:16:08,000
+We are going to review implementation a little bit later.
+
+203
+00:16:08,000 --> 00:16:12,000
+Actually, it was already implemented in the template of the code.
+
+204
+00:16:13,000 --> 00:16:18,000
+I just took it from the in controller and moved it into failure handler.
+
+205
+00:16:18,000 --> 00:16:21,000
+Configure it, log out and remember me feature.
+
+206
+00:16:22,000 --> 00:16:28,000
+Remember me configuration used literally in the same way like I showed you in the lesson about Remember
+
+207
+00:16:28,000 --> 00:16:29,000
+Me functionality.
+
+208
+00:16:30,000 --> 00:16:32,000
+The next bin is failure Handler.
+
+209
+00:16:32,000 --> 00:16:36,000
+We are going to review its implementation soon.
+
+210
+00:16:37,000 --> 00:16:42,000
+Also user details, service authentication provider and registration of the authentication provider
+
+211
+00:16:42,000 --> 00:16:45,000
+in the authentication manager.
+
+212
+00:16:45,000 --> 00:16:48,000
+Admin controller is the next file in the list.
+
+213
+00:16:48,000 --> 00:16:50,000
+This is just simple controller.
+
+214
+00:16:50,000 --> 00:16:56,000
+In order to resolve admin panel view that according to requirements should be protected.
+
+215
+00:16:57,000 --> 00:17:03,000
+There are no specific requirements to this panel in general, and this particular exam task will practice
+
+216
+00:17:03,000 --> 00:17:06,000
+our skills and configuration of the spring security.
+
+217
+00:17:07,000 --> 00:17:10,000
+That's why the simple page is enough.
+
+218
+00:17:10,000 --> 00:17:12,000
+In the edit profile controller.
+
+219
+00:17:12,000 --> 00:17:20,000
+I also made some changes because it used as encoder and now inject password encoder being that we declared.
+
+220
+00:17:21,000 --> 00:17:28,000
+I removed a lot from the sign in controller because part of the functionality described here goes to
+
+221
+00:17:28,000 --> 00:17:29,000
+the spring security.
+
+222
+00:17:29,000 --> 00:17:36,000
+Another part of the functionality is moved into authentication success handler and the last part of
+
+223
+00:17:36,000 --> 00:17:40,000
+the functionality is moved into the authentication failure handler.
+
+224
+00:17:41,000 --> 00:17:45,000
+Signout controller was removed because we don't need it.
+
+225
+00:17:45,000 --> 00:17:53,000
+Spring security will take care of Signout and we configure it Signout already in signup controller.
+
+226
+00:17:53,000 --> 00:18:01,000
+I also had to make changes in order to inject password and quarter bean and use its API.
+
+227
+00:18:01,000 --> 00:18:06,000
+Admin filter and management filter were removed because right now there is no need in them.
+
+228
+00:18:07,000 --> 00:18:11,000
+Authentication is performed by the spring security now.
+
+229
+00:18:12,000 --> 00:18:15,000
+Remember me filter is important and interesting.
+
+230
+00:18:15,000 --> 00:18:18,000
+One let me explain you why we need it.
+
+231
+00:18:18,000 --> 00:18:26,000
+So as you may notice, some behavior in the application relies on the presence of the user in the session.
+
+232
+00:18:26,000 --> 00:18:34,000
+Namely, we need to hide signing button in the header in case user is logged in and show his name.
+
+233
+00:18:34,000 --> 00:18:42,000
+And also we need to hide sign up button in case user is logged in and to show sign out button instead
+
+234
+00:18:42,000 --> 00:18:50,000
+we implemented Remember Me feature in the scenario when I close the web browser and open it again based
+
+235
+00:18:50,000 --> 00:18:59,000
+on the cookie set application authenticates our user, but the session is actually destroyed and new
+
+236
+00:18:59,000 --> 00:19:00,000
+one is created.
+
+237
+00:19:00,000 --> 00:19:09,000
+So this filter intercepts all the requests in case there is no user in the session configured, I check
+
+238
+00:19:09,000 --> 00:19:16,000
+whether there is somebody authenticated in the security context holder and in case there is somebody
+
+239
+00:19:16,000 --> 00:19:22,000
+authenticated, we get this user by email from the persistent storage and we set it into the session.
+
+240
+00:19:22,000 --> 00:19:24,000
+That's it.
+
+241
+00:19:24,000 --> 00:19:31,000
+Another challenge that you may face with in general with injecting beans into the web filters because
+
+242
+00:19:31,000 --> 00:19:39,000
+of the way how initialization happens, you can't inject beans by simply putting auto wired annotation.
+
+243
+00:19:40,000 --> 00:19:47,000
+One of the possible ways of how to initialize a property with the bin that you want is to get the reference
+
+244
+00:19:47,000 --> 00:19:51,000
+to the application context and extract bin from it.
+
+245
+00:19:51,000 --> 00:19:53,000
+How to do this?
+
+246
+00:19:53,000 --> 00:20:00,000
+You can see in these lines, the next class here is a default authentication failure handler.
+
+247
+00:20:00,000 --> 00:20:07,000
+And as already mentioned before, this code is part of the code that I took from the sign in controller
+
+248
+00:20:07,000 --> 00:20:09,000
+of the project template.
+
+249
+00:20:09,000 --> 00:20:16,000
+Taking into account that authentication is handled by the spring security, I need to put some part
+
+250
+00:20:16,000 --> 00:20:18,000
+of logic into the event handlers.
+
+251
+00:20:19,000 --> 00:20:26,000
+Namely, in this handler, I handle cases of the failure during the authentication in case there will
+
+252
+00:20:26,000 --> 00:20:32,000
+be three unsuccessful attempts of login, we update the variable of the unsuccessful login in order
+
+253
+00:20:32,000 --> 00:20:38,000
+to prevent brute force and stop wrong usage of the web application.
+
+254
+00:20:38,000 --> 00:20:42,000
+His next file here is a authentication success handler.
+
+255
+00:20:42,000 --> 00:20:50,000
+The purpose of this handler, first of all, is to make sure that we put user into the session in order
+
+256
+00:20:50,000 --> 00:20:57,000
+to use it later in the application during the purchase flow and other business related actions, and
+
+257
+00:20:57,000 --> 00:21:03,000
+taking into account that redirection to the configured success here doesn't work when we declare a success
+
+258
+00:21:03,000 --> 00:21:04,000
+handler.
+
+259
+00:21:04,000 --> 00:21:12,000
+Considering this, I also need to manage redirection of the user based on their roles in this event
+
+260
+00:21:12,000 --> 00:21:12,000
+handler.
+
+261
+00:21:13,000 --> 00:21:19,000
+So users with the admin role are redirected to the admin panel and all other users are redirected to
+
+262
+00:21:19,000 --> 00:21:22,000
+the home page according to our requirements.
+
+263
+00:21:23,000 --> 00:21:26,000
+Default authentication provider.
+
+264
+00:21:26,000 --> 00:21:30,000
+I used the same that we used and reviewed in the lesson.
+
+265
+00:21:30,000 --> 00:21:35,000
+Just checking username and password and returning authentication object.
+
+266
+00:21:36,000 --> 00:21:40,000
+The fork user details service almost the similar story.
+
+267
+00:21:40,000 --> 00:21:43,000
+I took the same implementation that I used in the lesson.
+
+268
+00:21:44,000 --> 00:21:47,000
+I believe there is no need for me to repeat myself on everything.
+
+269
+00:21:47,000 --> 00:21:53,000
+What we have reviewed in the lessons because in this case the length of this video will be the summary
+
+270
+00:21:53,000 --> 00:21:55,000
+length of all previous lessons.
+
+271
+00:21:55,000 --> 00:22:00,000
+Feel free to get back to the previous lessons in case you want to refresh your knowledge.
+
+272
+00:22:00,000 --> 00:22:07,000
+And in this video I will focus only on the specifics of the implementation of the application.
+
+273
+00:22:08,000 --> 00:22:14,000
+I removed and quarters that we used in the previous solution because now we are going to use password
+
+274
+00:22:14,000 --> 00:22:23,000
+encoder been added some changes in the profile personal tag taking into account we have array of roles
+
+275
+00:22:23,000 --> 00:22:24,000
+associated with the user.
+
+276
+00:22:24,000 --> 00:22:28,000
+Let's not display all the possible role names.
+
+277
+00:22:28,000 --> 00:22:31,000
+Here is the template file for admin panel.
+
+278
+00:22:31,000 --> 00:22:38,000
+So team, the main thing for us is to practice our skills in the configuration of the spring security.
+
+279
+00:22:38,000 --> 00:22:43,000
+That's why there is not so much JavaScript or anything else on this page.
+
+280
+00:22:43,000 --> 00:22:49,000
+It exists just for you to practice in configuring access to the admin resources.
+
+281
+00:22:50,000 --> 00:22:54,000
+Also, I introduced improvements in the not found page.
+
+282
+00:22:54,000 --> 00:23:02,000
+I used the URL from the core STL in order to not have problems with the relative paths in case Page
+
+283
+00:23:02,000 --> 00:23:08,000
+is not found, not in the root of our application, but in some other places.
+
+284
+00:23:08,000 --> 00:23:15,000
+Because previously we had issues with not being able to find required CSS resources using relative paths.
+
+285
+00:23:16,000 --> 00:23:22,000
+This improvement is not specified directly in the requirements of the exam task.
+
+286
+00:23:22,000 --> 00:23:29,000
+I just gradually improve our solution in case I found something strange or typos like here, for example.
+
+287
+00:23:30,000 --> 00:23:36,000
+Because our goal is to make completely ready to use online shop by the end of the course.
+
+288
+00:23:36,000 --> 00:23:38,000
+Java from zero to first job.
+
+289
+00:23:39,000 --> 00:23:45,000
+On the sign in page, I added Remember me checkbox and updated action in my form.
+
+290
+00:23:45,000 --> 00:23:48,000
+According to the configuration defined.
+
+291
+00:23:48,000 --> 00:23:56,000
+Also, I fixed type in the template project because for the password it is recommended to use password
+
+292
+00:23:56,000 --> 00:23:58,000
+element for the security reasons.
+
+293
+00:23:59,000 --> 00:24:06,000
+I've removed redundant sinks from the web.xml and also I had to adjust the styling for the checkbox
+
+294
+00:24:06,000 --> 00:24:12,000
+because opacity was set to zero and absolute position was a shift to the left.
+
+295
+00:24:13,000 --> 00:24:19,000
+So without commenting these styles in the style CSS, you won't be able to see the checkbox that you
+
+296
+00:24:19,000 --> 00:24:21,000
+put on the sign in page.
+
+297
+00:24:22,000 --> 00:24:23,000
+Be attentive.
+
+298
+00:24:23,000 --> 00:24:26,000
+I also made checkbox slightly bigger.
+
+299
+00:24:27,000 --> 00:24:31,000
+Basically that's all solutions that I've implemented.
+
+300
+00:24:32,000 --> 00:24:38,000
+And remember, in programming, especially on such advanced level and using such flexible framework
+
+301
+00:24:38,000 --> 00:24:43,000
+as spring, there are always multiple solutions to solve the same task.
+
+302
+00:24:43,000 --> 00:24:50,000
+So don't worry in case your implementation is slightly different, no need to worry about that is also
+
+303
+00:24:50,000 --> 00:24:56,000
+fine because like I said, there are multiple possible solutions of the same task.
+
+304
+00:24:57,000 --> 00:25:04,000
+I'm sure that this learning module was super useful for you, and we learned really a lot of things.
+
+305
+00:25:04,000 --> 00:25:11,000
+After completion of this exam task, you can consider yourself as professional in spring security.
+
+306
+00:25:11,000 --> 00:25:13,000
+Congratulations with this.
+
+307
+00:25:13,000 --> 00:25:20,000
+And always remember that in case you have any questions, you can put them below the video and I will
+
+308
+00:25:20,000 --> 00:25:21,000
+be happy to answer.
+
+309
+00:25:22,000 --> 00:25:24,000
+So thanks a lot for your attention.
+
+310
+00:25:25,000 --> 00:25:28,000
+We should agree today and see you in the next lesson.
+
diff --git a/85 - ===== EXAM Spring Security - Online Shop =====/001 Exam-task-description-with-the-reference-to-the-solution.url b/85 - ===== EXAM Spring Security - Online Shop =====/001 Exam-task-description-with-the-reference-to-the-solution.url
new file mode 100644
index 0000000000000000000000000000000000000000..1ebc8420515b08df2891442b3d368e47bd12eb81
--- /dev/null
+++ b/85 - ===== EXAM Spring Security - Online Shop =====/001 Exam-task-description-with-the-reference-to-the-solution.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://docs.google.com/document/d/1HjR-heOVqGgGVdtqf1_5r_T21Ax45lynDktLJzngHTU/edit?usp=sharing
\ No newline at end of file
diff --git a/85 - ===== EXAM Spring Security - Online Shop =====/external-links.txt b/85 - ===== EXAM Spring Security - Online Shop =====/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..d6310f066b138e7ac2afb8b912f4c6c57b673fec
--- /dev/null
+++ b/85 - ===== EXAM Spring Security - Online Shop =====/external-links.txt
@@ -0,0 +1,3 @@
+
+001 Exam-task-description-with-the-reference-to-the-solution
+https://docs.google.com/document/d/1HjR-heOVqGgGVdtqf1_5r_T21Ax45lynDktLJzngHTU/edit?usp=sharing
diff --git a/86 - Spring Data/001 Spring Data & Spring Data JPA Overview_en.srt b/86 - Spring Data/001 Spring Data & Spring Data JPA Overview_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..e0e82f356c8b6a5a7f0de2c3fd73d5e35698d028
--- /dev/null
+++ b/86 - Spring Data/001 Spring Data & Spring Data JPA Overview_en.srt
@@ -0,0 +1,664 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:09,000
+Welcome to the first lesson of the new module.
+
+3
+00:00:09,000 --> 00:00:16,000
+We are continuing learning spring framework and with this lesson we start learning of the Spring data
+
+4
+00:00:16,000 --> 00:00:17,000
+module.
+
+5
+00:00:17,000 --> 00:00:24,000
+In this first video we are going to learn what is spring data is we will make an overview in order.
+
+6
+00:00:24,000 --> 00:00:27,000
+You can understand what it is.
+
+7
+00:00:27,000 --> 00:00:34,000
+We will learn what spring data modules exists and we will focus our attention on the review of the Spring
+
+8
+00:00:34,000 --> 00:00:36,000
+Data JPA module.
+
+9
+00:00:36,000 --> 00:00:42,000
+You are going to understand the challenge that spring data JPA is supposed to help us with.
+
+10
+00:00:43,000 --> 00:00:46,000
+I will explain what spring data repositories are.
+
+11
+00:00:46,000 --> 00:00:53,000
+Also, we'll talk about repository pattern and at the end of the lesson we are going to use spring data,
+
+12
+00:00:53,000 --> 00:00:55,000
+JPA advantages and disadvantages.
+
+13
+00:00:55,000 --> 00:01:01,000
+This will be introductory lessons that will give you more context before we jump to practical coding
+
+14
+00:01:01,000 --> 00:01:06,000
+exercises in the following lessons, let's start our lesson.
+
+15
+00:01:06,000 --> 00:01:11,000
+Let's start with a brief overview of what actually spring data is.
+
+16
+00:01:11,000 --> 00:01:19,000
+The spring data is an umbrella project, having many subprojects or modules to provide uniform abstractions
+
+17
+00:01:19,000 --> 00:01:27,000
+and uniform utility methods for the data access layer in an application and supports a wide range of
+
+18
+00:01:27,000 --> 00:01:30,000
+databases and data stores.
+
+19
+00:01:30,000 --> 00:01:32,000
+What kind of projects?
+
+20
+00:01:32,000 --> 00:01:33,000
+For example?
+
+21
+00:01:33,000 --> 00:01:40,000
+Data graph data, JDBC data, JPA data, Mongo data, Solr, etcetera.
+
+22
+00:01:40,000 --> 00:01:47,000
+And it is important to understand that spring data is not a specification to implement or some kind
+
+23
+00:01:47,000 --> 00:01:48,000
+of standard.
+
+24
+00:01:48,000 --> 00:01:50,000
+It is just an abstraction.
+
+25
+00:01:50,000 --> 00:01:57,000
+It contains many different modules starting from the core Spring Data Commons module to specific ones
+
+26
+00:01:57,000 --> 00:02:01,000
+like spring data radius, spring data, Mongo, etcetera.
+
+27
+00:02:02,000 --> 00:02:08,000
+The goal of this abstraction is to bring consistency between the ways we access data on multiple data
+
+28
+00:02:08,000 --> 00:02:14,000
+stores, no matter whether we are talking about relational or NoSQL databases.
+
+29
+00:02:14,000 --> 00:02:20,000
+Another important thing to understand is to know what a spring data JPA is.
+
+30
+00:02:20,000 --> 00:02:29,000
+So as I already said, spring data is a common name that is used to group multiple sub projects and
+
+31
+00:02:29,000 --> 00:02:30,000
+spring data.
+
+32
+00:02:30,000 --> 00:02:35,000
+JPA is just one out of many other projects, but probably one of the most popular.
+
+33
+00:02:35,000 --> 00:02:40,000
+A lot of people saying that Spring Data JPA is a GP implementation.
+
+34
+00:02:40,000 --> 00:02:42,000
+Actually, it is not.
+
+35
+00:02:42,000 --> 00:02:48,000
+In reality, Spring Data JPA uses hibernate GP implementation.
+
+36
+00:02:48,000 --> 00:02:57,000
+GPA is a specification that defines an API for object relational mappings and for managing persistent
+
+37
+00:02:57,000 --> 00:02:58,000
+objects.
+
+38
+00:02:58,000 --> 00:03:04,000
+Hibernate and Eclipselink are two the most popular implementations of this specification and in the
+
+39
+00:03:04,000 --> 00:03:08,000
+case spring data JPA is not a GP implementation.
+
+40
+00:03:08,000 --> 00:03:14,000
+Then what it is, we can say that spring Data JPA is an add on for GPA.
+
+41
+00:03:15,000 --> 00:03:21,000
+It provides a framework that works with GPA and provides a complete abstraction over the data access
+
+42
+00:03:21,000 --> 00:03:22,000
+layer.
+
+43
+00:03:22,000 --> 00:03:27,000
+Taking into account that spring data JPA is add on on top of GPA.
+
+44
+00:03:28,000 --> 00:03:36,000
+It uses all features defined by the GPA specification, including entity mappings, lifecycle management
+
+45
+00:03:36,000 --> 00:03:39,000
+and GPA query capabilities.
+
+46
+00:03:39,000 --> 00:03:47,000
+And on top of that, spring data, JPA adds its own features like no code implementation of the DAO
+
+47
+00:03:47,000 --> 00:03:51,000
+and creation of database queries from the method names.
+
+48
+00:03:51,000 --> 00:03:56,000
+We are going to start learning the spring data from the Spring Data JPA module.
+
+49
+00:03:57,000 --> 00:04:02,000
+To begin with, let's understand the problem that we are going to address with the spring data.
+
+50
+00:04:02,000 --> 00:04:09,000
+If you are a student of my course Java from zero to first job and you learned DAO pattern in one of
+
+51
+00:04:09,000 --> 00:04:17,000
+the lessons, then you already realize what does it mean to define interface for DAO to implement it
+
+52
+00:04:17,000 --> 00:04:24,000
+and you have multiple entities and also in case you want to switch to another database, for example,
+
+53
+00:04:24,000 --> 00:04:29,000
+from relational to Non-relational, you need to implement all those again.
+
+54
+00:04:29,000 --> 00:04:33,000
+And imagine doing this for all entities in your application.
+
+55
+00:04:33,000 --> 00:04:41,000
+It is really big amount of code and it is good in case you don't have too much entities, but in case
+
+56
+00:04:41,000 --> 00:04:48,000
+you have a lot of models, you feel all the pain and most of the code looks similar.
+
+57
+00:04:49,000 --> 00:04:51,000
+What if we could simplify this?
+
+58
+00:04:51,000 --> 00:04:59,000
+There are a lot of advantages of such simplification, like, for example, decreasing the number of
+
+59
+00:04:59,000 --> 00:05:05,000
+artifacts that we need to create and support consistency of data access patterns and consistency of
+
+60
+00:05:05,000 --> 00:05:10,000
+configuration and spring data helps us to simplify this.
+
+61
+00:05:10,000 --> 00:05:17,000
+Spring data is going to address the challenge of the implementation of different DAO and their support.
+
+62
+00:05:18,000 --> 00:05:19,000
+Spring data.
+
+63
+00:05:19,000 --> 00:05:22,000
+JPA brings the concept of the repositories.
+
+64
+00:05:23,000 --> 00:05:24,000
+What are they?
+
+65
+00:05:25,000 --> 00:05:32,000
+Repositories are a set of interfaces that define ready to use methods to work with the data from the
+
+66
+00:05:32,000 --> 00:05:33,000
+repositories.
+
+67
+00:05:33,000 --> 00:05:40,000
+The JPA repository represents the layer in our application according to the concept.
+
+68
+00:05:40,000 --> 00:05:46,000
+You don't necessarily need to write queries anymore, but still you can.
+
+69
+00:05:46,000 --> 00:05:52,000
+And sometimes you have to write SQL queries using spring data JPA.
+
+70
+00:05:52,000 --> 00:05:55,000
+You don't need to write SQL statements.
+
+71
+00:05:55,000 --> 00:06:01,000
+So taking into account spring GPA uses hibernate GP implementation.
+
+72
+00:06:01,000 --> 00:06:07,000
+It uses entity manager for persistent and retrieving entities from the databases.
+
+73
+00:06:07,000 --> 00:06:11,000
+It also enables entity object and their mappings.
+
+74
+00:06:11,000 --> 00:06:19,000
+So in order to understand how spring data JPA works, it is nice to have experience of working with
+
+75
+00:06:19,000 --> 00:06:20,000
+Hibernate.
+
+76
+00:06:20,000 --> 00:06:26,000
+And in case you want to refresh your knowledge, I have a lot of detailed lessons about Hibernate in
+
+77
+00:06:26,000 --> 00:06:28,000
+my course Java from zero to first job.
+
+78
+00:06:29,000 --> 00:06:36,000
+Now it is time to review advantages and disadvantages of Spring Data JPA and we are going to start with
+
+79
+00:06:36,000 --> 00:06:37,000
+advantages.
+
+80
+00:06:38,000 --> 00:06:45,000
+The first advantage of the spring data JPA is its seamless integration with the rest of the spring framework.
+
+81
+00:06:45,000 --> 00:06:52,000
+Just imagine integration with all other spring based components in your application.
+
+82
+00:06:52,000 --> 00:06:55,000
+Accessing property configurations.
+
+83
+00:06:55,000 --> 00:07:00,000
+Auto wiring of the repositories into the application service layer.
+
+84
+00:07:00,000 --> 00:07:06,000
+When we will start learn Spring boot, you will understand how easily it is also configured in the spring
+
+85
+00:07:06,000 --> 00:07:11,000
+boot where we only need to provide the data source details.
+
+86
+00:07:12,000 --> 00:07:17,000
+The next advantage that I already mentioned previously is no code repositories.
+
+87
+00:07:17,000 --> 00:07:21,000
+Spring Data JPA implements repository pattern.
+
+88
+00:07:21,000 --> 00:07:24,000
+The repository pattern is pretty simple.
+
+89
+00:07:24,000 --> 00:07:33,000
+An interface defines the repository with all logical read and write operations for a specific entity.
+
+90
+00:07:33,000 --> 00:07:34,000
+That's it.
+
+91
+00:07:35,000 --> 00:07:42,000
+Implementing that pattern isn't too complicated, but writing the standard CRUD operations for each
+
+92
+00:07:42,000 --> 00:07:46,000
+entity creates a lot of repetitive code.
+
+93
+00:07:46,000 --> 00:07:54,000
+Spring Data JPA provides you a set of repository interfaces which you only need to extend to define
+
+94
+00:07:54,000 --> 00:07:58,000
+a specific repository for one of your entities.
+
+95
+00:07:58,000 --> 00:08:03,000
+On this slide, you can see example of the repository that can do the following things.
+
+96
+00:08:04,000 --> 00:08:09,000
+Persist update and remove one or multiple book entities.
+
+97
+00:08:09,000 --> 00:08:14,000
+Find one or more books by their primary keys.
+
+98
+00:08:14,000 --> 00:08:15,000
+Count.
+
+99
+00:08:15,000 --> 00:08:17,000
+Get and remove all books.
+
+100
+00:08:18,000 --> 00:08:21,000
+Check if a book with a given primary key exists.
+
+101
+00:08:22,000 --> 00:08:29,000
+And yes, this is literally all the code that you need by extending CRUD repository.
+
+102
+00:08:29,000 --> 00:08:32,000
+You can take advantage of spring data JPA.
+
+103
+00:08:33,000 --> 00:08:38,000
+This is probably one of the most impressive and attractive feature of spring data JPA.
+
+104
+00:08:39,000 --> 00:08:43,000
+The third advantage is reducing code.
+
+105
+00:08:43,000 --> 00:08:49,000
+Reducing the code means you also reduce the probability of bugs and mistakes.
+
+106
+00:08:49,000 --> 00:08:53,000
+Also, it just makes your life a little bit easier.
+
+107
+00:08:54,000 --> 00:08:59,000
+The next advantage is query generation based on the method names.
+
+108
+00:09:00,000 --> 00:09:07,000
+This is a super interesting feature, even in case you don't have masses that you need in one of the
+
+109
+00:09:07,000 --> 00:09:09,000
+predefined repositories.
+
+110
+00:09:09,000 --> 00:09:17,000
+You just need to name method in your interface according to pattern and required query will be automatically
+
+111
+00:09:17,000 --> 00:09:18,000
+generated for you.
+
+112
+00:09:18,000 --> 00:09:19,000
+Can you imagine that?
+
+113
+00:09:20,000 --> 00:09:23,000
+For example, pay attention to the example on the slide.
+
+114
+00:09:24,000 --> 00:09:30,000
+In this case we defined method find by title with the string parameter.
+
+115
+00:09:30,000 --> 00:09:38,000
+Now I can simply inject this repository in any class of the service layer and use the method to extract
+
+116
+00:09:38,000 --> 00:09:43,000
+book by fieldname where field name will be called title.
+
+117
+00:09:43,000 --> 00:09:53,000
+So we removed a lot of advantages and as experienced engineer IT director, I can sell spring data JPA
+
+118
+00:09:53,000 --> 00:09:54,000
+when it is needed.
+
+119
+00:09:54,000 --> 00:10:01,000
+But taking into account with this course, I want to share with you everything what I know.
+
+120
+00:10:01,000 --> 00:10:03,000
+I will be completely honest with you.
+
+121
+00:10:04,000 --> 00:10:07,000
+Spring Data JPA has its own disadvantages.
+
+122
+00:10:08,000 --> 00:10:09,000
+I will try to be short.
+
+123
+00:10:10,000 --> 00:10:17,000
+We already learned that spring data is an addition layer above common technologies for storing data.
+
+124
+00:10:17,000 --> 00:10:25,000
+Spring Data JPA is the most commonly used part of spring data is supposed to simplify GPU based code
+
+125
+00:10:25,000 --> 00:10:28,000
+by eliminating recurrent pieces of code.
+
+126
+00:10:29,000 --> 00:10:37,000
+But in reality, spring data JPA simplifies the code by sacrificing performance and flexibility sometimes.
+
+127
+00:10:37,000 --> 00:10:45,000
+Also, it doesn't provide a lot of new things because it still uses hibernate and hidden entity manager.
+
+128
+00:10:45,000 --> 00:10:53,000
+So it looks like the key feature of spring data JPA is just to save time on writing code rather than
+
+129
+00:10:53,000 --> 00:10:59,000
+to achieve better performance or optimization in the way how queries are generated.
+
+130
+00:11:00,000 --> 00:11:07,000
+There is a thought that overall spring data JPA is the best suited for demo application with empty databases,
+
+131
+00:11:07,000 --> 00:11:11,000
+primarily because of the performance concerns.
+
+132
+00:11:11,000 --> 00:11:19,000
+Of course, the project is evolving and of course it is getting better with each release and each new
+
+133
+00:11:19,000 --> 00:11:23,000
+version, you know, using spring data JPA or something else.
+
+134
+00:11:23,000 --> 00:11:26,000
+It is just a matter of style and habit.
+
+135
+00:11:27,000 --> 00:11:31,000
+Somebody likes cars with an automatic gearbox.
+
+136
+00:11:31,000 --> 00:11:36,000
+But I'm the guy who prefer to have manual gearbox in the programming.
+
+137
+00:11:36,000 --> 00:11:44,000
+I like the granularity and control that I get with the JDBC, but I accept the fact that somebody may
+
+138
+00:11:44,000 --> 00:11:48,000
+not like this as me, and that is fine.
+
+139
+00:11:48,000 --> 00:11:55,000
+As I said, it is a matter of style and as professionals we need to know different ways to achieve the
+
+140
+00:11:55,000 --> 00:11:56,000
+same goal.
+
+141
+00:11:56,000 --> 00:12:01,000
+As you may already guess, I prefer JDBC and I'm not joking.
+
+142
+00:12:01,000 --> 00:12:08,000
+You know that I am CEO of IT company and we have our own products, including mobile and web applications
+
+143
+00:12:08,000 --> 00:12:11,000
+and because of many different reasons I still.
+
+144
+00:12:11,000 --> 00:12:13,000
+Prefer using JDBC.
+
+145
+00:12:13,000 --> 00:12:18,000
+If you just want to use spring, there is also spring data JDBC module.
+
+146
+00:12:18,000 --> 00:12:22,000
+Like I said, my main concern is performance.
+
+147
+00:12:22,000 --> 00:12:28,000
+Yes, using JDBC is not so fancy and it takes longer to write the code.
+
+148
+00:12:28,000 --> 00:12:30,000
+But that's the way how I work.
+
+149
+00:12:31,000 --> 00:12:38,000
+I also saw how Spring Data JPA is applied in production environment and I can confirm that it is also
+
+150
+00:12:38,000 --> 00:12:39,000
+possible.
+
+151
+00:12:39,000 --> 00:12:47,000
+But in my opinion, spring data JPA brings not so much things besides fancy way to define Daos by just
+
+152
+00:12:47,000 --> 00:12:52,000
+creating interfaces and using non-optimized massive wrappers.
+
+153
+00:12:52,000 --> 00:13:00,000
+But even despite all these advantages, just remember that spring data also has advantages, and this
+
+154
+00:13:00,000 --> 00:13:06,000
+true professionals will have to understand what the spring data JPA is and be ready to apply gained
+
+155
+00:13:06,000 --> 00:13:09,000
+knowledge on practice when it is needed.
+
+156
+00:13:09,000 --> 00:13:14,000
+That's all what I wanted to share with you in this introductory lesson.
+
+157
+00:13:14,000 --> 00:13:17,000
+Let's recap what we have learned today.
+
+158
+00:13:17,000 --> 00:13:20,000
+Today we did an overview of spring data.
+
+159
+00:13:21,000 --> 00:13:24,000
+We reviewed what spring data modules exists.
+
+160
+00:13:25,000 --> 00:13:28,000
+Also, we learned what a spring data JPA is.
+
+161
+00:13:29,000 --> 00:13:31,000
+I explained what repositories are.
+
+162
+00:13:32,000 --> 00:13:34,000
+We discussed briefly repository pattern.
+
+163
+00:13:35,000 --> 00:13:41,000
+And at the end of the lesson we learned advantages and disadvantages of the Spring Data JPA.
+
+164
+00:13:41,000 --> 00:13:43,000
+That's it for today.
+
+165
+00:13:43,000 --> 00:13:45,000
+Thanks a lot for your attention.
+
+166
+00:13:45,000 --> 00:13:48,000
+Have a great day and see you in the next lesson.
+
diff --git a/86 - Spring Data/002 Source-code-of-examples-commit-with-changes-.url b/86 - Spring Data/002 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..9ad866a22a783d220419ae3afbcbbef7078dd83f
--- /dev/null
+++ b/86 - Spring Data/002 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/e9e37fb6749af4c7ec493a54acea7cadbbafd612
\ No newline at end of file
diff --git a/86 - Spring Data/002 Spring Data JPA Practice_en.srt b/86 - Spring Data/002 Spring Data JPA Practice_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..299ad2d3e279ef5c830d591e812f8f3d80eee907
--- /dev/null
+++ b/86 - Spring Data/002 Spring Data JPA Practice_en.srt
@@ -0,0 +1,996 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello Tim.
+
+2
+00:00:06,000 --> 00:00:11,000
+We already hold an overview of spring data and spring data JPA.
+
+3
+00:00:11,000 --> 00:00:18,000
+We learned advantages and disadvantages and key concepts and now it is time for practice.
+
+4
+00:00:18,000 --> 00:00:22,000
+This lesson will be completely dedicated to the practical examples.
+
+5
+00:00:22,000 --> 00:00:28,000
+Today we are going to configure our spring application to work with Spring Data JPA.
+
+6
+00:00:28,000 --> 00:00:35,000
+We are going to define all the necessary beans, configure data, source, add all necessary dependencies
+
+7
+00:00:35,000 --> 00:00:37,000
+and things like that.
+
+8
+00:00:37,000 --> 00:00:43,000
+During the video together we are going to create our first spring data JPA repository.
+
+9
+00:00:43,000 --> 00:00:48,000
+I'm going to show you how to define methods in the repository.
+
+10
+00:00:48,000 --> 00:00:55,000
+I will show you how we can use GPG and Native SQL queries in our repository.
+
+11
+00:00:56,000 --> 00:01:01,000
+Also, we will learn naming convention for masses in other spring data.
+
+12
+00:01:01,000 --> 00:01:06,000
+JPA can generate queries based on the method names in the interface of our repository.
+
+13
+00:01:06,000 --> 00:01:13,000
+We need to name masses according to the specific pattern and we will learn such keywords.
+
+14
+00:01:13,000 --> 00:01:20,000
+And during the live demo you are going to see end to end example to understand how spring data JPA repository
+
+15
+00:01:20,000 --> 00:01:24,000
+can be integrated into your application.
+
+16
+00:01:24,000 --> 00:01:26,000
+Let's start our lesson.
+
+17
+00:01:26,000 --> 00:01:32,000
+Before we start our lesson, I want to highlight that it is important that you watch previous theoretical
+
+18
+00:01:32,000 --> 00:01:40,000
+lessons because the key terms and concepts about spring data JPA were discussed in the previous video.
+
+19
+00:01:40,000 --> 00:01:46,000
+So as I promised, this lesson will be completely focused on the practical examples.
+
+20
+00:01:47,000 --> 00:01:51,000
+Let me jump to the practical code examples and screen sharing.
+
+21
+00:01:52,000 --> 00:01:58,000
+During the demo, I am going to use our spring training project that we used in our spring course from
+
+22
+00:01:58,000 --> 00:01:58,000
+the beginning.
+
+23
+00:01:59,000 --> 00:02:05,000
+And as always, you will be able to find all source code examples in attachments to the video.
+
+24
+00:02:05,000 --> 00:02:12,000
+So the first thing that we need to do, let's add all required dependencies into our POM XML.
+
+25
+00:02:12,000 --> 00:02:16,000
+Let me open pom XML and review what I have added.
+
+26
+00:02:16,000 --> 00:02:21,000
+The main dependency for our lesson is spring data JPA dependency.
+
+27
+00:02:21,000 --> 00:02:26,000
+You can check Maven repository and add latest available version from there.
+
+28
+00:02:27,000 --> 00:02:35,000
+Also additional dependencies that I have added is Jackson data bind few words about this dependency.
+
+29
+00:02:36,000 --> 00:02:41,000
+I added it in order to convert objects into JSON.
+
+30
+00:02:41,000 --> 00:02:50,000
+If you remember, JSON is a JavaScript object notation, very popular string format for data, serialization
+
+31
+00:02:50,000 --> 00:02:53,000
+and passing objects as strings in the network.
+
+32
+00:02:54,000 --> 00:03:02,000
+In our today's example, I am going to build a rest service that is going to return US user objects
+
+33
+00:03:02,000 --> 00:03:03,000
+in the JSON format.
+
+34
+00:03:04,000 --> 00:03:07,000
+Don't worry, we are going to learn rest.
+
+35
+00:03:07,000 --> 00:03:09,000
+Topic in the separate lesson.
+
+36
+00:03:09,000 --> 00:03:17,000
+There is nothing super complex in it and conversion into JSON is optional for this lesson and it is
+
+37
+00:03:17,000 --> 00:03:19,000
+done just for demo purposes.
+
+38
+00:03:19,000 --> 00:03:26,000
+The next changes that I introduced in this example are changes in the web config file.
+
+39
+00:03:26,000 --> 00:03:27,000
+Our configuration.
+
+40
+00:03:28,000 --> 00:03:30,000
+Let me open web config class.
+
+41
+00:03:31,000 --> 00:03:33,000
+Let's start from the top here.
+
+42
+00:03:33,000 --> 00:03:36,000
+I added few important annotations.
+
+43
+00:03:36,000 --> 00:03:39,000
+They are enable transaction management.
+
+44
+00:03:39,000 --> 00:03:45,000
+This annotation allows users to use transaction management in application.
+
+45
+00:03:46,000 --> 00:03:51,000
+Enables springs annotation driven transaction management capability.
+
+46
+00:03:51,000 --> 00:03:54,000
+Enable repositories.
+
+47
+00:03:54,000 --> 00:04:01,000
+This annotation indicates where the repositories classes are present and you can see that I specified
+
+48
+00:04:01,000 --> 00:04:06,000
+full package name where my repositories will be stored.
+
+49
+00:04:06,000 --> 00:04:11,000
+For the sake of the demo, we are going to implement only one repository today.
+
+50
+00:04:12,000 --> 00:04:15,000
+Properties Source with a database properties.
+
+51
+00:04:15,000 --> 00:04:17,000
+Let's review this file.
+
+52
+00:04:17,000 --> 00:04:21,000
+It is located in the SRC main resources.
+
+53
+00:04:21,000 --> 00:04:28,000
+As you can see, there is a similar properties that we usually use for configuration of the data source
+
+54
+00:04:28,000 --> 00:04:37,000
+because in spring data JPA we also need to configure data, source, driver name, URL, user password,
+
+55
+00:04:37,000 --> 00:04:43,000
+dialect and also specified property to show SQL queries.
+
+56
+00:04:43,000 --> 00:04:47,000
+Later in the configuration we are going to use this properties.
+
+57
+00:04:47,000 --> 00:04:53,000
+It is just a rule of thumb to keep variable properties separately from the source code.
+
+58
+00:04:53,000 --> 00:04:56,000
+Let's get back to web.config file.
+
+59
+00:04:56,000 --> 00:05:03,000
+For the sake of the demo, I separated spring data JPA configuration with markers here.
+
+60
+00:05:03,000 --> 00:05:10,000
+Taking into account, we add new feature with each new lesson to our imaginary project.
+
+61
+00:05:10,000 --> 00:05:18,000
+You can find here source code from other examples, but I use such markers to separate configurations
+
+62
+00:05:18,000 --> 00:05:21,000
+for different features that will learn.
+
+63
+00:05:21,000 --> 00:05:25,000
+The redundant code from previous lessons is just commanded.
+
+64
+00:05:26,000 --> 00:05:31,000
+For example, if you remember we configured spring security in the previous learning module.
+
+65
+00:05:32,000 --> 00:05:39,000
+I just commented that section in order to not deal with the security configuration in this lesson.
+
+66
+00:05:39,000 --> 00:05:47,000
+I also commanded configuration of the spring security filter in our application initializer, but feel
+
+67
+00:05:47,000 --> 00:05:50,000
+free to uncomment it if you wish.
+
+68
+00:05:50,000 --> 00:05:54,000
+So here you can see constants.
+
+69
+00:05:54,000 --> 00:06:00,000
+These are properties names in order we could extract required properties values from the properties
+
+70
+00:06:00,000 --> 00:06:01,000
+file.
+
+71
+00:06:02,000 --> 00:06:06,000
+The first thing that we need to do is to configure data source.
+
+72
+00:06:06,000 --> 00:06:10,000
+Here you can see that I use driver manager data source.
+
+73
+00:06:10,000 --> 00:06:19,000
+I set URL username password driver class name using values from the properties file that we already
+
+74
+00:06:19,000 --> 00:06:20,000
+reviewed.
+
+75
+00:06:20,000 --> 00:06:29,000
+Data source beam is configured and also we already had lesson where we learned how to extract properties
+
+76
+00:06:29,000 --> 00:06:29,000
+in spring.
+
+77
+00:06:30,000 --> 00:06:37,000
+We inject environment type and call get property name Passing the property name.
+
+78
+00:06:37,000 --> 00:06:42,000
+Then we need to configure local container entity manager factory bean.
+
+79
+00:06:43,000 --> 00:06:48,000
+We need this been to control the entities in this been.
+
+80
+00:06:48,000 --> 00:06:56,000
+You must specify the persistence provider that is hibernate persistence provider in our case.
+
+81
+00:06:56,000 --> 00:07:05,000
+Also, as you can see, I set data source packages to scan and I pass package name where all my entities
+
+82
+00:07:05,000 --> 00:07:09,000
+are stored and I set GPA properties.
+
+83
+00:07:09,000 --> 00:07:10,000
+Let's review.
+
+84
+00:07:10,000 --> 00:07:11,000
+What are they?
+
+85
+00:07:12,000 --> 00:07:18,000
+There is a separate method and you can see that I extract properties from the database.
+
+86
+00:07:18,000 --> 00:07:20,000
+Properties file that we configure it.
+
+87
+00:07:21,000 --> 00:07:27,000
+And the last but not the least, being that we are going to configure in this file is transaction manager.
+
+88
+00:07:27,000 --> 00:07:31,000
+In our case it is GP transaction manager.
+
+89
+00:07:31,000 --> 00:07:38,000
+Note that without configuring transaction manager we can't use transactional annotation.
+
+90
+00:07:39,000 --> 00:07:42,000
+Now let's review entities.
+
+91
+00:07:42,000 --> 00:07:48,000
+We created our entities during the lesson from the spring Security module when we configured authentication
+
+92
+00:07:48,000 --> 00:07:54,000
+with the users extracted from the database based on the roles and privileges.
+
+93
+00:07:54,000 --> 00:07:57,000
+So let me just make a brief overview.
+
+94
+00:07:57,000 --> 00:08:02,000
+Basically, each user can have multiple roles assigned.
+
+95
+00:08:02,000 --> 00:08:05,000
+Each role can have multiple privileges.
+
+96
+00:08:05,000 --> 00:08:09,000
+To be honest, nothing is extraordinary here.
+
+97
+00:08:10,000 --> 00:08:13,000
+I use GP annotations to configure entities.
+
+98
+00:08:14,000 --> 00:08:21,000
+In case you want to learn more, feel free to check GP section in my course Java from zero to first
+
+99
+00:08:21,000 --> 00:08:22,000
+job.
+
+100
+00:08:22,000 --> 00:08:28,000
+Now we are ready to create our first repository in the Repositories package.
+
+101
+00:08:28,000 --> 00:08:35,000
+I created sub package for spring data and here is user repository that I created.
+
+102
+00:08:36,000 --> 00:08:39,000
+I extended from the craft repository.
+
+103
+00:08:39,000 --> 00:08:43,000
+I believe it is important for you to know what a crowd repository is.
+
+104
+00:08:43,000 --> 00:08:46,000
+Let me open its source code.
+
+105
+00:08:47,000 --> 00:08:54,000
+So this is an interface for generic CRUD operations on a repository for a specific type.
+
+106
+00:08:54,000 --> 00:08:57,000
+You can see that this is parameterized type.
+
+107
+00:08:58,000 --> 00:09:05,000
+The first type should be the type of the entity you want to work with, and the second type is a type
+
+108
+00:09:05,000 --> 00:09:05,000
+of ID.
+
+109
+00:09:06,000 --> 00:09:16,000
+By extending CRUD repository by default, you can use methods like save save all find by ID exists by
+
+110
+00:09:16,000 --> 00:09:20,000
+the and other methods that you can see on the screen.
+
+111
+00:09:21,000 --> 00:09:29,000
+Basically there are sufficient to execute standard, create, read, update, delete operations and
+
+112
+00:09:29,000 --> 00:09:36,000
+as we discussed in the previous lesson, in case we need some additional data operations, we can easily
+
+113
+00:09:36,000 --> 00:09:38,000
+define new methods in our repository.
+
+114
+00:09:39,000 --> 00:09:42,000
+Let's get back to define few other methods.
+
+115
+00:09:43,000 --> 00:09:50,000
+For example, let's define method that will return us a list of users with the same first name.
+
+116
+00:09:50,000 --> 00:10:00,000
+We use spring data JPA predefined pattern find by and field name first name and parameter.
+
+117
+00:10:00,000 --> 00:10:01,000
+First name.
+
+118
+00:10:01,000 --> 00:10:02,000
+That's it.
+
+119
+00:10:03,000 --> 00:10:05,000
+That's literally everything.
+
+120
+00:10:05,000 --> 00:10:11,000
+What we need to do to define the behavior of finding all users by the first name field.
+
+121
+00:10:12,000 --> 00:10:19,000
+But what are the prefixes I can use when I define method name in Spring data JPA Repository?
+
+122
+00:10:20,000 --> 00:10:23,000
+What is the pardon and naming convention?
+
+123
+00:10:23,000 --> 00:10:29,000
+That's a great question and there are really different options and combinations that you can use while
+
+124
+00:10:29,000 --> 00:10:31,000
+naming your methods.
+
+125
+00:10:31,000 --> 00:10:39,000
+Spring Data JPA developers have tried to take into account the majority of possible options that you
+
+126
+00:10:39,000 --> 00:10:40,000
+might need.
+
+127
+00:10:40,000 --> 00:10:48,000
+This is one of the most important feature of spring data JPA because it reduces a lot of boilerplate
+
+128
+00:10:48,000 --> 00:10:48,000
+code.
+
+129
+00:10:49,000 --> 00:10:56,000
+Also, the chances of errors are less because these spring methods are well tested by many projects
+
+130
+00:10:56,000 --> 00:10:58,000
+already using them.
+
+131
+00:10:59,000 --> 00:11:06,000
+I don't think that it would be useful me creating each of the possible variation because the main thing
+
+132
+00:11:06,000 --> 00:11:12,000
+is that you understand operations, how to create method and how to call it.
+
+133
+00:11:13,000 --> 00:11:20,000
+And now let me show you the slides with the list of words that you can use when naming method, and
+
+134
+00:11:20,000 --> 00:11:25,000
+I will elaborate a little bit more on naming convention in Spring Data JPA.
+
+135
+00:11:26,000 --> 00:11:32,000
+I gathered all the keywords that you can use when declaring new method in repository.
+
+136
+00:11:33,000 --> 00:11:40,000
+Also, each keyword has sample and shows how it will be transformed into the gql.
+
+137
+00:11:40,000 --> 00:11:48,000
+You can see here's example of and or is equals between less than and other keywords.
+
+138
+00:11:48,000 --> 00:11:53,000
+Please put the video on the post now and explore the slides.
+
+139
+00:11:53,000 --> 00:11:56,000
+As you can see, there are multiple of them.
+
+140
+00:11:57,000 --> 00:12:01,000
+Feel free to get back to these examples when it will be needed.
+
+141
+00:12:02,000 --> 00:12:08,000
+Once you finished review, press play and continue with the next examples.
+
+142
+00:12:08,000 --> 00:12:14,000
+In case we want a more control, we can specify customized query using gql.
+
+143
+00:12:14,000 --> 00:12:17,000
+Take a look at this example.
+
+144
+00:12:17,000 --> 00:12:25,000
+In case I want to retrieve users by the first name ignoring case, I can specify this query using lower
+
+145
+00:12:25,000 --> 00:12:31,000
+function right on top of the method that I'm going to use a little bit later.
+
+146
+00:12:31,000 --> 00:12:34,000
+I'm going to show you this method in action to.
+
+147
+00:12:35,000 --> 00:12:40,000
+Also, if we need, we can use native SQL queries.
+
+148
+00:12:40,000 --> 00:12:42,000
+The principle is the same.
+
+149
+00:12:42,000 --> 00:12:49,000
+We use query annotation above the method and we specify native equals to true.
+
+150
+00:12:50,000 --> 00:12:51,000
+Let's proceed now.
+
+151
+00:12:53,000 --> 00:12:57,000
+To continue with creation of our imaginary business case.
+
+152
+00:12:57,000 --> 00:13:04,000
+The next thing that we need to do is actually some service that is located in our business layer of
+
+153
+00:13:04,000 --> 00:13:08,000
+application that is going to use our repository.
+
+154
+00:13:08,000 --> 00:13:15,000
+For this, I created user service class and injected my user repository here.
+
+155
+00:13:15,000 --> 00:13:20,000
+In our particular case, we just delegate calls to the repository.
+
+156
+00:13:21,000 --> 00:13:25,000
+But theoretically, this is the place where you can implement your business.
+
+157
+00:13:25,000 --> 00:13:33,000
+Logic, for example, is a make multiple requests with a repository to get the data that you need or
+
+158
+00:13:33,000 --> 00:13:35,000
+to process the data received.
+
+159
+00:13:35,000 --> 00:13:40,000
+In another way, it is up to you and your business logic.
+
+160
+00:13:41,000 --> 00:13:47,000
+Transactional annotation indicates that the message will be executed in the transaction.
+
+161
+00:13:47,000 --> 00:13:54,000
+Spring will take care of the transaction management and now we need to create controller class in order
+
+162
+00:13:54,000 --> 00:13:58,000
+to interact with a business layer over the web.
+
+163
+00:13:58,000 --> 00:14:02,000
+In our today's example, I'm going to implement Rest controller.
+
+164
+00:14:02,000 --> 00:14:09,000
+Don't worry, we are going to cover rest, architecture, topic and topic of rest controllers in other
+
+165
+00:14:09,000 --> 00:14:10,000
+lessons.
+
+166
+00:14:10,000 --> 00:14:17,000
+But right now I'm going to make just short and brief overview to help you understand what is happening
+
+167
+00:14:17,000 --> 00:14:17,000
+here.
+
+168
+00:14:18,000 --> 00:14:22,000
+I used a rest controller annotation in simple words.
+
+169
+00:14:22,000 --> 00:14:29,000
+Rest controller annotation is a combination of controller and response body annotation.
+
+170
+00:14:29,000 --> 00:14:36,000
+You already know what a controller annotation is, and I believe I showed you a response body annotation
+
+171
+00:14:36,000 --> 00:14:37,000
+once.
+
+172
+00:14:37,000 --> 00:14:41,000
+But let me remind you was the response body annotation.
+
+173
+00:14:41,000 --> 00:14:49,000
+Our view resolver is not triggered and we write the value that is returned from the method in controller
+
+174
+00:14:49,000 --> 00:14:54,000
+directly into the response body of our response object.
+
+175
+00:14:54,000 --> 00:14:56,000
+Why we need this?
+
+176
+00:14:56,000 --> 00:15:05,000
+Very often we implement applications that talk not directly to the end user, but talk with other applications
+
+177
+00:15:05,000 --> 00:15:07,000
+and just passing data.
+
+178
+00:15:07,000 --> 00:15:15,000
+In this case, there is no need to implement view layer and present data on the nice looking web pages,
+
+179
+00:15:15,000 --> 00:15:23,000
+or you can use other framework on the front end and you just need to supply data to its components.
+
+180
+00:15:23,000 --> 00:15:31,000
+That's why we don't need to resolve separate view and we can just put the data into the response body.
+
+181
+00:15:31,000 --> 00:15:37,000
+Anyway, the cases can be different and we are going to review them in other lessons too.
+
+182
+00:15:37,000 --> 00:15:45,000
+In our today's lesson, I just didn't want to resolve views because we need just to make sure that our
+
+183
+00:15:45,000 --> 00:15:51,000
+spring data JPA works well and to seize data that is actually returned.
+
+184
+00:15:51,000 --> 00:15:59,000
+And this is exactly why we added Jackson dependency for data serialization from Java objects into JSON
+
+185
+00:15:59,000 --> 00:16:00,000
+and vice versa.
+
+186
+00:16:01,000 --> 00:16:08,000
+When I return some object and we tell Spring to write it into the response body how spring should handle
+
+187
+00:16:08,000 --> 00:16:16,000
+this because we can't put Java object into the response body, but we can put string into the response
+
+188
+00:16:16,000 --> 00:16:17,000
+body.
+
+189
+00:16:17,000 --> 00:16:25,000
+So spring uses Jackson in order to serialize Java, object into the JSON and return it to the client.
+
+190
+00:16:25,000 --> 00:16:26,000
+Is it clear?
+
+191
+00:16:27,000 --> 00:16:34,000
+So I use rest controller annotation and here a lot of different methods to interact with our business
+
+192
+00:16:34,000 --> 00:16:35,000
+layer.
+
+193
+00:16:35,000 --> 00:16:41,000
+Our goal for today's demo is to them a message from our user repository.
+
+194
+00:16:42,000 --> 00:16:46,000
+Let's review today how we work such methods.
+
+195
+00:16:46,000 --> 00:16:47,000
+Get user by ID.
+
+196
+00:16:48,000 --> 00:16:56,000
+We'll just pass ID of one saved user and we expect to get back json of user.
+
+197
+00:16:57,000 --> 00:16:59,000
+Net users by first name.
+
+198
+00:16:59,000 --> 00:17:03,000
+Will pass first name and we expect two users to be returned.
+
+199
+00:17:04,000 --> 00:17:07,000
+Get user by first name case insensitive.
+
+200
+00:17:08,000 --> 00:17:15,000
+The goal of this endpoint invocation is to prove that GPU queries work as expected.
+
+201
+00:17:16,000 --> 00:17:24,000
+If you remember, for such behavior, we declared GPU query get users ordered by first name.
+
+202
+00:17:24,000 --> 00:17:30,000
+We will check this endpoint too in order to prove that native queries work as expected.
+
+203
+00:17:30,000 --> 00:17:30,000
+To.
+
+204
+00:17:31,000 --> 00:17:39,000
+The rest of the masses can be checked via a special client like Postman because we need to send requests
+
+205
+00:17:39,000 --> 00:17:48,000
+via post, delete, put HTTP methods, but don't pay too much attention to those methods so far.
+
+206
+00:17:48,000 --> 00:17:52,000
+We are going to learn how they work in separate lesson.
+
+207
+00:17:53,000 --> 00:17:57,000
+So I started Web server and deployed our application.
+
+208
+00:17:57,000 --> 00:18:03,000
+Now it is time to send some queries to the web server and see what will be returned.
+
+209
+00:18:03,000 --> 00:18:10,000
+We are going to start from extracting user by ID user slash seven.
+
+210
+00:18:11,000 --> 00:18:15,000
+Seven is an ID of one of our users from the database.
+
+211
+00:18:15,000 --> 00:18:21,000
+I just checked beforehand in the database and made requests.
+
+212
+00:18:21,000 --> 00:18:25,000
+So we can see that JSON is returned.
+
+213
+00:18:25,000 --> 00:18:34,000
+If you wish, you can use any JSON file that is available online to see how our Java object is transformed
+
+214
+00:18:34,000 --> 00:18:36,000
+into the JSON string.
+
+215
+00:18:36,000 --> 00:18:40,000
+By the way, this is a good way to learn JSON structure.
+
+216
+00:18:41,000 --> 00:18:42,000
+This is pretty intuitive.
+
+217
+00:18:43,000 --> 00:18:51,000
+You can see the name of the fields and field values ID first name, last name, email, password, etcetera.
+
+218
+00:18:51,000 --> 00:18:57,000
+There is an array of roles and each role may have array of privileges.
+
+219
+00:18:57,000 --> 00:19:05,000
+Anyway, we can see that our repository returned us the data that we expected because this user has
+
+220
+00:19:05,000 --> 00:19:06,000
+ID seven.
+
+221
+00:19:07,000 --> 00:19:09,000
+Let's check another endpoint.
+
+222
+00:19:10,000 --> 00:19:13,000
+Users by first name slash admin.
+
+223
+00:19:14,000 --> 00:19:19,000
+The next endpoint that we are going to check is getting users by first name.
+
+224
+00:19:19,000 --> 00:19:27,000
+I use admin as a first name parameter and when I send request I receive two users in return because
+
+225
+00:19:27,000 --> 00:19:31,000
+in my database there are two users with admin first name.
+
+226
+00:19:32,000 --> 00:19:35,000
+Everything is simple and predictable.
+
+227
+00:19:35,000 --> 00:19:41,000
+We implemented SQL query that returns US users ignoring case.
+
+228
+00:19:41,000 --> 00:19:43,000
+Let's try that endpoint.
+
+229
+00:19:44,000 --> 00:19:52,000
+Users by first name case insensitive slash admin starting from the lower case.
+
+230
+00:19:53,000 --> 00:20:01,000
+And when I use case insensitive and point, I again see our two users with admin first name because
+
+231
+00:20:01,000 --> 00:20:05,000
+in the SQL query we used lower function.
+
+232
+00:20:05,000 --> 00:20:14,000
+Let's now check the last endpoint in our today's demo to make sure that native queries also work users
+
+233
+00:20:14,000 --> 00:20:15,000
+ordered by first name.
+
+234
+00:20:16,000 --> 00:20:19,000
+And you can see we have three users returned.
+
+235
+00:20:19,000 --> 00:20:27,000
+The first two users with the first name admin and the third one is with test first name.
+
+236
+00:20:27,000 --> 00:20:35,000
+That proves that ordering by first name works as expected, and that means that we can apply other native
+
+237
+00:20:35,000 --> 00:20:36,000
+SQL queries.
+
+238
+00:20:37,000 --> 00:20:37,000
+Super.
+
+239
+00:20:38,000 --> 00:20:41,000
+That's all what I wanted to share with you in this lesson.
+
+240
+00:20:41,000 --> 00:20:45,000
+Let's recap what we have learned in the video.
+
+241
+00:20:46,000 --> 00:20:49,000
+In this video, we configure it Spring Data JPA.
+
+242
+00:20:49,000 --> 00:20:52,000
+We created our GPA repository.
+
+243
+00:20:53,000 --> 00:20:58,000
+I explained how we can work with a SQL queries in our GPA repositories.
+
+244
+00:20:59,000 --> 00:21:04,000
+I showed how we can declare native SQL queries in our GPA repositories.
+
+245
+00:21:04,000 --> 00:21:13,000
+We discussed naming convention and learned how to name methods in the GPA repository and also we reviewed
+
+246
+00:21:13,000 --> 00:21:19,000
+live demo with a spring data JPA to understand how it works and to end.
+
+247
+00:21:20,000 --> 00:21:21,000
+That's all for this lesson.
+
+248
+00:21:21,000 --> 00:21:23,000
+Thanks a lot for your attention.
+
+249
+00:21:23,000 --> 00:21:27,000
+Have a great day and see you in the next lesson.
+
diff --git a/86 - Spring Data/external-links.txt b/86 - Spring Data/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..317ef03b1107e0d793ed982c84111be37de11927
--- /dev/null
+++ b/86 - Spring Data/external-links.txt
@@ -0,0 +1,3 @@
+
+002 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/e9e37fb6749af4c7ec493a54acea7cadbbafd612
diff --git a/87 - ===== EXAM Spring Data JPA - Online Shop =====/001 EXAM Spring Data JPA - Online Shop.html b/87 - ===== EXAM Spring Data JPA - Online Shop =====/001 EXAM Spring Data JPA - Online Shop.html
new file mode 100644
index 0000000000000000000000000000000000000000..b740efcc316cf21794dc67b06929e9a69c37ea68
--- /dev/null
+++ b/87 - ===== EXAM Spring Data JPA - Online Shop =====/001 EXAM Spring Data JPA - Online Shop.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ EXAM Spring Data JPA - Online Shop
+
+
+
+
+
+
+
diff --git a/88 - Spring JDBC/001 Spring JDBC Overview_en.srt b/88 - Spring JDBC/001 Spring JDBC Overview_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..dc1420bd461d4101b2e2a91e38e80b8e4dedd584
--- /dev/null
+++ b/88 - Spring JDBC/001 Spring JDBC Overview_en.srt
@@ -0,0 +1,624 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:13,000
+Today we continue learning spring and in this lesson we are going to talk about spring JDBC.
+
+3
+00:00:14,000 --> 00:00:20,000
+We are going to start our lesson from remembering what JDBC is in general.
+
+4
+00:00:20,000 --> 00:00:26,000
+I'm bad that if you watch spring module of my course, you already know what JDBC is.
+
+5
+00:00:26,000 --> 00:00:32,000
+But we will just briefly remember after that we'll talk about why we should use spring JDBC.
+
+6
+00:00:33,000 --> 00:00:38,000
+What problems of JDBC API are solved with the spring JDBC.
+
+7
+00:00:39,000 --> 00:00:40,000
+I will explain.
+
+8
+00:00:40,000 --> 00:00:45,000
+What is the difference between spring JDBC and spring data JDBC.
+
+9
+00:00:46,000 --> 00:00:49,000
+Then we'll review different spring JDBC classes.
+
+10
+00:00:49,000 --> 00:00:59,000
+Namely we are going to learn JDBC template named parameter jdbc template simple jdbc insert simple JDBC
+
+11
+00:00:59,000 --> 00:01:00,000
+call.
+
+12
+00:01:00,000 --> 00:01:01,000
+Let's start our lesson.
+
+13
+00:01:02,000 --> 00:01:05,000
+Let's start from overview of JDBC.
+
+14
+00:01:05,000 --> 00:01:11,000
+I believe that if you watch this course then you already have understanding of what JDBC is.
+
+15
+00:01:11,000 --> 00:01:17,000
+But for the sake of this lesson, let me just briefly remind you what the JDBC is.
+
+16
+00:01:17,000 --> 00:01:21,000
+JDBC stands for Java Database Connectivity.
+
+17
+00:01:21,000 --> 00:01:27,000
+JDBC is a Java API to connect and execute the query with the database.
+
+18
+00:01:27,000 --> 00:01:30,000
+It is a part of Java Standard Edition.
+
+19
+00:01:30,000 --> 00:01:36,000
+JDBC API uses JDBC drivers to connect with the database.
+
+20
+00:01:36,000 --> 00:01:42,000
+We can use JDBC API to access data stored in any relational database.
+
+21
+00:01:42,000 --> 00:01:49,000
+With the help of JDBC API, we can save, update, delete and fetch data from the database.
+
+22
+00:01:50,000 --> 00:01:53,000
+If you want to learn more about Java JDBC.
+
+23
+00:01:53,000 --> 00:02:00,000
+Just to remind you that in my course Java from zero to first job I have separate section about JDBC.
+
+24
+00:02:00,000 --> 00:02:08,000
+So why we can't just use plane JDBC and why we should use spring JDBC instead?
+
+25
+00:02:08,000 --> 00:02:10,000
+What are benefits?
+
+26
+00:02:10,000 --> 00:02:12,000
+Let's try to figure it out.
+
+27
+00:02:13,000 --> 00:02:20,000
+First of all, I would like to highlight that spring JDBC is a powerful mechanism to connect to the
+
+28
+00:02:20,000 --> 00:02:23,000
+database and execute SQL queries.
+
+29
+00:02:23,000 --> 00:02:31,000
+As you may already guess, it uses JDBC API under the hood and it helps us to deal with different problems
+
+30
+00:02:31,000 --> 00:02:32,000
+of JDBC API.
+
+31
+00:02:33,000 --> 00:02:36,000
+What kind of problems?
+
+32
+00:02:36,000 --> 00:02:44,000
+When we use JDBC, we need to write a lot of code before and after executing the query, such as creating
+
+33
+00:02:44,000 --> 00:02:48,000
+connection statement, closing the result, set connection, etcetera.
+
+34
+00:02:48,000 --> 00:02:55,000
+Even despite we can use try with resources block still, we need to remember about it and implement
+
+35
+00:02:55,000 --> 00:02:57,000
+it carefully.
+
+36
+00:02:57,000 --> 00:03:02,000
+We need to perform exception handling code on the database logic.
+
+37
+00:03:02,000 --> 00:03:04,000
+We need to handle transactions.
+
+38
+00:03:04,000 --> 00:03:11,000
+You remember that with the JDBC, we can manage transactions by manually committing transactions when
+
+39
+00:03:11,000 --> 00:03:12,000
+needed.
+
+40
+00:03:12,000 --> 00:03:17,000
+Repetition of all this code in different methods is a time consuming task.
+
+41
+00:03:18,000 --> 00:03:24,000
+If you follow my course and don't skip lessons, then you should know already that there is spring data
+
+42
+00:03:24,000 --> 00:03:26,000
+JDBC sub project.
+
+43
+00:03:26,000 --> 00:03:29,000
+So is it the same as spring JDBC?
+
+44
+00:03:30,000 --> 00:03:32,000
+No, it is not the same.
+
+45
+00:03:32,000 --> 00:03:37,000
+And if it is different then what is the difference?
+
+46
+00:03:37,000 --> 00:03:45,000
+Spring JDBC project just provides all of the spring abstractions over the plain JDBC data source that
+
+47
+00:03:45,000 --> 00:03:47,000
+you can use with the spring framework.
+
+48
+00:03:47,000 --> 00:03:55,000
+For example, Spring's data source, which nicely hook into spring's transaction management capabilities
+
+49
+00:03:55,000 --> 00:03:57,000
+like transactional annotation.
+
+50
+00:03:57,000 --> 00:04:05,000
+Also, the JDBC template is part of this module which allows you to execute SQL statements and extract
+
+51
+00:04:05,000 --> 00:04:13,000
+objects from the result sets without dealing with exception handling or details of properly closing
+
+52
+00:04:13,000 --> 00:04:17,000
+statements, connections and things like that.
+
+53
+00:04:17,000 --> 00:04:25,000
+Spring data JDBC, on the other hand, provides the spring data abstraction over spring JDBC.
+
+54
+00:04:25,000 --> 00:04:35,000
+That is, you can create a spring data crud repository and simple entity, not a GPA entity and a spring
+
+55
+00:04:35,000 --> 00:04:36,000
+data does.
+
+56
+00:04:36,000 --> 00:04:43,000
+It will create your queries for you without you having to write native CRUD queries over JDBC.
+
+57
+00:04:44,000 --> 00:04:51,000
+Basically, this is the key difference between spring JDBC project and spring data.
+
+58
+00:04:51,000 --> 00:04:55,000
+JDBC sub project of Spring data project.
+
+59
+00:04:55,000 --> 00:04:57,000
+Hope you are not confused now.
+
+60
+00:04:58,000 --> 00:05:04,000
+Let's get back to the spring JDBC and discuss the main classes in the spring JDBC.
+
+61
+00:05:05,000 --> 00:05:08,000
+There are different ways how you can work with the spring JDBC.
+
+62
+00:05:09,000 --> 00:05:19,000
+I can name four main approaches with JDBC template named parameter jdbc template simple JDBC insert
+
+63
+00:05:19,000 --> 00:05:21,000
+and simple JDBC call.
+
+64
+00:05:22,000 --> 00:05:27,000
+So basically you can use these classes to interact with the JDBC API.
+
+65
+00:05:27,000 --> 00:05:31,000
+During the practical examples, we are going to review how to work with them.
+
+66
+00:05:31,000 --> 00:05:37,000
+JDBC template is a classic spring JDBC approach and the most popular.
+
+67
+00:05:37,000 --> 00:05:43,000
+This is lowest level approach and all others use a JDBC template under the hood.
+
+68
+00:05:44,000 --> 00:05:50,000
+Pay attention to the part where I said that all others use a JDBC template.
+
+69
+00:05:50,000 --> 00:05:51,000
+Under the hood.
+
+70
+00:05:51,000 --> 00:05:59,000
+Let's make brief overview of different approaches and we will try to understand what are the differences
+
+71
+00:05:59,000 --> 00:06:02,000
+between them and when to use what.
+
+72
+00:06:03,000 --> 00:06:11,000
+And we are going to start from review of the JDBC template class taking into account it is used under
+
+73
+00:06:11,000 --> 00:06:11,000
+the hood.
+
+74
+00:06:11,000 --> 00:06:21,000
+Even in other classes, you can understand that it takes a central place among spring JDBC support classes.
+
+75
+00:06:21,000 --> 00:06:29,000
+It takes care of creation and release of resources such as creating and closing of connection, object,
+
+76
+00:06:29,000 --> 00:06:29,000
+etcetera.
+
+77
+00:06:29,000 --> 00:06:33,000
+So it will not lead to any problem.
+
+78
+00:06:33,000 --> 00:06:41,000
+If you forget to close the connection, it handles the exception and provides the informative exception
+
+79
+00:06:41,000 --> 00:06:48,000
+messages with the help of exception classes defined in the work Spring Framework DAO package.
+
+80
+00:06:49,000 --> 00:06:57,000
+We can perform all the database operations with the help of JDBC template class such as insertion,
+
+81
+00:06:57,000 --> 00:07:06,000
+update, deletion and retrieval of the data from the database instances of the template class are thread
+
+82
+00:07:06,000 --> 00:07:15,000
+safe once configured so you can configure a single instance of a JDBC template and then safely inject
+
+83
+00:07:15,000 --> 00:07:18,000
+this shared reference into multiple Daos.
+
+84
+00:07:19,000 --> 00:07:26,000
+A common practice when using the JDBC template class is to configure a data source in your spring configuration
+
+85
+00:07:26,000 --> 00:07:28,000
+file and then dependency.
+
+86
+00:07:28,000 --> 00:07:32,000
+Inject that shared data source bean into your DAO classes.
+
+87
+00:07:33,000 --> 00:07:42,000
+Now let's review named parameter JDBC template and to understand it better, let's compare it with JDBC
+
+88
+00:07:42,000 --> 00:07:42,000
+template.
+
+89
+00:07:42,000 --> 00:07:50,000
+When you use JDBC template, you give it SQL that has a question mark placeholder for each parameter
+
+90
+00:07:50,000 --> 00:07:52,000
+you want to substitute in the SQL.
+
+91
+00:07:53,000 --> 00:08:01,000
+When you assign parameters in the code, you have to pass input arguments in an array and they are used
+
+92
+00:08:01,000 --> 00:08:07,000
+in the order in which they appear in the array like you can see on the slide.
+
+93
+00:08:08,000 --> 00:08:11,000
+You can see I created an array of arguments.
+
+94
+00:08:12,000 --> 00:08:22,000
+I created SQL query with question marks, and then I pass SQL query array of arguments and result set
+
+95
+00:08:22,000 --> 00:08:23,000
+extractor.
+
+96
+00:08:24,000 --> 00:08:26,000
+I'm going to explain you what it is.
+
+97
+00:08:26,000 --> 00:08:30,000
+Later during the practical coding exercise.
+
+98
+00:08:31,000 --> 00:08:39,000
+Named parameter JDBC template allows you to assign names to the parameter placeholders and pass in a
+
+99
+00:08:39,000 --> 00:08:44,000
+map so the template can match the map names to the placeholders.
+
+100
+00:08:44,000 --> 00:08:54,000
+So your code would look like other example on the slide we create again SQL query pay attention that
+
+101
+00:08:54,000 --> 00:08:59,000
+we use named parameter my A and my B.
+
+102
+00:08:59,000 --> 00:09:10,000
+After that I create map object and I put in the map keys and values and after that I call query method
+
+103
+00:09:10,000 --> 00:09:14,000
+and pass SQL arguments and result set extractor.
+
+104
+00:09:14,000 --> 00:09:23,000
+The idea is that matching the arguments by name is less error prone than having to specify them in a
+
+105
+00:09:23,000 --> 00:09:24,000
+particular order.
+
+106
+00:09:25,000 --> 00:09:33,000
+In real life applications, you store SQL queries in the separate files and it may be easy to accidentally
+
+107
+00:09:33,000 --> 00:09:36,000
+put the parameters in the wrong order.
+
+108
+00:09:37,000 --> 00:09:39,000
+Few words about simple jdbc.
+
+109
+00:09:39,000 --> 00:09:40,000
+Insert.
+
+110
+00:09:41,000 --> 00:09:42,000
+Simple JDBC.
+
+111
+00:09:42,000 --> 00:09:48,000
+Insert optimized database metadata to limit the amount of necessary configuration.
+
+112
+00:09:48,000 --> 00:09:56,000
+This approach simplifies coding so that you only need to provide the name of the table or procedure
+
+113
+00:09:56,000 --> 00:10:02,000
+and provide a map of parameters matching the column names to help you understand it better.
+
+114
+00:10:02,000 --> 00:10:05,000
+Let's look on the example on the slide.
+
+115
+00:10:06,000 --> 00:10:12,000
+If you need to make an insert with the JDBC template, you would have something like you can see on
+
+116
+00:10:12,000 --> 00:10:13,000
+the slide.
+
+117
+00:10:14,000 --> 00:10:17,000
+You would create JDBC template object.
+
+118
+00:10:17,000 --> 00:10:19,000
+SQL insert statement.
+
+119
+00:10:19,000 --> 00:10:25,000
+And after that you would call update method on JDBC template passing parameters.
+
+120
+00:10:25,000 --> 00:10:33,000
+In case we use simple JDBC insert clause, our code will look like on the example on the slide.
+
+121
+00:10:33,000 --> 00:10:38,000
+As you can see, I create instance of simple jdbc insert type.
+
+122
+00:10:38,000 --> 00:10:40,000
+I specify concrete table.
+
+123
+00:10:40,000 --> 00:10:46,000
+After that I create object of map type and they put values into it.
+
+124
+00:10:46,000 --> 00:10:51,000
+The keys are column names in the table that we specified.
+
+125
+00:10:51,000 --> 00:10:56,000
+The returned value is the number of rows affected by the query.
+
+126
+00:10:56,000 --> 00:11:04,000
+As you can see with a simple JDBC insert, you don't have to write SQL, insert statement and using
+
+127
+00:11:04,000 --> 00:11:05,000
+named parameters.
+
+128
+00:11:05,000 --> 00:11:09,000
+Same as the column names make the code more readable.
+
+129
+00:11:10,000 --> 00:11:13,000
+Let's now talk about simple JDBC call.
+
+130
+00:11:14,000 --> 00:11:20,000
+In simple words, this is a tool provided by spring JDBC to invoke stored procedures.
+
+131
+00:11:21,000 --> 00:11:26,000
+If you don't remember what stored procedures are, please refer to my course Java from zero to first
+
+132
+00:11:26,000 --> 00:11:27,000
+job.
+
+133
+00:11:27,000 --> 00:11:33,000
+There is a section about SQL where I have separate lesson about stored procedures.
+
+134
+00:11:34,000 --> 00:11:42,000
+A simple JDBC call is a multi-threaded reusable object representing a call to a stored procedure or
+
+135
+00:11:42,000 --> 00:11:43,000
+a stored function.
+
+136
+00:11:43,000 --> 00:11:51,000
+It provides metadata processing to simplify the code needed to access basic stored procedures functions.
+
+137
+00:11:51,000 --> 00:11:58,000
+All you need to provide is the name of the procedure or function and the map containing the parameters
+
+138
+00:11:58,000 --> 00:12:00,000
+when you execute the call.
+
+139
+00:12:01,000 --> 00:12:08,000
+The names of the supplied parameters will be matched up within and out parameters declared when the
+
+140
+00:12:08,000 --> 00:12:10,000
+stored procedure was created.
+
+141
+00:12:11,000 --> 00:12:13,000
+Let's look at the example on the slide.
+
+142
+00:12:13,000 --> 00:12:16,000
+Create object of simple JDBC call.
+
+143
+00:12:17,000 --> 00:12:22,000
+Then I can specify in parameters if required by the procedure.
+
+144
+00:12:23,000 --> 00:12:31,000
+Then we can execute the procedure and get the values of the out parameters into map and then we can
+
+145
+00:12:31,000 --> 00:12:34,000
+read out the values returned from the procedure.
+
+146
+00:12:35,000 --> 00:12:43,000
+Note the names of in and out parameters must match the names declared by the stored procedure of function.
+
+147
+00:12:44,000 --> 00:12:48,000
+Basically, that's all what I wanted to share with you in this video.
+
+148
+00:12:48,000 --> 00:12:55,000
+In the next lesson, we are going to have practical examples and full lesson of coding exercises.
+
+149
+00:12:55,000 --> 00:12:59,000
+And right now, let's recap what we have learned in the video.
+
+150
+00:13:00,000 --> 00:13:03,000
+Today we learned what a spring JDBC is.
+
+151
+00:13:03,000 --> 00:13:10,000
+I explained what problems of JDBC API can be easily solved with a spring JDBC.
+
+152
+00:13:11,000 --> 00:13:19,000
+After this lesson, we understand the difference between spring JDBC and spring data JDBC projects.
+
+153
+00:13:19,000 --> 00:13:28,000
+We learned different classes from spring JDBC, namely JDBC template named parameter JDBC template simple
+
+154
+00:13:28,000 --> 00:13:32,000
+JDBC insert simple JDBC call.
+
+155
+00:13:33,000 --> 00:13:34,000
+Thanks a lot for your attention.
+
+156
+00:13:34,000 --> 00:13:37,000
+Have a great day and see you in the next lesson.
+
diff --git a/88 - Spring JDBC/002 Source-code-of-examples-commit-with-changes-.url b/88 - Spring JDBC/002 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..4dcdd898ad1edceeca6778ea1967ae17b648729b
--- /dev/null
+++ b/88 - Spring JDBC/002 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/914fe50d4a0da192c913cd2d91560f3a03d60fa1
\ No newline at end of file
diff --git a/88 - Spring JDBC/002 Spring JDBC Practice_en.srt b/88 - Spring JDBC/002 Spring JDBC Practice_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..c7f175e7170601530a5e5574d5de284edf86eee3
--- /dev/null
+++ b/88 - Spring JDBC/002 Spring JDBC Practice_en.srt
@@ -0,0 +1,1396 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:09,000
+Today we are going to have a lesson full of practical examples.
+
+3
+00:00:09,000 --> 00:00:13,000
+And today we continue learning Spring JDBC.
+
+4
+00:00:14,000 --> 00:00:20,000
+We're going to start this lesson from the overview of the main packages in the Spring JDBC Library.
+
+5
+00:00:20,000 --> 00:00:28,000
+This is supposed to help you to navigate in the documentation and understand how classes are grouped
+
+6
+00:00:28,000 --> 00:00:29,000
+in the library.
+
+7
+00:00:30,000 --> 00:00:33,000
+After that, we will jump to practical code examples.
+
+8
+00:00:33,000 --> 00:00:37,000
+We'll configure the dependencies needed in our PWM XML.
+
+9
+00:00:37,000 --> 00:00:44,000
+For all practical examples, we are going to configure all required beans and then I'm going to show
+
+10
+00:00:44,000 --> 00:00:48,000
+you in action how to work with key classes from Spring JDBC.
+
+11
+00:00:49,000 --> 00:00:56,000
+Namely, we are going to have examples with JDBC template named parameter JDBC template simple jdbc
+
+12
+00:00:56,000 --> 00:00:59,000
+insert simple JDBC call.
+
+13
+00:01:00,000 --> 00:01:07,000
+I'm going to show you how to do batch updates and what parameter source utils class is.
+
+14
+00:01:07,000 --> 00:01:15,000
+Also, during the lesson, I'm going to explain you what row mapper is, how and when to use it.
+
+15
+00:01:15,000 --> 00:01:17,000
+Let's start our lesson.
+
+16
+00:01:18,000 --> 00:01:21,000
+And as I said before, we jump to practical code examples.
+
+17
+00:01:21,000 --> 00:01:28,000
+Let me just make a brief overview of packages in Spring JDBC library in order you could understand the
+
+18
+00:01:28,000 --> 00:01:35,000
+logic of grouping classes and in order to help you to navigate in the documentation in case you would
+
+19
+00:01:35,000 --> 00:01:37,000
+like to find something.
+
+20
+00:01:37,000 --> 00:01:43,000
+So all classes in spring JDBC are grouped into four separate packages.
+
+21
+00:01:43,000 --> 00:01:50,000
+They are core in this package located the core functionality of JDBC.
+
+22
+00:01:50,000 --> 00:01:55,000
+There are a few sub packages like metadata named Param.
+
+23
+00:01:55,000 --> 00:01:57,000
+Simple support.
+
+24
+00:01:58,000 --> 00:02:06,000
+Some of the important classes under this package include JDBC template simple JDBC insert simple JDBC
+
+25
+00:02:06,000 --> 00:02:10,000
+call and named parameter JDBC template.
+
+26
+00:02:10,000 --> 00:02:16,000
+In the previous lesson we made a review of these classes, so make sure you watch the previous lesson
+
+27
+00:02:17,000 --> 00:02:18,000
+config.
+
+28
+00:02:18,000 --> 00:02:23,000
+This package defines the spring JDBC configuration namespace.
+
+29
+00:02:23,000 --> 00:02:32,000
+It contains such classes as JDBC namespace handler and sorted resources Factory Bin data source.
+
+30
+00:02:32,000 --> 00:02:37,000
+In this package, you can find utility classes to access a data source.
+
+31
+00:02:37,000 --> 00:02:44,000
+It also has various data source implementation for testing JDBC code outside of the Jakarta Enterprise
+
+32
+00:02:44,000 --> 00:02:46,000
+Edition container.
+
+33
+00:02:47,000 --> 00:02:47,000
+Object.
+
+34
+00:02:48,000 --> 00:02:53,000
+The classes in this package represent relational database management system queries.
+
+35
+00:02:53,000 --> 00:02:58,000
+Updates and stored procedures as thread safe reusable objects.
+
+36
+00:02:58,000 --> 00:03:03,000
+It is also about database access in an object oriented manner.
+
+37
+00:03:03,000 --> 00:03:07,000
+It allows running queries and returns the results as a business object.
+
+38
+00:03:07,000 --> 00:03:13,000
+It also maps the query results between the columns and properties of business objects.
+
+39
+00:03:14,000 --> 00:03:15,000
+Support.
+
+40
+00:03:15,000 --> 00:03:22,000
+This package contains support classes for classes on the core and object packages.
+
+41
+00:03:22,000 --> 00:03:27,000
+For example, it provides a SQL exception translation functionality.
+
+42
+00:03:27,000 --> 00:03:28,000
+That's it.
+
+43
+00:03:29,000 --> 00:03:35,000
+As I promised you at the beginning of the lesson today, we are going to have a lot of practical examples.
+
+44
+00:03:35,000 --> 00:03:40,000
+So let me start with the screen sharing and jump to the coding exercises.
+
+45
+00:03:40,000 --> 00:03:44,000
+All source code examples you can find in attachments to the video.
+
+46
+00:03:45,000 --> 00:03:48,000
+Just use the link attached to the video.
+
+47
+00:03:48,000 --> 00:03:54,000
+You can clone repository if you wish and try the source code on your computer.
+
+48
+00:03:55,000 --> 00:04:00,000
+We're going to start with adding dependency into our pom.xml.
+
+49
+00:04:00,000 --> 00:04:04,000
+We just need to add spring JDBC dependency and that's it.
+
+50
+00:04:04,000 --> 00:04:09,000
+In my case I use the same version as for other spring dependencies.
+
+51
+00:04:09,000 --> 00:04:15,000
+You are welcome to check Maven repository and to select the version that you need.
+
+52
+00:04:16,000 --> 00:04:22,000
+Also, if you follow the course attentively, then you remember that in previous lessons we added all
+
+53
+00:04:22,000 --> 00:04:25,000
+the Jackson data bind dependency.
+
+54
+00:04:25,000 --> 00:04:30,000
+It is needed in order to convert objects into the JSON and vice versa.
+
+55
+00:04:30,000 --> 00:04:36,000
+Spring internally is going to use this dependency when we will use response body.
+
+56
+00:04:36,000 --> 00:04:37,000
+Let's move on.
+
+57
+00:04:38,000 --> 00:04:41,000
+Now let's configure all necessary bins.
+
+58
+00:04:42,000 --> 00:04:44,000
+I open Web.config class.
+
+59
+00:04:44,000 --> 00:04:48,000
+We need to make sure that our data source bin is configured.
+
+60
+00:04:48,000 --> 00:04:54,000
+We configure it it already in our previous lessons when we learned spring data JPA.
+
+61
+00:04:54,000 --> 00:04:55,000
+Here it is.
+
+62
+00:04:56,000 --> 00:05:01,000
+Also, pay attention that it takes values from the property resource.
+
+63
+00:05:01,000 --> 00:05:07,000
+Just to remind you that here on top we also declared property source with the database properties.
+
+64
+00:05:07,000 --> 00:05:12,000
+Database Properties file is located in our resources folder.
+
+65
+00:05:12,000 --> 00:05:19,000
+I'm going to use the same properties because nothing is changed in our database configurations.
+
+66
+00:05:19,000 --> 00:05:24,000
+I mean JDBC driver username and password.
+
+67
+00:05:24,000 --> 00:05:30,000
+Also, there is an interesting question about whether you need to create multiple JDBC template instances
+
+68
+00:05:30,000 --> 00:05:37,000
+or no, or just to create one instance and inject it in each DAO implementation.
+
+69
+00:05:38,000 --> 00:05:43,000
+Let's answer this question based on the example of the JDBC template.
+
+70
+00:05:43,000 --> 00:05:51,000
+JDBC template is thread safe, lock free, meaning it should not cause performance degradation when
+
+71
+00:05:51,000 --> 00:05:53,000
+shared between concurrent threads.
+
+72
+00:05:53,000 --> 00:06:00,000
+Thus, there are no compelling reasons for more than one instance per data source.
+
+73
+00:06:00,000 --> 00:06:05,000
+There is no problem to inject JDBC template to your multiple DAO.
+
+74
+00:06:05,000 --> 00:06:14,000
+The template is used to wire your data to the physical resource database connection when you need to
+
+75
+00:06:14,000 --> 00:06:15,000
+run database query.
+
+76
+00:06:16,000 --> 00:06:22,000
+Spring manages the life cycle of the beans you need for working with your persistence layer.
+
+77
+00:06:22,000 --> 00:06:25,000
+The advantages of using a template are.
+
+78
+00:06:25,000 --> 00:06:32,000
+JDBC template manages physical resources required to interact with the database automatically.
+
+79
+00:06:32,000 --> 00:06:37,000
+By saying this, I mean create and release the database connections.
+
+80
+00:06:37,000 --> 00:06:44,000
+The spring JDBC template converts the standard JDBC SQL exceptions into runtime exceptions.
+
+81
+00:06:44,000 --> 00:06:48,000
+This allows you to react more flexible to the errors.
+
+82
+00:06:49,000 --> 00:06:56,000
+The spring JDBC template converts also the vendor specific error messages into better understandable
+
+83
+00:06:56,000 --> 00:06:57,000
+error messages.
+
+84
+00:06:58,000 --> 00:07:02,000
+So I created bin of the JDBC template here.
+
+85
+00:07:02,000 --> 00:07:07,000
+Pay attention that I inject data source into this class.
+
+86
+00:07:08,000 --> 00:07:12,000
+I created such been as named parameter jdbc template.
+
+87
+00:07:12,000 --> 00:07:15,000
+Also using data source been.
+
+88
+00:07:15,000 --> 00:07:19,000
+The next files that I would like to review with you is user Dao.
+
+89
+00:07:20,000 --> 00:07:26,000
+If you want to refresh your knowledge about Dao pattern, please refer to my course Java from zero to
+
+90
+00:07:26,000 --> 00:07:26,000
+first job.
+
+91
+00:07:27,000 --> 00:07:32,000
+There you can find separate lesson about data access object design pattern.
+
+92
+00:07:32,000 --> 00:07:39,000
+So our user DAO class will be in charge of the interaction with the relational database.
+
+93
+00:07:39,000 --> 00:07:47,000
+Basically, this is a class where we will use objects created based on the spring JDBC libraries classes
+
+94
+00:07:47,000 --> 00:07:50,000
+in order to build and execute queries.
+
+95
+00:07:50,000 --> 00:07:52,000
+Let's look through it.
+
+96
+00:07:53,000 --> 00:08:00,000
+I injected JDBC template named parameter JDBC template and data source beans for the sake of examples
+
+97
+00:08:00,000 --> 00:08:03,000
+that I described in this file.
+
+98
+00:08:03,000 --> 00:08:05,000
+Let's review the first simple example.
+
+99
+00:08:05,000 --> 00:08:13,000
+Just simple select statement that returns us integer total count of users in the database.
+
+100
+00:08:14,000 --> 00:08:22,000
+I use method query for object of JDBC template object and pass the SQL query and class to which I want
+
+101
+00:08:22,000 --> 00:08:24,000
+to cast the result.
+
+102
+00:08:24,000 --> 00:08:32,000
+As you can see, I want to extract total count of users present in the database in the table user.
+
+103
+00:08:33,000 --> 00:08:36,000
+Obviously the result will be integer number.
+
+104
+00:08:36,000 --> 00:08:39,000
+That's why class for casting is integer.
+
+105
+00:08:40,000 --> 00:08:46,000
+Just to note, I believe that you understand that SQL queries can be stored in different files.
+
+106
+00:08:46,000 --> 00:08:54,000
+For example, you can store SQL queries in properties files and fetch them when needed.
+
+107
+00:08:54,000 --> 00:09:00,000
+In this lesson, I decided to keep SQL queries as part of the source code for demo purposes in order
+
+108
+00:09:00,000 --> 00:09:08,000
+to not switch screens very fast and do not navigate between multiple files a lot of times.
+
+109
+00:09:08,000 --> 00:09:12,000
+So just look at this first simple example.
+
+110
+00:09:13,000 --> 00:09:19,000
+I just injected JDBC template and just call methods that I need with a SQL query.
+
+111
+00:09:19,000 --> 00:09:20,000
+That's it.
+
+112
+00:09:20,000 --> 00:09:24,000
+No more creating Connection Creating Statement Objects.
+
+113
+00:09:24,000 --> 00:09:26,000
+Closing Connection.
+
+114
+00:09:26,000 --> 00:09:27,000
+Closing Statements.
+
+115
+00:09:27,000 --> 00:09:30,000
+Extracting ResultSet Closing Result Set.
+
+116
+00:09:30,000 --> 00:09:34,000
+Can you see how simple code looks like?
+
+117
+00:09:34,000 --> 00:09:41,000
+That's one of the biggest advantages of spring simplification and removing of boilerplate code.
+
+118
+00:09:42,000 --> 00:09:47,000
+Basically, I have nothing more to add here with regards to this first example.
+
+119
+00:09:48,000 --> 00:09:54,000
+Integer will be returned and I'm going to demo how this code works at the end of the lesson.
+
+120
+00:09:55,000 --> 00:09:56,000
+Let's continue.
+
+121
+00:09:57,000 --> 00:10:00,000
+Let's review simple insert statement.
+
+122
+00:10:00,000 --> 00:10:03,000
+Here you can see method at sample user.
+
+123
+00:10:03,000 --> 00:10:09,000
+This is how you can execute insert statement with the JDBC template object.
+
+124
+00:10:10,000 --> 00:10:17,000
+Pay attention that I use question marks for SQL query parameters instead of string concatenation in
+
+125
+00:10:17,000 --> 00:10:19,000
+order to avoid SQL injection.
+
+126
+00:10:19,000 --> 00:10:27,000
+After the SQL statement, I pass parameters that should be injected into the SQL statement similar to
+
+127
+00:10:27,000 --> 00:10:29,000
+the prepared statement from the JDBC.
+
+128
+00:10:29,000 --> 00:10:31,000
+If you remember.
+
+129
+00:10:31,000 --> 00:10:38,000
+Of course, all these parameters should go from the outside and should be passed to the method.
+
+130
+00:10:38,000 --> 00:10:46,000
+But in order to not complicate example and put all focus on the spring JDBC, I decided to hardcode
+
+131
+00:10:46,000 --> 00:10:47,000
+some values here.
+
+132
+00:10:48,000 --> 00:10:53,000
+Now let's review how we can work with the named parameter JDBC template.
+
+133
+00:10:54,000 --> 00:11:01,000
+I believe that from previous theoretical lessons you already know the purpose of this type.
+
+134
+00:11:01,000 --> 00:11:08,000
+But just to remind you, we are going to use a special template in order to use named parameters instead
+
+135
+00:11:08,000 --> 00:11:09,000
+of question marks.
+
+136
+00:11:09,000 --> 00:11:17,000
+This makes sense because in general it is considered that risk of making mistake was named parameters
+
+137
+00:11:17,000 --> 00:11:18,000
+is less.
+
+138
+00:11:18,000 --> 00:11:26,000
+Imagine in case your SQL queries are stored in another file and you need to pass parameters in a strict
+
+139
+00:11:26,000 --> 00:11:32,000
+sequence and you need to make sure that you passed all parameters correctly.
+
+140
+00:11:32,000 --> 00:11:40,000
+Or let's imagine that somebody adjusted SQL statement and you have wrong sequence of arguments right
+
+141
+00:11:40,000 --> 00:11:42,000
+now configured in the source code.
+
+142
+00:11:43,000 --> 00:11:50,000
+Anyway, haven't parameter name and associated value will give you better visibility and control over
+
+143
+00:11:50,000 --> 00:11:53,000
+building the and SQL query.
+
+144
+00:11:54,000 --> 00:11:55,000
+Under the hood.
+
+145
+00:11:55,000 --> 00:12:03,000
+It substitutes the named parameters to jdbc question mark placeholder and delegates to the wrapped JDBC
+
+146
+00:12:03,000 --> 00:12:06,000
+template to run the queries.
+
+147
+00:12:06,000 --> 00:12:15,000
+So here is the method that is called get last name of user by id where I use named parameter JDBC template.
+
+148
+00:12:15,000 --> 00:12:19,000
+I declare a variable of the SQL parameter source type.
+
+149
+00:12:20,000 --> 00:12:29,000
+This interface is intended to wrap various implementations like a map or a Java bean with a consistent
+
+150
+00:12:29,000 --> 00:12:30,000
+interface.
+
+151
+00:12:30,000 --> 00:12:34,000
+I create object of map parameter source.
+
+152
+00:12:34,000 --> 00:12:42,000
+Basically, this is implementation of SQL parameter source that holds a given map of parameters into
+
+153
+00:12:42,000 --> 00:12:43,000
+the map.
+
+154
+00:12:43,000 --> 00:12:47,000
+I added parameter with value passed as method argument.
+
+155
+00:12:48,000 --> 00:12:53,000
+After that I pass SQL query to the query for object method.
+
+156
+00:12:53,000 --> 00:12:56,000
+Pay attention how I use named parameter.
+
+157
+00:12:57,000 --> 00:13:05,000
+Here's a ye named parameter and I pass my map in order to inject parameter values into the SQL query.
+
+158
+00:13:05,000 --> 00:13:08,000
+Basically that's how it works.
+
+159
+00:13:08,000 --> 00:13:16,000
+But you can use not only map of parameters, you can also use bean for mapping parameters.
+
+160
+00:13:16,000 --> 00:13:18,000
+Let me show you how.
+
+161
+00:13:18,000 --> 00:13:20,000
+Below you can see similar method.
+
+162
+00:13:20,000 --> 00:13:22,000
+There are few differences.
+
+163
+00:13:22,000 --> 00:13:32,000
+Instead of passing just integer id, I pass user object and instead of creation map SQL parameter source
+
+164
+00:13:32,000 --> 00:13:34,000
+or object, I create bean property.
+
+165
+00:13:35,000 --> 00:13:40,000
+SQL Parameter Source object and pass my user object into the constructor.
+
+166
+00:13:40,000 --> 00:13:47,000
+This object obtains parameter values from bean properties of a given Java bean object.
+
+167
+00:13:47,000 --> 00:13:53,000
+The names of the bean properties have to match the parameter names.
+
+168
+00:13:53,000 --> 00:13:55,000
+The rest is the same.
+
+169
+00:13:56,000 --> 00:14:00,000
+I pass named parameters to the query for object method.
+
+170
+00:14:01,000 --> 00:14:04,000
+Also here you can see example of batch update.
+
+171
+00:14:05,000 --> 00:14:12,000
+In this particular example, I update our database by executing multiple insert statements and inserting
+
+172
+00:14:12,000 --> 00:14:13,000
+users.
+
+173
+00:14:13,000 --> 00:14:22,000
+I bet you remember that in JDBC we also can make batch updates and I showed you examples if you remember.
+
+174
+00:14:22,000 --> 00:14:30,000
+So this is needed in order to optimize amount of queries sent to the database from our application in
+
+175
+00:14:30,000 --> 00:14:39,000
+case we send batch request, all requests are sent at once and executed in one cycle in database, and
+
+176
+00:14:39,000 --> 00:14:42,000
+this gives us additional optimization.
+
+177
+00:14:43,000 --> 00:14:49,000
+This is helpful when you want to update multiple records in one table.
+
+178
+00:14:50,000 --> 00:14:53,000
+I use class that is called SQL parameter source utils.
+
+179
+00:14:53,000 --> 00:14:59,000
+It helps me to create batch source based on the array of my objects.
+
+180
+00:14:59,000 --> 00:15:05,000
+And after that, having the SQL query, I can just pass the batch for execution.
+
+181
+00:15:06,000 --> 00:15:13,000
+Another super interesting and useful feature of spring JDBC is possibility to map query results to Java
+
+182
+00:15:13,000 --> 00:15:17,000
+objects by implementing row mapper interface.
+
+183
+00:15:18,000 --> 00:15:24,000
+In the simple JDBC, I believe you remember that you had to work with a result set and extract values
+
+184
+00:15:24,000 --> 00:15:26,000
+from the result set.
+
+185
+00:15:26,000 --> 00:15:35,000
+Actually there is a way how to create reusable code even in JDBC, but in spring JDBC it is implemented
+
+186
+00:15:35,000 --> 00:15:39,000
+out of the box and in the very elegant way.
+
+187
+00:15:39,000 --> 00:15:45,000
+Let's review an example in the separate package that is called Row Mappers.
+
+188
+00:15:45,000 --> 00:15:47,000
+I implemented Row mapper.
+
+189
+00:15:48,000 --> 00:15:50,000
+Everything is simple here.
+
+190
+00:15:50,000 --> 00:15:56,000
+I declare a class that is called user row mapper that implements row mapper interface.
+
+191
+00:15:57,000 --> 00:16:03,000
+This interface makes me implement one single method that is called map row.
+
+192
+00:16:03,000 --> 00:16:09,000
+This method takes result set as method, argument and row numbers.
+
+193
+00:16:09,000 --> 00:16:16,000
+Inside I will create user object and will do mapping between data from the result set and user object
+
+194
+00:16:16,000 --> 00:16:17,000
+properties.
+
+195
+00:16:17,000 --> 00:16:21,000
+I just return the user object from this method.
+
+196
+00:16:21,000 --> 00:16:25,000
+Let me now open my user dialogue class here.
+
+197
+00:16:25,000 --> 00:16:28,000
+I have method that is called Get User by ID.
+
+198
+00:16:28,000 --> 00:16:36,000
+You can see that I use JDBC template to submit the SQL statement to extract all values from the user
+
+199
+00:16:36,000 --> 00:16:40,000
+table where ID is equal to the one specified.
+
+200
+00:16:41,000 --> 00:16:49,000
+According to the API, I need to pass an array with parameters and the second int array of argument
+
+201
+00:16:49,000 --> 00:16:50,000
+types.
+
+202
+00:16:50,000 --> 00:16:52,000
+Y int array.
+
+203
+00:16:52,000 --> 00:16:58,000
+Because according to the API, I need to use constants from the java types class.
+
+204
+00:16:59,000 --> 00:17:03,000
+I passed integer argument, so I just specify integer.
+
+205
+00:17:04,000 --> 00:17:11,000
+I believe that it is clear and logical for you that there should be mapping between types in this array
+
+206
+00:17:11,000 --> 00:17:14,000
+and actual types of arguments passed.
+
+207
+00:17:14,000 --> 00:17:20,000
+And the fourth argument is our row mapper and we have user object returned.
+
+208
+00:17:20,000 --> 00:17:21,000
+That's it.
+
+209
+00:17:22,000 --> 00:17:28,000
+Just to remind you that in case you have any questions, please do not hesitate to ask your questions
+
+210
+00:17:28,000 --> 00:17:31,000
+below the video and I will be happy to answer.
+
+211
+00:17:31,000 --> 00:17:33,000
+Let's move on.
+
+212
+00:17:33,000 --> 00:17:41,000
+So the only things that we still didn't review are examples with simple JDBC classes, the ones that
+
+213
+00:17:41,000 --> 00:17:49,000
+we reviewed in theoretical Lesson two, namely simple JDBC insert and simple JDBC call.
+
+214
+00:17:50,000 --> 00:17:53,000
+Let's start review from the simple JDBC insert.
+
+215
+00:17:53,000 --> 00:18:01,000
+As you remember, I can use simple JDBC insert to generate the insert statement based on the configurations
+
+216
+00:18:01,000 --> 00:18:02,000
+provided.
+
+217
+00:18:02,000 --> 00:18:08,000
+All we need is to provide the table name column names and values.
+
+218
+00:18:08,000 --> 00:18:13,000
+We already had method that inserts simple user data.
+
+219
+00:18:14,000 --> 00:18:20,000
+I created the similar method, but just using simple jdbc insert object.
+
+220
+00:18:20,000 --> 00:18:27,000
+I need to create object itself and you can see that I configure the table during the creation of the
+
+221
+00:18:27,000 --> 00:18:28,000
+object.
+
+222
+00:18:28,000 --> 00:18:32,000
+We're going to work with the user test table.
+
+223
+00:18:32,000 --> 00:18:37,000
+After that I create map where I will put all required parameters.
+
+224
+00:18:37,000 --> 00:18:44,000
+The key will be column name and the value will be the value that we want to insert.
+
+225
+00:18:44,000 --> 00:18:49,000
+After that I just call execute method and pass all my parameters.
+
+226
+00:18:49,000 --> 00:18:56,000
+Pay attention that using simple JDBC insert object, I don't create any SQL statements.
+
+227
+00:18:57,000 --> 00:18:58,000
+That's how it works.
+
+228
+00:18:59,000 --> 00:19:02,000
+You can see commanded line here.
+
+229
+00:19:02,000 --> 00:19:06,000
+This is just a useful reminder about the API.
+
+230
+00:19:06,000 --> 00:19:14,000
+Sometimes it is nice to get the primary key after insertion in order to proceed using this data further
+
+231
+00:19:14,000 --> 00:19:16,000
+in our business logic.
+
+232
+00:19:16,000 --> 00:19:24,000
+For this, you need to configure auto generated column and use method, execute and return key, just
+
+233
+00:19:24,000 --> 00:19:26,000
+like you can see in the example here.
+
+234
+00:19:27,000 --> 00:19:35,000
+And also we can pass data by using the map parameter source and being property parameter source.
+
+235
+00:19:36,000 --> 00:19:42,000
+And the last but not the least for code examples for today is example of simple JDBC call.
+
+236
+00:19:42,000 --> 00:19:49,000
+As you remember from previous lesson, object of this type is used to invoke stored procedure to invoke
+
+237
+00:19:49,000 --> 00:19:50,000
+stored procedure.
+
+238
+00:19:50,000 --> 00:19:55,000
+Let's make sure that stored procedure is created in the database.
+
+239
+00:19:55,000 --> 00:20:02,000
+In the comments on top of the related demo method, I pasted code that you can execute in the database
+
+240
+00:20:02,000 --> 00:20:04,000
+in order to create stored procedure.
+
+241
+00:20:05,000 --> 00:20:10,000
+And once stored procedure is created, this code will work.
+
+242
+00:20:11,000 --> 00:20:17,000
+I create object of simple JDBC call and I specify procedure name.
+
+243
+00:20:17,000 --> 00:20:20,000
+This is the name of procedure that I've created before.
+
+244
+00:20:20,000 --> 00:20:24,000
+The lesson in the database using the script above.
+
+245
+00:20:24,000 --> 00:20:29,000
+Our procedure has in parameter and out parameters.
+
+246
+00:20:30,000 --> 00:20:32,000
+Our in parameter is ID.
+
+247
+00:20:33,000 --> 00:20:36,000
+Our out parameters are first name and last name.
+
+248
+00:20:37,000 --> 00:20:42,000
+I create map parameters source and pass parameter into it.
+
+249
+00:20:43,000 --> 00:20:49,000
+I use this parameter source object during the execution of the stored procedure here.
+
+250
+00:20:49,000 --> 00:20:58,000
+As a result of execution, I receive map where string and names of output parameters and object is actually
+
+251
+00:20:58,000 --> 00:21:00,000
+values of output parameters.
+
+252
+00:21:00,000 --> 00:21:07,000
+I create user object and populate user with values that I received as out parameters.
+
+253
+00:21:07,000 --> 00:21:13,000
+Just to remind you that in case you want to learn more about stored procedures, feel free to check
+
+254
+00:21:13,000 --> 00:21:20,000
+my course Java from zero to first job and there you will find the separate lesson about stored procedures.
+
+255
+00:21:20,000 --> 00:21:24,000
+Basically that's it about simple JDBC call.
+
+256
+00:21:25,000 --> 00:21:29,000
+The only thing that is left is to make sure that everything works as expected.
+
+257
+00:21:30,000 --> 00:21:33,000
+So create a service layer.
+
+258
+00:21:33,000 --> 00:21:40,000
+This is just to help you understand how this DAO may be integrated in real life application.
+
+259
+00:21:40,000 --> 00:21:46,000
+Most likely you are going to have some clos on the service layer where you will apply all your business
+
+260
+00:21:46,000 --> 00:21:47,000
+logic.
+
+261
+00:21:47,000 --> 00:21:51,000
+In my particular demo I created a new class in the service package.
+
+262
+00:21:52,000 --> 00:21:55,000
+The class is called User Service JDBC Dao.
+
+263
+00:21:56,000 --> 00:22:03,000
+I inject my DAO class here and on this level you can apply any application business logic that you need.
+
+264
+00:22:04,000 --> 00:22:08,000
+And the service will be injected into the controller in Chan.
+
+265
+00:22:08,000 --> 00:22:14,000
+I created another class called User Rest Controller JDBC Demo.
+
+266
+00:22:14,000 --> 00:22:21,000
+Basically, I created here endpoints in order to be able to demo you all the methods that we have just
+
+267
+00:22:21,000 --> 00:22:23,000
+reviewed in the user dao.
+
+268
+00:22:23,000 --> 00:22:27,000
+I believe there is nothing new for you in this controller.
+
+269
+00:22:27,000 --> 00:22:36,000
+Please make sure you don't skip lessons when you watch my course because I count on this few lessons
+
+270
+00:22:36,000 --> 00:22:44,000
+ago we learned spring GPA and I showed you similar example of rest controller and explained that rest
+
+271
+00:22:44,000 --> 00:22:51,000
+controller annotation is basically a combination of two annotations, controller and response body.
+
+272
+00:22:52,000 --> 00:22:59,000
+Let me run the server and show you that all methods work as expected and that we receive the data that
+
+273
+00:22:59,000 --> 00:23:00,000
+we expect to receive.
+
+274
+00:23:01,000 --> 00:23:06,000
+First of all, here is how our user table looks like in the database.
+
+275
+00:23:06,000 --> 00:23:11,000
+Three records and such columns, nothing extraordinary.
+
+276
+00:23:11,000 --> 00:23:14,000
+Now let me open the web browser.
+
+277
+00:23:14,000 --> 00:23:20,000
+In the web browser, I'm going to send requests and demo the methods in the sequence that we reviewed
+
+278
+00:23:20,000 --> 00:23:21,000
+them.
+
+279
+00:23:21,000 --> 00:23:26,000
+We're going to start with the first method where one extract total user count.
+
+280
+00:23:27,000 --> 00:23:34,000
+This is a simple request that we created with a JDBC template, and as you can see, we receive value
+
+281
+00:23:34,000 --> 00:23:40,000
+three as expected, because as you saw, I have three records in the user table.
+
+282
+00:23:40,000 --> 00:23:46,000
+The next example is about adding sample user using JDBC template.
+
+283
+00:23:49,000 --> 00:23:53,000
+After sending this request, I receive one.
+
+284
+00:23:54,000 --> 00:23:56,000
+Because one record has been inserted.
+
+285
+00:23:56,000 --> 00:24:01,000
+Let me also show you the database In the database.
+
+286
+00:24:01,000 --> 00:24:04,000
+You can see that additional record is added.
+
+287
+00:24:04,000 --> 00:24:09,000
+The next example is about using named parameter JDBC template.
+
+288
+00:24:09,000 --> 00:24:13,000
+We are going to extract a last name by user ID.
+
+289
+00:24:14,000 --> 00:24:19,000
+User ID seven has first name admin and last name admin.
+
+290
+00:24:19,000 --> 00:24:23,000
+So everything works as expected.
+
+291
+00:24:24,000 --> 00:24:29,000
+The next demo was about injecting parameters into the query using bin properties.
+
+292
+00:24:29,000 --> 00:24:31,000
+SQL Parameter Source.
+
+293
+00:24:31,000 --> 00:24:37,000
+I used user with a yy7 and I received the same last name.
+
+294
+00:24:37,000 --> 00:24:44,000
+By the way, this trick is pretty useful when you need to inject multiple parameters into the SQL query
+
+295
+00:24:44,000 --> 00:24:48,000
+in order to not list them all manually.
+
+296
+00:24:49,000 --> 00:24:55,000
+You just pass bean and spring automatically matches parameters with properties.
+
+297
+00:24:56,000 --> 00:25:03,000
+The next example is related to the case when you use feature of query execution in batch.
+
+298
+00:25:03,000 --> 00:25:06,000
+Do you remember we implemented batch in set demo?
+
+299
+00:25:06,000 --> 00:25:14,000
+So to review this code in action, you can send request to the following resource user batch and set
+
+300
+00:25:14,000 --> 00:25:15,000
+demo.
+
+301
+00:25:15,000 --> 00:25:21,000
+And after that we can open database our user test table.
+
+302
+00:25:21,000 --> 00:25:26,000
+And just to be sure that new records were created in one batch.
+
+303
+00:25:26,000 --> 00:25:33,000
+As I already mentioned, this should help you to increase performance in cases when you need to update
+
+304
+00:25:33,000 --> 00:25:36,000
+the same table with multiple records.
+
+305
+00:25:37,000 --> 00:25:41,000
+Let me now show you the example of user row mapper in action.
+
+306
+00:25:41,000 --> 00:25:48,000
+So in the browser I send a request to the user JDBC demo seven.
+
+307
+00:25:48,000 --> 00:25:56,000
+And as you can see, JSON is returned, user is converted into JSON because we configured our controller
+
+308
+00:25:56,000 --> 00:26:01,000
+in such way it would write output directly into the response body.
+
+309
+00:26:01,000 --> 00:26:09,000
+And taking into account that our method returns user object, it is automatically serialized into the
+
+310
+00:26:09,000 --> 00:26:14,000
+JSON using JSON library that is added into the pom.xml.
+
+311
+00:26:14,000 --> 00:26:22,000
+And as you can see, all fields that we populated inside our user role mapper are successfully populated.
+
+312
+00:26:22,000 --> 00:26:24,000
+Also the danger lesson.
+
+313
+00:26:24,000 --> 00:26:29,000
+We learned how to work with simple insert objects.
+
+314
+00:26:29,000 --> 00:26:30,000
+Let's check the demo.
+
+315
+00:26:31,000 --> 00:26:37,000
+We also implemented method that inserts the user with a simple JDBC insert.
+
+316
+00:26:38,000 --> 00:26:42,000
+Let me send request to the foreign resource user.
+
+317
+00:26:42,000 --> 00:26:44,000
+Add test user too.
+
+318
+00:26:45,000 --> 00:26:50,000
+As you remember, for the sake of the demo, I did request to the user test table.
+
+319
+00:26:50,000 --> 00:26:51,000
+Let's check.
+
+320
+00:26:51,000 --> 00:26:53,000
+That record has been added.
+
+321
+00:26:53,000 --> 00:26:55,000
+And here it is.
+
+322
+00:26:55,000 --> 00:26:56,000
+The record has been added.
+
+323
+00:26:57,000 --> 00:27:02,000
+And the last but not the least, is the demo of the stored procedure invocation.
+
+324
+00:27:02,000 --> 00:27:07,000
+Let me send the request to the following resource user.
+
+325
+00:27:07,000 --> 00:27:10,000
+Last Name Procedure demo seven.
+
+326
+00:27:11,000 --> 00:27:17,000
+As you can see, we have populated on the first name and last name in our user object because our stored
+
+327
+00:27:17,000 --> 00:27:21,000
+procedure has only two output parameters.
+
+328
+00:27:21,000 --> 00:27:25,000
+Anyway, you can create any stored procedure you wish.
+
+329
+00:27:25,000 --> 00:27:32,000
+The main thing is for you to understand the mechanics and how everything works under the hood.
+
+330
+00:27:32,000 --> 00:27:37,000
+Knowing this, you can change parameters or queries by examples.
+
+331
+00:27:37,000 --> 00:27:40,000
+It will be like a piece of cake for you.
+
+332
+00:27:41,000 --> 00:27:44,000
+You're going to find source code examples in attachments to the video.
+
+333
+00:27:45,000 --> 00:27:47,000
+Feel free to explore examples.
+
+334
+00:27:47,000 --> 00:27:53,000
+Also, in case you have any questions, please put your questions below the video and I will be happy
+
+335
+00:27:53,000 --> 00:27:54,000
+to answer.
+
+336
+00:27:55,000 --> 00:27:59,000
+Now let's recap what we have learned in this lesson.
+
+337
+00:28:00,000 --> 00:28:04,000
+Today we made overview of the spring JDBC packages.
+
+338
+00:28:04,000 --> 00:28:08,000
+Now you know how the library is structured and where to search.
+
+339
+00:28:08,000 --> 00:28:10,000
+What we learned.
+
+340
+00:28:11,000 --> 00:28:12,000
+Spring JDBC configuration.
+
+341
+00:28:12,000 --> 00:28:14,000
+Now you know everything.
+
+342
+00:28:14,000 --> 00:28:19,000
+What we need to configure in order to start using features of spring JDBC.
+
+343
+00:28:19,000 --> 00:28:27,000
+I showed you today a lot of practical code examples, namely examples with JDBC template with named
+
+344
+00:28:27,000 --> 00:28:33,000
+parameter JDBC template simple JDBC insert and simple JDBC call.
+
+345
+00:28:33,000 --> 00:28:39,000
+Also during the lesson I explained you what row mapper is and how to use it.
+
+346
+00:28:39,000 --> 00:28:45,000
+And we learned how to make batch update with SQL parameter source utils class.
+
+347
+00:28:46,000 --> 00:28:48,000
+That's all for this lesson.
+
+348
+00:28:48,000 --> 00:28:50,000
+Thanks a lot for your attention.
+
+349
+00:28:50,000 --> 00:28:53,000
+Have a great day and see you in the next lesson.
+
diff --git a/88 - Spring JDBC/external-links.txt b/88 - Spring JDBC/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0e61568ac28fb9325e8157da8a868f1d3de14054
--- /dev/null
+++ b/88 - Spring JDBC/external-links.txt
@@ -0,0 +1,3 @@
+
+002 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/914fe50d4a0da192c913cd2d91560f3a03d60fa1
diff --git a/89 - ===== EXAM Spring JDBC - Online Shop =====/001 EXAM Spring JDBC - Online Shop.html b/89 - ===== EXAM Spring JDBC - Online Shop =====/001 EXAM Spring JDBC - Online Shop.html
new file mode 100644
index 0000000000000000000000000000000000000000..06e99b922bd03fd3cafec2e9cf452796153ea608
--- /dev/null
+++ b/89 - ===== EXAM Spring JDBC - Online Shop =====/001 EXAM Spring JDBC - Online Shop.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ EXAM Spring JDBC - Online Shop
+
+
+
+
+
+
+
diff --git a/90 - Spring AOP/001 Aspect Oriented Programming_en.srt b/90 - Spring AOP/001 Aspect Oriented Programming_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..a2a29cc9ac2dc683522988211c7a3d26fe61aece
--- /dev/null
+++ b/90 - Spring AOP/001 Aspect Oriented Programming_en.srt
@@ -0,0 +1,860 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello Tim.
+
+2
+00:00:06,000 --> 00:00:11,000
+With this video lesson, we start a new and very important topic.
+
+3
+00:00:11,000 --> 00:00:14,000
+We are going to learn aspect oriented programming.
+
+4
+00:00:14,000 --> 00:00:20,000
+Today we will start our lesson from learning the definition of aspect oriented programming.
+
+5
+00:00:20,000 --> 00:00:28,000
+To understand what it is, I will explain you what cross-cutting concern is, What is an aspect?
+
+6
+00:00:28,000 --> 00:00:32,000
+Why we need AOP and where to use it.
+
+7
+00:00:32,000 --> 00:00:37,000
+We will review the most common examples of using aspect oriented programming.
+
+8
+00:00:38,000 --> 00:00:44,000
+I will present you the most common and the most popular AOP implementations, and after that we are
+
+9
+00:00:44,000 --> 00:00:50,000
+going to focus our attention on learning the key terms and concepts of the AOP.
+
+10
+00:00:50,000 --> 00:01:00,000
+Namely, I am going to explain you what joint point is Pointcut advice Introduction Target Object Interceptor,
+
+11
+00:01:00,000 --> 00:01:08,000
+AOP Proxy and we even and at the end of the lesson we are going to summarize the advantages and disadvantages
+
+12
+00:01:08,000 --> 00:01:08,000
+of the AOP.
+
+13
+00:01:09,000 --> 00:01:11,000
+Let's start our lesson.
+
+14
+00:01:12,000 --> 00:01:18,000
+Let's start from the overview of and understanding better what it actually is.
+
+15
+00:01:18,000 --> 00:01:23,000
+As you may already guess, AOP stands for aspect oriented programming.
+
+16
+00:01:23,000 --> 00:01:27,000
+This is not the easiest topic for understanding, to be honest.
+
+17
+00:01:27,000 --> 00:01:30,000
+That's why we learn it just now.
+
+18
+00:01:30,000 --> 00:01:38,000
+Also, it is relatively rare used directly, but it is very often used in different frameworks under
+
+19
+00:01:38,000 --> 00:01:39,000
+the hood.
+
+20
+00:01:39,000 --> 00:01:44,000
+And also this often pops up as a topic during the technical interview.
+
+21
+00:01:45,000 --> 00:01:52,000
+AOP is a paradigm that supposed to increase the modularity of the different parts of an application
+
+22
+00:01:52,000 --> 00:01:54,000
+by separating cross-cutting concerns.
+
+23
+00:01:55,000 --> 00:02:00,000
+The most of my students often ask me what are cross-cutting concerns?
+
+24
+00:02:01,000 --> 00:02:03,000
+Okay, let me answer that.
+
+25
+00:02:03,000 --> 00:02:11,000
+Cross-cutting concern is an aspect of a program that affects several modules without the possibility
+
+26
+00:02:11,000 --> 00:02:14,000
+of being encapsulated in any of them.
+
+27
+00:02:14,000 --> 00:02:22,000
+For example, if writing an application for handling medical records, the indexing of such records
+
+28
+00:02:22,000 --> 00:02:31,000
+is a core concern while logging a history of changes to the record database or user database or an authentication
+
+29
+00:02:31,000 --> 00:02:38,000
+system would be cross-cutting concerns since they interact with more parts of the program.
+
+30
+00:02:38,000 --> 00:02:45,000
+So AOP breaks the program logic into separate parts that are called concerns.
+
+31
+00:02:45,000 --> 00:02:53,000
+The functions that span multiple points of an application, unnamed cross-cutting concerns and these
+
+32
+00:02:53,000 --> 00:02:59,000
+cross-cutting concerns are conceptually separate from the application's business logic.
+
+33
+00:03:00,000 --> 00:03:07,000
+A cross-cutting concern is a type of concern that has the power to impact the entire application and
+
+34
+00:03:07,000 --> 00:03:12,000
+should always be centralized in one location in the program as possible.
+
+35
+00:03:12,000 --> 00:03:18,000
+But probably now you have another question What is an aspect of a program?
+
+36
+00:03:19,000 --> 00:03:26,000
+An aspect of a program is a feature linked to many other parts of the program, but which is not related
+
+37
+00:03:26,000 --> 00:03:28,000
+to the program's primary function.
+
+38
+00:03:29,000 --> 00:03:37,000
+An aspect crosscuts the program's core concerns, therefore violating its separation of concerns that
+
+39
+00:03:37,000 --> 00:03:40,000
+tries to encapsulate unrelated functions.
+
+40
+00:03:40,000 --> 00:03:46,000
+And again, the most clear example in my opinion, is about login.
+
+41
+00:03:46,000 --> 00:03:51,000
+For example, login code can crosscut many modules.
+
+42
+00:03:51,000 --> 00:03:57,000
+The aspect of login should be separate from the functional concerns of the module.
+
+43
+00:03:57,000 --> 00:03:58,000
+It crosscuts.
+
+44
+00:03:59,000 --> 00:04:01,000
+What are the examples?
+
+45
+00:04:01,000 --> 00:04:05,000
+There are various useful examples of aspects in software development.
+
+46
+00:04:05,000 --> 00:04:14,000
+Like, for example, login, auditing, data validation, declarative transactions, security caching,
+
+47
+00:04:14,000 --> 00:04:15,000
+etcetera.
+
+48
+00:04:15,000 --> 00:04:16,000
+Is it clear?
+
+49
+00:04:17,000 --> 00:04:20,000
+So let's get back to again.
+
+50
+00:04:20,000 --> 00:04:26,000
+And the question is how it is actually done and how it is implemented.
+
+51
+00:04:26,000 --> 00:04:33,000
+The AOP is implemented by adding additional behavior to the existing code without making changes to
+
+52
+00:04:33,000 --> 00:04:35,000
+the original code.
+
+53
+00:04:35,000 --> 00:04:38,000
+Sounds interesting already, isn't it?
+
+54
+00:04:39,000 --> 00:04:45,000
+So basically, in order to add some additional functionality to some methods, you don't need to open
+
+55
+00:04:45,000 --> 00:04:49,000
+the class and actually fix the source code.
+
+56
+00:04:49,000 --> 00:04:54,000
+You can add additional functionality actually without editing the source code.
+
+57
+00:04:54,000 --> 00:04:56,000
+Sounds like magic.
+
+58
+00:04:56,000 --> 00:04:57,000
+Don't you think so?
+
+59
+00:04:58,000 --> 00:05:07,000
+We can also compare AOP with OP object oriented programming to understand better.
+
+60
+00:05:08,000 --> 00:05:16,000
+The key unit of modularity in AOP is the class, whereas in aspect oriented programming, the unit of
+
+61
+00:05:16,000 --> 00:05:19,000
+modularity is the aspect.
+
+62
+00:05:19,000 --> 00:05:27,000
+AOP allows you to decouple cross-cutting concerns from the objects that they affect in the development
+
+63
+00:05:27,000 --> 00:05:27,000
+process.
+
+64
+00:05:28,000 --> 00:05:30,000
+Now let me explain you.
+
+65
+00:05:30,000 --> 00:05:32,000
+Why do we need AOP?
+
+66
+00:05:32,000 --> 00:05:38,000
+I believe that you already had a chance to understand the advantages that we expect to get by using
+
+67
+00:05:38,000 --> 00:05:39,000
+AOP approach.
+
+68
+00:05:39,000 --> 00:05:45,000
+But let me elaborate a little bit more and explain you based on examples.
+
+69
+00:05:45,000 --> 00:05:51,000
+Imagine that we have the following test class with the three methods that you can see on the screen.
+
+70
+00:05:52,000 --> 00:05:59,000
+And imagine that you need to ensure a login after each method in this class is completed without AOP.
+
+71
+00:05:59,000 --> 00:06:00,000
+What would you do?
+
+72
+00:06:01,000 --> 00:06:07,000
+You would create instance of logger and you would adjust source code of each method by adding logging
+
+73
+00:06:07,000 --> 00:06:08,000
+in each method.
+
+74
+00:06:08,000 --> 00:06:09,000
+Is that correct?
+
+75
+00:06:10,000 --> 00:06:13,000
+With aspect oriented programming approach.
+
+76
+00:06:13,000 --> 00:06:16,000
+You don't need to adjust each method.
+
+77
+00:06:16,000 --> 00:06:22,000
+You just need to declare, let's say, rules when and what should be executed.
+
+78
+00:06:23,000 --> 00:06:26,000
+Let's imagine that rule sounds like this.
+
+79
+00:06:26,000 --> 00:06:30,000
+Log the method name according to the predefined pattern.
+
+80
+00:06:30,000 --> 00:06:32,000
+One method is completed.
+
+81
+00:06:32,000 --> 00:06:42,000
+So to sum it up when we should use AOP, it can be used when we need allow users to implement custom
+
+82
+00:06:42,000 --> 00:06:43,000
+elements.
+
+83
+00:06:43,000 --> 00:06:49,000
+These elements can be really helpful for adding some additional features and functionalities that were
+
+84
+00:06:49,000 --> 00:06:52,000
+not present in the software at the beginning.
+
+85
+00:06:53,000 --> 00:07:01,000
+I believe you understand that AUP is an approach and to implement AUP in your program, you need some
+
+86
+00:07:01,000 --> 00:07:01,000
+tool.
+
+87
+00:07:02,000 --> 00:07:07,000
+There are different libraries that can help you to implement in Java.
+
+88
+00:07:07,000 --> 00:07:12,000
+They are aspect Spring, AOP, JBoss, AOP.
+
+89
+00:07:13,000 --> 00:07:20,000
+All implementations use the same terminology that we are going to learn today, but the details of implementation
+
+90
+00:07:20,000 --> 00:07:22,000
+can be different.
+
+91
+00:07:22,000 --> 00:07:28,000
+Anyway, in my opinion aspect and spring AOP the most popular ones.
+
+92
+00:07:29,000 --> 00:07:34,000
+Okay, let's learn the key terms and concepts that are widely used in AOP.
+
+93
+00:07:34,000 --> 00:07:37,000
+No matter what implementation do you use?
+
+94
+00:07:38,000 --> 00:07:43,000
+So on this slide, you can see the key concepts.
+
+95
+00:07:43,000 --> 00:07:45,000
+They are joint point.
+
+96
+00:07:45,000 --> 00:07:48,000
+Point Cut Advice.
+
+97
+00:07:48,000 --> 00:07:54,000
+Introduction Target Object aspect Interceptor.
+
+98
+00:07:54,000 --> 00:07:57,000
+AOP Proxy even.
+
+99
+00:07:58,000 --> 00:08:03,000
+Let's now spend some time understanding each of these key concepts.
+
+100
+00:08:03,000 --> 00:08:04,000
+Let's go one by one.
+
+101
+00:08:05,000 --> 00:08:08,000
+The first one in our list is Joint Point.
+
+102
+00:08:09,000 --> 00:08:16,000
+Durant point is any point in your program, such as method execution, exception, handling, field
+
+103
+00:08:16,000 --> 00:08:18,000
+access, etcetera.
+
+104
+00:08:18,000 --> 00:08:23,000
+The different libraries that you can use to apply your approach.
+
+105
+00:08:23,000 --> 00:08:29,000
+But if we talk about spring AOP, for example, it supports only massive execution.
+
+106
+00:08:29,000 --> 00:08:30,000
+Join point.
+
+107
+00:08:31,000 --> 00:08:40,000
+Join point symbolizes a point in your application where you can easily plug in the aspect of your software.
+
+108
+00:08:41,000 --> 00:08:42,000
+Point cut.
+
+109
+00:08:43,000 --> 00:08:46,000
+Let's understand now what a point cut is.
+
+110
+00:08:46,000 --> 00:08:51,000
+It is an expression language of AOP that matches join points.
+
+111
+00:08:52,000 --> 00:08:59,000
+Point cut is an expression that is matched with joint points to determine whether advice needs to be
+
+112
+00:08:59,000 --> 00:09:01,000
+executed or not.
+
+113
+00:09:01,000 --> 00:09:07,000
+Point cut uses different kinds of expressions that are matched with the joint points.
+
+114
+00:09:07,000 --> 00:09:13,000
+For example, Spring Framework uses the point cut expression language.
+
+115
+00:09:13,000 --> 00:09:18,000
+The next key concept from our list is advice.
+
+116
+00:09:19,000 --> 00:09:24,000
+Advice represents an action taken by an aspect at a particular joint point.
+
+117
+00:09:24,000 --> 00:09:27,000
+If you don't understand the statement, don't worry.
+
+118
+00:09:27,000 --> 00:09:31,000
+I will try to explain advice in different ways now.
+
+119
+00:09:32,000 --> 00:09:38,000
+Advices are actions taken for a particular joint point in terms of programming.
+
+120
+00:09:38,000 --> 00:09:47,000
+The methods that get executed when a certain joint point with matching point is reached in the application.
+
+121
+00:09:48,000 --> 00:09:52,000
+You can think of advices as servlet filters, for example.
+
+122
+00:09:53,000 --> 00:09:58,000
+Based on the execution strategy of advice, there are the following types.
+
+123
+00:09:58,000 --> 00:10:05,000
+Before advice, these advices run before the execution of join point.
+
+124
+00:10:06,000 --> 00:10:14,000
+After returning advice in case you want to execute advice only if the join point method executes normally,
+
+125
+00:10:14,000 --> 00:10:18,000
+then you should use after returning advice.
+
+126
+00:10:18,000 --> 00:10:24,000
+We can use after returning annotation to mark a method as after returning advice.
+
+127
+00:10:24,000 --> 00:10:32,000
+After throwing advice, this advice gets executed only when join point method throws an exception.
+
+128
+00:10:33,000 --> 00:10:36,000
+We can use it to roll back the transaction declaratively.
+
+129
+00:10:37,000 --> 00:10:46,000
+After finally advice and advice that gets executed after the joint point finished execution, whether
+
+130
+00:10:46,000 --> 00:10:48,000
+normally or by throwing an exception.
+
+131
+00:10:49,000 --> 00:10:51,000
+Around the device.
+
+132
+00:10:51,000 --> 00:10:54,000
+This is the most important and powerful advice.
+
+133
+00:10:54,000 --> 00:11:01,000
+This advice surrounds the join point method, and we can also choose whether to execute the join point
+
+134
+00:11:01,000 --> 00:11:03,000
+method or not.
+
+135
+00:11:03,000 --> 00:11:10,000
+We can write advice code that gets executed before and after the execution of the join point method.
+
+136
+00:11:11,000 --> 00:11:18,000
+It is the responsibility of around advice to invoke the join point method and return values if the market
+
+137
+00:11:18,000 --> 00:11:20,000
+returns something.
+
+138
+00:11:21,000 --> 00:11:22,000
+Introduction.
+
+139
+00:11:22,000 --> 00:11:28,000
+Introduction concept means introduction of additional masses and fields for a type.
+
+140
+00:11:29,000 --> 00:11:34,000
+It allows you to introduce new interface to any advanced object.
+
+141
+00:11:35,000 --> 00:11:43,000
+An introduction is another term in spring that helps you to add new methods or features to the existing
+
+142
+00:11:43,000 --> 00:11:43,000
+classes.
+
+143
+00:11:43,000 --> 00:11:51,000
+It basically means the introduction of additional methods and domains for a particular type as per the
+
+144
+00:11:51,000 --> 00:11:53,000
+requirements of the software.
+
+145
+00:11:53,000 --> 00:12:00,000
+It allows you to introduce a new interface to any advanced object for your particular system.
+
+146
+00:12:00,000 --> 00:12:03,000
+So in short, about introduction.
+
+147
+00:12:03,000 --> 00:12:07,000
+Declaring additional methods or fields on behalf of a type.
+
+148
+00:12:08,000 --> 00:12:17,000
+Spring allows you to introduce new interfaces and the corresponding implementation to any advanced object.
+
+149
+00:12:17,000 --> 00:12:25,000
+For example, you could use an introduction to make a bean implement and is modified interface to simplify
+
+150
+00:12:25,000 --> 00:12:26,000
+caching.
+
+151
+00:12:27,000 --> 00:12:31,000
+The next important concept in AOP is target object.
+
+152
+00:12:31,000 --> 00:12:33,000
+What is it?
+
+153
+00:12:33,000 --> 00:12:37,000
+This is the object on which advices are applied.
+
+154
+00:12:37,000 --> 00:12:41,000
+Our business object is it contains some business logic.
+
+155
+00:12:41,000 --> 00:12:46,000
+In spring it is also known as proxied object.
+
+156
+00:12:46,000 --> 00:12:53,000
+That is because target object in spring AOP is implemented using runtime proxies.
+
+157
+00:12:53,000 --> 00:12:57,000
+So this object is always a proxied object.
+
+158
+00:12:57,000 --> 00:13:06,000
+It means that a subclass is created at the runtime, whereas the target method is overridden and device
+
+159
+00:13:06,000 --> 00:13:10,000
+is included based on its configuration.
+
+160
+00:13:10,000 --> 00:13:11,000
+Is it clear?
+
+161
+00:13:12,000 --> 00:13:14,000
+In order to apply the advice.
+
+162
+00:13:14,000 --> 00:13:19,000
+The method that is invoked on target object is overridden.
+
+163
+00:13:19,000 --> 00:13:24,000
+Well already learned such key concepts in as aspect.
+
+164
+00:13:24,000 --> 00:13:26,000
+But just to recap.
+
+165
+00:13:26,000 --> 00:13:29,000
+Taking into account, we are looking through all the key concepts.
+
+166
+00:13:29,000 --> 00:13:32,000
+First of all, aspect it is a class.
+
+167
+00:13:32,000 --> 00:13:36,000
+This class contains advices during points.
+
+168
+00:13:36,000 --> 00:13:37,000
+ET cetera.
+
+169
+00:13:37,000 --> 00:13:44,000
+Aspect can be a normal class configured through spring XML configuration, or we can use spring aspect
+
+170
+00:13:45,000 --> 00:13:48,000
+integration to define a class as aspect.
+
+171
+00:13:48,000 --> 00:13:50,000
+Using aspect annotation.
+
+172
+00:13:50,000 --> 00:13:57,000
+An aspect is a modularization of a concern that cuts across multiple classes.
+
+173
+00:13:57,000 --> 00:14:03,000
+For example, the class that contains after returning advice can be named aspect.
+
+174
+00:14:03,000 --> 00:14:09,000
+An application can have any number of aspects depending on the requirement of the software.
+
+175
+00:14:10,000 --> 00:14:14,000
+Now let's learn what an interceptor is.
+
+176
+00:14:14,000 --> 00:14:20,000
+In simple words, it is an aspect that contains only one advice.
+
+177
+00:14:20,000 --> 00:14:23,000
+The next concept is AOP Proxy.
+
+178
+00:14:24,000 --> 00:14:31,000
+AOP Proxy is used to implement aspect contracts created by AOP framework.
+
+179
+00:14:31,000 --> 00:14:38,000
+It will be a dynamic proxy or CG lip proxy in spring framework.
+
+180
+00:14:38,000 --> 00:14:47,000
+Spring implementation uses JDK Dynamic proxy to create the proxy classes with target classes and advice
+
+181
+00:14:47,000 --> 00:14:48,000
+invocations.
+
+182
+00:14:48,000 --> 00:14:51,000
+These are called AOP proxy classes.
+
+183
+00:14:51,000 --> 00:14:59,000
+We can also use CG lip proxy by adding it as a dependency in the spring AOP project.
+
+184
+00:15:00,000 --> 00:15:03,000
+And the last but not the least from our list is we even.
+
+185
+00:15:05,000 --> 00:15:13,000
+Leven is a process of linking aspect with other application types or objects to create an advanced object.
+
+186
+00:15:13,000 --> 00:15:18,000
+We even can be done at compile time, load time or runtime.
+
+187
+00:15:19,000 --> 00:15:23,000
+Spring performs even at runtime.
+
+188
+00:15:24,000 --> 00:15:29,000
+And the last thing that I would like to talk with you today is about advantages and disadvantages of
+
+189
+00:15:29,000 --> 00:15:31,000
+the aspect oriented programming.
+
+190
+00:15:32,000 --> 00:15:35,000
+And one advantages it is worth to mention the following ones.
+
+191
+00:15:36,000 --> 00:15:39,000
+AOP respects modularity.
+
+192
+00:15:39,000 --> 00:15:42,000
+It reduces the coupling of dependencies.
+
+193
+00:15:43,000 --> 00:15:47,000
+It makes code more readable, reusable and maintainable.
+
+194
+00:15:48,000 --> 00:15:53,000
+If we want to discuss disadvantages, then we should mention the following ones.
+
+195
+00:15:54,000 --> 00:16:02,000
+The bargain can be more difficult because there is more code than I can see at the beginning to configure
+
+196
+00:16:02,000 --> 00:16:03,000
+breakpoints properly.
+
+197
+00:16:04,000 --> 00:16:09,000
+A requires discipline to refrain from overuse.
+
+198
+00:16:10,000 --> 00:16:18,000
+In general, aspect oriented programming can be called as dark art because it can perform some black
+
+199
+00:16:18,000 --> 00:16:19,000
+magic behind the scenes.
+
+200
+00:16:19,000 --> 00:16:28,000
+In the old world and in your code, I believe you can understand that with AOP, we can change the way
+
+201
+00:16:28,000 --> 00:16:34,000
+of method execution, replace the result, or even prevent it from running at all.
+
+202
+00:16:35,000 --> 00:16:45,000
+Taking into account APIs such power you always should remember about it and use with caution and understanding
+
+203
+00:16:45,000 --> 00:16:52,000
+and necessary use of in your application can be dangerous and result into unexpected errors.
+
+204
+00:16:53,000 --> 00:16:55,000
+That's all what I wanted to discuss with you.
+
+205
+00:16:56,000 --> 00:16:59,000
+Let's recap what we have learned in this lesson.
+
+206
+00:17:00,000 --> 00:17:05,000
+So the day we learned what an aspect oriented programming is.
+
+207
+00:17:06,000 --> 00:17:11,000
+I explained you what cross-cutting concern and what aspect actually are.
+
+208
+00:17:11,000 --> 00:17:16,000
+We learned why we need AOP and where to use AOP.
+
+209
+00:17:17,000 --> 00:17:20,000
+I showed you main AOP implementations.
+
+210
+00:17:20,000 --> 00:17:29,000
+We learned key terms and concepts of AOP like Joint Point, point cut and voice introduction, target
+
+211
+00:17:29,000 --> 00:17:33,000
+object Interceptor, AOP, proxy weaving.
+
+212
+00:17:33,000 --> 00:17:39,000
+And at the end of the lesson, we learned the advantages and disadvantages of the AOP.
+
+213
+00:17:40,000 --> 00:17:41,000
+That's all for this lesson.
+
+214
+00:17:42,000 --> 00:17:43,000
+Thanks a lot for your attention.
+
+215
+00:17:43,000 --> 00:17:47,000
+Have a great day and see you in the next lesson.
+
diff --git a/90 - Spring AOP/002 Source-code-of-examples-commit-with-changes-.url b/90 - Spring AOP/002 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..30aef3b8f954144e672d86794387e60a076c68b4
--- /dev/null
+++ b/90 - Spring AOP/002 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/ab0084445a16c0c8897cc80308c28817d9dace8a
\ No newline at end of file
diff --git a/90 - Spring AOP/002 Spring AOP with AspectJ Practice_en.srt b/90 - Spring AOP/002 Spring AOP with AspectJ Practice_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..774e42d6b76e89ca77d6022792e93e3ef6673ac1
--- /dev/null
+++ b/90 - Spring AOP/002 Spring AOP with AspectJ Practice_en.srt
@@ -0,0 +1,1076 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello Tim.
+
+2
+00:00:06,000 --> 00:00:09,000
+We continue learning aspect oriented programming.
+
+3
+00:00:09,000 --> 00:00:15,000
+I hope that you watched previous theoretical lesson about AOP in this video.
+
+4
+00:00:15,000 --> 00:00:21,000
+We are going to have a lot of practical examples with Spring, AOP and aspect J.
+
+5
+00:00:22,000 --> 00:00:28,000
+We're going to start our lesson from review of required dependencies that we need to add into our project.
+
+6
+00:00:29,000 --> 00:00:34,000
+Together we are going to create aspect and configure point cards and advices.
+
+7
+00:00:34,000 --> 00:00:41,000
+I'm going to show you different pointcut designators that can be used and recognized by spring AOP.
+
+8
+00:00:42,000 --> 00:00:50,000
+Also, I will show you how to enable aspect configuration support with enable aspect Autoproxy annotation
+
+9
+00:00:50,000 --> 00:00:53,000
+and after everything will be configured.
+
+10
+00:00:53,000 --> 00:00:58,000
+We are going to see live examples and how all the code works together.
+
+11
+00:00:58,000 --> 00:01:05,000
+Let's start our lesson and as I already mentioned today, we are going to have a lesson full of practical
+
+12
+00:01:05,000 --> 00:01:06,000
+examples.
+
+13
+00:01:06,000 --> 00:01:08,000
+So let me start screen sharing.
+
+14
+00:01:09,000 --> 00:01:14,000
+As always, you can find the reference to the source code examples in attachments to the video.
+
+15
+00:01:14,000 --> 00:01:21,000
+And in case you have any questions, please let me know in comments below the video.
+
+16
+00:01:21,000 --> 00:01:28,000
+As we already learned in the previous lesson aspect, oriented programming complements object oriented
+
+17
+00:01:28,000 --> 00:01:33,000
+programming by providing another way of thinking about program structure.
+
+18
+00:01:33,000 --> 00:01:38,000
+The key unit of modularity in OOP is the class.
+
+19
+00:01:38,000 --> 00:01:42,000
+Whereas in AOP, the unit of modularity is the aspect.
+
+20
+00:01:43,000 --> 00:01:47,000
+Let's start from adding required dependencies.
+
+21
+00:01:47,000 --> 00:01:55,000
+I opened pom.xml, so there is a separate library spring AOP that contains interfaces and classes by
+
+22
+00:01:55,000 --> 00:01:59,000
+implementing which you can configure advices that you need.
+
+23
+00:01:59,000 --> 00:02:08,000
+But I can say that approach based on aspect annotations is popular and so widespread that in my personal
+
+24
+00:02:08,000 --> 00:02:15,000
+experience this is dominated approach of configuring aspects even in spring based applications.
+
+25
+00:02:15,000 --> 00:02:22,000
+Spring framework recognizes aspect annotations and introduces aspect support.
+
+26
+00:02:22,000 --> 00:02:28,000
+That's why in this particular practical example we will add aspect dependencies only.
+
+27
+00:02:29,000 --> 00:02:36,000
+Aspect refers to a style of declaring aspects as a regular Java classes annotated with annotations.
+
+28
+00:02:36,000 --> 00:02:41,000
+The aspect style was introduced by aspect project.
+
+29
+00:02:41,000 --> 00:02:49,000
+Spring interprets the same annotations as aspect j using a library supplied by aspect J for Pointcut
+
+30
+00:02:49,000 --> 00:02:51,000
+parsing and matching.
+
+31
+00:02:51,000 --> 00:02:57,000
+So I added aspect j runtime and aspect j tools dependencies here.
+
+32
+00:02:58,000 --> 00:03:00,000
+Just for logging purposes.
+
+33
+00:03:00,000 --> 00:03:08,000
+I also added self for G and log back, but this is optional in case you don't need and don't want to
+
+34
+00:03:08,000 --> 00:03:09,000
+configure login.
+
+35
+00:03:09,000 --> 00:03:11,000
+This is not necessary.
+
+36
+00:03:11,000 --> 00:03:18,000
+The main thing for the sake of today's demo is to add these aspect dependencies.
+
+37
+00:03:18,000 --> 00:03:21,000
+Let's now review our business object.
+
+38
+00:03:21,000 --> 00:03:25,000
+In our today's example, we are going to deal with the user class.
+
+39
+00:03:25,000 --> 00:03:31,000
+All examples related to today's lesson will be located in the AOP package here.
+
+40
+00:03:31,000 --> 00:03:37,000
+Nothing is extraordinary, just properties like first name and last name.
+
+41
+00:03:37,000 --> 00:03:44,000
+I also preconfigured default first name and last name just for the sake of example getters and setters
+
+42
+00:03:44,000 --> 00:03:47,000
+and one message that throws exception.
+
+43
+00:03:47,000 --> 00:03:53,000
+This is created for the sake of example in order I can demonstrate different types of advices.
+
+44
+00:03:54,000 --> 00:03:56,000
+Now let's create aspect.
+
+45
+00:03:57,000 --> 00:04:03,000
+Please make sure you watch the previous lesson because in previous lesson we discussed all the terminologies
+
+46
+00:04:03,000 --> 00:04:05,000
+that I use in this lesson.
+
+47
+00:04:05,000 --> 00:04:11,000
+But just to recap aspect is a class that contains advices and point cards.
+
+48
+00:04:12,000 --> 00:04:17,000
+I open class that is called demo aspect, as I already mentioned.
+
+49
+00:04:17,000 --> 00:04:21,000
+Actually Spring app can be configured in different ways.
+
+50
+00:04:21,000 --> 00:04:24,000
+There are three ways of configuration.
+
+51
+00:04:24,000 --> 00:04:29,000
+They are by spring old style DTD based.
+
+52
+00:04:29,000 --> 00:04:38,000
+I'm not sure you will use it ever again by aspect annotation style by spring XML configuration style
+
+53
+00:04:39,000 --> 00:04:47,000
+schema based, but the most widely used approach is spring aspect, annotation style, and in this lesson
+
+54
+00:04:47,000 --> 00:04:51,000
+we will use aspect annotations for configuration.
+
+55
+00:04:52,000 --> 00:05:00,000
+With the aspect support enabled any been defined in your application context with a class that is aspect
+
+56
+00:05:01,000 --> 00:05:03,000
+aspect has the aspect annotation.
+
+57
+00:05:03,000 --> 00:05:12,000
+Mean will be automatically detected by spring and used to configure spring AOP taking into account the
+
+58
+00:05:12,000 --> 00:05:14,000
+use annotation based configuration.
+
+59
+00:05:14,000 --> 00:05:22,000
+I also added component annotation in order inversion of control container create been of such type.
+
+60
+00:05:23,000 --> 00:05:29,000
+If you use XML based configuration, then you need to register your bean in XML.
+
+61
+00:05:29,000 --> 00:05:36,000
+Having just aspect annotation is not enough for auto detection in the classpath, you need to register
+
+62
+00:05:36,000 --> 00:05:39,000
+it as a spring bean for proper configuration.
+
+63
+00:05:40,000 --> 00:05:41,000
+Aspects.
+
+64
+00:05:41,000 --> 00:05:47,000
+Classes annotated with aspect may have masses and fields just like any other class.
+
+65
+00:05:47,000 --> 00:05:54,000
+They may also contain point, card advice and introduction inter-type declarations.
+
+66
+00:05:55,000 --> 00:06:03,000
+Another interesting and important question Can you advise on aspects with other aspects in spring AOP?
+
+67
+00:06:03,000 --> 00:06:09,000
+It is not possible to have aspects themselves be the target of advice from other aspects.
+
+68
+00:06:10,000 --> 00:06:18,000
+The aspect annotation on a class marks it as an aspect and hence excludes it from autoproxy.
+
+69
+00:06:18,000 --> 00:06:21,000
+So we declare it aspect.
+
+70
+00:06:21,000 --> 00:06:22,000
+Put annotation.
+
+71
+00:06:22,000 --> 00:06:23,000
+All good.
+
+72
+00:06:23,000 --> 00:06:25,000
+What's next?
+
+73
+00:06:25,000 --> 00:06:29,000
+The next thing let's declare a different point class.
+
+74
+00:06:29,000 --> 00:06:38,000
+Just to remind you that point cards determine joint points of interest and thus enable us to control
+
+75
+00:06:38,000 --> 00:06:40,000
+when advice executes.
+
+76
+00:06:40,000 --> 00:06:44,000
+Spring AOP only supports method execution.
+
+77
+00:06:44,000 --> 00:06:52,000
+Join points for spring beans so you can think of a pointcut as matching the execution of methods on
+
+78
+00:06:52,000 --> 00:06:53,000
+spring beans.
+
+79
+00:06:54,000 --> 00:06:56,000
+A Pointcut declaration has two parts.
+
+80
+00:06:57,000 --> 00:07:05,000
+A signature comprising a name and any parameters and the pointcut expressions that determines exactly
+
+81
+00:07:05,000 --> 00:07:08,000
+which message executions were interested in.
+
+82
+00:07:08,000 --> 00:07:16,000
+In the aspect annotation style of AOP, a Pointcut signatures provided by a regular method definition
+
+83
+00:07:16,000 --> 00:07:22,000
+and the Pointcut expression is indicated using the Pointcut annotation.
+
+84
+00:07:22,000 --> 00:07:27,000
+The method seven as a Pointcut signature must have a void return type.
+
+85
+00:07:28,000 --> 00:07:29,000
+Pay attention to this.
+
+86
+00:07:30,000 --> 00:07:33,000
+Let's review the first and the most simple example.
+
+87
+00:07:34,000 --> 00:07:42,000
+The point card named Select all will match the execution of any message in the current package, namely
+
+88
+00:07:42,000 --> 00:07:45,000
+package with our examples.
+
+89
+00:07:45,000 --> 00:07:46,000
+Is it clear?
+
+90
+00:07:46,000 --> 00:07:53,000
+So here we specified execution as it is obviously related directly to the method execution.
+
+91
+00:07:53,000 --> 00:07:55,000
+What else we can specify here?
+
+92
+00:07:56,000 --> 00:08:01,000
+Aspect G provides a lot of different pointcut designators.
+
+93
+00:08:01,000 --> 00:08:08,000
+Unfortunately or fortunately, not all of them are supported by spring aspect oriented programming.
+
+94
+00:08:08,000 --> 00:08:15,000
+On this slide you can see only those pointcut designators that are supported by spring AOP.
+
+95
+00:08:16,000 --> 00:08:18,000
+Let's review them.
+
+96
+00:08:18,000 --> 00:08:23,000
+Execution for matching method execution join points.
+
+97
+00:08:23,000 --> 00:08:28,000
+This is probably the most popular pointcut designator when working with spring AOP.
+
+98
+00:08:29,000 --> 00:08:38,000
+Within this one limits matching the join points within certain types simply as execution of master declared
+
+99
+00:08:38,000 --> 00:08:40,000
+within a matching type when using spring AOP.
+
+100
+00:08:41,000 --> 00:08:45,000
+This limits matching to join points.
+
+101
+00:08:45,000 --> 00:08:48,000
+The execution of matches when using spring AOP.
+
+102
+00:08:49,000 --> 00:08:54,000
+Whereas a reference spring AOP proxy is an instance of the given type.
+
+103
+00:08:55,000 --> 00:08:57,000
+And the rest are on the slide.
+
+104
+00:08:58,000 --> 00:09:01,000
+I believe there is no need to be reading out loud.
+
+105
+00:09:01,000 --> 00:09:09,000
+Each one just press on, pause the video and read through the slide and remember that in case you have
+
+106
+00:09:09,000 --> 00:09:16,000
+any questions, you are always welcome to post your questions below the video and I will be happy to
+
+107
+00:09:16,000 --> 00:09:17,000
+answer.
+
+108
+00:09:17,000 --> 00:09:23,000
+Because Spring AOP limits matching to only method execution join points.
+
+109
+00:09:23,000 --> 00:09:31,000
+The discussion of the Pointcut designators gives a narrower definition than you will find in the aspect
+
+110
+00:09:31,000 --> 00:09:33,000
+programming guide.
+
+111
+00:09:33,000 --> 00:09:41,000
+The full aspect Pointcut language supports additional Pointcut designators that are not supported in
+
+112
+00:09:41,000 --> 00:09:41,000
+spring.
+
+113
+00:09:42,000 --> 00:09:46,000
+So once you look through the slide, we are good to continue.
+
+114
+00:09:48,000 --> 00:09:52,000
+On this slide, you are going to see different examples of point cuts.
+
+115
+00:09:52,000 --> 00:10:00,000
+For example, the execution of any public method is execution of any method with the name beginning
+
+116
+00:10:00,000 --> 00:10:01,000
+with set.
+
+117
+00:10:01,000 --> 00:10:08,000
+The execution of any method defined by the account service interface and so on.
+
+118
+00:10:09,000 --> 00:10:17,000
+Again, I would ask you to put the video on pause and look through the slide at your own pace, taking
+
+119
+00:10:17,000 --> 00:10:20,000
+into account the different variety of combinations.
+
+120
+00:10:20,000 --> 00:10:25,000
+I tried to specify different examples to highlight different cases.
+
+121
+00:10:25,000 --> 00:10:32,000
+I'm sure you will find these examples useful when you will need to come up with your own expression
+
+122
+00:10:32,000 --> 00:10:33,000
+at work.
+
+123
+00:10:33,000 --> 00:10:39,000
+Once you looked through the examples, you're welcome to press play button to continue.
+
+124
+00:10:40,000 --> 00:10:47,000
+That was a lot of examples and I'm sure they are super helpful because next time when you will think
+
+125
+00:10:47,000 --> 00:10:54,000
+about creation of the point card, you can just check these examples and create them according to the
+
+126
+00:10:54,000 --> 00:10:55,000
+pattern.
+
+127
+00:10:56,000 --> 00:11:00,000
+So you saw examples of the point cards on the slide.
+
+128
+00:11:00,000 --> 00:11:05,000
+I believe you have understanding what it is and how to declare a point cut.
+
+129
+00:11:05,000 --> 00:11:11,000
+Now, I want to you understand the mechanics and how to use point cut in the application.
+
+130
+00:11:12,000 --> 00:11:18,000
+I believe there is no need for me to create all possible combinations of point cuts because we reviewed
+
+131
+00:11:18,000 --> 00:11:21,000
+different examples already on the slides.
+
+132
+00:11:21,000 --> 00:11:27,000
+So here in the application I'm going to have two point cuts, ones that we have already created.
+
+133
+00:11:27,000 --> 00:11:32,000
+It is for all masses execution from the current package.
+
+134
+00:11:32,000 --> 00:11:40,000
+And here's one more like you have seen already on the example, this type of point cut designators that
+
+135
+00:11:40,000 --> 00:11:42,000
+can be used only in spring AOP.
+
+136
+00:11:43,000 --> 00:11:46,000
+It is designator called beam.
+
+137
+00:11:46,000 --> 00:11:51,000
+You can limit the matching of join points to a particular spring bin.
+
+138
+00:11:51,000 --> 00:11:56,000
+Here on the screen you can see how I created user bin point cut.
+
+139
+00:11:56,000 --> 00:12:01,000
+You can see a right bin and name of my bin user.
+
+140
+00:12:01,000 --> 00:12:04,000
+I'm going to show you advice demo with this point.
+
+141
+00:12:04,000 --> 00:12:05,000
+Cut to.
+
+142
+00:12:06,000 --> 00:12:07,000
+Amazing.
+
+143
+00:12:07,000 --> 00:12:14,000
+Now we reviewed how to declare a pointcut and what syntax we can use to declare a pointcut.
+
+144
+00:12:14,000 --> 00:12:17,000
+Now it is time to learn how to declare advices.
+
+145
+00:12:17,000 --> 00:12:20,000
+As you remember, we have five types of advices.
+
+146
+00:12:20,000 --> 00:12:22,000
+Let's remember them.
+
+147
+00:12:22,000 --> 00:12:25,000
+We learned them in our previous theoretical lesson.
+
+148
+00:12:25,000 --> 00:12:36,000
+They are before advice, after returning, advice after throwing advice after finally advice and round
+
+149
+00:12:36,000 --> 00:12:36,000
+advice.
+
+150
+00:12:37,000 --> 00:12:40,000
+Let's configure advices of each type here.
+
+151
+00:12:40,000 --> 00:12:42,000
+Let's go one by one.
+
+152
+00:12:43,000 --> 00:12:45,000
+Before advice.
+
+153
+00:12:45,000 --> 00:12:53,000
+Advice that executes before a join point, but which doesn't have the ability to prevent execution flow
+
+154
+00:12:53,000 --> 00:12:58,000
+proceeding to the join point unless it throws an exception.
+
+155
+00:12:59,000 --> 00:13:03,000
+You can see that I declared before advice for the select all point cut.
+
+156
+00:13:03,000 --> 00:13:11,000
+So this code will be applied, whereas the point cut expression from the select all point cut will match.
+
+157
+00:13:11,000 --> 00:13:13,000
+Is that clear?
+
+158
+00:13:13,000 --> 00:13:16,000
+And also for the sake of the demo I created.
+
+159
+00:13:16,000 --> 00:13:23,000
+One more advice for the user being point cut just to show you that everything will work as expected
+
+160
+00:13:23,000 --> 00:13:25,000
+for another point, cut to.
+
+161
+00:13:26,000 --> 00:13:30,000
+The next advice here is after returning advice.
+
+162
+00:13:30,000 --> 00:13:36,000
+After returning the device to be executed after join point completes normally.
+
+163
+00:13:37,000 --> 00:13:44,000
+For example, if a message returns without throwing an exception in case we want to get access to the
+
+164
+00:13:44,000 --> 00:13:50,000
+returned value and work with it, somehow you just declare, return an attribute and declare a message
+
+165
+00:13:50,000 --> 00:13:51,000
+parameter.
+
+166
+00:13:52,000 --> 00:13:56,000
+Return value will be injected into this local variable.
+
+167
+00:13:56,000 --> 00:14:02,000
+In our particular case, I would just print it to console to show you how it works.
+
+168
+00:14:03,000 --> 00:14:10,000
+I believe that it is clear and sounds logical that the name used in the return attribute must correspond
+
+169
+00:14:10,000 --> 00:14:13,000
+to the name of a parameter in the advice method.
+
+170
+00:14:15,000 --> 00:14:22,000
+And returning clause also restricts matching to only those method executions that return a value of
+
+171
+00:14:22,000 --> 00:14:28,000
+the specified type object in this case, which will match any return value.
+
+172
+00:14:29,000 --> 00:14:35,000
+Please note that it is not possible to return a totally different reference when using after returning
+
+173
+00:14:35,000 --> 00:14:36,000
+advice.
+
+174
+00:14:36,000 --> 00:14:38,000
+Okay, let's move on.
+
+175
+00:14:39,000 --> 00:14:48,000
+After throwing advice, this advice to be executed if a method exits by throwing an exception in the
+
+176
+00:14:48,000 --> 00:14:49,000
+similar way.
+
+177
+00:14:49,000 --> 00:14:54,000
+In case you want to get access to the exception thrown, you need to declare this in the annotation
+
+178
+00:14:54,000 --> 00:15:02,000
+configuration where throwing attribute and declare a method parameter with the same name as thrown clause
+
+179
+00:15:02,000 --> 00:15:10,000
+also restricts matching to only those method executions that throw an exception of the specified type.
+
+180
+00:15:11,000 --> 00:15:13,000
+Exception in our specific case.
+
+181
+00:15:14,000 --> 00:15:19,000
+The next type of advice is after finally advice.
+
+182
+00:15:20,000 --> 00:15:28,000
+After finally advice to be executed regardless of the means by which a join point exits normal or exceptional
+
+183
+00:15:28,000 --> 00:15:35,000
+return, we are going just to print text into the console in order to indicate that this advice has
+
+184
+00:15:35,000 --> 00:15:36,000
+been executed.
+
+185
+00:15:37,000 --> 00:15:43,000
+And the last but not the least advice type example here is around advice.
+
+186
+00:15:43,000 --> 00:15:49,000
+Around advice surrounds a joint point such as method invocation.
+
+187
+00:15:49,000 --> 00:15:53,000
+This is the most powerful kind of advice around.
+
+188
+00:15:53,000 --> 00:15:58,000
+Advice can perform custom behavior before and after the method invocation.
+
+189
+00:15:58,000 --> 00:16:05,000
+It is also responsible for choosing whether to proceed to the join point or to shortcut the advice method
+
+190
+00:16:05,000 --> 00:16:10,000
+execution by returning its own return value or throwing an exception.
+
+191
+00:16:11,000 --> 00:16:18,000
+So when it is recommended to use around advice, around advice is often used if you need to share state
+
+192
+00:16:18,000 --> 00:16:27,000
+before and after method execution in a thread safe manner, starting and stopping a timer, for example,
+
+193
+00:16:27,000 --> 00:16:33,000
+always use the least powerful form of advice that meets your requirements.
+
+194
+00:16:33,000 --> 00:16:41,000
+That means that it is not recommended to use a rounded voice if simple before advice is enough for your
+
+195
+00:16:41,000 --> 00:16:42,000
+specific case.
+
+196
+00:16:43,000 --> 00:16:46,000
+A rounded voice is declared using the round annotation.
+
+197
+00:16:47,000 --> 00:16:52,000
+The first parameter of the advice method must be of type preceding joint point.
+
+198
+00:16:53,000 --> 00:17:00,000
+Within the body of that voice, colon precede on the preceding joint point causes the underlying method
+
+199
+00:17:00,000 --> 00:17:02,000
+to execute.
+
+200
+00:17:02,000 --> 00:17:07,000
+The proceed mascot may also be called passing in an object array.
+
+201
+00:17:07,000 --> 00:17:13,000
+The values in the array will be used as the arguments to the method execution when it proceeds.
+
+202
+00:17:14,000 --> 00:17:20,000
+Pay attention that I'm responsible for method invocation and returning the returned value of the method.
+
+203
+00:17:21,000 --> 00:17:23,000
+Also potential is invoked.
+
+204
+00:17:23,000 --> 00:17:25,000
+Method may throw exception.
+
+205
+00:17:25,000 --> 00:17:31,000
+That's why we need either to declare a throws declaration or to handle the potential exception.
+
+206
+00:17:32,000 --> 00:17:40,000
+For the sake of the demo, I will print console output before calling the method from advice and after
+
+207
+00:17:40,000 --> 00:17:42,000
+we called method from advice.
+
+208
+00:17:43,000 --> 00:17:44,000
+That's it.
+
+209
+00:17:44,000 --> 00:17:46,000
+We're getting configuration of advices.
+
+210
+00:17:46,000 --> 00:17:51,000
+Just one minor thing to do and we are ready for running our application.
+
+211
+00:17:51,000 --> 00:17:56,000
+Another important point is to enable aspect support.
+
+212
+00:17:57,000 --> 00:17:58,000
+The use aspect.
+
+213
+00:17:58,000 --> 00:18:06,000
+Aspects In a spring configuration you need to enable spring support for configuring spring AOP based
+
+214
+00:18:06,000 --> 00:18:16,000
+on aspect aspects and auto production beans based on whether or not they are advised by those aspects.
+
+215
+00:18:16,000 --> 00:18:25,000
+By auto proxy, I mean that if spring determines that a bean is advised by one or more aspects, it
+
+216
+00:18:25,000 --> 00:18:33,000
+will automatically generate a proxy for that bean to intercept method invocations and ensure that advice
+
+217
+00:18:33,000 --> 00:18:35,000
+is executed as needed.
+
+218
+00:18:35,000 --> 00:18:41,000
+You can enable it with an XML configuration or with a special annotation.
+
+219
+00:18:41,000 --> 00:18:42,000
+Let me show it to you.
+
+220
+00:18:43,000 --> 00:18:51,000
+Here I have demo a class where I have main method to demo all the examples that we have reviewed, but
+
+221
+00:18:51,000 --> 00:18:54,000
+also this class serves as a configuration.
+
+222
+00:18:54,000 --> 00:18:59,000
+You can see that I added enable aspect auto proxy annotation.
+
+223
+00:18:59,000 --> 00:19:08,000
+That's enough in order to make spring auto detect aspect annotations and configuration and to make proxies
+
+224
+00:19:08,000 --> 00:19:11,000
+when needed to intercept method invocations.
+
+225
+00:19:12,000 --> 00:19:16,000
+And now we are completely fine to run our example.
+
+226
+00:19:16,000 --> 00:19:18,000
+Let's take a look at main method.
+
+227
+00:19:19,000 --> 00:19:22,000
+I create annotation config application context.
+
+228
+00:19:23,000 --> 00:19:26,000
+I scan package with our ALP examples.
+
+229
+00:19:26,000 --> 00:19:35,000
+I extract user bin and in order to show you all type of advices I am going to invoke method that doesn't
+
+230
+00:19:35,000 --> 00:19:36,000
+throw any exception.
+
+231
+00:19:36,000 --> 00:19:44,000
+And then I will call one method that deliberately throws exception in order to demo you all kind of
+
+232
+00:19:44,000 --> 00:19:45,000
+advices configure it.
+
+233
+00:19:46,000 --> 00:19:47,000
+That's it.
+
+234
+00:19:47,000 --> 00:19:52,000
+Let me run the program and explore the console output together with you.
+
+235
+00:19:53,000 --> 00:19:58,000
+At the beginning you can see that we entered rounded voice before calling method.
+
+236
+00:19:59,000 --> 00:20:02,000
+After that we have to before advices.
+
+237
+00:20:02,000 --> 00:20:09,000
+If you remember, we created before advice for select all pointcut and one before advice for the user
+
+238
+00:20:09,000 --> 00:20:10,000
+being pointcut.
+
+239
+00:20:11,000 --> 00:20:18,000
+Then we have after returning advice and we print returned values that we got inside the advice.
+
+240
+00:20:18,000 --> 00:20:22,000
+Here is the first name of configure it user bin.
+
+241
+00:20:22,000 --> 00:20:26,000
+After that, after finally advice worked.
+
+242
+00:20:26,000 --> 00:20:32,000
+And only after that we can say that we are about to leave our around advice.
+
+243
+00:20:32,000 --> 00:20:37,000
+That's why we can see console output from around advice here.
+
+244
+00:20:38,000 --> 00:20:42,000
+Then I actually print returned first name to console.
+
+245
+00:20:42,000 --> 00:20:43,000
+That's it.
+
+246
+00:20:44,000 --> 00:20:50,000
+Now we have the second method demo in the similar way you can see first console output from the round
+
+247
+00:20:50,000 --> 00:20:55,000
+advice and then we see console output from two before advices.
+
+248
+00:20:56,000 --> 00:21:04,000
+Then we don't see after returning advice because method didn't finish execution properly and exception
+
+249
+00:21:04,000 --> 00:21:05,000
+was thrown.
+
+250
+00:21:06,000 --> 00:21:10,000
+I see the console output from the method that exception has been thrown.
+
+251
+00:21:10,000 --> 00:21:18,000
+Then I entered after throwing advice and I print the class of the exception to console because I got
+
+252
+00:21:18,000 --> 00:21:26,000
+access to it inside the advice and then I see console output from the after finally advice and stack
+
+253
+00:21:26,000 --> 00:21:28,000
+trace of exception.
+
+254
+00:21:29,000 --> 00:21:35,000
+Pay attention that you can't see the last console output from the rounded device because during the
+
+255
+00:21:35,000 --> 00:21:38,000
+method execution exception was thrown.
+
+256
+00:21:38,000 --> 00:21:40,000
+And team please.
+
+257
+00:21:40,000 --> 00:21:46,000
+Even in case something is not clear, let me know and I will be happy to help you.
+
+258
+00:21:46,000 --> 00:21:47,000
+Amazing.
+
+259
+00:21:47,000 --> 00:21:48,000
+That's how it works.
+
+260
+00:21:48,000 --> 00:21:51,000
+And that's all what I wanted to share with you.
+
+261
+00:21:51,000 --> 00:21:54,000
+Let's recap what we have learned today.
+
+262
+00:21:55,000 --> 00:21:58,000
+We learned on practice.
+
+263
+00:21:58,000 --> 00:22:03,000
+Now you know how to create aspect, how to configure pointcuts and advices.
+
+264
+00:22:04,000 --> 00:22:07,000
+We learned different pointcut designators.
+
+265
+00:22:07,000 --> 00:22:13,000
+You saw how to activate spring AOP support of aspect annotations.
+
+266
+00:22:13,000 --> 00:22:16,000
+And we reviewed live code examples.
+
+267
+00:22:17,000 --> 00:22:19,000
+That's all what I wanted to share with you today.
+
+268
+00:22:19,000 --> 00:22:21,000
+Thanks a lot for your attention.
+
+269
+00:22:21,000 --> 00:22:24,000
+Have a great day and see you in the next lesson.
+
diff --git a/90 - Spring AOP/external-links.txt b/90 - Spring AOP/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..849d6ab8ed5813f0927ae35fd84e88b8f24a2dd4
--- /dev/null
+++ b/90 - Spring AOP/external-links.txt
@@ -0,0 +1,3 @@
+
+002 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/ab0084445a16c0c8897cc80308c28817d9dace8a
diff --git a/91 - REST Architecture/001 REST Architecture Overview and Key Principles_en.srt b/91 - REST Architecture/001 REST Architecture Overview and Key Principles_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..616afe82db255b1d2133184f90a1cfbf338b8343
--- /dev/null
+++ b/91 - REST Architecture/001 REST Architecture Overview and Key Principles_en.srt
@@ -0,0 +1,1012 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:09,000
+Today we start learning interesting and important topic.
+
+3
+00:00:09,000 --> 00:00:12,000
+We're going to learn rest architecture.
+
+4
+00:00:13,000 --> 00:00:19,000
+This is going to be theoretical lesson, but it is important to understand concepts that we are going
+
+5
+00:00:19,000 --> 00:00:26,000
+to use in the following practical lessons where we are going to learn different ways of how we can implement
+
+6
+00:00:26,000 --> 00:00:28,000
+rest architecture in the application.
+
+7
+00:00:29,000 --> 00:00:35,000
+We'll start the video from the understanding such definitions as Rest and Rest API.
+
+8
+00:00:36,000 --> 00:00:41,000
+After that, we are going to talk about key principles of rest architectural style.
+
+9
+00:00:41,000 --> 00:00:45,000
+These principles distinguish rest approach uniquely.
+
+10
+00:00:45,000 --> 00:00:51,000
+Namely, we are going to talk about client server communication, stateless communication caching,
+
+11
+00:00:51,000 --> 00:00:55,000
+uniform interface, layered system code on demand.
+
+12
+00:00:56,000 --> 00:01:02,000
+After that, I'm going to explain the concept of the resource in rest and resource methods.
+
+13
+00:01:03,000 --> 00:01:09,000
+And at the end of the lesson, I'm going to compare rest with HTTP because a lot of people use these
+
+14
+00:01:09,000 --> 00:01:16,000
+two terms interchangeably, but actually they are different and we are going to understand why.
+
+15
+00:01:17,000 --> 00:01:19,000
+Let's start our lesson.
+
+16
+00:01:19,000 --> 00:01:21,000
+Let's start with definition.
+
+17
+00:01:21,000 --> 00:01:24,000
+So what is rest?
+
+18
+00:01:25,000 --> 00:01:29,000
+Rest stands for representational state transfer.
+
+19
+00:01:29,000 --> 00:01:34,000
+It is an architectural style for distributed hypermedia systems.
+
+20
+00:01:34,000 --> 00:01:37,000
+It was presented the first time in the 2000.
+
+21
+00:01:38,000 --> 00:01:44,000
+It was established with the goal of improving performance, scalability and simplicity by enforcing
+
+22
+00:01:44,000 --> 00:01:47,000
+specific limits on an API.
+
+23
+00:01:47,000 --> 00:01:55,000
+It has gained popularity because of the opportunity to cover various devices and applications in rest
+
+24
+00:01:55,000 --> 00:01:56,000
+architecture.
+
+25
+00:01:56,000 --> 00:02:04,000
+A rest server simply provides access to resources and rest client accesses and modifies the resources.
+
+26
+00:02:04,000 --> 00:02:05,000
+Here.
+
+27
+00:02:05,000 --> 00:02:10,000
+Each resource is identified by Uri's global IDs.
+
+28
+00:02:10,000 --> 00:02:17,000
+Rest uses various representation to represent a resource like text JSON.
+
+29
+00:02:17,000 --> 00:02:18,000
+XML.
+
+30
+00:02:18,000 --> 00:02:20,000
+JSON is the most popular one.
+
+31
+00:02:21,000 --> 00:02:26,000
+A web API or API of a web service that is conforming to the rest.
+
+32
+00:02:26,000 --> 00:02:30,000
+Architectural style is called Rest API.
+
+33
+00:02:31,000 --> 00:02:38,000
+These Web services utilize a stateless protocol to make textual representations of their online resources
+
+34
+00:02:38,000 --> 00:02:41,000
+available for reading and processing.
+
+35
+00:02:42,000 --> 00:02:48,000
+A client performs well known HTTP protocol based activities like Fetch, Update and delete.
+
+36
+00:02:49,000 --> 00:02:57,000
+And similar to other architectural styles and patterns, Rest has its own guiding principles and constraints.
+
+37
+00:02:57,000 --> 00:03:04,000
+These principles must be satisfied if a service interface needs to be referred as restful.
+
+38
+00:03:04,000 --> 00:03:12,000
+Let's now review key rest principles guidelines of how they're also called in other sources.
+
+39
+00:03:12,000 --> 00:03:13,000
+Constraints.
+
+40
+00:03:13,000 --> 00:03:22,000
+They are client server communication, stateless communication caching Uniform interface layer system
+
+41
+00:03:22,000 --> 00:03:24,000
+code on demand.
+
+42
+00:03:24,000 --> 00:03:26,000
+Let's review them one by one.
+
+43
+00:03:27,000 --> 00:03:32,000
+The first rest principle is about client server separation.
+
+44
+00:03:32,000 --> 00:03:39,000
+The client server design pattern enforces the separation of concerns, which helps the client and the
+
+45
+00:03:39,000 --> 00:03:42,000
+server components evolve independently.
+
+46
+00:03:42,000 --> 00:03:45,000
+What does it mean for the rest architecture?
+
+47
+00:03:45,000 --> 00:03:52,000
+This means that according to rest architectural approach, client and server can be developed independently
+
+48
+00:03:52,000 --> 00:03:54,000
+and don't have to know about each other.
+
+49
+00:03:55,000 --> 00:04:00,000
+The server side shouldn't affect the way how client is implemented.
+
+50
+00:04:00,000 --> 00:04:06,000
+The server should just provide the API to send the essential data when requested.
+
+51
+00:04:06,000 --> 00:04:09,000
+This also gives us another advantage.
+
+52
+00:04:09,000 --> 00:04:16,000
+You can change client without changing the server side and changing the server side shouldn't impact
+
+53
+00:04:16,000 --> 00:04:17,000
+the client side.
+
+54
+00:04:18,000 --> 00:04:27,000
+By separating the user interface concerns client from the data storage concerns server side, we improve
+
+55
+00:04:27,000 --> 00:04:33,000
+the portability of the user interface across multiple platforms and improves scalability by simplifying
+
+56
+00:04:33,000 --> 00:04:35,000
+the server components.
+
+57
+00:04:36,000 --> 00:04:40,000
+The next rest principle can be called as stateless communication.
+
+58
+00:04:40,000 --> 00:04:48,000
+Statelessness mandates that each request from the client to the server must contain all of the information
+
+59
+00:04:48,000 --> 00:04:51,000
+necessary to understand and complete the request.
+
+60
+00:04:52,000 --> 00:04:55,000
+Rest based systems are stateless.
+
+61
+00:04:55,000 --> 00:05:01,000
+This means that the client state remains unknown to the server and vice versa.
+
+62
+00:05:01,000 --> 00:05:09,000
+This constraint allows the server and the client to understand any sent message, even if they haven't
+
+63
+00:05:09,000 --> 00:05:11,000
+seen the preceding ones.
+
+64
+00:05:11,000 --> 00:05:18,000
+The server can't take advantage of any previously stored context information on the server.
+
+65
+00:05:19,000 --> 00:05:24,000
+For this reason, the session state should be entirely stored on the client side.
+
+66
+00:05:25,000 --> 00:05:26,000
+Let's move on.
+
+67
+00:05:27,000 --> 00:05:35,000
+Now let's talk about such constraint of rest architecture as caching or like it also called cacheable
+
+68
+00:05:35,000 --> 00:05:36,000
+data.
+
+69
+00:05:37,000 --> 00:05:44,000
+The cacheable constraint requires that the response should implicitly or explicitly label itself as
+
+70
+00:05:44,000 --> 00:05:47,000
+cacheable or non-cacheable.
+
+71
+00:05:47,000 --> 00:05:54,000
+Data and response caching are critical in today's world because it results in better client side performance.
+
+72
+00:05:55,000 --> 00:05:57,000
+Why it is so important.
+
+73
+00:05:57,000 --> 00:06:03,000
+Because caching is one of the ways to improve performance and performance is one of the key goals of
+
+74
+00:06:03,000 --> 00:06:05,000
+rest architecture.
+
+75
+00:06:05,000 --> 00:06:11,000
+Basically, this is logical why you should send new request to fetch the data.
+
+76
+00:06:11,000 --> 00:06:17,000
+If it's state not changed and it is cached already on the client side.
+
+77
+00:06:17,000 --> 00:06:25,000
+This increases performance if the response is cacheable the client application gets the right to reuse
+
+78
+00:06:25,000 --> 00:06:28,000
+the response data later for equivalent requests.
+
+79
+00:06:29,000 --> 00:06:37,000
+It also gives a server more scalability options due to the smaller burden on the server by using HTTP
+
+80
+00:06:37,000 --> 00:06:45,000
+headers and origin server indicates whether response can be cached and if so, for how long.
+
+81
+00:06:45,000 --> 00:06:50,000
+Optimizes the network using cache and improves the overall quality of service.
+
+82
+00:06:50,000 --> 00:06:52,000
+In the following ways.
+
+83
+00:06:52,000 --> 00:06:53,000
+Reduce bandwidth.
+
+84
+00:06:53,000 --> 00:06:55,000
+Reduce latency.
+
+85
+00:06:55,000 --> 00:06:57,000
+Reduce load on servers.
+
+86
+00:06:57,000 --> 00:06:59,000
+Hide network Failures.
+
+87
+00:06:59,000 --> 00:07:07,000
+Talking about recommendations, it is worth to mention get requests should be cacheable by default until
+
+88
+00:07:07,000 --> 00:07:10,000
+a special condition arises.
+
+89
+00:07:10,000 --> 00:07:14,000
+Usually browsers treat all get requests as cacheable.
+
+90
+00:07:15,000 --> 00:07:23,000
+Post requests are not cacheable by default, but can be made cacheable if is an express header or a
+
+91
+00:07:23,000 --> 00:07:30,000
+cache control header with a directive to explicitly allows, caching is added to the response.
+
+92
+00:07:30,000 --> 00:07:34,000
+Responses to put and delete requests are not cacheable at all.
+
+93
+00:07:35,000 --> 00:07:43,000
+The uniform interface constraint that any restful architecture should comply with actually means that,
+
+94
+00:07:43,000 --> 00:07:49,000
+along with the data server responses, should also announce available actions and resources.
+
+95
+00:07:50,000 --> 00:07:57,000
+In other words, querying resources should allow the client to request other actions and resources without
+
+96
+00:07:57,000 --> 00:07:59,000
+knowing them in advance.
+
+97
+00:07:59,000 --> 00:08:02,000
+Let's look at the example of response.
+
+98
+00:08:02,000 --> 00:08:08,000
+You can see it on the slide just by analyzing the single response.
+
+99
+00:08:08,000 --> 00:08:12,000
+A client knows what entities were queried.
+
+100
+00:08:12,000 --> 00:08:14,000
+Articles in this example.
+
+101
+00:08:14,000 --> 00:08:17,000
+How are these entities are structured?
+
+102
+00:08:17,000 --> 00:08:25,000
+Articles have fields ID title author commands how to retrieve related entities.
+
+103
+00:08:25,000 --> 00:08:35,000
+For example, the author and the comments that there are more entities of type articles than based on
+
+104
+00:08:35,000 --> 00:08:38,000
+the current response length and pagination links.
+
+105
+00:08:39,000 --> 00:08:47,000
+Using interfaces to decouple classes from the implementation of their dependencies is a pretty old concept
+
+106
+00:08:47,000 --> 00:08:48,000
+in rust.
+
+107
+00:08:48,000 --> 00:08:55,000
+You use the same concept to decouple the client from the implementation of the rest service in order
+
+108
+00:08:55,000 --> 00:09:00,000
+to define such an interface, a contract between the client and the service.
+
+109
+00:09:00,000 --> 00:09:02,000
+You have to use standards.
+
+110
+00:09:02,000 --> 00:09:10,000
+This is because if you want an internet size network of rest services, you have to enforce global concepts
+
+111
+00:09:10,000 --> 00:09:14,000
+like standards to make them understand each other.
+
+112
+00:09:14,000 --> 00:09:21,000
+By applying the principle of generality to the components interface, we can simplify the overall system
+
+113
+00:09:21,000 --> 00:09:25,000
+architecture and improve the visibility of interactions.
+
+114
+00:09:25,000 --> 00:09:32,000
+Multiple architectural constraints help in obtaining a uniform interface and guiding the behavior of
+
+115
+00:09:32,000 --> 00:09:33,000
+components.
+
+116
+00:09:33,000 --> 00:09:38,000
+The following four constraints can achieve a uniform rest interface.
+
+117
+00:09:39,000 --> 00:09:42,000
+The first one an amplification of resources.
+
+118
+00:09:42,000 --> 00:09:47,000
+You use the UI standard to identify a resource.
+
+119
+00:09:47,000 --> 00:09:54,000
+The interface must uniquely identify each resource involved in the interaction between the client and
+
+120
+00:09:54,000 --> 00:09:54,000
+the server.
+
+121
+00:09:55,000 --> 00:10:01,000
+The second constraint Manipulation of resources through representations.
+
+122
+00:10:01,000 --> 00:10:05,000
+You use the HTTP standard to describe communication.
+
+123
+00:10:05,000 --> 00:10:13,000
+So for example, get means that you want to retrieve data about the UI identified resource.
+
+124
+00:10:13,000 --> 00:10:18,000
+You can describe an operation with an HTTP method and the URI.
+
+125
+00:10:19,000 --> 00:10:23,000
+The third constraint Self-descriptive messages.
+
+126
+00:10:23,000 --> 00:10:30,000
+Each resource representation should carry enough information to describe how to process the message.
+
+127
+00:10:30,000 --> 00:10:37,000
+It should also provide information of the additional actions that the client can perform on the resource.
+
+128
+00:10:37,000 --> 00:10:47,000
+You use standard meme types and standard RDF vocabulary to make messages self-descriptive so the client
+
+129
+00:10:47,000 --> 00:10:53,000
+can find the data by checking the semantics and it doesn't have to know the application specific data
+
+130
+00:10:53,000 --> 00:10:54,000
+structure.
+
+131
+00:10:54,000 --> 00:10:56,000
+This service uses.
+
+132
+00:10:57,000 --> 00:11:01,000
+I used here the term RDF vocabulary.
+
+133
+00:11:01,000 --> 00:11:03,000
+Let me explain you what it is.
+
+134
+00:11:04,000 --> 00:11:08,000
+RDF stands for the Resource Description Framework.
+
+135
+00:11:08,000 --> 00:11:15,000
+It is a world wide Web consortium standard originally designed as a data model for metadata.
+
+136
+00:11:15,000 --> 00:11:23,000
+It has come to be used as a general method for description and exchange of graph data.
+
+137
+00:11:23,000 --> 00:11:31,000
+RDF provides a variety of syntax, notations and data serialization formats that you potentially may
+
+138
+00:11:31,000 --> 00:11:35,000
+reuse while designing your rest services.
+
+139
+00:11:36,000 --> 00:11:37,000
+Don't worry about formats.
+
+140
+00:11:37,000 --> 00:11:43,000
+We are going to have practical examples and lessons full of practical exercises where we will build
+
+141
+00:11:43,000 --> 00:11:47,000
+our rest services and I will show you how it works.
+
+142
+00:11:47,000 --> 00:11:50,000
+And the force constraint.
+
+143
+00:11:50,000 --> 00:11:59,000
+Hypermedia as the engine of application state, also known as Hateoas, you use hyperlinks and possibly
+
+144
+00:11:59,000 --> 00:12:05,000
+you write templates to decouple the client from the application specific structure.
+
+145
+00:12:05,000 --> 00:12:11,000
+You can annotate these hyperlinks so the client will understand what they mean.
+
+146
+00:12:12,000 --> 00:12:16,000
+The client should have only the initial UI of the application.
+
+147
+00:12:17,000 --> 00:12:25,000
+The client application should dynamically drive all other resources and interactions with use of hyperlinks.
+
+148
+00:12:26,000 --> 00:12:34,000
+Uniform interface Rest Architectural constraint is not the one the easiest to understand, but the one
+
+149
+00:12:34,000 --> 00:12:35,000
+which is also important.
+
+150
+00:12:36,000 --> 00:12:42,000
+Remember that in case you have any questions, you can always ask your questions below the video and
+
+151
+00:12:42,000 --> 00:12:44,000
+I will be happy to answer.
+
+152
+00:12:44,000 --> 00:12:46,000
+Let's continue.
+
+153
+00:12:47,000 --> 00:12:48,000
+The next rest.
+
+154
+00:12:48,000 --> 00:12:51,000
+Architectural constraint is called layered system.
+
+155
+00:12:52,000 --> 00:12:58,000
+If you remember previously in the course we had a lesson that is called layered architecture.
+
+156
+00:12:58,000 --> 00:13:05,000
+It is kind of similar thing that I'm going to explain you now and also in my course, Java from zero
+
+157
+00:13:05,000 --> 00:13:11,000
+to first job together with my students, we implemented online shop according to the layered architecture
+
+158
+00:13:11,000 --> 00:13:13,000
+design pattern.
+
+159
+00:13:13,000 --> 00:13:20,000
+The key concept in the layered system is that each layer has specific function and code is structured
+
+160
+00:13:20,000 --> 00:13:28,000
+accordingly and separated logically between layers according to the rest architectural approach.
+
+161
+00:13:28,000 --> 00:13:36,000
+Layered system term has slightly different shape and form, but the concept is the same to divide responsibilities
+
+162
+00:13:36,000 --> 00:13:41,000
+between modules that are located in different logical layers.
+
+163
+00:13:41,000 --> 00:13:50,000
+If you remember when we learned layered architecture, I highlighted that in layered system, each component
+
+164
+00:13:50,000 --> 00:13:55,000
+can't see beyond the immediate layer they're interacting with.
+
+165
+00:13:56,000 --> 00:14:04,000
+That means that changes in one layer theoretically may impact only the nearest level, but not impacting
+
+166
+00:14:04,000 --> 00:14:06,000
+the whole graph of layers.
+
+167
+00:14:07,000 --> 00:14:13,000
+The rest API layers have their responsibilities and come in hierarchical order.
+
+168
+00:14:13,000 --> 00:14:18,000
+For example, one layer may be responsible for storing data on the server.
+
+169
+00:14:19,000 --> 00:14:26,000
+The second for deploying the APIs on another server and the third for authenticating requests in another
+
+170
+00:14:26,000 --> 00:14:27,000
+server.
+
+171
+00:14:27,000 --> 00:14:34,000
+All layers act as mediators between the client and applications deployed on the server side.
+
+172
+00:14:35,000 --> 00:14:43,000
+In this way we prevent direct interaction between the client and server side applications and as a result,
+
+173
+00:14:43,000 --> 00:14:46,000
+a client doesn't know which server.
+
+174
+00:14:46,000 --> 00:14:48,000
+A component is a address.
+
+175
+00:14:48,000 --> 00:14:54,000
+And the most important thing they don't want to know and don't need to know.
+
+176
+00:14:55,000 --> 00:15:01,000
+This gives us different advantages, namely, it improves the APIs overall security.
+
+177
+00:15:02,000 --> 00:15:11,000
+Also, it improves flexibility because adding altering or removing APIs on other levels shouldn't impact
+
+178
+00:15:11,000 --> 00:15:16,000
+the key components that are in charge of interaction with client.
+
+179
+00:15:17,000 --> 00:15:20,000
+The next constraint is called code on demand.
+
+180
+00:15:21,000 --> 00:15:29,000
+Rest also allows client functionality to extend by downloading and executing code in the form of applets
+
+181
+00:15:29,000 --> 00:15:30,000
+or scripts.
+
+182
+00:15:31,000 --> 00:15:39,000
+The downloaded code simplifies clients by reducing the number of features required to be implemented.
+
+183
+00:15:39,000 --> 00:15:46,000
+Servers can provide part of features delivered to the client in the form of code, and the client only
+
+184
+00:15:46,000 --> 00:15:48,000
+needs to execute the code.
+
+185
+00:15:48,000 --> 00:15:56,000
+Rest Architectural style allows users to download and run code in the form of Java applets or scripts
+
+186
+00:15:56,000 --> 00:15:58,000
+such as JavaScript.
+
+187
+00:15:58,000 --> 00:16:05,000
+I wouldn't say that Java applets are popular and working nowadays at all, but with regard to JavaScript,
+
+188
+00:16:05,000 --> 00:16:07,000
+this can be relevant.
+
+189
+00:16:07,000 --> 00:16:14,000
+For example, clients can retrieve the rendering code for UI widgets by calling your API.
+
+190
+00:16:15,000 --> 00:16:22,000
+But still, the most common scenario of using rest APIs is to deliver static resource representations
+
+191
+00:16:22,000 --> 00:16:24,000
+in XML or JSON.
+
+192
+00:16:25,000 --> 00:16:31,000
+It also worth to mention that the key concept in the rest architecture is the concept of resource.
+
+193
+00:16:31,000 --> 00:16:36,000
+The key abstraction of information in rest is a resource.
+
+194
+00:16:36,000 --> 00:16:39,000
+An information that we can name can be a resource.
+
+195
+00:16:40,000 --> 00:16:47,000
+For example, a rest resource can be a document or image, a temporal service, a collection of other
+
+196
+00:16:47,000 --> 00:16:48,000
+resources.
+
+197
+00:16:49,000 --> 00:16:54,000
+A rest API consists of an assembly of interlinked resources.
+
+198
+00:16:55,000 --> 00:17:00,000
+This set of resources is known as the Rest APIs Resource model.
+
+199
+00:17:01,000 --> 00:17:07,000
+Another important thing to understand in the rest terminology is resource masses.
+
+200
+00:17:07,000 --> 00:17:14,000
+These are masses that are used to perform the desired transition between two states of any resource.
+
+201
+00:17:14,000 --> 00:17:21,000
+There is a common misunderstanding that HTTP methods and rest masses are the same thing.
+
+202
+00:17:21,000 --> 00:17:23,000
+No, they are not.
+
+203
+00:17:23,000 --> 00:17:33,000
+For example, rest dictates the usage of delete to erase a document, be it a file state etcetera behind
+
+204
+00:17:33,000 --> 00:17:34,000
+the URI.
+
+205
+00:17:34,000 --> 00:17:45,000
+Whereas with HTTP you would misuse probably a get or post query like this product and post with a parameter
+
+206
+00:17:45,000 --> 00:17:46,000
+delete ID.
+
+207
+00:17:47,000 --> 00:17:56,000
+Another example is if we decide that application APIs will use HTTP post for updating a resource rather
+
+208
+00:17:56,000 --> 00:17:59,000
+than most people recommend http put.
+
+209
+00:17:59,000 --> 00:17:59,000
+It's all.
+
+210
+00:18:00,000 --> 00:18:08,000
+Still, the application interface will be restful, but just an advice to remember taking into account
+
+211
+00:18:08,000 --> 00:18:10,000
+a rest doesn't have a standard.
+
+212
+00:18:11,000 --> 00:18:17,000
+Make sure that everyone working on the product uses the same definition.
+
+213
+00:18:17,000 --> 00:18:21,000
+This should be set by the development lead of your team.
+
+214
+00:18:22,000 --> 00:18:27,000
+So we already started the topic about comparison of rest and HTTP.
+
+215
+00:18:28,000 --> 00:18:32,000
+I would like to highlight that rest is not the same as HTTP.
+
+216
+00:18:33,000 --> 00:18:36,000
+We can say it in the following way.
+
+217
+00:18:36,000 --> 00:18:40,000
+Rest is the way HTTP should be used.
+
+218
+00:18:40,000 --> 00:18:42,000
+Rest is not a standard.
+
+219
+00:18:43,000 --> 00:18:45,000
+It is also not a protocol like HTTP.
+
+220
+00:18:46,000 --> 00:18:48,000
+It is not even a specification.
+
+221
+00:18:48,000 --> 00:18:57,000
+We already learned that rest is just an architectural style approach for distributed hypermedia systems
+
+222
+00:18:57,000 --> 00:19:02,000
+and architectural principles and constraints that we discuss.
+
+223
+00:19:02,000 --> 00:19:10,000
+It may help to create large interconnected systems such as the Internet and make them very efficient
+
+224
+00:19:10,000 --> 00:19:11,000
+with high performance.
+
+225
+00:19:12,000 --> 00:19:16,000
+On the other hand, HTTP is a protocol standard.
+
+226
+00:19:16,000 --> 00:19:19,000
+While it is not the same as rest.
+
+227
+00:19:19,000 --> 00:19:25,000
+It exhibits many features of a restful system in the world of HTTP.
+
+228
+00:19:25,000 --> 00:19:29,000
+Resources are typically files on a remote server.
+
+229
+00:19:30,000 --> 00:19:40,000
+This could be HTML, CSS, JavaScript images and all the other files that comprise modern web pages.
+
+230
+00:19:40,000 --> 00:19:46,000
+Each file is treated as distinct resource that is addressable using a unique URL.
+
+231
+00:19:47,000 --> 00:19:56,000
+One more difference between rest and the HTTP rest is not a communication protocol while HTTP is.
+
+232
+00:19:57,000 --> 00:20:04,000
+And another difference pretty formal one, but still the most modern web servers use cookies and sessions
+
+233
+00:20:04,000 --> 00:20:06,000
+to store state.
+
+234
+00:20:06,000 --> 00:20:13,000
+And as you may already know that using cookies, we get access to the session object that is stored
+
+235
+00:20:13,000 --> 00:20:15,000
+on the server side.
+
+236
+00:20:15,000 --> 00:20:24,000
+And you remember that rest architecture says that client stores the state and the server is stateless.
+
+237
+00:20:24,000 --> 00:20:31,000
+So when we use cookies and sessions on the server side formally, this is not anymore rest style.
+
+238
+00:20:32,000 --> 00:20:36,000
+This is one of the controversial points to think about.
+
+239
+00:20:36,000 --> 00:20:44,000
+So to sum it up, you are going to hear that different people still use such terms as rest and HTTP
+
+240
+00:20:44,000 --> 00:20:46,000
+interchangeably.
+
+241
+00:20:46,000 --> 00:20:50,000
+But as we already discussed, these are different things.
+
+242
+00:20:50,000 --> 00:20:52,000
+And now you know why?
+
+243
+00:20:53,000 --> 00:20:56,000
+That's all what I wanted to share with you in this lesson.
+
+244
+00:20:56,000 --> 00:20:59,000
+Let's recap what we have learned today.
+
+245
+00:21:00,000 --> 00:21:04,000
+Today we learned what rest and rest terms mean.
+
+246
+00:21:05,000 --> 00:21:09,000
+I explained key principles of the rest architectural style.
+
+247
+00:21:09,000 --> 00:21:18,000
+Namely, we talked about client server communication, stateless communication, caching, uniform interface,
+
+248
+00:21:18,000 --> 00:21:21,000
+layered system and code on demand.
+
+249
+00:21:22,000 --> 00:21:27,000
+Also I explained your concept of the resource in the rest architecture.
+
+250
+00:21:27,000 --> 00:21:36,000
+We talked about resource methods and we compared rest with HTTP protocol to understand the difference.
+
+251
+00:21:36,000 --> 00:21:38,000
+That's all for today.
+
+252
+00:21:38,000 --> 00:21:40,000
+Thanks a lot for your attention.
+
+253
+00:21:40,000 --> 00:21:44,000
+Have a great day and see you in the next lesson.
+
diff --git a/91 - REST Architecture/002 Naming Convention for RESTful Services_en.srt b/91 - REST Architecture/002 Naming Convention for RESTful Services_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..b21953d1c08126b2de5dff9019b612f39bc6875c
--- /dev/null
+++ b/91 - REST Architecture/002 Naming Convention for RESTful Services_en.srt
@@ -0,0 +1,820 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:12,000
+In this video we are going to learn important things about naming convention in RESTful services.
+
+3
+00:00:12,000 --> 00:00:17,000
+This is important topic before we started creation of your rest API.
+
+4
+00:00:17,000 --> 00:00:24,000
+We are going to start our lesson from review and understanding of why it is important to follow guidelines
+
+5
+00:00:24,000 --> 00:00:29,000
+and naming convention during the creation of restful service and the rest.
+
+6
+00:00:29,000 --> 00:00:36,000
+Part of the lesson will be dedicated to the discussion of the principles, rules, guidelines, recommendations.
+
+7
+00:00:36,000 --> 00:00:41,000
+They are use nouns to represent resources, not verbs.
+
+8
+00:00:41,000 --> 00:00:50,000
+Use pluralized nouns for resources, use hyphens and lowercase use forward slashes for Iraqi but not
+
+9
+00:00:50,000 --> 00:00:59,000
+trailing forward slash avoid using file extensions API versioning use query parameters punctuation for
+
+10
+00:00:59,000 --> 00:01:05,000
+list intuitive names no jargon no abridging.
+
+11
+00:01:05,000 --> 00:01:11,000
+Avoid using special characters and keep your API consistent.
+
+12
+00:01:11,000 --> 00:01:13,000
+So let's start our lesson.
+
+13
+00:01:14,000 --> 00:01:20,000
+Let's try to understand first why this topic is so important and why I decided to dedicate the whole
+
+14
+00:01:20,000 --> 00:01:22,000
+lesson to this topic.
+
+15
+00:01:22,000 --> 00:01:24,000
+Design of the API.
+
+16
+00:01:24,000 --> 00:01:30,000
+It is super important task because most likely multiple clients and very often multiple generations
+
+17
+00:01:30,000 --> 00:01:33,000
+of other developers and clients are going to use it.
+
+18
+00:01:33,000 --> 00:01:41,000
+And to ensure scalability of your API efficient support, it is better to follow some standards and
+
+19
+00:01:41,000 --> 00:01:44,000
+guidelines during the naming your APIs.
+
+20
+00:01:45,000 --> 00:01:51,000
+This will save us from having additional issues related with misunderstanding and potential errors.
+
+21
+00:01:52,000 --> 00:01:58,000
+Because at the end of the day our API should be intuitive and built in the logical way.
+
+22
+00:01:58,000 --> 00:02:06,000
+Very often I don't even look at the documentation because I assume that in case entity is named in this
+
+23
+00:02:06,000 --> 00:02:13,000
+way, then end point for collection of entities should be available with this name using this rest method.
+
+24
+00:02:14,000 --> 00:02:15,000
+Do you understand my point?
+
+25
+00:02:15,000 --> 00:02:21,000
+Knowing the best practices for naming your restful APIs is particularly important.
+
+26
+00:02:21,000 --> 00:02:28,000
+Using Rest API and naming conventions dramatically lowers the learning curve and makes it easier for
+
+27
+00:02:28,000 --> 00:02:33,000
+new developers and third party users to start with the API.
+
+28
+00:02:33,000 --> 00:02:39,000
+The more people understand how to use the proper methods, the easier it is for everyone.
+
+29
+00:02:39,000 --> 00:02:45,000
+These standards should be required for every UI naming process.
+
+30
+00:02:45,000 --> 00:02:52,000
+That's why I decided to hold this lesson before we started learning the implementation part of the rest
+
+31
+00:02:52,000 --> 00:02:53,000
+Architecture.
+
+32
+00:02:54,000 --> 00:02:59,000
+The Danger lesson we are going to review the most popular and important guidelines is that I strongly
+
+33
+00:02:59,000 --> 00:03:04,000
+recommend you to follow during designing your API and naming endpoints.
+
+34
+00:03:05,000 --> 00:03:11,000
+I've already shared the list of recommendations that we are going to review today during the agenda.
+
+35
+00:03:11,000 --> 00:03:18,000
+So let's just go one by one and the first recommendations that we are going to review sounds like this.
+
+36
+00:03:19,000 --> 00:03:23,000
+Use nouns to represent resources, but not verbs.
+
+37
+00:03:23,000 --> 00:03:32,000
+Basically the resource identifier its UI shouldn't declare any create, read, update or delete operations.
+
+38
+00:03:32,000 --> 00:03:38,000
+You have request methods for that to define what should be done with the resource.
+
+39
+00:03:38,000 --> 00:03:41,000
+Read, create, update or delete.
+
+40
+00:03:41,000 --> 00:03:48,000
+But instead you need to define the noun, the name of the resource that you interact with.
+
+41
+00:03:49,000 --> 00:03:58,000
+RESTful Uris should refer to a resource that is a sink noun instead of referring to an action verb.
+
+42
+00:03:59,000 --> 00:04:03,000
+Because nouns have properties which verbs do not have.
+
+43
+00:04:03,000 --> 00:04:06,000
+Similar to resources have attributes.
+
+44
+00:04:07,000 --> 00:04:10,000
+On the slide you can see good and bad examples.
+
+45
+00:04:10,000 --> 00:04:13,000
+Pay attention also to the delete orders.
+
+46
+00:04:13,000 --> 00:04:14,000
+Uri.
+
+47
+00:04:14,000 --> 00:04:18,000
+It is kind of a verb noun combination.
+
+48
+00:04:18,000 --> 00:04:21,000
+It is also not recommended to do like that.
+
+49
+00:04:22,000 --> 00:04:28,000
+Looking at the good examples, I believe you can agree with me that they are readable and intuitive.
+
+50
+00:04:29,000 --> 00:04:37,000
+Obviously that resource with employees identifier and employee ID requested via get method should read
+
+51
+00:04:37,000 --> 00:04:41,000
+the resource with an ID of specific employee entity.
+
+52
+00:04:42,000 --> 00:04:46,000
+This is simple rule to follow, so just please don't forget it.
+
+53
+00:04:47,000 --> 00:04:53,000
+The next thing that probably you are thinking about right now, if we use nouns, should we use plural
+
+54
+00:04:53,000 --> 00:04:54,000
+or singular?
+
+55
+00:04:55,000 --> 00:05:01,000
+Of course this is a matter of your own preference, but the rule of thumb is to use plurals for all
+
+56
+00:05:01,000 --> 00:05:06,000
+resources unless they are singleton resources, for example.
+
+57
+00:05:06,000 --> 00:05:09,000
+Config y plurals.
+
+58
+00:05:09,000 --> 00:05:16,000
+Well, they are just more preferred because they represent more of something generic in a sense.
+
+59
+00:05:17,000 --> 00:05:23,000
+On this slide you can see bad and good examples with item and employee endpoints.
+
+60
+00:05:23,000 --> 00:05:25,000
+Let's continue.
+
+61
+00:05:25,000 --> 00:05:33,000
+The next recommendation to follow is to use hyphens to separate words and use lowercase for all words.
+
+62
+00:05:33,000 --> 00:05:34,000
+Don't use camel.
+
+63
+00:05:35,000 --> 00:05:45,000
+Don't use underscores the RFC 1786 specification for your rise standards also denotes that your eyes
+
+64
+00:05:45,000 --> 00:05:52,000
+are case sensitive except for the scheme and host components of the URL.
+
+65
+00:05:52,000 --> 00:06:00,000
+Given the widespread use of it, avoid any unnecessary confusion due to inconsistent capitalization.
+
+66
+00:06:00,000 --> 00:06:08,000
+Rest API can be developed by backend developers with different primary skills, and you know that in
+
+67
+00:06:08,000 --> 00:06:11,000
+different programming languages there are different names.
+
+68
+00:06:11,000 --> 00:06:12,000
+Style.
+
+69
+00:06:12,000 --> 00:06:16,000
+For example, in PHP it is common to use underscores.
+
+70
+00:06:16,000 --> 00:06:23,000
+In Java and C sharp, it is common to use camelcase and sometimes engineers either forget or just want
+
+71
+00:06:23,000 --> 00:06:28,000
+to apply their own habits while designing the rest API.
+
+72
+00:06:28,000 --> 00:06:33,000
+So remember the recommendation is to use hyphens to separate words.
+
+73
+00:06:33,000 --> 00:06:36,000
+It is more readable and user friendly.
+
+74
+00:06:36,000 --> 00:06:43,000
+Also, hyphens are much better for Google search as hyphens are recommended by Google itself to make
+
+75
+00:06:43,000 --> 00:06:49,000
+its web crawling job easier, thus creating more consistent results.
+
+76
+00:06:50,000 --> 00:06:53,000
+You can review good and bad examples on the slide.
+
+77
+00:06:54,000 --> 00:07:00,000
+The next rule is to use forward slashes for Iraqi but not trailing forward slash.
+
+78
+00:07:00,000 --> 00:07:03,000
+Let me explain what this rule is all about.
+
+79
+00:07:04,000 --> 00:07:09,000
+Usually forward slashes are used for the show in the Iraqi normal.
+
+80
+00:07:09,000 --> 00:07:15,000
+People might not know why the words in the link are separated by forward slashes.
+
+81
+00:07:16,000 --> 00:07:23,000
+As a developer, you should be familiar with the reason the forward slashes denote the UI.
+
+82
+00:07:23,000 --> 00:07:32,000
+Iraqi APIs are typically structured in Iraqi, but there is no need to use slash at the end of the endpoint.
+
+83
+00:07:33,000 --> 00:07:34,000
+Okay, let's move on.
+
+84
+00:07:35,000 --> 00:07:41,000
+The next guideline that I would like to review with you is about not adding file extensions to the Uris.
+
+85
+00:07:41,000 --> 00:07:45,000
+There is just no need in adding file extensions to the URI.
+
+86
+00:07:46,000 --> 00:07:50,000
+File extension simply adds unnecessary length and complexity.
+
+87
+00:07:51,000 --> 00:07:58,000
+Imagine that you would like to change the format of response instead of JSON to return XML and what
+
+88
+00:07:58,000 --> 00:07:59,000
+to do.
+
+89
+00:07:59,000 --> 00:08:07,000
+You need to change API to update the endpoint and you also need to update your client and documentation.
+
+90
+00:08:07,000 --> 00:08:14,000
+There are unnecessary actions that you can avoid in case you just don't use the file extensions as a
+
+91
+00:08:14,000 --> 00:08:15,000
+part of the URI.
+
+92
+00:08:16,000 --> 00:08:22,000
+Again, I recommend you observe bad and good examples presented on the slide.
+
+93
+00:08:22,000 --> 00:08:26,000
+Another important recommendation is to version your API.
+
+94
+00:08:27,000 --> 00:08:34,000
+Always mark your API with the version because imagine that you want to introduce improvements or upgrades
+
+95
+00:08:34,000 --> 00:08:41,000
+that change the way how API works or change even the name of a resource which is not recommended.
+
+96
+00:08:41,000 --> 00:08:46,000
+But still there can be cases and you have a few challenges.
+
+97
+00:08:46,000 --> 00:08:52,000
+The first one How to ensure compatibility of your client with the existing API.
+
+98
+00:08:52,000 --> 00:08:59,000
+The second one How to make all clients aware that significant changes are released and they need to
+
+99
+00:08:59,000 --> 00:09:03,000
+take changes into consideration when they process the response.
+
+100
+00:09:03,000 --> 00:09:09,000
+So never think about your API like something final and usable forever.
+
+101
+00:09:10,000 --> 00:09:16,000
+There is always a chance that new features will be added or some changes to the existing API will be
+
+102
+00:09:16,000 --> 00:09:23,000
+introduced and you never want to break your existing and working API that is already used by clients.
+
+103
+00:09:23,000 --> 00:09:30,000
+Also, when you are using versioning from the very beginning and documented, it indirectly tells the
+
+104
+00:09:30,000 --> 00:09:34,000
+users that there might be changes in the future.
+
+105
+00:09:34,000 --> 00:09:39,000
+It is good to prepare your users for any upcoming changes ahead of time.
+
+106
+00:09:39,000 --> 00:09:44,000
+You can specify a version in the left part of the endpoint in order.
+
+107
+00:09:44,000 --> 00:09:46,000
+The version has the highest scope.
+
+108
+00:09:47,000 --> 00:09:53,000
+Your clients will be interested only in the major version updates, so it will be enough to specify
+
+109
+00:09:53,000 --> 00:09:58,000
+just major versions like version one or version two, etcetera.
+
+110
+00:09:59,000 --> 00:10:01,000
+Just like in the example on the slide.
+
+111
+00:10:02,000 --> 00:10:10,000
+By doing so, if the API is being used by external entities, changing the endpoint will not really
+
+112
+00:10:10,000 --> 00:10:12,000
+affect the existing ones.
+
+113
+00:10:13,000 --> 00:10:17,000
+I like this approach, but there are also four other ways of versioning.
+
+114
+00:10:18,000 --> 00:10:26,000
+They are versioning in the subdomain versioning as an additional header, versioning as an additional
+
+115
+00:10:26,000 --> 00:10:32,000
+field in the accept content type header, versioning as a media type.
+
+116
+00:10:32,000 --> 00:10:33,000
+Let's review them.
+
+117
+00:10:34,000 --> 00:10:36,000
+Versioning in the subdomain.
+
+118
+00:10:36,000 --> 00:10:43,000
+This one puts the version within the UI but makes it associated with the domain like you can see on
+
+119
+00:10:43,000 --> 00:10:44,000
+the slide.
+
+120
+00:10:44,000 --> 00:10:48,000
+This is very similar to the version in placed at the end.
+
+121
+00:10:48,000 --> 00:10:56,000
+However, this approach has one advantage that can allow you to host your API on different servers.
+
+122
+00:10:57,000 --> 00:11:00,000
+Another approach is versioning as an additional header.
+
+123
+00:11:00,000 --> 00:11:04,000
+This version uses Mimetypes to include the API version.
+
+124
+00:11:05,000 --> 00:11:08,000
+It looks something like you can see on this slide.
+
+125
+00:11:09,000 --> 00:11:13,000
+Version as an additional field in the accept Content-type header.
+
+126
+00:11:13,000 --> 00:11:19,000
+This one is similar to the previous point that we discussed on how to include it.
+
+127
+00:11:19,000 --> 00:11:22,000
+Except is the result is different.
+
+128
+00:11:22,000 --> 00:11:24,000
+Here is how it looks like.
+
+129
+00:11:24,000 --> 00:11:28,000
+Pay attention to this slide to understand the difference.
+
+130
+00:11:29,000 --> 00:11:31,000
+Versioning as a media type.
+
+131
+00:11:31,000 --> 00:11:37,000
+This is also similar as the three previous ways all use the Mimetypes sync.
+
+132
+00:11:38,000 --> 00:11:42,000
+The only differences are where or how to put the versioning.
+
+133
+00:11:42,000 --> 00:11:46,000
+Here are some examples presented on the slide.
+
+134
+00:11:47,000 --> 00:11:53,000
+The next guideline that we are going to discuss is about using query parameters in your API.
+
+135
+00:11:53,000 --> 00:12:00,000
+Very often you are going to have requirements to support filtering or sorting or pagination, and to
+
+136
+00:12:00,000 --> 00:12:04,000
+implement this requirement you would need to take into account input parameters.
+
+137
+00:12:04,000 --> 00:12:13,000
+It can be field that is used for sorting and sorting order or filtering criteria and instead of creating
+
+138
+00:12:13,000 --> 00:12:16,000
+new API use query parameters.
+
+139
+00:12:16,000 --> 00:12:23,000
+For example, if you want to filter users to keep in the collection, only those where location is equal
+
+140
+00:12:23,000 --> 00:12:29,000
+to USA, then you can use location query parameter like you can see on the slide.
+
+141
+00:12:30,000 --> 00:12:36,000
+Or in case you want to declare multiple filtering criteria, you can use something like you can see
+
+142
+00:12:36,000 --> 00:12:42,000
+in another example on the slide when I used department and region criteria.
+
+143
+00:12:43,000 --> 00:12:48,000
+Another helpful advice that I want to give you is to use punctuation for lists.
+
+144
+00:12:48,000 --> 00:12:53,000
+Sometimes we want to allow client to fetch multiple resources.
+
+145
+00:12:53,000 --> 00:13:01,000
+In such cases we can use punctuation, comma or semicolon, but comma is used more often.
+
+146
+00:13:01,000 --> 00:13:05,000
+If client wants to access multiple user resources.
+
+147
+00:13:05,000 --> 00:13:10,000
+We can design our API in the way like you can see on the screen.
+
+148
+00:13:10,000 --> 00:13:15,000
+You can see that between ID one and two there is a comma.
+
+149
+00:13:15,000 --> 00:13:18,000
+The next guidelines that I would like to review is use.
+
+150
+00:13:18,000 --> 00:13:20,000
+Sounds pretty logical and simple.
+
+151
+00:13:20,000 --> 00:13:23,000
+Make your names intuitive.
+
+152
+00:13:23,000 --> 00:13:30,000
+Try to select simplest and the most commonly used word to refer to a given concept.
+
+153
+00:13:30,000 --> 00:13:37,000
+Your endpoint names and resource names should be self-describing and easy to understand.
+
+154
+00:13:37,000 --> 00:13:42,000
+It should save time of clients and developers when interacting with the API.
+
+155
+00:13:42,000 --> 00:13:49,000
+When you design an API and trying to come up with the name, try to position yourself as a consumer,
+
+156
+00:13:49,000 --> 00:13:53,000
+as someone who doesn't know anything about your services.
+
+157
+00:13:54,000 --> 00:14:01,000
+I would expect to be able to understand the basic use of API just by reading the API endpoints naming.
+
+158
+00:14:02,000 --> 00:14:07,000
+If I would like to fully understand how to use it, then I would read deeper.
+
+159
+00:14:07,000 --> 00:14:11,000
+Ideally, the name has to be something that represents a whole.
+
+160
+00:14:12,000 --> 00:14:19,000
+In addition, you would like to avoid causing confusion by avoiding abbreviations or shorthand as well.
+
+161
+00:14:19,000 --> 00:14:26,000
+For example, when you name a resource as users from the name, it is clear that with this endpoint
+
+162
+00:14:26,000 --> 00:14:31,000
+you can access user resource and get user information.
+
+163
+00:14:31,000 --> 00:14:33,000
+Resource has a lot of data.
+
+164
+00:14:33,000 --> 00:14:40,000
+We can make this conclusion by plural version of the noun and logical addition to this rule.
+
+165
+00:14:40,000 --> 00:14:43,000
+Avoid using jargon.
+
+166
+00:14:43,000 --> 00:14:46,000
+Clients shouldn't spend time guessing.
+
+167
+00:14:47,000 --> 00:14:50,000
+Use less domain centric jargon.
+
+168
+00:14:50,000 --> 00:14:57,000
+Sometimes that's common and more understandable is going to make your APIs a lot more usable.
+
+169
+00:14:58,000 --> 00:15:00,000
+Pay attention to the example on the slide.
+
+170
+00:15:01,000 --> 00:15:06,000
+For example, in this case, what does f n mean?
+
+171
+00:15:06,000 --> 00:15:07,000
+Function?
+
+172
+00:15:07,000 --> 00:15:08,000
+Which function?
+
+173
+00:15:08,000 --> 00:15:09,000
+This is not clear.
+
+174
+00:15:09,000 --> 00:15:15,000
+So stick with your common sense and choose intuitive, clear names.
+
+175
+00:15:16,000 --> 00:15:23,000
+Another guideline that we partially discussed recommendations that is also follows from the previous
+
+176
+00:15:23,000 --> 00:15:24,000
+one.
+
+177
+00:15:24,000 --> 00:15:28,000
+Avoid obliging and point resource names.
+
+178
+00:15:28,000 --> 00:15:37,000
+In fact, branch names can actually create confusion in your API as developers struggle to guess and
+
+179
+00:15:37,000 --> 00:15:40,000
+sometimes understand the names you have chosen.
+
+180
+00:15:40,000 --> 00:15:45,000
+For example, there is no need to use tell no end point.
+
+181
+00:15:45,000 --> 00:15:48,000
+It is better to use phone number.
+
+182
+00:15:48,000 --> 00:15:55,000
+Another simple but also important recommendation is to avoid using special characters.
+
+183
+00:15:55,000 --> 00:16:00,000
+I understand that this is logical, but still it is a guideline to remember.
+
+184
+00:16:01,000 --> 00:16:07,000
+Sinks like person signed 20 which represents the space character should not be used either.
+
+185
+00:16:08,000 --> 00:16:15,000
+Again, Z is in itself already goes against the intuitive naming convention.
+
+186
+00:16:15,000 --> 00:16:23,000
+So try to avoid using characters like person signed 20 in your naming as those have other meanings already.
+
+187
+00:16:24,000 --> 00:16:28,000
+We review today a lot of guidelines and recommendations.
+
+188
+00:16:28,000 --> 00:16:35,000
+And the last but not the least guideline is about consistency in your API because consistency is a key
+
+189
+00:16:35,000 --> 00:16:38,000
+and it deserves special recognition.
+
+190
+00:16:39,000 --> 00:16:47,000
+Always use the same name to refer to a given concept within your API, because even in case you follow
+
+191
+00:16:47,000 --> 00:16:51,000
+all other guidelines that we reviewed, they were nothing.
+
+192
+00:16:51,000 --> 00:16:54,000
+If your API is inconsistent.
+
+193
+00:16:55,000 --> 00:16:57,000
+That's all what I wanted to share with you today.
+
+194
+00:16:57,000 --> 00:17:01,000
+Let's recap what we have learned in the lesson.
+
+195
+00:17:01,000 --> 00:17:07,000
+Today we learn two key principles and guidelines that are recommended to follow while designing your
+
+196
+00:17:07,000 --> 00:17:09,000
+Rest API and RESTful services.
+
+197
+00:17:09,000 --> 00:17:15,000
+We learned such guidelines use nouns to represent resources, not verbs.
+
+198
+00:17:15,000 --> 00:17:24,000
+We use pluralized nouns for resources, use hyphens and lowercase use forward slashes for Iraqi but
+
+199
+00:17:24,000 --> 00:17:33,000
+not trailing forward slash avoid using file extensions API versioning use query parameters punctuation
+
+200
+00:17:33,000 --> 00:17:38,000
+for lists intuitive names No jargon no abridging.
+
+201
+00:17:39,000 --> 00:17:41,000
+Avoid using special characters.
+
+202
+00:17:41,000 --> 00:17:43,000
+Keep your API consistent.
+
+203
+00:17:44,000 --> 00:17:45,000
+That's it.
+
+204
+00:17:45,000 --> 00:17:47,000
+Thanks a lot for your attention.
+
+205
+00:17:47,000 --> 00:17:50,000
+Have a great day and see you in the next lesson.
+
diff --git a/91 - REST Architecture/003 RESTful Service Implementation with Spring MVC_en.srt b/91 - REST Architecture/003 RESTful Service Implementation with Spring MVC_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..eacd0af52fe7543e215a84887e6d8a7aa334372d
--- /dev/null
+++ b/91 - REST Architecture/003 RESTful Service Implementation with Spring MVC_en.srt
@@ -0,0 +1,1092 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:15,000
+By this moment in our course, we learned what raster architecture is and learned RESTful service naming
+
+3
+00:00:15,000 --> 00:00:16,000
+convention.
+
+4
+00:00:16,000 --> 00:00:24,000
+We are ready to jump to the practical exercises and start implementation of our own restful service.
+
+5
+00:00:24,000 --> 00:00:30,000
+I must admit that there are different frameworks, different tools, and different programming languages
+
+6
+00:00:30,000 --> 00:00:33,000
+that you can use to create restful service.
+
+7
+00:00:33,000 --> 00:00:37,000
+In this lesson, we are going to create our restful service using Spring MVC.
+
+8
+00:00:37,000 --> 00:00:43,000
+We will start our lesson with the configuration of the required dependencies.
+
+9
+00:00:43,000 --> 00:00:48,000
+Then we will jump to creation of our first custom rest web service.
+
+10
+00:00:48,000 --> 00:00:55,000
+I'm going to explain you how to use rest controller annotation and how it is different from the controller
+
+11
+00:00:55,000 --> 00:00:56,000
+annotation.
+
+12
+00:00:56,000 --> 00:01:01,000
+We will learn such annotations and configurations as response body.
+
+13
+00:01:01,000 --> 00:01:08,000
+Request body pass a variable request param response status response entity.
+
+14
+00:01:08,000 --> 00:01:15,000
+And at the end of the lesson I'm going to show you how we can read HTTP headers in rest controller We
+
+15
+00:01:15,000 --> 00:01:17,000
+are request header annotation.
+
+16
+00:01:18,000 --> 00:01:24,000
+Let's start our lesson and take into account that this is going to be practical lesson.
+
+17
+00:01:24,000 --> 00:01:27,000
+Let's jump to practical exercises.
+
+18
+00:01:27,000 --> 00:01:32,000
+As always, you can find source code examples in attachments to the lesson.
+
+19
+00:01:33,000 --> 00:01:38,000
+Feel free to clone the repository and run the code examples from the lesson locally.
+
+20
+00:01:39,000 --> 00:01:41,000
+I'm starting screen sharing.
+
+21
+00:01:41,000 --> 00:01:48,000
+Just a reminder that this is the lesson about creation of restful service with spring MVC, but not
+
+22
+00:01:48,000 --> 00:01:51,000
+about spring MVC itself.
+
+23
+00:01:51,000 --> 00:01:54,000
+So my assumption is that you have clear understanding already.
+
+24
+00:01:54,000 --> 00:02:00,000
+What is spring MVC is, you know, how to configure component scanning of the elements, how to declare
+
+25
+00:02:00,000 --> 00:02:04,000
+configuration, how to use web application, initializer.
+
+26
+00:02:04,000 --> 00:02:10,000
+I will not stop on the questions that we have already learned in the spring MVC section of my course.
+
+27
+00:02:10,000 --> 00:02:12,000
+Java from zero to first job.
+
+28
+00:02:12,000 --> 00:02:18,000
+If you would like to learn more, feel free to check the section of the course about Spring MVC where
+
+29
+00:02:18,000 --> 00:02:23,000
+I explained in the details how to kick off spring MVC application.
+
+30
+00:02:24,000 --> 00:02:28,000
+Okay, let's continue with the dependencies overview.
+
+31
+00:02:28,000 --> 00:02:35,000
+If you follow my course Java from zero to first job where we implement our own online shop from scratch,
+
+32
+00:02:35,000 --> 00:02:41,000
+then you should already have all required dependencies in your pom.xml file declared.
+
+33
+00:02:41,000 --> 00:02:46,000
+But just in case you jump directly to this lesson, let me recap.
+
+34
+00:02:46,000 --> 00:02:53,000
+What are the key dependencies should be present in the classpath in order you can succeed with examples
+
+35
+00:02:53,000 --> 00:02:55,000
+from this lesson.
+
+36
+00:02:55,000 --> 00:03:01,000
+The main thing is that you have spring MVC dependency, spring context and Jackson data bind.
+
+37
+00:03:02,000 --> 00:03:06,000
+These dependencies are the key for today's examples.
+
+38
+00:03:06,000 --> 00:03:13,000
+The rest of the dependencies depend on the tools and frameworks that you are going to use on the persistence
+
+39
+00:03:13,000 --> 00:03:14,000
+level.
+
+40
+00:03:14,000 --> 00:03:20,000
+If you follow my course Java from zero to first job, then by this moment in our course you already
+
+41
+00:03:20,000 --> 00:03:28,000
+learned how to work with Spring data JPA and Spring JDBC and can work with any of these tools on the
+
+42
+00:03:28,000 --> 00:03:29,000
+persistence layer.
+
+43
+00:03:30,000 --> 00:03:35,000
+So I assume that you can add all relevant dependencies for the persistence layer.
+
+44
+00:03:36,000 --> 00:03:43,000
+All examples that I prepared for this lesson are located under the rest package in the user rest controller
+
+45
+00:03:43,000 --> 00:03:44,000
+class.
+
+46
+00:03:44,000 --> 00:03:51,000
+All other classes that are going to be used today were reviewed in previous lessons, so I wouldn't
+
+47
+00:03:51,000 --> 00:03:51,000
+stop on them.
+
+48
+00:03:52,000 --> 00:04:00,000
+For example, pay attention that I inject user service here and user service in turn uses user repository.
+
+49
+00:04:01,000 --> 00:04:07,000
+As I said, if you want to get more detailed comments about persistence layer, feel free to check previous
+
+50
+00:04:07,000 --> 00:04:14,000
+lessons from my course Java from zero to first job about spring data, JPA and Spring JDBC.
+
+51
+00:04:14,000 --> 00:04:20,000
+And in this lesson we will focus only on designing of our rest endpoints.
+
+52
+00:04:20,000 --> 00:04:25,000
+And the first concept that we need to talk about is understanding the difference between controller
+
+53
+00:04:25,000 --> 00:04:27,000
+and rest controller.
+
+54
+00:04:27,000 --> 00:04:35,000
+So when we implement controller in spring, usually we market with controller annotation.
+
+55
+00:04:35,000 --> 00:04:42,000
+This is just a specialization of the component annotation that we use to mark our components in order.
+
+56
+00:04:42,000 --> 00:04:45,000
+Spring can manage life cycles of these beans.
+
+57
+00:04:45,000 --> 00:04:50,000
+It allows to auto detect implementation classes by classpath scanning.
+
+58
+00:04:51,000 --> 00:04:56,000
+Rest controller is a specialized version of the controller annotation.
+
+59
+00:04:56,000 --> 00:05:02,000
+If we open source code of rest controller annotation we would notice it is.
+
+60
+00:05:02,000 --> 00:05:07,000
+Is marked with controller annotation and response body annotation.
+
+61
+00:05:07,000 --> 00:05:09,000
+So in simple words.
+
+62
+00:05:09,000 --> 00:05:16,000
+Rest controller annotation is just a combination of controller and response body annotations.
+
+63
+00:05:16,000 --> 00:05:23,000
+This simplifies the implementation from the development side because in case you use rest controller.
+
+64
+00:05:23,000 --> 00:05:27,000
+Annotation you should not use response body annotation.
+
+65
+00:05:27,000 --> 00:05:30,000
+So what does response body annotation do?
+
+66
+00:05:30,000 --> 00:05:37,000
+This annotation tells the controller that the object returned should be serialized into the JSON format
+
+67
+00:05:37,000 --> 00:05:41,000
+and passed back in the HTTP response body.
+
+68
+00:05:41,000 --> 00:05:46,000
+That's why we added Jackson data bind in our dependencies.
+
+69
+00:05:47,000 --> 00:05:52,000
+Jackson Library is responsible for this JSON serialization.
+
+70
+00:05:52,000 --> 00:06:00,000
+In the example you can see that I can add produces attribute and specify media type that this endpoint
+
+71
+00:06:00,000 --> 00:06:06,000
+supposed to produce response body will consider this configuration.
+
+72
+00:06:06,000 --> 00:06:14,000
+In this example, I vividly specified that JSON value will be returned, but JSON is used by default.
+
+73
+00:06:15,000 --> 00:06:22,000
+I can open media type class just to show you that there are different constants available that you can
+
+74
+00:06:22,000 --> 00:06:24,000
+specify instead of the JSON.
+
+75
+00:06:24,000 --> 00:06:31,000
+Theoretically you can have multiple end points that are mapped to the same path, but that just produces
+
+76
+00:06:31,000 --> 00:06:33,000
+output of different type.
+
+77
+00:06:33,000 --> 00:06:41,000
+Depending on the accept header of the HTTP request, it will be identified which endpoint will be invoked,
+
+78
+00:06:41,000 --> 00:06:45,000
+and the first endpoint that is declared here is relatively simple.
+
+79
+00:06:45,000 --> 00:06:52,000
+I just extract all users from the persistence layer and return the list of users.
+
+80
+00:06:52,000 --> 00:06:54,000
+So what will actually happen?
+
+81
+00:06:54,000 --> 00:07:01,000
+Taking into account this is a rest controller, my list of users will be serialized into the JSON array
+
+82
+00:07:01,000 --> 00:07:03,000
+and returned from the method.
+
+83
+00:07:04,000 --> 00:07:09,000
+I'm going to show you this when we will come to testing of our API.
+
+84
+00:07:10,000 --> 00:07:13,000
+There is also annotations that is called request body.
+
+85
+00:07:13,000 --> 00:07:16,000
+It is not the same as response body.
+
+86
+00:07:16,000 --> 00:07:20,000
+So let's find out what is the difference in simple words.
+
+87
+00:07:20,000 --> 00:07:30,000
+The request body annotation Deserialize The HTTP request body into a Java object like this, we can
+
+88
+00:07:30,000 --> 00:07:33,000
+pass resources to the restful service.
+
+89
+00:07:33,000 --> 00:07:37,000
+For example, we can send JSON of our user object.
+
+90
+00:07:37,000 --> 00:07:46,000
+We have post method in order to create resource and in our method insert user you can see how I use
+
+91
+00:07:46,000 --> 00:07:48,000
+request body annotation.
+
+92
+00:07:48,000 --> 00:07:56,000
+Basically it will be again deserialized with the help of spring and Jackson data bind into the Java
+
+93
+00:07:56,000 --> 00:08:05,000
+object and then I will use this Java object to store in my persistent storage by default the type we
+
+94
+00:08:05,000 --> 00:08:12,000
+annotate with the request body annotation must correspond to the JSON sent from our client.
+
+95
+00:08:12,000 --> 00:08:19,000
+The next thing that we need to know in order to use it efficiently while implementing our restful service
+
+96
+00:08:19,000 --> 00:08:27,000
+is pass variable annotation pass Verbal annotation can be used to handle template variables in the request
+
+97
+00:08:27,000 --> 00:08:32,000
+URI mapping and set them as method parameters.
+
+98
+00:08:32,000 --> 00:08:39,000
+Like for example, you can see in the get user buy method, you can see that in the UI.
+
+99
+00:08:39,000 --> 00:08:47,000
+I used variable and in the method parameters I use pass variable annotation in order to tell the spring
+
+100
+00:08:47,000 --> 00:08:55,000
+that this variable value should be injected into this method argument in order, I can use it in the
+
+101
+00:08:55,000 --> 00:09:02,000
+method during the implementation of the endpoint, you can use multiple pass variables as much as you
+
+102
+00:09:02,000 --> 00:09:05,000
+need and to handle multiple pass variables.
+
+103
+00:09:05,000 --> 00:09:10,000
+We can use map like you can see here in the command line.
+
+104
+00:09:10,000 --> 00:09:17,000
+By default, values for all pass variables are mandatory in case it will be needed.
+
+105
+00:09:17,000 --> 00:09:25,000
+You can set required attribute of pass variable to false because in case you would leave pass variable
+
+106
+00:09:25,000 --> 00:09:33,000
+as required and you wouldn't send it, exception will be produced, but actually usually we specify
+
+107
+00:09:33,000 --> 00:09:36,000
+pass variables to make them required.
+
+108
+00:09:36,000 --> 00:09:40,000
+So you shouldn't do something which is not logical during the development.
+
+109
+00:09:40,000 --> 00:09:43,000
+Just be aware that you have such tool set.
+
+110
+00:09:44,000 --> 00:09:52,000
+If you want to use optional API, then you can map pass variable with optional what optional API is
+
+111
+00:09:52,000 --> 00:09:54,000
+and when to use it.
+
+112
+00:09:54,000 --> 00:10:01,000
+You can check in the separate lesson in my course, but just quickly to remind you this API helps you
+
+113
+00:10:01,000 --> 00:10:02,000
+to handle different.
+
+114
+00:10:03,000 --> 00:10:06,000
+This was no values, including no checks.
+
+115
+00:10:06,000 --> 00:10:13,000
+And setting some default values in case is a reason now and many, many other different things.
+
+116
+00:10:13,000 --> 00:10:18,000
+The next important configurations that we are going to use in our restful services.
+
+117
+00:10:18,000 --> 00:10:23,000
+Building it with spring MVC is request param annotation.
+
+118
+00:10:23,000 --> 00:10:29,000
+Request parameterization helps us to extract query parameters from the request.
+
+119
+00:10:29,000 --> 00:10:36,000
+Like in this example, when I want to fetch all users filtering them by the first name, you can see
+
+120
+00:10:36,000 --> 00:10:39,000
+that first name is a query parameter.
+
+121
+00:10:39,000 --> 00:10:42,000
+In this case it is not pass variable.
+
+122
+00:10:42,000 --> 00:10:52,000
+Also pay attention that the resource name is the same in different request mapping users and in order
+
+123
+00:10:52,000 --> 00:10:59,000
+to not have an exception, that tells us that I have multiple same request mappings, I need to keep
+
+124
+00:10:59,000 --> 00:11:07,000
+them different In case you would use different request method, the endpoints will become different.
+
+125
+00:11:07,000 --> 00:11:16,000
+But in this particular case, everywhere I use get request method and in real life too you may have
+
+126
+00:11:16,000 --> 00:11:24,000
+end point with the same name, same request method and you need to come up how to make these endpoints
+
+127
+00:11:24,000 --> 00:11:25,000
+different.
+
+128
+00:11:26,000 --> 00:11:33,000
+I can keep them different by specifying the request parameters, but how was the question mark in the
+
+129
+00:11:33,000 --> 00:11:36,000
+URI to keep them different?
+
+130
+00:11:36,000 --> 00:11:39,000
+You don't need to use question mark in the URL mapping.
+
+131
+00:11:40,000 --> 00:11:47,000
+What you have to do instead is to use params attribute in order to specify parameters name.
+
+132
+00:11:47,000 --> 00:11:54,000
+This is how spring will differentiate endpoints with the same resource name but with different query
+
+133
+00:11:54,000 --> 00:11:55,000
+parameters.
+
+134
+00:11:55,000 --> 00:12:01,000
+It is important for you to understand that we are talking about not pass variable here.
+
+135
+00:12:02,000 --> 00:12:05,000
+But the way how we work with it is similar.
+
+136
+00:12:05,000 --> 00:12:13,000
+You use request param annotation with the type and request parameter is injected into the method parameter.
+
+137
+00:12:13,000 --> 00:12:19,000
+This is the simplest and the most common use case of using request parameter annotation.
+
+138
+00:12:20,000 --> 00:12:27,000
+In the next example, you can see that I declared sort by request parameter and you can build logic
+
+139
+00:12:27,000 --> 00:12:31,000
+for sorting based on the value passed with this parameter.
+
+140
+00:12:31,000 --> 00:12:39,000
+In this example, in case somebody passed first name field, in this case I sort results by the first
+
+141
+00:12:39,000 --> 00:12:40,000
+name.
+
+142
+00:12:40,000 --> 00:12:43,000
+Otherwise I just return all users.
+
+143
+00:12:44,000 --> 00:12:48,000
+Also created a few more requests parameter demo methods.
+
+144
+00:12:48,000 --> 00:12:50,000
+Let's review them together.
+
+145
+00:12:50,000 --> 00:12:56,000
+You can use request parameter with optional in order to get benefits of the optional API.
+
+146
+00:12:56,000 --> 00:13:01,000
+You can specify whether the request parameter is required or no.
+
+147
+00:13:01,000 --> 00:13:09,000
+In this case I specified that the request parameter is not mandatory and in case it will be absent there
+
+148
+00:13:09,000 --> 00:13:11,000
+will not be any error.
+
+149
+00:13:11,000 --> 00:13:19,000
+In case you expect to process multiple request parameters, you can use request parameter notation together
+
+150
+00:13:19,000 --> 00:13:22,000
+with map during the program execution.
+
+151
+00:13:22,000 --> 00:13:30,000
+All your request parameters will be injected into the map and after that you can iterate over the entries
+
+152
+00:13:30,000 --> 00:13:33,000
+set to interact with the parameters.
+
+153
+00:13:33,000 --> 00:13:41,000
+What to do In case I want to have endpoints that would read form data request parameters similar to
+
+154
+00:13:41,000 --> 00:13:45,000
+the ones that we send via HTML forms.
+
+155
+00:13:45,000 --> 00:13:49,000
+But note that we pass after the question mark in the URI.
+
+156
+00:13:50,000 --> 00:13:56,000
+In this case, you can vividly specify what type of data is consumed by this endpoint.
+
+157
+00:13:56,000 --> 00:14:04,000
+You can declare the JSON point, consumes application form data and in this case you don't need to use
+
+158
+00:14:04,000 --> 00:14:06,000
+request param annotation.
+
+159
+00:14:06,000 --> 00:14:09,000
+You need to use request body annotation.
+
+160
+00:14:10,000 --> 00:14:16,000
+This annotation will help you to inject key value pairs into multi-value map object.
+
+161
+00:14:16,000 --> 00:14:24,000
+Also, in case one parameter has multiple values, you can map values into the list like you can see
+
+162
+00:14:24,000 --> 00:14:26,000
+in the following example.
+
+163
+00:14:26,000 --> 00:14:31,000
+You can see in the command lines that this can be applied to the cases.
+
+164
+00:14:31,000 --> 00:14:37,000
+When you have list of the separate parameters or just comma separated values.
+
+165
+00:14:38,000 --> 00:14:42,000
+There is also an option to specify default value for the request param.
+
+166
+00:14:43,000 --> 00:14:49,000
+I encourage you to look through the source code of the annotation and read attribute names.
+
+167
+00:14:49,000 --> 00:14:54,000
+In most cases they are self describing requisite default value, for example.
+
+168
+00:14:54,000 --> 00:15:01,000
+And even in case you have any questions, please feel free to post your questions below the video and
+
+169
+00:15:01,000 --> 00:15:03,000
+I will be happy to answer.
+
+170
+00:15:03,000 --> 00:15:08,000
+Let's learn now how to use response status in Spring MVC.
+
+171
+00:15:08,000 --> 00:15:15,000
+You have opportunity to set the status code of an HTTP response if you want to set response status of
+
+172
+00:15:15,000 --> 00:15:16,000
+your controller method.
+
+173
+00:15:17,000 --> 00:15:24,000
+You can just use annotation response status over the method like you can see in this example.
+
+174
+00:15:24,000 --> 00:15:31,000
+You may need to set up different statuses based on the defined and agreed contract.
+
+175
+00:15:31,000 --> 00:15:36,000
+You can use response status just with HTTP status code.
+
+176
+00:15:36,000 --> 00:15:39,000
+Or you can also specify the reason.
+
+177
+00:15:40,000 --> 00:15:44,000
+Reason will be specified as a separate message in the response.
+
+178
+00:15:44,000 --> 00:15:46,000
+Here you can see an example.
+
+179
+00:15:46,000 --> 00:15:51,000
+In this case I return I'm a post response status.
+
+180
+00:15:51,000 --> 00:15:56,000
+This response status is equivalent to the 418 status code.
+
+181
+00:15:57,000 --> 00:15:59,000
+The HTTP 418.
+
+182
+00:15:59,000 --> 00:16:00,000
+I'm a teapot.
+
+183
+00:16:00,000 --> 00:16:08,000
+Client error response code indicates that the server refuses to brew coffee because it is permanently
+
+184
+00:16:08,000 --> 00:16:09,000
+teapot.
+
+185
+00:16:10,000 --> 00:16:10,000
+Yes.
+
+186
+00:16:10,000 --> 00:16:12,000
+This is an interesting joke.
+
+187
+00:16:13,000 --> 00:16:21,000
+This error message was designed as a one of the April Fools jokes, and the error states that any teapot
+
+188
+00:16:21,000 --> 00:16:26,000
+that has been asked to brew coffee shall respond with this message.
+
+189
+00:16:27,000 --> 00:16:31,000
+Funnily enough, also the status code is not used.
+
+190
+00:16:31,000 --> 00:16:34,000
+It is supported by many HTTP libraries.
+
+191
+00:16:34,000 --> 00:16:42,000
+Some time ago there was an effort to have this error removed so that the number can be used in an official
+
+192
+00:16:42,000 --> 00:16:43,000
+capacity.
+
+193
+00:16:43,000 --> 00:16:52,000
+However, this was met with a resistance and led to the creation of the SAFE 418 initiative.
+
+194
+00:16:52,000 --> 00:16:56,000
+As such, the message and status code remain.
+
+195
+00:16:56,000 --> 00:17:03,000
+Also, you can specify HTTP status as a return type if you wish, and after processing the request,
+
+196
+00:17:03,000 --> 00:17:05,000
+you can return the status.
+
+197
+00:17:05,000 --> 00:17:13,000
+For example, when we delete user, there is no resource that we can return after sending the request,
+
+198
+00:17:13,000 --> 00:17:20,000
+we via delete method to user's resource and return no content status but attention.
+
+199
+00:17:21,000 --> 00:17:29,000
+In this case it will be returned as message body because response status code will actually be 200.
+
+200
+00:17:30,000 --> 00:17:31,000
+Be attentive with that.
+
+201
+00:17:32,000 --> 00:17:38,000
+If we want to have different status code in response, you need to use response status annotation.
+
+202
+00:17:39,000 --> 00:17:47,000
+In case user has been successfully created and inserted, I send confirmation create it will be returned
+
+203
+00:17:47,000 --> 00:17:48,000
+in response body.
+
+204
+00:17:49,000 --> 00:17:55,000
+When I send request was put method to update the resource and in case the resource has been updated,
+
+205
+00:17:56,000 --> 00:17:58,000
+return accepted status.
+
+206
+00:17:59,000 --> 00:18:02,000
+But what to do in case I need more flexibility?
+
+207
+00:18:02,000 --> 00:18:10,000
+And like in this case I want to identify what response status to return during the execution.
+
+208
+00:18:10,000 --> 00:18:11,000
+And not always.
+
+209
+00:18:11,000 --> 00:18:16,000
+I can specify it in the annotation before methods gets executed.
+
+210
+00:18:16,000 --> 00:18:18,000
+There are different workarounds that you can apply.
+
+211
+00:18:18,000 --> 00:18:23,000
+One of them is to work with the HTTP response object directly.
+
+212
+00:18:23,000 --> 00:18:26,000
+Another one is to use response entity.
+
+213
+00:18:26,000 --> 00:18:30,000
+So let's learn how to work with the response entity object.
+
+214
+00:18:31,000 --> 00:18:37,000
+If you are familiar with Spring framework, then you know that there are different ways of how you can
+
+215
+00:18:37,000 --> 00:18:39,000
+achieve the same result in spring.
+
+216
+00:18:39,000 --> 00:18:43,000
+The similar story is here you have different options.
+
+217
+00:18:43,000 --> 00:18:45,000
+How to tune your HTTP response.
+
+218
+00:18:45,000 --> 00:18:51,000
+And I prepared examples for you to show how you can tune HTTP response via response.
+
+219
+00:18:51,000 --> 00:19:00,000
+Entity response Entity is a type to represent the whole HTTP response, including status code headers
+
+220
+00:19:00,000 --> 00:19:01,000
+and response body.
+
+221
+00:19:02,000 --> 00:19:04,000
+Do you use response entity?
+
+222
+00:19:04,000 --> 00:19:11,000
+You need to declare it as return type of your method and spring will take the rest with regards to processing
+
+223
+00:19:11,000 --> 00:19:14,000
+this object and preparing the response.
+
+224
+00:19:15,000 --> 00:19:17,000
+Let's look at examples.
+
+225
+00:19:17,000 --> 00:19:22,000
+In the first example you can see that I set return type as response entity.
+
+226
+00:19:22,000 --> 00:19:31,000
+Important thing is that there are builders that you can use to build response entity to static masses
+
+227
+00:19:31,000 --> 00:19:38,000
+will return object of header builder type and four methods will return object of body builder type.
+
+228
+00:19:38,000 --> 00:19:41,000
+Body builder extends header builder.
+
+229
+00:19:41,000 --> 00:19:50,000
+In this example I invoke okay method and they use body builder to create response entity with the header
+
+230
+00:19:50,000 --> 00:19:55,000
+method I can specify header with the body mass that I can specify body.
+
+231
+00:19:55,000 --> 00:20:01,000
+I believe everything is clear and there is no need in the additional explanation because methods are
+
+232
+00:20:01,000 --> 00:20:02,000
+self-describing.
+
+233
+00:20:03,000 --> 00:20:10,000
+And of course remember that in case something is not clear to you, you can always ask your questions
+
+234
+00:20:10,000 --> 00:20:14,000
+below the video in comments and I will be happy to answer.
+
+235
+00:20:15,000 --> 00:20:18,000
+There is also another way to create response entity.
+
+236
+00:20:18,000 --> 00:20:21,000
+You can see commanded lines here.
+
+237
+00:20:21,000 --> 00:20:26,000
+Basically you can create response entity object with a new keyword.
+
+238
+00:20:26,000 --> 00:20:34,000
+In this particular example, I created headers and then I created Object of the Response entity type
+
+239
+00:20:34,000 --> 00:20:40,000
+using constructor with response body headers and HTTP status.
+
+240
+00:20:40,000 --> 00:20:46,000
+You can check the source code and make sure that there are different constructors that you can use to
+
+241
+00:20:46,000 --> 00:20:49,000
+create response entity object.
+
+242
+00:20:49,000 --> 00:20:56,000
+And the last but not the least for today, let's learn how to read HTTP headers in rest controller.
+
+243
+00:20:56,000 --> 00:21:03,000
+You can use request header annotation to read headers individually as well as all together.
+
+244
+00:21:04,000 --> 00:21:11,000
+In the first example here you can see how I put request header annotation before the parameter.
+
+245
+00:21:11,000 --> 00:21:14,000
+I believe you already know how this will work.
+
+246
+00:21:14,000 --> 00:21:20,000
+Spring will take care of injecting the request header value into the parameter.
+
+247
+00:21:20,000 --> 00:21:25,000
+Basically you just need to specify which request header you want to parse.
+
+248
+00:21:26,000 --> 00:21:32,000
+You can use one of the constants of the HTTP headers like you can see in this example.
+
+249
+00:21:33,000 --> 00:21:35,000
+Basically that will be enough.
+
+250
+00:21:35,000 --> 00:21:43,000
+Optionally, you can use required attribute to specify whether this request header is required or no
+
+251
+00:21:43,000 --> 00:21:51,000
+default is set to true, which causes an exception in case such header is absent.
+
+252
+00:21:51,000 --> 00:21:54,000
+Alternatively, you can provide a default value.
+
+253
+00:21:55,000 --> 00:22:02,000
+In this case, you will not receive exception because of missing value due to the default value is there.
+
+254
+00:22:02,000 --> 00:22:09,000
+In the second example you can see how I use request header annotation with the map parameter.
+
+255
+00:22:09,000 --> 00:22:17,000
+This will lead us to reading of all request headers and inject all the values into the map together
+
+256
+00:22:17,000 --> 00:22:19,000
+with the request headers names.
+
+257
+00:22:19,000 --> 00:22:27,000
+In this particular example, I just iterate over all headers and brings them to console and in response
+
+258
+00:22:27,000 --> 00:22:29,000
+I return total amount of headers.
+
+259
+00:22:30,000 --> 00:22:31,000
+That's it.
+
+260
+00:22:31,000 --> 00:22:37,000
+We learned a lot today and created our restful service with Spring MVC.
+
+261
+00:22:37,000 --> 00:22:44,000
+We still have to learn how to test our restful service, but I would keep this topic for our next lesson,
+
+262
+00:22:44,000 --> 00:22:46,000
+so stay tuned.
+
+263
+00:22:47,000 --> 00:22:51,000
+And now let's recap what we have learned in the lesson.
+
+264
+00:22:51,000 --> 00:22:56,000
+In this lesson, we learned how to create restful service with Spring MVC.
+
+265
+00:22:57,000 --> 00:23:00,000
+We learned and configured all required dependencies.
+
+266
+00:23:00,000 --> 00:23:06,000
+Now you know the difference between rest controller and controller annotations in spring.
+
+267
+00:23:07,000 --> 00:23:14,000
+I explained you what the response body annotation is among other annotations and configurations that
+
+268
+00:23:14,000 --> 00:23:16,000
+we learned during the lesson.
+
+269
+00:23:16,000 --> 00:23:24,000
+It is worth to mention request body pass, variable request param response status response entity and
+
+270
+00:23:24,000 --> 00:23:29,000
+request header to read http headers in rest controller.
+
+271
+00:23:29,000 --> 00:23:31,000
+That's all for today.
+
+272
+00:23:31,000 --> 00:23:33,000
+Thanks a lot for your attention.
+
+273
+00:23:33,000 --> 00:23:36,000
+Have a great day and see you in the next lesson.
+
diff --git a/91 - REST Architecture/003 Source-code-of-examples-commit-with-changes-.url b/91 - REST Architecture/003 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..a011523c1e4e82331494159081fca3ca74640717
--- /dev/null
+++ b/91 - REST Architecture/003 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/5f6b4f695bb88865978fb7cbe622855783c17cfa
\ No newline at end of file
diff --git a/91 - REST Architecture/004 Review of tools for API testing & Postman Installation_en.srt b/91 - REST Architecture/004 Review of tools for API testing & Postman Installation_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..154dd2102202d2ae6248ff1922d752e13fa62d4e
--- /dev/null
+++ b/91 - REST Architecture/004 Review of tools for API testing & Postman Installation_en.srt
@@ -0,0 +1,664 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:11,000
+In this video lesson, we are going to make an overview of the tools for testing.
+
+3
+00:00:12,000 --> 00:00:19,000
+I believe that this will give you directions for further learning and you will understand what you need
+
+4
+00:00:19,000 --> 00:00:22,000
+and what to suit your needs is the best.
+
+5
+00:00:23,000 --> 00:00:29,000
+During the review of the API testing tools, I will make a short overview of soap messaging protocol
+
+6
+00:00:29,000 --> 00:00:33,000
+and tools for testing web services that use soap.
+
+7
+00:00:34,000 --> 00:00:39,000
+I will focus your attention on the three very popular tools for testing.
+
+8
+00:00:39,000 --> 00:00:44,000
+They are Postman, Fiddler and Wireshark.
+
+9
+00:00:44,000 --> 00:00:49,000
+We will compare them between each other and the remaining part of the lesson.
+
+10
+00:00:49,000 --> 00:00:54,000
+We are going to talk about postman comparison of desktop and web version.
+
+11
+00:00:54,000 --> 00:01:00,000
+By the end of this lesson you are going to have postman installed on your computer and you will be prepared
+
+12
+00:01:00,000 --> 00:01:01,000
+for the following lessons.
+
+13
+00:01:01,000 --> 00:01:03,000
+Let's start our lesson.
+
+14
+00:01:04,000 --> 00:01:07,000
+Let's review tools for API testing.
+
+15
+00:01:07,000 --> 00:01:10,000
+There are several tools available for API testing.
+
+16
+00:01:10,000 --> 00:01:12,000
+Here are some popular ones.
+
+17
+00:01:13,000 --> 00:01:14,000
+Postman.
+
+18
+00:01:14,000 --> 00:01:21,000
+Postman is a popular tool for API testing that allows you to send requests and analyze responses in
+
+19
+00:01:21,000 --> 00:01:23,000
+a user friendly interface.
+
+20
+00:01:23,000 --> 00:01:29,000
+We are going to talk about it more in this video and in the following ones.
+
+21
+00:01:29,000 --> 00:01:30,000
+Fiddler.
+
+22
+00:01:30,000 --> 00:01:35,000
+It is indeed another popular tool for testing and debugging.
+
+23
+00:01:35,000 --> 00:01:43,000
+Particularly for analyzing and manipulating http https traffic between a client and the server.
+
+24
+00:01:43,000 --> 00:01:50,000
+It offers features like request interception, debugging, and performance testing.
+
+25
+00:01:51,000 --> 00:01:56,000
+Wireshark is another popular tool that can be used for testing and debugging.
+
+26
+00:01:56,000 --> 00:02:04,000
+It is a network protocol analyzer that captures and displays network packets in real time, allowing
+
+27
+00:02:04,000 --> 00:02:10,000
+you to inspect the details of the packets exchanged between the client and the server.
+
+28
+00:02:10,000 --> 00:02:18,000
+While Wireshark may not be specialized for API testing as some of other tools I mentioned earlier,
+
+29
+00:02:18,000 --> 00:02:27,000
+it can still be a useful tool for troubleshooting and diagnosing network related issues in communication.
+
+30
+00:02:27,000 --> 00:02:35,000
+So in addition to the tools I mentioned earlier, Wireshark is also a valuable tool for testing and
+
+31
+00:02:35,000 --> 00:02:36,000
+debugging.
+
+32
+00:02:37,000 --> 00:02:38,000
+Swap UI.
+
+33
+00:02:38,000 --> 00:02:47,000
+Swap UI is an open source API testing tool that allows you to create and run automated functional regression
+
+34
+00:02:47,000 --> 00:02:51,000
+compliance and load tests for rest and soap APIs.
+
+35
+00:02:51,000 --> 00:02:54,000
+But what is soap?
+
+36
+00:02:54,000 --> 00:02:58,000
+Soap stands for Simple Object Access Protocol.
+
+37
+00:02:58,000 --> 00:03:04,000
+It is a messaging protocol that is used to exchange structure data between different applications over
+
+38
+00:03:04,000 --> 00:03:05,000
+the Internet.
+
+39
+00:03:05,000 --> 00:03:15,000
+It relies on XML as its message format and is typically used in web services to send requests and receive
+
+40
+00:03:15,000 --> 00:03:16,000
+responses.
+
+41
+00:03:17,000 --> 00:03:23,000
+Soap is a tool used for testing and developing web services that use soap.
+
+42
+00:03:24,000 --> 00:03:25,000
+Insomnia.
+
+43
+00:03:25,000 --> 00:03:34,000
+Insomnia is a free and open source rest client that enables you to send HTTP requests and user response
+
+44
+00:03:34,000 --> 00:03:36,000
+in a user friendly interface.
+
+45
+00:03:37,000 --> 00:03:38,000
+G matter.
+
+46
+00:03:38,000 --> 00:03:45,000
+Apache G matter is a popular open source tool for load testing and performance measurement of APIs,
+
+47
+00:03:45,000 --> 00:03:48,000
+web applications and other services.
+
+48
+00:03:49,000 --> 00:03:49,000
+You, man.
+
+49
+00:03:50,000 --> 00:03:56,000
+It is a common line tools that allows you to run and test postman collections from the command line,
+
+50
+00:03:56,000 --> 00:04:02,000
+making it a Gil for automated testing and integration with CI CD pipelines.
+
+51
+00:04:03,000 --> 00:04:09,000
+Rest assured it is a Java based library for testing restful APIs.
+
+52
+00:04:09,000 --> 00:04:17,000
+It allows you to write tests in Java and provides built in support for various HTTP methods, authentication
+
+53
+00:04:17,000 --> 00:04:19,000
+and response validation.
+
+54
+00:04:20,000 --> 00:04:25,000
+These are just few examples of the many tools available for API testing.
+
+55
+00:04:25,000 --> 00:04:32,000
+The choice of tool will depend on your specific needs, preferences and technical expertise.
+
+56
+00:04:33,000 --> 00:04:39,000
+All eight tools that I mentioned on the previous slide are really popular ones, but I would like to
+
+57
+00:04:39,000 --> 00:04:42,000
+draw your attention to three out of them.
+
+58
+00:04:42,000 --> 00:04:46,000
+They are Postman, fiddler and Wireshark.
+
+59
+00:04:47,000 --> 00:04:54,000
+I can't say that these tools are better than other API testing and debugging tools as the suitability
+
+60
+00:04:54,000 --> 00:04:58,000
+of a particular tool will depend on your specific needs and preferences.
+
+61
+00:04:58,000 --> 00:05:06,000
+However, these tools are widely used and have some advantages that make them popular choices among
+
+62
+00:05:06,000 --> 00:05:08,000
+developers and testers.
+
+63
+00:05:08,000 --> 00:05:11,000
+Postman is user friendly tools.
+
+64
+00:05:11,000 --> 00:05:17,000
+It provides a graphical user interface for creating testing and documenting APIs.
+
+65
+00:05:17,000 --> 00:05:25,000
+It supports a wide range of HTTP methods and formats and provides features like automatic request generation.
+
+66
+00:05:25,000 --> 00:05:27,000
+Code snippets and request history.
+
+67
+00:05:28,000 --> 00:05:35,000
+It is also used for easy collaboration with team members and integrates well with other tools in the
+
+68
+00:05:35,000 --> 00:05:37,000
+API development workflow.
+
+69
+00:05:37,000 --> 00:05:41,000
+Fiddler is a powerful web debugging proxy.
+
+70
+00:05:41,000 --> 00:05:49,000
+It can also be used to simulate network conditions such as low bandwidth or high latency.
+
+71
+00:05:49,000 --> 00:05:58,000
+To test the behavior of APIs under different network conditions, Wireshark is a network protocol analyzer.
+
+72
+00:05:58,000 --> 00:06:06,000
+It is often used to diagnose and troubleshoot network related issues and can be a valuable tool in identifying
+
+73
+00:06:06,000 --> 00:06:08,000
+and resolving issues.
+
+74
+00:06:09,000 --> 00:06:15,000
+Overall, the choice of tool will depend on the specific requirements of your API.
+
+75
+00:06:15,000 --> 00:06:21,000
+Testing and debugging tasks, as well as your personal preferences and experience.
+
+76
+00:06:21,000 --> 00:06:26,000
+All three tools used for debugging and testing network traffic.
+
+77
+00:06:26,000 --> 00:06:32,000
+Postman is an HTTP client that allows you to send HTTP requests and receive responses.
+
+78
+00:06:32,000 --> 00:06:40,000
+Fiddler is a web debugging proxy that captures and analyzes HTTP traffic between your computer and the
+
+79
+00:06:40,000 --> 00:06:41,000
+Internet.
+
+80
+00:06:41,000 --> 00:06:48,000
+And Wireshark is a network protocol analyzer that captures and displays network packets in real time.
+
+81
+00:06:48,000 --> 00:06:50,000
+That is a short summary.
+
+82
+00:06:50,000 --> 00:06:57,000
+So let's talk about Postman right now, because it is the most popular tool in my opinion.
+
+83
+00:06:58,000 --> 00:07:03,000
+As you already learned from the agenda today, we are going to talk about Postman.
+
+84
+00:07:04,000 --> 00:07:09,000
+I already told you on the high level about this tool during the review of previous slides.
+
+85
+00:07:09,000 --> 00:07:16,000
+In my opinion, Postman is tool number one that should be installed on your computer if you develop
+
+86
+00:07:16,000 --> 00:07:16,000
+for web.
+
+87
+00:07:17,000 --> 00:07:24,000
+It is relatively lightweight, it is super intuitive and you are going to see that it wouldn't take
+
+88
+00:07:24,000 --> 00:07:31,000
+too much time of yours to understand the interface and this is a huge advantage.
+
+89
+00:07:31,000 --> 00:07:36,000
+Let's learn this tool better to learn postman tool better.
+
+90
+00:07:36,000 --> 00:07:39,000
+Let's learn key components of this tool.
+
+91
+00:07:39,000 --> 00:07:42,000
+They are request builder.
+
+92
+00:07:42,000 --> 00:07:49,000
+Postman provides a user friendly interface for creating HTTP requests, allowing you to specify parameters
+
+93
+00:07:49,000 --> 00:07:55,000
+like HTTP method, URL headers and body response view.
+
+94
+00:07:56,000 --> 00:08:02,000
+Explore the response Status Code Size Response Time Headers Response Body.
+
+95
+00:08:03,000 --> 00:08:04,000
+Collection.
+
+96
+00:08:04,000 --> 00:08:11,000
+A collection in Postman is a group of related requests that can be organized and saved together.
+
+97
+00:08:11,000 --> 00:08:18,000
+It allows you to group and organize your requests for easier management and sharing with others.
+
+98
+00:08:18,000 --> 00:08:20,000
+Environment.
+
+99
+00:08:20,000 --> 00:08:26,000
+An environment in Postman allows you to configure variables that can be used across multiple requests.
+
+100
+00:08:27,000 --> 00:08:35,000
+This feature can be used to specify things like server URLs, authentication tokens or other parameters
+
+101
+00:08:35,000 --> 00:08:38,000
+that may change based on the environment.
+
+102
+00:08:40,000 --> 00:08:41,000
+Test scripts.
+
+103
+00:08:41,000 --> 00:08:48,000
+Postman provides a scripting feature that allows you to write JavaScript code to automate tasks, customize
+
+104
+00:08:48,000 --> 00:08:52,000
+requests, and perform assertions on responses.
+
+105
+00:08:52,000 --> 00:08:56,000
+Test scripts can be used to validate the response data.
+
+106
+00:08:56,000 --> 00:09:01,000
+Automate test cases and perform other custom operations.
+
+107
+00:09:02,000 --> 00:09:02,000
+Runner.
+
+108
+00:09:03,000 --> 00:09:09,000
+The postman runner allows it to execute a collection of requests automatically and generate reports.
+
+109
+00:09:09,000 --> 00:09:16,000
+It can be used for testing APIs, generating test reports and monitoring API performance.
+
+110
+00:09:17,000 --> 00:09:18,000
+Integrations.
+
+111
+00:09:18,000 --> 00:09:26,000
+Postman integrates with other tools in the API development workflow, such as Git, Jenkins and Swagger,
+
+112
+00:09:26,000 --> 00:09:30,000
+allowing for easier collaboration and workflow management.
+
+113
+00:09:30,000 --> 00:09:39,000
+Postman also offers several advanced features that help developers automate testing and improve productivity,
+
+114
+00:09:39,000 --> 00:09:43,000
+such as the ability to write test scripts in JavaScript.
+
+115
+00:09:43,000 --> 00:09:48,000
+Set environment variables and integrate with other development tools.
+
+116
+00:09:48,000 --> 00:09:56,000
+Overall, Postman plays a crucial role in the development process by making it easier for developers
+
+117
+00:09:56,000 --> 00:09:58,000
+to test and debug APIs.
+
+118
+00:09:58,000 --> 00:10:05,000
+Collaborate with team members and improve the overall quality and reliability of their APIs.
+
+119
+00:10:06,000 --> 00:10:10,000
+Let's now install the postman on your laptop.
+
+120
+00:10:10,000 --> 00:10:14,000
+I will provide you with step by step installation guide.
+
+121
+00:10:14,000 --> 00:10:19,000
+First of all, open a web browser and navigate to the Postman website.
+
+122
+00:10:20,000 --> 00:10:29,000
+You can easily get navigated directly to the downloads page or find hyper references on the home page.
+
+123
+00:10:30,000 --> 00:10:36,000
+Now you need to select whether you want to download desktop version or to use browser version.
+
+124
+00:10:36,000 --> 00:10:40,000
+Each version has its own advantages and disadvantages.
+
+125
+00:10:40,000 --> 00:10:46,000
+The desktop version of Postman is a standalone application that can be installed on your computer.
+
+126
+00:10:46,000 --> 00:10:52,000
+It offers more features and customization options compared to the browser version.
+
+127
+00:10:52,000 --> 00:10:59,000
+With the desktop version, you can create and manage collections of requests, write the scripts and
+
+128
+00:10:59,000 --> 00:11:05,000
+collaborate with the team members using features like version control and shared workspaces.
+
+129
+00:11:05,000 --> 00:11:13,000
+The desktop version also offers a more streamlined and faster user experience as it doesn't rely on
+
+130
+00:11:13,000 --> 00:11:14,000
+a web browser.
+
+131
+00:11:15,000 --> 00:11:21,000
+On the other hand, the browser version of Postman is a lightweight extension that can be installed
+
+132
+00:11:21,000 --> 00:11:23,000
+directly in your web browser.
+
+133
+00:11:23,000 --> 00:11:31,000
+It is a yield for quick testing and debugging of APIs as it doesn't require any installation or setup.
+
+134
+00:11:31,000 --> 00:11:38,000
+The browser version is also useful for users who prefer to work within their web browser and do not
+
+135
+00:11:38,000 --> 00:11:41,000
+want to switch between multiple applications.
+
+136
+00:11:41,000 --> 00:11:46,000
+However, it may have limited features compared to the desktop version.
+
+137
+00:11:47,000 --> 00:11:53,000
+Ultimately, the choice between the desktop and browser version of Postman depends on your specific
+
+138
+00:11:53,000 --> 00:11:55,000
+needs and preferences.
+
+139
+00:11:55,000 --> 00:12:03,000
+If you need advanced features and customizations or you work with APIs, frequently, the desktop version
+
+140
+00:12:03,000 --> 00:12:05,000
+may be a better fit.
+
+141
+00:12:05,000 --> 00:12:12,000
+However, if you only need basic API testing capabilities or prefer to work within your web browser,
+
+142
+00:12:12,000 --> 00:12:16,000
+the browser version may be more suitable.
+
+143
+00:12:16,000 --> 00:12:24,000
+So I believe that we will go with desktop version for that just download installer by clicking the biggest
+
+144
+00:12:24,000 --> 00:12:26,000
+button that you can see on the screen.
+
+145
+00:12:26,000 --> 00:12:33,000
+It automatically detects that have Windows and it offers me to download installer for Windows.
+
+146
+00:12:33,000 --> 00:12:39,000
+But in case you have other operating system, you can select another one below.
+
+147
+00:12:40,000 --> 00:12:47,000
+Once the download is complete, locate the downloaded file in your downloads folder or wherever you
+
+148
+00:12:47,000 --> 00:12:50,000
+saved it and just run installation file.
+
+149
+00:12:51,000 --> 00:12:55,000
+What will happen after doesn't require explanation.
+
+150
+00:12:55,000 --> 00:13:02,000
+Postman will be installed by default in the program files folder and will ask you nothing.
+
+151
+00:13:02,000 --> 00:13:04,000
+Now you can launch it.
+
+152
+00:13:04,000 --> 00:13:11,000
+When you launched it, you need to select whether you want to create an account and log in using credentials
+
+153
+00:13:11,000 --> 00:13:15,000
+or you will continue without registration.
+
+154
+00:13:15,000 --> 00:13:20,000
+Basically, you can click this link, skip, and go to the app and that's it.
+
+155
+00:13:21,000 --> 00:13:26,000
+In the next lesson, I'm going to make practical exercises together with you, and I will do screen
+
+156
+00:13:26,000 --> 00:13:31,000
+sharing to give you more practical experience of working with Postman.
+
+157
+00:13:31,000 --> 00:13:39,000
+Together we'll test our Rest API that we created in the previous lesson, But now let's recap what we
+
+158
+00:13:39,000 --> 00:13:41,000
+have learned in this video.
+
+159
+00:13:42,000 --> 00:13:46,000
+Today we did an overview of tools for API testing.
+
+160
+00:13:46,000 --> 00:13:51,000
+Now you know the difference between them and which one to choose.
+
+161
+00:13:51,000 --> 00:13:55,000
+I explained you what a soap messaging protocol is.
+
+162
+00:13:55,000 --> 00:14:01,000
+You know, such popular tools as Postman, Fiddler and Wireshark.
+
+163
+00:14:01,000 --> 00:14:07,000
+We learned key components of Postman compared desktop and web version.
+
+164
+00:14:07,000 --> 00:14:12,000
+And in the end of the lesson, we installed Postman desktop version on your computer.
+
+165
+00:14:12,000 --> 00:14:14,000
+Thanks a lot for your attention.
+
+166
+00:14:14,000 --> 00:14:17,000
+Have a great day and see you in the next lesson.
+
diff --git a/91 - REST Architecture/005 API Testing with Postman_en.srt b/91 - REST Architecture/005 API Testing with Postman_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..470a43ff9f8b9a5e3d778f68f51aaf708c2bf108
--- /dev/null
+++ b/91 - REST Architecture/005 API Testing with Postman_en.srt
@@ -0,0 +1,1140 @@
+1
+00:00:06,000 --> 00:00:07,000
+Hello, Tim.
+
+2
+00:00:07,000 --> 00:00:09,000
+We created a restful service.
+
+3
+00:00:09,000 --> 00:00:15,000
+We did an overview of tools for the API testing, and we installed Postman.
+
+4
+00:00:15,000 --> 00:00:18,000
+This all we did in previous lessons.
+
+5
+00:00:18,000 --> 00:00:22,000
+And now it is time to learn how we can test our API.
+
+6
+00:00:23,000 --> 00:00:29,000
+This is going to be less full of practical examples, so we'll start lesson directly from the screen
+
+7
+00:00:29,000 --> 00:00:30,000
+sharing.
+
+8
+00:00:30,000 --> 00:00:37,000
+I'm going to make an overview of Postman interface and main UI elements that we are going to interact
+
+9
+00:00:37,000 --> 00:00:38,000
+with.
+
+10
+00:00:38,000 --> 00:00:45,000
+Also, I'm going to share with you a collection of requests and I will show you how you can import those
+
+11
+00:00:45,000 --> 00:00:50,000
+in your postman in order to repeat after me all my queries.
+
+12
+00:00:50,000 --> 00:00:56,000
+I will show how to export existing collections or how to create new collections.
+
+13
+00:00:57,000 --> 00:01:01,000
+I'm going to show you how you can send requests with different methods.
+
+14
+00:01:01,000 --> 00:01:03,000
+We'll read response.
+
+15
+00:01:03,000 --> 00:01:08,000
+We are going to learn how to work with responses and how to analyze them.
+
+16
+00:01:09,000 --> 00:01:14,000
+Also, we'll learn how to send and read custom headers.
+
+17
+00:01:14,000 --> 00:01:19,000
+We'll perform testing of our restful service that we created in previous lesson.
+
+18
+00:01:19,000 --> 00:01:23,000
+So we'll test all endpoints that we created.
+
+19
+00:01:24,000 --> 00:01:31,000
+We'll test, create, read, update, delete operations with a resource using our rest API.
+
+20
+00:01:32,000 --> 00:01:38,000
+Also, I'm going to explain you the difference between form data and form URL encoded.
+
+21
+00:01:38,000 --> 00:01:45,000
+Let's start our lesson and from this point we can jump to the live demo and I will proceed with the
+
+22
+00:01:45,000 --> 00:01:46,000
+screen sharing.
+
+23
+00:01:46,000 --> 00:01:50,000
+So here you can see Interface of the Postman.
+
+24
+00:01:50,000 --> 00:01:55,000
+Let me make a high level overview of the key UI elements here.
+
+25
+00:01:55,000 --> 00:02:00,000
+And after that we will dive deeper in details of each section by using it.
+
+26
+00:02:00,000 --> 00:02:07,000
+As you may already see, the Postman desktop version has a clean and user friendly interface that is
+
+27
+00:02:07,000 --> 00:02:10,000
+divided into several sections.
+
+28
+00:02:10,000 --> 00:02:14,000
+The main sections of the interface include sidebar.
+
+29
+00:02:14,000 --> 00:02:22,000
+The sidebar is located on the left hand side of the screen and provides access to all the features and
+
+30
+00:02:22,000 --> 00:02:24,000
+functions in Postman.
+
+31
+00:02:24,000 --> 00:02:33,000
+It includes tabs for collections, APIs, environments, mock servers, monitors and history request
+
+32
+00:02:33,000 --> 00:02:34,000
+builder.
+
+33
+00:02:34,000 --> 00:02:41,000
+The request builder is located in the center of the screen and allows you to create and send requests
+
+34
+00:02:41,000 --> 00:02:42,000
+to APIs.
+
+35
+00:02:42,000 --> 00:02:49,000
+It includes fields for the request mask, URL, parameters, headers and body.
+
+36
+00:02:50,000 --> 00:02:55,000
+Also, in case endpoint requires authorization, you can configure it here too.
+
+37
+00:02:55,000 --> 00:02:58,000
+You can capture cookies.
+
+38
+00:02:59,000 --> 00:03:00,000
+Quote, pain.
+
+39
+00:03:00,000 --> 00:03:03,000
+Here on the right you can find really useful tool.
+
+40
+00:03:03,000 --> 00:03:06,000
+It is called code snippet.
+
+41
+00:03:06,000 --> 00:03:14,000
+Basically, you can generate the code to execute required query no matter what you want to use curl
+
+42
+00:03:14,000 --> 00:03:17,000
+request or C-sharp or Java.
+
+43
+00:03:17,000 --> 00:03:22,000
+Just use this dropdown list to select what you need.
+
+44
+00:03:22,000 --> 00:03:28,000
+Later, you can use this code in your program in order to execute the query that you need.
+
+45
+00:03:29,000 --> 00:03:30,000
+Response.
+
+46
+00:03:30,000 --> 00:03:32,000
+Pain is a response.
+
+47
+00:03:32,000 --> 00:03:39,000
+Pain is located to the bottom of the request builder and displays the response data returned by the
+
+48
+00:03:39,000 --> 00:03:39,000
+API.
+
+49
+00:03:40,000 --> 00:03:45,000
+It includes tabs for the response body headers and cookies.
+
+50
+00:03:45,000 --> 00:03:50,000
+That's the place where we will observe what server responded us.
+
+51
+00:03:50,000 --> 00:03:53,000
+Test and console panes.
+
+52
+00:03:53,000 --> 00:04:01,000
+The test and console panes are located at the bottom of the screen and allow you to write and run tests
+
+53
+00:04:01,000 --> 00:04:03,000
+for your API requests.
+
+54
+00:04:03,000 --> 00:04:09,000
+The console pane displays log messages and errors generated by postman.
+
+55
+00:04:10,000 --> 00:04:11,000
+Top bar.
+
+56
+00:04:12,000 --> 00:04:18,000
+The top bar is located at the very top of the screen and includes the work space management.
+
+57
+00:04:19,000 --> 00:04:27,000
+Also, you can create an account if you want to personalize your experience or use Postman without account.
+
+58
+00:04:27,000 --> 00:04:28,000
+It is up to you.
+
+59
+00:04:29,000 --> 00:04:33,000
+Also, you can use search bar and settings.
+
+60
+00:04:33,000 --> 00:04:40,000
+Overall, the possible interface is designed to be intuitive and user friendly, with key UI elements
+
+61
+00:04:40,000 --> 00:04:44,000
+organized in a logical and easy to use manner.
+
+62
+00:04:45,000 --> 00:04:48,000
+So it is time to start using Postman.
+
+63
+00:04:48,000 --> 00:04:54,000
+For the sake of the demo, I started the web server and deployed the rest APIs that we developed together
+
+64
+00:04:54,000 --> 00:05:02,000
+in the previous lesson to interact with user resource and more demo endpoints.
+
+65
+00:05:02,000 --> 00:05:05,000
+Make sure that your server is running.
+
+66
+00:05:05,000 --> 00:05:10,000
+And now I'm going to execute queries imitating the development process.
+
+67
+00:05:11,000 --> 00:05:19,000
+Usually during the development you design and point implement it and then you want to test how it works.
+
+68
+00:05:19,000 --> 00:05:25,000
+You just open the postman and send some queries and explore what is returned.
+
+69
+00:05:26,000 --> 00:05:31,000
+So now when we know the interface, we can start working with Postman.
+
+70
+00:05:32,000 --> 00:05:40,000
+In the previous lesson we created our rest API and now let's learn Postman better by actually working
+
+71
+00:05:40,000 --> 00:05:40,000
+with it.
+
+72
+00:05:40,000 --> 00:05:49,000
+I will just imitate the regular flow that I would do as a developer or when I was supposed to test endpoints.
+
+73
+00:05:49,000 --> 00:05:54,000
+Today I'm going to show you how to create your own collections of requests.
+
+74
+00:05:55,000 --> 00:06:01,000
+But before we start, I want to say that in attachments to this lesson, you are going to find the reference
+
+75
+00:06:01,000 --> 00:06:03,000
+to the export of collections.
+
+76
+00:06:03,000 --> 00:06:11,000
+Basically, you can click import here and import my collections that I have shared in the attachments
+
+77
+00:06:11,000 --> 00:06:12,000
+to this lesson.
+
+78
+00:06:12,000 --> 00:06:18,000
+You just need drag and drop my export file into the area inside your postman.
+
+79
+00:06:19,000 --> 00:06:27,000
+Taking into account I already have such a collection, I would import it as a copy and after importing
+
+80
+00:06:27,000 --> 00:06:33,000
+you are going to have the same list of requests that I'm going to review with you today.
+
+81
+00:06:33,000 --> 00:06:39,000
+Or you can just follow my examples and create your own collection as you wish.
+
+82
+00:06:39,000 --> 00:06:46,000
+In case you want to export your collection, you can just find three dots here and click export.
+
+83
+00:06:46,000 --> 00:06:47,000
+That's it.
+
+84
+00:06:48,000 --> 00:06:50,000
+Let's send our first request.
+
+85
+00:06:51,000 --> 00:06:53,000
+Everything is simple here.
+
+86
+00:06:53,000 --> 00:06:59,000
+You just paste the URL into query pane where I take this URL.
+
+87
+00:06:59,000 --> 00:07:03,000
+Well, I deployed my web application.
+
+88
+00:07:03,000 --> 00:07:08,000
+It is available at localhost at default port 8080.
+
+89
+00:07:08,000 --> 00:07:12,000
+Our deployed application is called Spring Web.
+
+90
+00:07:12,000 --> 00:07:15,000
+And then goes, name of my endpoint.
+
+91
+00:07:16,000 --> 00:07:18,000
+Let me open the source code.
+
+92
+00:07:18,000 --> 00:07:19,000
+Here it is.
+
+93
+00:07:20,000 --> 00:07:21,000
+Users.
+
+94
+00:07:21,000 --> 00:07:24,000
+Let's get back to the postman.
+
+95
+00:07:24,000 --> 00:07:29,000
+Now we need to check which request method we are going to use to reach the resource.
+
+96
+00:07:29,000 --> 00:07:36,000
+By default, it is get method here, but you can use drop down to select the method that you need.
+
+97
+00:07:37,000 --> 00:07:39,000
+I'm ready to send the request.
+
+98
+00:07:39,000 --> 00:07:43,000
+I click send button and here is the response.
+
+99
+00:07:43,000 --> 00:07:46,000
+Let's explore it together.
+
+100
+00:07:46,000 --> 00:07:50,000
+This endpoint should return a collection of users.
+
+101
+00:07:50,000 --> 00:07:51,000
+You can see 200.
+
+102
+00:07:51,000 --> 00:07:52,000
+Okay.
+
+103
+00:07:52,000 --> 00:07:55,000
+Status code time of response.
+
+104
+00:07:55,000 --> 00:07:57,000
+Size of the response.
+
+105
+00:07:58,000 --> 00:07:58,000
+Here.
+
+106
+00:07:58,000 --> 00:08:05,000
+You can also use navigation pane to explore is a body or cookies or headers.
+
+107
+00:08:05,000 --> 00:08:09,000
+In this case there are no cookies, but there are some headers.
+
+108
+00:08:09,000 --> 00:08:14,000
+You can explore the response in the pretty or raw format.
+
+109
+00:08:14,000 --> 00:08:21,000
+Usually it is hard to work with raw format because it is not readable with pretty format.
+
+110
+00:08:21,000 --> 00:08:25,000
+You can collapse and expand the elements of the response.
+
+111
+00:08:26,000 --> 00:08:29,000
+The format of the response is auto detected.
+
+112
+00:08:29,000 --> 00:08:35,000
+But in case you need to change the format of the response, you can use this dropdown.
+
+113
+00:08:35,000 --> 00:08:40,000
+So in the response, you can see that I have multiple users here.
+
+114
+00:08:41,000 --> 00:08:49,000
+What you also would like to do usually is to store the request in order to not create the same request
+
+115
+00:08:49,000 --> 00:08:50,000
+each time from scratch.
+
+116
+00:08:51,000 --> 00:08:53,000
+So let's click Save Button.
+
+117
+00:08:54,000 --> 00:09:02,000
+But taking into account that this request is already saved in my postman, let's use save as option.
+
+118
+00:09:02,000 --> 00:09:06,000
+Specify meaningful name for the query in order.
+
+119
+00:09:06,000 --> 00:09:09,000
+You can easily understand what it is about.
+
+120
+00:09:10,000 --> 00:09:17,000
+You can also add the description to the query if you want to be able to recall what it is about later.
+
+121
+00:09:17,000 --> 00:09:21,000
+Each request should be a part of some collection.
+
+122
+00:09:21,000 --> 00:09:25,000
+You can see that I have collections here created already.
+
+123
+00:09:25,000 --> 00:09:33,000
+You can create new collection by clicking new collection button or just select one of the existing collections
+
+124
+00:09:33,000 --> 00:09:35,000
+in order to save the query.
+
+125
+00:09:36,000 --> 00:09:42,000
+Inside the collection, you can create folders in case you want to group your queries in another way.
+
+126
+00:09:42,000 --> 00:09:48,000
+Also, you can navigate between collections and folders using these breadcrumbs.
+
+127
+00:09:49,000 --> 00:09:50,000
+Taking into account.
+
+128
+00:09:50,000 --> 00:09:53,000
+I have this query saved already.
+
+129
+00:09:53,000 --> 00:09:58,000
+I would just click cancel button, but you can click save button.
+
+130
+00:09:58,000 --> 00:10:04,000
+All your collections you can find in the left pane collections.
+
+131
+00:10:04,000 --> 00:10:09,000
+Here they just double click on the request and you will open it.
+
+132
+00:10:10,000 --> 00:10:18,000
+The next request is to fetch user by ID using the endpoint that we created in previous lesson I specify
+
+133
+00:10:18,000 --> 00:10:21,000
+users end point and user ID.
+
+134
+00:10:22,000 --> 00:10:27,000
+Send request and here is my user with ID seven.
+
+135
+00:10:27,000 --> 00:10:30,000
+Everything works as expected.
+
+136
+00:10:30,000 --> 00:10:36,000
+I will not stop too much on this request because it is pretty straightforward.
+
+137
+00:10:36,000 --> 00:10:43,000
+Even in case you have any questions, remember that you can ask your questions below the video and I
+
+138
+00:10:43,000 --> 00:10:45,000
+will be happy to answer those.
+
+139
+00:10:45,000 --> 00:10:46,000
+Let's continue.
+
+140
+00:10:47,000 --> 00:10:50,000
+The next request is with request parameter.
+
+141
+00:10:50,000 --> 00:10:58,000
+This time we want to filter users by the first name and we learned that it is a good practice to use
+
+142
+00:10:58,000 --> 00:11:01,000
+request parameters for filtering and sorting.
+
+143
+00:11:01,000 --> 00:11:10,000
+In this case, I specify first name request parameter that is equal to admin, and in the response I
+
+144
+00:11:10,000 --> 00:11:14,000
+have multiple users who have first name admin.
+
+145
+00:11:15,000 --> 00:11:24,000
+Feel free to use query params section in order to add, enable or disable some query parameters and
+
+146
+00:11:24,000 --> 00:11:26,000
+it will help you to build the query.
+
+147
+00:11:27,000 --> 00:11:35,000
+The main thing is to specify key and value, but optionally for the documenting purposes you can specify
+
+148
+00:11:35,000 --> 00:11:41,000
+description to the next request is similar to the one that we have removed.
+
+149
+00:11:41,000 --> 00:11:46,000
+We use sort by query parameter to sort results by first name field.
+
+150
+00:11:47,000 --> 00:11:53,000
+You can notice that users in our response will be sorted by first name values.
+
+151
+00:11:53,000 --> 00:11:57,000
+The next thing is to demo post request.
+
+152
+00:11:57,000 --> 00:12:01,000
+We created request parameters demo endpoint.
+
+153
+00:12:01,000 --> 00:12:04,000
+Let me show it to you in the source code.
+
+154
+00:12:04,000 --> 00:12:11,000
+Just to remind you, this is the endpoint that can be accessed via post method and request.
+
+155
+00:12:11,000 --> 00:12:18,000
+Params still means not something what is sent in body of the request, but something what is specified
+
+156
+00:12:18,000 --> 00:12:20,000
+in the query as a parameter.
+
+157
+00:12:21,000 --> 00:12:29,000
+So in this case, when I send a request and pass one parameter, it is taken into account on the server
+
+158
+00:12:29,000 --> 00:12:35,000
+side and according to the logic that we created will return it back in the response.
+
+159
+00:12:35,000 --> 00:12:36,000
+Is it clear?
+
+160
+00:12:37,000 --> 00:12:38,000
+Amazing.
+
+161
+00:12:38,000 --> 00:12:44,000
+We also created an endpoint that passes all requests parameters into the map.
+
+162
+00:12:45,000 --> 00:12:54,000
+You can pass multiple parameters and in Java source code you can work with all of them as with the map.
+
+163
+00:12:55,000 --> 00:12:57,000
+And here is how this endpoint works.
+
+164
+00:12:58,000 --> 00:13:03,000
+I send request and return entry set of parameters.
+
+165
+00:13:04,000 --> 00:13:12,000
+In case you want to pass information in the request body similar to the way how we transmit this data
+
+166
+00:13:12,000 --> 00:13:16,000
+with the help of HTML forms, you can do it too.
+
+167
+00:13:16,000 --> 00:13:24,000
+Let's navigate to the body tab, specify the data type that you want to send as form data.
+
+168
+00:13:25,000 --> 00:13:29,000
+Select is a form data or form URL encoded.
+
+169
+00:13:29,000 --> 00:13:32,000
+What is the difference between these?
+
+170
+00:13:32,000 --> 00:13:40,000
+The main difference between the two is in how the data is formatted and send form.
+
+171
+00:13:40,000 --> 00:13:47,000
+Data is used to send binary data such as images or files as well as text data.
+
+172
+00:13:47,000 --> 00:13:55,000
+It is commonly used when uploading files or submitting forms with file inputs in form data.
+
+173
+00:13:55,000 --> 00:14:03,000
+Each key value pair is separated by a boundary string and is sent in a separate section, which makes
+
+174
+00:14:03,000 --> 00:14:07,000
+it more suitable for sending large files.
+
+175
+00:14:08,000 --> 00:14:11,000
+X3W form urlencoded.
+
+176
+00:14:11,000 --> 00:14:20,000
+On the other hand, is used to send simple text data in the format of key value pairs separated by an
+
+177
+00:14:20,000 --> 00:14:22,000
+ampersand symbol.
+
+178
+00:14:22,000 --> 00:14:29,000
+It is commonly used when submitting form data without file inputs in form.
+
+179
+00:14:29,000 --> 00:14:30,000
+Urlencoded.
+
+180
+00:14:30,000 --> 00:14:35,000
+The data is encoded and sent as a single string in the request body.
+
+181
+00:14:36,000 --> 00:14:42,000
+In summary, if you need to send binary data or large files, use form data.
+
+182
+00:14:42,000 --> 00:14:49,000
+If you are sending simple text data, use X3W form URL encoded.
+
+183
+00:14:49,000 --> 00:14:55,000
+So in this case I select form URL encoded and send the request.
+
+184
+00:14:56,000 --> 00:15:00,000
+In response we can see form data from the request body.
+
+185
+00:15:00,000 --> 00:15:08,000
+And just to remind you that on the backend side we need to specify that this endpoint consumes specific
+
+186
+00:15:08,000 --> 00:15:11,000
+media type in the source code.
+
+187
+00:15:11,000 --> 00:15:17,000
+You can see that I specified that this endpoint consumes application form URL encoded.
+
+188
+00:15:17,000 --> 00:15:19,000
+That's how it works.
+
+189
+00:15:19,000 --> 00:15:26,000
+Also, I wanted to show you that theoretically you can pass list of parameters, comma, separated values
+
+190
+00:15:26,000 --> 00:15:29,000
+like you can see in this example.
+
+191
+00:15:29,000 --> 00:15:37,000
+You can send multiple IDs at once, putting them in one request parameter that is called IDs.
+
+192
+00:15:38,000 --> 00:15:42,000
+On the backend side, they are passed into the list of values.
+
+193
+00:15:43,000 --> 00:15:46,000
+I just print the list of values into the response.
+
+194
+00:15:46,000 --> 00:15:52,000
+Nothing special, but you can build your business logic around the list of values.
+
+195
+00:15:52,000 --> 00:15:53,000
+As you wish.
+
+196
+00:15:54,000 --> 00:16:01,000
+The next thing that I would like to show you is how you can test that custom response status is returned.
+
+197
+00:16:02,000 --> 00:16:08,000
+Just to remind you that on the backend for one of our endpoints, we configure it.
+
+198
+00:16:08,000 --> 00:16:16,000
+I'm a T port response status and when I send requests to this endpoint in the Postman, I can see that
+
+199
+00:16:16,000 --> 00:16:20,000
+the response status code is 418.
+
+200
+00:16:20,000 --> 00:16:22,000
+You can see status code here.
+
+201
+00:16:23,000 --> 00:16:28,000
+This is achieved by using response status annotation in the source code.
+
+202
+00:16:28,000 --> 00:16:36,000
+Another interesting thing about Postman, you can see that server generated HTML page for us.
+
+203
+00:16:36,000 --> 00:16:41,000
+You can use preview mode in order to preview page markup.
+
+204
+00:16:41,000 --> 00:16:49,000
+Also here you can see the reason that we also specified in the response status annotation demo endpoint
+
+205
+00:16:49,000 --> 00:16:50,000
+reason.
+
+206
+00:16:50,000 --> 00:16:54,000
+Now let's delete the resource using rest API.
+
+207
+00:16:55,000 --> 00:17:00,000
+If you remember, we have test user John Doe with a 12.
+
+208
+00:17:00,000 --> 00:17:02,000
+Let's remove it.
+
+209
+00:17:02,000 --> 00:17:08,000
+I specify user ID that I want to delete and send request via delete method.
+
+210
+00:17:09,000 --> 00:17:13,000
+Pay attention that no content string has been returned.
+
+211
+00:17:13,000 --> 00:17:14,000
+Why?
+
+212
+00:17:14,000 --> 00:17:21,000
+Because I used HTTP status as a returned value and it was casted to string value.
+
+213
+00:17:22,000 --> 00:17:25,000
+The actual status of the response is 200.
+
+214
+00:17:25,000 --> 00:17:26,000
+Okay.
+
+215
+00:17:27,000 --> 00:17:27,000
+Why?
+
+216
+00:17:27,000 --> 00:17:28,000
+I show you this.
+
+217
+00:17:29,000 --> 00:17:36,000
+Just to highlight that in case you want to control response status, setting up the returned value is
+
+218
+00:17:36,000 --> 00:17:37,000
+not enough.
+
+219
+00:17:37,000 --> 00:17:42,000
+You need to use response status annotation to configure custom response status.
+
+220
+00:17:43,000 --> 00:17:50,000
+And this time, in case we would request user's resource, we are going to see that there is no John
+
+221
+00:17:50,000 --> 00:17:52,000
+Doe user object anymore.
+
+222
+00:17:53,000 --> 00:17:57,000
+Thus, we can be sure that endpoint works as expected.
+
+223
+00:17:58,000 --> 00:18:00,000
+Let's now create the resource.
+
+224
+00:18:00,000 --> 00:18:03,000
+Usually we create resources with the post method.
+
+225
+00:18:04,000 --> 00:18:07,000
+In our rest service we have users endpoint.
+
+226
+00:18:08,000 --> 00:18:12,000
+Does it create resource in case resource is reached with a post method?
+
+227
+00:18:13,000 --> 00:18:23,000
+In this case we need to open body tab, select row form of data and insert the JSON of your user resource.
+
+228
+00:18:24,000 --> 00:18:33,000
+You can see here that I pass key value pairs That reflects the state of the user object and I just click
+
+229
+00:18:33,000 --> 00:18:34,000
+send request button.
+
+230
+00:18:35,000 --> 00:18:36,000
+That's it.
+
+231
+00:18:36,000 --> 00:18:38,000
+Resource is created.
+
+232
+00:18:38,000 --> 00:18:43,000
+Let's now call all users to make sure that the new user is created.
+
+233
+00:18:44,000 --> 00:18:49,000
+And in the bottom we can see that new user with fake data was created.
+
+234
+00:18:50,000 --> 00:18:51,000
+Amazing.
+
+235
+00:18:51,000 --> 00:18:55,000
+Let's imagine now that we want to update resource.
+
+236
+00:18:55,000 --> 00:18:58,000
+Usually we update resource, we have put method.
+
+237
+00:18:59,000 --> 00:19:08,000
+So in the next example, I also send JSON in the body of the request, but I want to update an email.
+
+238
+00:19:09,000 --> 00:19:13,000
+I want to change email in order it would have test email domain.
+
+239
+00:19:14,000 --> 00:19:16,000
+Let me send the request.
+
+240
+00:19:16,000 --> 00:19:19,000
+Web server accepted my request.
+
+241
+00:19:19,000 --> 00:19:21,000
+Let's check all users again.
+
+242
+00:19:23,000 --> 00:19:32,000
+And you can see that email value right now ends up not with Email.com but with test email.com.
+
+243
+00:19:32,000 --> 00:19:40,000
+And pay attention that in real life, in case you have applications that consists from multiple services,
+
+244
+00:19:40,000 --> 00:19:45,000
+the services can exchange the data and communicate in the similar way.
+
+245
+00:19:45,000 --> 00:19:53,000
+We just use Postman as a client now, but in real life this can be any other application generating
+
+246
+00:19:53,000 --> 00:19:57,000
+requests and acting as a client of our application.
+
+247
+00:19:57,000 --> 00:20:04,000
+The next thing that I wanted you to demo is how to return an object of response entity type.
+
+248
+00:20:04,000 --> 00:20:11,000
+You can remember that in previous lesson when we created our restful service, I showed you that you
+
+249
+00:20:11,000 --> 00:20:19,000
+can return response entity in order to configure response status response headers and response body
+
+250
+00:20:19,000 --> 00:20:20,000
+in one object.
+
+251
+00:20:21,000 --> 00:20:29,000
+In this particular example, you can see that after I send request, I receive custom response body
+
+252
+00:20:29,000 --> 00:20:31,000
+and custom response header.
+
+253
+00:20:31,000 --> 00:20:34,000
+Let me show it to you on the header.
+
+254
+00:20:34,000 --> 00:20:34,000
+Stop.
+
+255
+00:20:35,000 --> 00:20:39,000
+Here you can see custom header and fake data.
+
+256
+00:20:40,000 --> 00:20:45,000
+Also, if you wish, you can configure custom status code.
+
+257
+00:20:46,000 --> 00:20:51,000
+The next example is to demo and check request header annotation.
+
+258
+00:20:52,000 --> 00:20:59,000
+I can specify custom headers and submit them to the rest API on the header stop.
+
+259
+00:20:59,000 --> 00:21:05,000
+You can see headers that are added by default here and additional custom header.
+
+260
+00:21:05,000 --> 00:21:14,000
+For example, in case I want to send accept language header, I just add it here and specify value for
+
+261
+00:21:14,000 --> 00:21:14,000
+it.
+
+262
+00:21:14,000 --> 00:21:22,000
+And as usual, you're welcome to leave any description in case it would help us in documenting the requests.
+
+263
+00:21:23,000 --> 00:21:31,000
+When I send a request, my endpoint passes, request header and return header value in response.
+
+264
+00:21:32,000 --> 00:21:34,000
+Everything works as expected.
+
+265
+00:21:34,000 --> 00:21:36,000
+Let's move on.
+
+266
+00:21:36,000 --> 00:21:43,000
+In the next example, I demonstrate endpoints that parses all the headers into the map and in the source
+
+267
+00:21:43,000 --> 00:21:49,000
+code you can work with the map of key value pairs that represent headers.
+
+268
+00:21:49,000 --> 00:21:54,000
+In this particular case, I just send them back in the response.
+
+269
+00:21:54,000 --> 00:21:55,000
+That's it.
+
+270
+00:21:55,000 --> 00:21:58,000
+We tested all our endpoints.
+
+271
+00:21:59,000 --> 00:22:04,000
+I hope that this lesson was useful for you and it will help you during the daily activities.
+
+272
+00:22:04,000 --> 00:22:08,000
+Let's recap what we have learned in the lesson.
+
+273
+00:22:09,000 --> 00:22:14,000
+Today we learned postman user interface and key UI elements.
+
+274
+00:22:14,000 --> 00:22:22,000
+I showed you how we can work with collections, how to import export collections, and how to create
+
+275
+00:22:22,000 --> 00:22:23,000
+new collections of requests.
+
+276
+00:22:24,000 --> 00:22:28,000
+You saw how to work with requests and responses.
+
+277
+00:22:28,000 --> 00:22:33,000
+During the lesson, we sent requests with a different HTTP methods.
+
+278
+00:22:33,000 --> 00:22:37,000
+Also, you saw how to read responses.
+
+279
+00:22:38,000 --> 00:22:43,000
+We worked with custom headers by sending them and receiving custom headers.
+
+280
+00:22:43,000 --> 00:22:48,000
+We tested our restful service and all its endpoints.
+
+281
+00:22:49,000 --> 00:22:56,000
+Also, you learned how to execute, create, read, update and delete operations with resource.
+
+282
+00:22:56,000 --> 00:23:04,000
+And at the end of the lesson, we learned the difference between form data and X3W form URL encoded.
+
+283
+00:23:05,000 --> 00:23:07,000
+That's all for this lesson.
+
+284
+00:23:07,000 --> 00:23:09,000
+Thanks a lot for your attention.
+
+285
+00:23:09,000 --> 00:23:12,000
+Have a great day and see you in the next lesson.
+
diff --git a/91 - REST Architecture/005 Commit-with-changes.url b/91 - REST Architecture/005 Commit-with-changes.url
new file mode 100644
index 0000000000000000000000000000000000000000..d3f4ba55a881eb0fa8978f7777331a1736ee0962
--- /dev/null
+++ b/91 - REST Architecture/005 Commit-with-changes.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/36722187fd1478db83cd95bd24f6204e4e228092
\ No newline at end of file
diff --git a/91 - REST Architecture/005 Postman-collections.url b/91 - REST Architecture/005 Postman-collections.url
new file mode 100644
index 0000000000000000000000000000000000000000..c521b36cbe9dc33e2c9e70a09a016e56ecdf8b98
--- /dev/null
+++ b/91 - REST Architecture/005 Postman-collections.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/tree/master/src/main/resources/postman-collections
\ No newline at end of file
diff --git a/91 - REST Architecture/external-links.txt b/91 - REST Architecture/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..d2a61fde155eecd8d738aff4b7646b75e1c34743
--- /dev/null
+++ b/91 - REST Architecture/external-links.txt
@@ -0,0 +1,9 @@
+
+003 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/5f6b4f695bb88865978fb7cbe622855783c17cfa
+
+005 Postman-collections
+https://github.com/AndriiPiatakha/java-learnit-spring-web/tree/master/src/main/resources/postman-collections
+
+005 Commit-with-changes
+https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/36722187fd1478db83cd95bd24f6204e4e228092
diff --git a/92 - Spring Boot/001 Spring Boot Introduction_en.srt b/92 - Spring Boot/001 Spring Boot Introduction_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..b2d735ac958fdfecbddc9a7ecf85f7988c9fedc1
--- /dev/null
+++ b/92 - Spring Boot/001 Spring Boot Introduction_en.srt
@@ -0,0 +1,1084 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, Kim.
+
+2
+00:00:06,000 --> 00:00:13,000
+With this lesson, we start learning Spring Boot taking into account this is an introduction to Spring
+
+3
+00:00:13,000 --> 00:00:13,000
+boot.
+
+4
+00:00:13,000 --> 00:00:20,000
+This is going to be theoretical lesson, but I'm sure that it is super important in order we can set
+
+5
+00:00:20,000 --> 00:00:27,000
+the context, understand what spring boot is, when to use it, and other general things.
+
+6
+00:00:27,000 --> 00:00:34,000
+We're going to start from the important question that students ask me very often where to start learning
+
+7
+00:00:34,000 --> 00:00:35,000
+of Spring boot.
+
+8
+00:00:35,000 --> 00:00:39,000
+Do we need to start learning other modules from spring framework?
+
+9
+00:00:39,000 --> 00:00:42,000
+Or we can start learning of the spring boot directly?
+
+10
+00:00:42,000 --> 00:00:47,000
+We are going to review this question and we will try to answer it.
+
+11
+00:00:47,000 --> 00:00:53,000
+You're going to understand what is the difference and what a connection between Spring framework and
+
+12
+00:00:53,000 --> 00:00:54,000
+Spring boot.
+
+13
+00:00:54,000 --> 00:00:57,000
+I will explain you what Spring Boot is.
+
+14
+00:00:57,000 --> 00:01:05,000
+We'll discuss its key features, take into account that opinionated development approach is used in
+
+15
+00:01:05,000 --> 00:01:06,000
+the spring boot.
+
+16
+00:01:06,000 --> 00:01:08,000
+We're going to learn what it is.
+
+17
+00:01:09,000 --> 00:01:14,000
+I will explain when to use and when not to use Spring Boot.
+
+18
+00:01:14,000 --> 00:01:20,000
+And at the end of the lesson, we are going to summarize advantages and disadvantages of Spring Boot.
+
+19
+00:01:20,000 --> 00:01:22,000
+Let's start our lesson.
+
+20
+00:01:22,000 --> 00:01:26,000
+Let's start from the first and important question.
+
+21
+00:01:26,000 --> 00:01:33,000
+A lot of students of mine ask me where to start learning Spring Boot and what's it worth to start learning
+
+22
+00:01:33,000 --> 00:01:40,000
+Spring Boot straight away in case there is no understanding about Spring Framework and its other projects.
+
+23
+00:01:40,000 --> 00:01:47,000
+Because very often students hear Spring boot like a buzzword and believes that they need to learn it
+
+24
+00:01:47,000 --> 00:01:54,000
+as soon as possible and start learning it without understanding of what spring framework is.
+
+25
+00:01:54,000 --> 00:02:02,000
+In general, if a student of my course Java from zero to first job, then you remember that when we
+
+26
+00:02:02,000 --> 00:02:08,000
+started learning of spring modules, different spring projects, I said that there are two different
+
+27
+00:02:08,000 --> 00:02:10,000
+approaches in learning Spring framework.
+
+28
+00:02:10,000 --> 00:02:18,000
+The first one is to run projects from spring framework and only then start learning Spring Boot and
+
+29
+00:02:18,000 --> 00:02:25,000
+the second approach start learning of spring boot and gradually learn all the projects of Spring framework.
+
+30
+00:02:25,000 --> 00:02:33,000
+Based on my experience and work with many students during multiple years, I can confirm that In my
+
+31
+00:02:33,000 --> 00:02:38,000
+opinion, you should start from learning Spring framework and its different projects.
+
+32
+00:02:38,000 --> 00:02:39,000
+Why?
+
+33
+00:02:39,000 --> 00:02:44,000
+Because at the end of the day, Spring Boot is built on top of spring framework.
+
+34
+00:02:44,000 --> 00:02:51,000
+So understanding spring frameworks, core concepts and features is essential.
+
+35
+00:02:51,000 --> 00:02:58,000
+Before diving into spring boot, Spring Framework provides a strong foundation for building enterprise
+
+36
+00:02:58,000 --> 00:03:05,000
+level Java applications, and it includes several modules that cover different aspects of application
+
+37
+00:03:05,000 --> 00:03:11,000
+development, such as core container data, access, web and more.
+
+38
+00:03:11,000 --> 00:03:19,000
+Familiarity with these modules will give you a better understanding of how Spring Boot works and its
+
+39
+00:03:19,000 --> 00:03:21,000
+underlying mechanisms.
+
+40
+00:03:21,000 --> 00:03:27,000
+Once you have a good understanding of spring framework, you can then move on to spring boot.
+
+41
+00:03:27,000 --> 00:03:34,000
+Spring Boot simplifies the setup and configuration of spring based applications, making it easier to
+
+42
+00:03:34,000 --> 00:03:40,000
+create standalone production grade spring applications quickly.
+
+43
+00:03:40,000 --> 00:03:47,000
+However, it is important to note that Spring Boot doesn't replace spring framework entirely, as it
+
+44
+00:03:47,000 --> 00:03:50,000
+still relies on many of its core components.
+
+45
+00:03:50,000 --> 00:03:58,000
+So it is best for students to learn spring framework first and then move on to Spring Boot to gain a
+
+46
+00:03:58,000 --> 00:04:05,000
+deeper understanding of how both frameworks work together to create powerful and scalable applications.
+
+47
+00:04:05,000 --> 00:04:12,000
+By saying this, I want to highlight that in case you didn't watch previous lessons about spring, I
+
+48
+00:04:12,000 --> 00:04:18,000
+would recommend you to start from them because it will help you to understand some basic concepts about
+
+49
+00:04:18,000 --> 00:04:21,000
+spring framework and some terminology.
+
+50
+00:04:21,000 --> 00:04:24,000
+In this lesson we start learning spring Boot.
+
+51
+00:04:24,000 --> 00:04:27,000
+So let's understand what a spring boot is.
+
+52
+00:04:28,000 --> 00:04:35,000
+Spring Boot is a popular Java based framework that is used to create standalone production, ready spring
+
+53
+00:04:35,000 --> 00:04:40,000
+applications quickly and with minimal setup like we already discussed.
+
+54
+00:04:40,000 --> 00:04:47,000
+It is built on top of the spring framework and provides a number of additional features and improvements
+
+55
+00:04:47,000 --> 00:04:55,000
+to simplify the development process and reduce the time and effort required to build complex applications.
+
+56
+00:04:55,000 --> 00:05:01,000
+Also, we can say that Spring Boot is a spring module that provides the rapid application development
+
+57
+00:05:01,000 --> 00:05:03,000
+feature to the spring framework.
+
+58
+00:05:03,000 --> 00:05:11,000
+It is used to create a standalone spring based application that you can just run because it needs minimal
+
+59
+00:05:11,000 --> 00:05:12,000
+spring configuration.
+
+60
+00:05:13,000 --> 00:05:21,000
+In short, Spring Boot is a combination of spring framework and embedded server, so you even don't
+
+61
+00:05:21,000 --> 00:05:24,000
+need to configure Tomcat separately.
+
+62
+00:05:24,000 --> 00:05:32,000
+The web server is built in and you can run the application with Java very simply because the application
+
+63
+00:05:32,000 --> 00:05:35,000
+is packaged into the jar archive.
+
+64
+00:05:36,000 --> 00:05:36,000
+In spring boot.
+
+65
+00:05:37,000 --> 00:05:42,000
+There is no requirement for XML configuration deployment descriptor.
+
+66
+00:05:42,000 --> 00:05:47,000
+It uses convention over configuration software design paradigm.
+
+67
+00:05:47,000 --> 00:05:50,000
+That means it decreases the effort of the developer.
+
+68
+00:05:51,000 --> 00:05:58,000
+One of the key features of Spring Boot is its opinionated approach to application development, which
+
+69
+00:05:58,000 --> 00:06:06,000
+means that it provides a set of defaults and conventions that are optimized for common use cases.
+
+70
+00:06:06,000 --> 00:06:13,000
+This approach minimizes the need for developers to make many decisions about configuration and setup,
+
+71
+00:06:13,000 --> 00:06:17,000
+allowing them to focus on writing business logic instead.
+
+72
+00:06:18,000 --> 00:06:23,000
+We're going to talk more about the opinionated approach on the separate slide.
+
+73
+00:06:23,000 --> 00:06:31,000
+Spring Boot also includes a number of built in features and tools that are designed to make common tasks,
+
+74
+00:06:31,000 --> 00:06:39,000
+such as setting up a web server, handling data persistence, or integrating with external services
+
+75
+00:06:39,000 --> 00:06:42,000
+as simple and straightforward as possible.
+
+76
+00:06:42,000 --> 00:06:49,000
+Additionally, Spring Boot has a large and active community, which means that developers can easily
+
+77
+00:06:49,000 --> 00:06:56,000
+find help, resources and third party plugins to extend its functionality.
+
+78
+00:06:57,000 --> 00:07:04,000
+Overall, Spring Boot is an excellent choice for Java developers who want to create robust, scalable
+
+79
+00:07:04,000 --> 00:07:08,000
+and maintainable applications quickly and efficiently.
+
+80
+00:07:09,000 --> 00:07:11,000
+Let's now learn features of Spring boot.
+
+81
+00:07:12,000 --> 00:07:14,000
+This will help you to understand it better.
+
+82
+00:07:15,000 --> 00:07:22,000
+Spring Boot comes with a rich set of features that make it an excellent choice for developing modern
+
+83
+00:07:22,000 --> 00:07:24,000
+Java applications.
+
+84
+00:07:24,000 --> 00:07:26,000
+Here are some of its key features.
+
+85
+00:07:27,000 --> 00:07:29,000
+Easy setup and configuration.
+
+86
+00:07:29,000 --> 00:07:30,000
+Spring Boot.
+
+87
+00:07:30,000 --> 00:07:38,000
+Opinionated approach to application development simplifies the setup process and provides a set of default
+
+88
+00:07:38,000 --> 00:07:42,000
+configurations that are optimized for common use cases.
+
+89
+00:07:43,000 --> 00:07:50,000
+Developers can get up and running with a new project quickly without having to spend a lot of time on
+
+90
+00:07:50,000 --> 00:07:51,000
+configuration and setup.
+
+91
+00:07:52,000 --> 00:07:54,000
+Built in web server.
+
+92
+00:07:54,000 --> 00:08:00,000
+I already told you that Spring Boot includes an embedded web server which allows developers to easily
+
+93
+00:08:00,000 --> 00:08:07,000
+create web based applications without having to configure and manage an external web server.
+
+94
+00:08:07,000 --> 00:08:15,000
+So there is no problems with questions which Tomcat version to download and how to run it and how to
+
+95
+00:08:15,000 --> 00:08:17,000
+deploy our web application.
+
+96
+00:08:18,000 --> 00:08:19,000
+Dependency management.
+
+97
+00:08:19,000 --> 00:08:26,000
+Spring Boot includes a powerful dependency management system that makes it easy to manage the dependencies
+
+98
+00:08:26,000 --> 00:08:29,000
+required by an application.
+
+99
+00:08:29,000 --> 00:08:36,000
+It automatically manages versions and conflicts and can then load and cache dependencies automatically.
+
+100
+00:08:36,000 --> 00:08:40,000
+But be aware that each feature comes with a price.
+
+101
+00:08:40,000 --> 00:08:47,000
+A little bit later in the lesson, I am going to explain that automatic dependency management can lead
+
+102
+00:08:47,000 --> 00:08:48,000
+to troubles.
+
+103
+00:08:48,000 --> 00:08:53,000
+Basically, everything what is happened without our control can lead to troubles.
+
+104
+00:08:53,000 --> 00:08:55,000
+Just remember this.
+
+105
+00:08:56,000 --> 00:08:57,000
+Automatic configuration.
+
+106
+00:08:58,000 --> 00:09:04,000
+Spring Boot uses convention over configuration to automatically configure common components such as
+
+107
+00:09:04,000 --> 00:09:11,000
+data sources, messaging systems, and web servers based on the dependencies that are included in an
+
+108
+00:09:11,000 --> 00:09:12,000
+application.
+
+109
+00:09:13,000 --> 00:09:14,000
+Actuator.
+
+110
+00:09:14,000 --> 00:09:23,000
+Spring boot actuator provides a set of endpoints and tools that make it easy to monitor and manage an
+
+111
+00:09:23,000 --> 00:09:25,000
+application at runtime.
+
+112
+00:09:25,000 --> 00:09:33,000
+It includes health checks, metrics and other diagnostic tools that can be used to monitor and troubleshoot
+
+113
+00:09:33,000 --> 00:09:35,000
+an application in production.
+
+114
+00:09:36,000 --> 00:09:38,000
+Spring Boot Common Line interface.
+
+115
+00:09:38,000 --> 00:09:44,000
+Spring Boot includes a command line interface that makes it easy to quickly prototype and develop new
+
+116
+00:09:44,000 --> 00:09:46,000
+applications.
+
+117
+00:09:46,000 --> 00:09:53,000
+The command line interface provides a set of commands for creating testing and running applications.
+
+118
+00:09:54,000 --> 00:09:55,000
+Integrations.
+
+119
+00:09:55,000 --> 00:10:02,000
+Spring Boot integrates with a wide range of other technologies and frameworks, including Spring Cloud
+
+120
+00:10:02,000 --> 00:10:03,000
+and more.
+
+121
+00:10:03,000 --> 00:10:10,000
+Overall, Spring Boot is a powerful and flexible framework that makes it easy to develop, deploy and
+
+122
+00:10:10,000 --> 00:10:13,000
+manage modern Java applications.
+
+123
+00:10:13,000 --> 00:10:21,000
+Its rich set of features and tools make it a popular choice for developers of all levels of experience.
+
+124
+00:10:21,000 --> 00:10:26,000
+Previously, I mentioned that Spring Boot uses opinionated development approach.
+
+125
+00:10:26,000 --> 00:10:29,000
+Let's understand what it is.
+
+126
+00:10:29,000 --> 00:10:36,000
+Opinionated development is an approach that emphasizes a strong point of view on how software should
+
+127
+00:10:36,000 --> 00:10:39,000
+be designed, built and deployed.
+
+128
+00:10:39,000 --> 00:10:46,000
+In this approach, a framework or toolset provides a set of predefined conventions and best practices
+
+129
+00:10:46,000 --> 00:10:52,000
+that guide developers towards a specific way of building applications.
+
+130
+00:10:53,000 --> 00:10:59,000
+According to another definition, an opinionated approach is a software design pattern that guides users
+
+131
+00:10:59,000 --> 00:11:07,000
+when creating spring apps, that helps developers add and customize starter dependencies.
+
+132
+00:11:07,000 --> 00:11:15,000
+Spring Boots Opinionated approach chooses the right values and packages to install saving developers
+
+133
+00:11:15,000 --> 00:11:15,000
+time.
+
+134
+00:11:16,000 --> 00:11:22,000
+An opinionated framework like Spring Boot is designed to make certain decisions for developers, reducing
+
+135
+00:11:22,000 --> 00:11:27,000
+the amount of time and effort required to set up an application.
+
+136
+00:11:27,000 --> 00:11:33,000
+For example, Spring Boots Auto Configuration feature automatically configures many common components
+
+137
+00:11:33,000 --> 00:11:41,000
+like data sources, web servers and messaging systems based on the dependencies included in the application.
+
+138
+00:11:42,000 --> 00:11:49,000
+This opinionated approach can have several benefits, such as faster development, reduced complexity
+
+139
+00:11:49,000 --> 00:11:51,000
+and improved consistency.
+
+140
+00:11:51,000 --> 00:11:58,000
+Developers can focus on building the application's unique features and business logic rather than spending
+
+141
+00:11:58,000 --> 00:12:02,000
+time on routine tasks like configuration and setup.
+
+142
+00:12:03,000 --> 00:12:11,000
+However, be attentive, the opinionated approach can also be a disadvantage if developers need to deviate
+
+143
+00:12:11,000 --> 00:12:15,000
+from the frameworks predefined conventions.
+
+144
+00:12:15,000 --> 00:12:23,000
+This can require more effort and expertise as developers must understand the frameworks, architecture
+
+145
+00:12:23,000 --> 00:12:27,000
+and implementation details to customize it effectively.
+
+146
+00:12:27,000 --> 00:12:36,000
+That's exactly what I mean when I say that you need to understand how spring works, then it will be
+
+147
+00:12:36,000 --> 00:12:44,000
+easier for you to master spring boot and also level of flexibility of spring boot potentially may become
+
+148
+00:12:44,000 --> 00:12:50,000
+as one of the disadvantages, in my opinion, that we're going to talk about, when we will talk about
+
+149
+00:12:50,000 --> 00:12:52,000
+advantages and disadvantages.
+
+150
+00:12:52,000 --> 00:12:59,000
+An opinionated development approach can be a powerful tool for improving productivity and consistency,
+
+151
+00:12:59,000 --> 00:13:06,000
+but it is important to weigh the benefits and tradeoffs for your specific project and team.
+
+152
+00:13:07,000 --> 00:13:10,000
+We already learned the definition of spring boot.
+
+153
+00:13:10,000 --> 00:13:16,000
+Let's understand when it is more applicable and when it is less applicable.
+
+154
+00:13:16,000 --> 00:13:20,000
+Let's start from learning of when it is good idea to use spring boot.
+
+155
+00:13:21,000 --> 00:13:28,000
+Spring Boot is an excellent choice for developing a wide range of Java based applications, but it is
+
+156
+00:13:28,000 --> 00:13:33,000
+particularly well suited for projects that require rapid development.
+
+157
+00:13:33,000 --> 00:13:41,000
+Spring Boots Opinionated approach to application development along with its easy setup and configuration,
+
+158
+00:13:41,000 --> 00:13:47,000
+make it an ideal choice for rapid prototyping and development of new applications.
+
+159
+00:13:47,000 --> 00:13:49,000
+Microservices.
+
+160
+00:13:49,000 --> 00:13:56,000
+Spring Boot is well suited for developing microservices based architectures as it provides built in
+
+161
+00:13:56,000 --> 00:14:03,000
+support for restful web services, messaging systems and service discovery, among other features.
+
+162
+00:14:04,000 --> 00:14:06,000
+Cloud Native applications.
+
+163
+00:14:06,000 --> 00:14:13,000
+Spring Boot is designed to work well in cloud native environments and includes built in support for
+
+164
+00:14:13,000 --> 00:14:19,000
+containerization and deployment to cloud platforms like Kubernetes and Cloud Foundry.
+
+165
+00:14:20,000 --> 00:14:22,000
+Robustness and scalability.
+
+166
+00:14:22,000 --> 00:14:29,000
+Spring boots built in features for handling data, persistence, caching and security, among other
+
+167
+00:14:29,000 --> 00:14:35,000
+things, make it a robust and scalable framework for building complex applications.
+
+168
+00:14:36,000 --> 00:14:38,000
+Integration with other technologies.
+
+169
+00:14:38,000 --> 00:14:44,000
+Spring Boot is highly extensible and can be easily integrated with a wide range of other technologies
+
+170
+00:14:44,000 --> 00:14:52,000
+and frameworks, making it a popular choice for projects that require integration with multiple systems.
+
+171
+00:14:52,000 --> 00:14:58,000
+In general, if you are developing Java based applications, it requires rapid development, robustness,
+
+172
+00:14:58,000 --> 00:15:01,000
+scalability and integration with other technologies.
+
+173
+00:15:01,000 --> 00:15:04,000
+Spring Boot is an excellent choice.
+
+174
+00:15:04,000 --> 00:15:10,000
+Additionally, if you are developing microservices based or cloud native applications.
+
+175
+00:15:10,000 --> 00:15:16,000
+Spring Boot provides many features and tools that can make the development process much smoother and
+
+176
+00:15:16,000 --> 00:15:18,000
+more efficient.
+
+177
+00:15:18,000 --> 00:15:25,000
+While Spring Boot is a powerful and flexible framework that is well suited for developing many different
+
+178
+00:15:25,000 --> 00:15:32,000
+types of Java applications, there are some cases where it may not be the best choice.
+
+179
+00:15:32,000 --> 00:15:37,000
+Here are some situations where you may want to consider using a different framework.
+
+180
+00:15:37,000 --> 00:15:39,000
+Small applications.
+
+181
+00:15:39,000 --> 00:15:45,000
+If you are developing a small lightweight application that doesn't require a lot of additional features
+
+182
+00:15:45,000 --> 00:15:49,000
+or functionality, spring boot may be overkill.
+
+183
+00:15:49,000 --> 00:15:54,000
+In this case, a simpler, more lightweight framework may be a better choice.
+
+184
+00:15:55,000 --> 00:15:58,000
+Tight control over application configuration.
+
+185
+00:15:58,000 --> 00:16:04,000
+While Spring Boot is opinionated, approach to configuration can simplify development.
+
+186
+00:16:04,000 --> 00:16:10,000
+It may be a disadvantage if you need tight control over application configuration.
+
+187
+00:16:10,000 --> 00:16:16,000
+In this case, a more flexible framework like spring framework may be a better choice.
+
+188
+00:16:16,000 --> 00:16:19,000
+Applications with specific performance requirements.
+
+189
+00:16:20,000 --> 00:16:27,000
+While Spring Boot is designed to be fast and efficient, there may be cases where more specialized framework
+
+190
+00:16:27,000 --> 00:16:30,000
+is required for high performance applications.
+
+191
+00:16:31,000 --> 00:16:34,000
+Projects with existing architecture technology stack.
+
+192
+00:16:35,000 --> 00:16:41,000
+If you are working on a project that has an existing architecture or technology stack, it may be more
+
+193
+00:16:41,000 --> 00:16:45,000
+difficult to integrate Spring Boot into the existing environment.
+
+194
+00:16:45,000 --> 00:16:50,000
+In this case, it may be better to stick with the existing tools and technologies.
+
+195
+00:16:51,000 --> 00:16:56,000
+Projects that require tight control over application startup time.
+
+196
+00:16:56,000 --> 00:17:03,000
+While spring boots, rapid development and easy setup can be a big advantage, it may come at the cost
+
+197
+00:17:03,000 --> 00:17:06,000
+of slower startup times for the application.
+
+198
+00:17:07,000 --> 00:17:14,000
+If your project requires tight control over application startup time, a more lightweight framework
+
+199
+00:17:14,000 --> 00:17:15,000
+may be a better choice.
+
+200
+00:17:15,000 --> 00:17:22,000
+Overall, Spring Boot is an excellent choice for many Java based projects, but there may be cases where
+
+201
+00:17:22,000 --> 00:17:26,000
+a different framework or approach is more appropriate.
+
+202
+00:17:26,000 --> 00:17:33,000
+It is important to evaluate your project requirements carefully and choose the framework that best meets
+
+203
+00:17:33,000 --> 00:17:34,000
+your needs.
+
+204
+00:17:35,000 --> 00:17:39,000
+Based on what we have learned, let's try to summarize.
+
+205
+00:17:39,000 --> 00:17:42,000
+Advantages and disadvantages of Spring Boot.
+
+206
+00:17:42,000 --> 00:17:44,000
+Let's start from advantages.
+
+207
+00:17:45,000 --> 00:17:50,000
+Spring Boot has numerous advantages that make it a popular choice for Java developers.
+
+208
+00:17:50,000 --> 00:17:53,000
+Here are some of the key advantages of Spring boot.
+
+209
+00:17:53,000 --> 00:17:56,000
+Rapid Application Development.
+
+210
+00:17:56,000 --> 00:18:02,000
+Spring Boot is opinionated approach and easy setup allowed developers to quickly create new applications
+
+211
+00:18:02,000 --> 00:18:04,000
+and get them up and running.
+
+212
+00:18:05,000 --> 00:18:06,000
+Simplified Configuration.
+
+213
+00:18:07,000 --> 00:18:13,000
+Spring Boots Auto Configuration Feature simplifies the configuration process, reducing the amount of
+
+214
+00:18:13,000 --> 00:18:16,000
+boilerplate code that developers need to write.
+
+215
+00:18:17,000 --> 00:18:18,000
+Embedded Web Server.
+
+216
+00:18:18,000 --> 00:18:25,000
+Spring Boot includes an embedded web server, which allows developers to easily create web based applications
+
+217
+00:18:25,000 --> 00:18:29,000
+without having to configure and manage an external web server.
+
+218
+00:18:30,000 --> 00:18:31,000
+Dependency Management.
+
+219
+00:18:31,000 --> 00:18:38,000
+Spring Boots Dependency Management System automatically manages versions and conflicts, making it easier
+
+220
+00:18:38,000 --> 00:18:43,000
+for developers to manage the dependencies required by an application.
+
+221
+00:18:43,000 --> 00:18:45,000
+Automatic configuration.
+
+222
+00:18:45,000 --> 00:18:52,000
+Spring Boot automatically configures common components such as data sources, messaging systems and
+
+223
+00:18:52,000 --> 00:18:57,000
+web servers based on the dependencies included in an application.
+
+224
+00:18:57,000 --> 00:18:58,000
+Actuator.
+
+225
+00:18:58,000 --> 00:19:06,000
+Spring boot actuator provides a set of endpoints and tools that make it easy to monitor and manage an
+
+226
+00:19:06,000 --> 00:19:13,000
+application at runtime, including health checks, metrics and other diagnostic tools.
+
+227
+00:19:13,000 --> 00:19:15,000
+Microservices.
+
+228
+00:19:15,000 --> 00:19:22,000
+Spring Boot is well suited for developing microservices based architecture as it provides built in support
+
+229
+00:19:22,000 --> 00:19:27,000
+for restful web services, messaging systems and service discovery.
+
+230
+00:19:28,000 --> 00:19:32,000
+Cloud Native Spring Boot is designed to work well in a cloud.
+
+231
+00:19:32,000 --> 00:19:37,000
+Native environments with built in support for containerization and deployment to cloud platforms like
+
+232
+00:19:37,000 --> 00:19:39,000
+Kubernetes and Cloud Foundry.
+
+233
+00:19:40,000 --> 00:19:42,000
+Integration with other technologies.
+
+234
+00:19:42,000 --> 00:19:49,000
+Spring Boot is highly extensible and can be easily integrated with a wide range of other technologies
+
+235
+00:19:49,000 --> 00:19:55,000
+and frameworks, making it a popular choice for projects that require integration with multiple systems.
+
+236
+00:19:56,000 --> 00:20:01,000
+So as you can see, this is a summary of what we have learned already.
+
+237
+00:20:02,000 --> 00:20:08,000
+While Spring Boot has numerous advantages, there are also some potential disadvantages to consider
+
+238
+00:20:08,000 --> 00:20:12,000
+when choosing whether to use it for your project or not.
+
+239
+00:20:12,000 --> 00:20:15,000
+Here are some of the key disadvantages of spring boot.
+
+240
+00:20:16,000 --> 00:20:18,000
+Limited flexibility.
+
+241
+00:20:18,000 --> 00:20:19,000
+As we already discussed.
+
+242
+00:20:19,000 --> 00:20:26,000
+But just to summarize, while spring Boots opinionated approach can simplify development, it can also
+
+243
+00:20:26,000 --> 00:20:33,000
+limit flexibility, making it more difficult to customize the application to meet specific requirements.
+
+244
+00:20:33,000 --> 00:20:35,000
+Learning Curve.
+
+245
+00:20:35,000 --> 00:20:42,000
+While Spring Boot is designed to be easy to use, there is still a learning curve involved, particularly
+
+246
+00:20:42,000 --> 00:20:46,000
+for developers who are new to the spring ecosystem.
+
+247
+00:20:46,000 --> 00:20:48,000
+Increased application size.
+
+248
+00:20:49,000 --> 00:20:56,000
+Spring boots, extensive set of features and auto configuration can lead to larger application sizes,
+
+249
+00:20:56,000 --> 00:21:02,000
+which may be a disadvantage for applications with strict size requirements.
+
+250
+00:21:03,000 --> 00:21:10,000
+Overhead Spring Boot's, auto configuration and other features can introduce some additional overhead,
+
+251
+00:21:10,000 --> 00:21:15,000
+which may be a disadvantage for applications with strict performance requirements.
+
+252
+00:21:16,000 --> 00:21:18,000
+Opinionated approach.
+
+253
+00:21:18,000 --> 00:21:24,000
+While spring boots opinionated approach can be a benefit for developers who are looking for a quick
+
+254
+00:21:24,000 --> 00:21:31,000
+and easy way to build an application, it can also be a disadvantage for developers who prefer more
+
+255
+00:21:31,000 --> 00:21:36,000
+control over their application architecture and implementation.
+
+256
+00:21:36,000 --> 00:21:38,000
+Steep dependency.
+
+257
+00:21:39,000 --> 00:21:46,000
+Spring boot dependency management system can result in a deep Iraqi of dependencies, which can be difficult
+
+258
+00:21:46,000 --> 00:21:51,000
+to manage and may cause conflicts or compatibility issues.
+
+259
+00:21:51,000 --> 00:21:53,000
+Complexity for small projects.
+
+260
+00:21:53,000 --> 00:22:01,000
+For very small projects that don't require many features, Spring Boot may be overkill and introduce
+
+261
+00:22:01,000 --> 00:22:03,000
+unnecessary complexity.
+
+262
+00:22:03,000 --> 00:22:07,000
+Basically, that's all what I wanted to share with you today.
+
+263
+00:22:07,000 --> 00:22:11,000
+Let's recap what we have learned in the video.
+
+264
+00:22:11,000 --> 00:22:14,000
+We learned what a spring boot is.
+
+265
+00:22:14,000 --> 00:22:16,000
+We learned its key features.
+
+266
+00:22:17,000 --> 00:22:21,000
+I explained what an opinionated development approach is.
+
+267
+00:22:21,000 --> 00:22:27,000
+Now you know when to use spring boot and when not to use spring boot.
+
+268
+00:22:27,000 --> 00:22:32,000
+And at the end of the lesson, we learned its advantages and disadvantages.
+
+269
+00:22:33,000 --> 00:22:35,000
+That's it for this lesson.
+
+270
+00:22:35,000 --> 00:22:37,000
+Thanks a lot for your attention.
+
+271
+00:22:37,000 --> 00:22:40,000
+Have a great day and see you in the next lesson.
+
diff --git a/92 - Spring Boot/002 Source-code-of-the-first-Spring-Boot-project-from-the-lesson-commit-with-changes-.url b/92 - Spring Boot/002 Source-code-of-the-first-Spring-Boot-project-from-the-lesson-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..bffd63871da15e8f929cd5c5cd1ad8fd08f59424
--- /dev/null
+++ b/92 - Spring Boot/002 Source-code-of-the-first-Spring-Boot-project-from-the-lesson-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/ed97cff607917d923b693146b5fcdc08d507d422
\ No newline at end of file
diff --git a/92 - Spring Boot/002 Spring-Initializr-Tool.url b/92 - Spring Boot/002 Spring-Initializr-Tool.url
new file mode 100644
index 0000000000000000000000000000000000000000..904242062126c25bbd990d2c19c413b284db8361
--- /dev/null
+++ b/92 - Spring Boot/002 Spring-Initializr-Tool.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://start.spring.io/
\ No newline at end of file
diff --git a/92 - Spring Boot/002 The First Spring Boot Project_en.srt b/92 - Spring Boot/002 The First Spring Boot Project_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..a882ea7fe6ccfdac9c3322d5720a489b5f2e4e85
--- /dev/null
+++ b/92 - Spring Boot/002 The First Spring Boot Project_en.srt
@@ -0,0 +1,876 @@
+1
+00:00:05,000 --> 00:00:10,000
+Hello, dear students, we already learned what a spring boot is in the previous lesson.
+
+2
+00:00:10,000 --> 00:00:14,000
+And in this lesson, we are going to have practical activities.
+
+3
+00:00:14,000 --> 00:00:19,000
+We are going to create our first spring boot project and run it.
+
+4
+00:00:19,000 --> 00:00:26,000
+We are going to start this lesson from London Spring Initializer two because we are going to use it
+
+5
+00:00:26,000 --> 00:00:28,000
+for the Spring Boot project generation.
+
+6
+00:00:29,000 --> 00:00:36,000
+In total, I'm going to show you two main ways to generate your first spring boot project where spring
+
+7
+00:00:36,000 --> 00:00:41,000
+initializer web tool and directly in your eclipse IDE.
+
+8
+00:00:41,000 --> 00:00:47,000
+We will learn these two ways and will set up projects in the IDE for further development.
+
+9
+00:00:48,000 --> 00:00:51,000
+And we are going to have a lot of practical activity today.
+
+10
+00:00:52,000 --> 00:00:57,000
+We will create our first spring MVC controller in our first spring boot application.
+
+11
+00:00:57,000 --> 00:00:59,000
+Let's start our lesson.
+
+12
+00:01:00,000 --> 00:01:04,000
+The first thing that I want to demo you is spring initializer tool.
+
+13
+00:01:04,000 --> 00:01:10,000
+Let me explain what it is, because we are going to use this tool today in the lesson to create our
+
+14
+00:01:10,000 --> 00:01:12,000
+first spring boot project.
+
+15
+00:01:12,000 --> 00:01:20,000
+Spring Initializer is a web based tool provided by the Spring Team to help bootstrap and generate spring
+
+16
+00:01:20,000 --> 00:01:21,000
+boot projects with ease.
+
+17
+00:01:21,000 --> 00:01:28,000
+It simplifies the process of setting up a new spring boot project by generating a project structure
+
+18
+00:01:28,000 --> 00:01:34,000
+with the required dependencies and configurations based on your selections.
+
+19
+00:01:35,000 --> 00:01:41,000
+Key features of spring initializer include project customization.
+
+20
+00:01:41,000 --> 00:01:49,000
+Spring Initializer allows you to customize various aspects of your project, such as project, metadata,
+
+21
+00:01:49,000 --> 00:01:52,000
+dependencies and build systems.
+
+22
+00:01:52,000 --> 00:01:56,000
+You can specify the project's group and artifact name.
+
+23
+00:01:56,000 --> 00:02:05,000
+Select the desired spring boot version and add dependencies like Spring Web, spring data, JPA security
+
+24
+00:02:05,000 --> 00:02:07,000
+testing frameworks and more.
+
+25
+00:02:08,000 --> 00:02:10,000
+Starter dependencies.
+
+26
+00:02:10,000 --> 00:02:19,000
+Spring initializer leverages starter dependencies which are opinionated dependency descriptors to simplify
+
+27
+00:02:19,000 --> 00:02:24,000
+the inclusion of common libraries and frameworks in your project.
+
+28
+00:02:24,000 --> 00:02:30,000
+Starters provide a convenient way to add functionality to your spring boot project by automatically
+
+29
+00:02:30,000 --> 00:02:34,000
+configuring the necessary dependencies and boilerplate code.
+
+30
+00:02:35,000 --> 00:02:36,000
+Configuration options.
+
+31
+00:02:37,000 --> 00:02:43,000
+The tool offers additional configuration options for your project, including choosing the Build System
+
+32
+00:02:43,000 --> 00:02:51,000
+MAVEN or Gradle Java version, packaging format, Java and more.
+
+33
+00:02:51,000 --> 00:02:59,000
+It also allows you to specify advanced settings like choosing a specific spring boot version or enabling
+
+34
+00:02:59,000 --> 00:03:01,000
+specific features like Kotlin support.
+
+35
+00:03:02,000 --> 00:03:04,000
+Project generation.
+
+36
+00:03:04,000 --> 00:03:11,000
+Once you have customized your project settings, Spring Initializer generates a downloadable project
+
+37
+00:03:11,000 --> 00:03:17,000
+archive that contains the project structure and the necessary configuration files.
+
+38
+00:03:17,000 --> 00:03:25,000
+You can choose to download the project as zip file or directly import it into your favorite IDE.
+
+39
+00:03:25,000 --> 00:03:28,000
+Integration with Ides.
+
+40
+00:03:28,000 --> 00:03:35,000
+Spring initializer provides seamless integration with popular IDES, making it easier to create and
+
+41
+00:03:35,000 --> 00:03:38,000
+import projects directly from the IDE.
+
+42
+00:03:38,000 --> 00:03:42,000
+Supported ides include IntelliJ Eclipse.
+
+43
+00:03:42,000 --> 00:03:49,000
+The integration helps you skip manual project setup steps and jump straight into development.
+
+44
+00:03:50,000 --> 00:03:56,000
+A little bit later today during the demo, I'm going to show you which extension you can install into
+
+45
+00:03:56,000 --> 00:04:02,000
+your eclipse IDE in order to generate spring boot project directly from the IDE.
+
+46
+00:04:02,000 --> 00:04:09,000
+As you can see, spring initializer simplifies the process of creating spring boot projects by providing
+
+47
+00:04:09,000 --> 00:04:17,000
+an intuitive web based interface, customizable options and a streamlined project generation mechanism.
+
+48
+00:04:17,000 --> 00:04:25,000
+It helps developers get started quickly with Spring Boot and reduces the initial setup overhead, allowing
+
+49
+00:04:25,000 --> 00:04:28,000
+them to focus on building their applications.
+
+50
+00:04:29,000 --> 00:04:33,000
+As I already said, this is going to be practical lesson.
+
+51
+00:04:33,000 --> 00:04:38,000
+So let me start screen sharing and we will jump directly to practical examples.
+
+52
+00:04:39,000 --> 00:04:43,000
+So you already learned what a spring initializer tool is.
+
+53
+00:04:43,000 --> 00:04:45,000
+Let me show you how to work with it.
+
+54
+00:04:45,000 --> 00:04:53,000
+On practice, you can get access to it using this URL, I will leave a link in attachments to the video.
+
+55
+00:04:53,000 --> 00:04:55,000
+Here we have user friendly UI.
+
+56
+00:04:56,000 --> 00:05:00,000
+Let me comment on some UI elements and key labels here.
+
+57
+00:05:01,000 --> 00:05:02,000
+Project.
+
+58
+00:05:02,000 --> 00:05:09,000
+It defines the kind of project we can create is a MAVEN project or GRADLE project.
+
+59
+00:05:09,000 --> 00:05:15,000
+If you are a student of my Java from zero to first job course and you watched the section about automation
+
+60
+00:05:15,000 --> 00:05:21,000
+build tools, then you already know my opinion and why I select Maven.
+
+61
+00:05:21,000 --> 00:05:26,000
+If you want to learn more, you can check the relevant section in my course Java from zero to first
+
+62
+00:05:26,000 --> 00:05:29,000
+Job language.
+
+63
+00:05:29,000 --> 00:05:35,000
+Spring Initializer provides the choice among three languages Java, Kotlin and Groovy.
+
+64
+00:05:36,000 --> 00:05:43,000
+Java is selected by default and in this lesson we will not discuss which language is better.
+
+65
+00:05:43,000 --> 00:05:49,000
+You're welcome to select the one you like the most, but I keep Java selected.
+
+66
+00:05:49,000 --> 00:05:50,000
+Spring boot.
+
+67
+00:05:50,000 --> 00:05:53,000
+We can select the spring boot version.
+
+68
+00:05:54,000 --> 00:05:55,000
+Project metadata.
+
+69
+00:05:55,000 --> 00:06:01,000
+It contains information related to the project, such as group, artifact, etcetera.
+
+70
+00:06:02,000 --> 00:06:06,000
+Usually group is used in package name.
+
+71
+00:06:06,000 --> 00:06:11,000
+Artifact denotes the application name and also used in package name.
+
+72
+00:06:11,000 --> 00:06:20,000
+I will change group name to the common name that I use in my course and also set artifact name to reflect
+
+73
+00:06:20,000 --> 00:06:22,000
+the goal of this project.
+
+74
+00:06:23,000 --> 00:06:24,000
+Name.
+
+75
+00:06:24,000 --> 00:06:28,000
+It is the same as artifact description.
+
+76
+00:06:28,000 --> 00:06:34,000
+In the description field, we can write a description of the project package name.
+
+77
+00:06:34,000 --> 00:06:38,000
+Usually it is a combination of our group name and artifact name.
+
+78
+00:06:38,000 --> 00:06:42,000
+If you are familiar with Maven, you should be aware about such practice.
+
+79
+00:06:43,000 --> 00:06:44,000
+Packaging.
+
+80
+00:06:44,000 --> 00:06:47,000
+We can select the packaging of the project.
+
+81
+00:06:47,000 --> 00:06:50,000
+We can choose either jar or war.
+
+82
+00:06:50,000 --> 00:06:57,000
+I select Jar because one of the advantages of the spring boot is to have just Java installed on your
+
+83
+00:06:57,000 --> 00:07:05,000
+computer in order to run web application and you can run Jar archives with Java Command.
+
+84
+00:07:05,000 --> 00:07:06,000
+Java.
+
+85
+00:07:07,000 --> 00:07:11,000
+We can select the JVM version which we want to use.
+
+86
+00:07:11,000 --> 00:07:17,000
+We'll use Java 11 version because it is latest long term support version.
+
+87
+00:07:17,000 --> 00:07:25,000
+I know that Oracle releases new version of Java each six months, but even despite this crazy enumeration,
+
+88
+00:07:25,000 --> 00:07:32,000
+Steal Java Version eight is the most popular around the world, and Java version 11 is the latest long
+
+89
+00:07:32,000 --> 00:07:34,000
+term support version.
+
+90
+00:07:34,000 --> 00:07:40,000
+If you want to learn more about versions and what is long term support version, please refer to my
+
+91
+00:07:40,000 --> 00:07:42,000
+course Java from zero to first job.
+
+92
+00:07:43,000 --> 00:07:49,000
+This is a lesson about Java installation where I explained more about Java versions.
+
+93
+00:07:50,000 --> 00:07:51,000
+Dependencies.
+
+94
+00:07:51,000 --> 00:07:56,000
+Dependencies are the collection of artifacts that we can add to our project.
+
+95
+00:07:57,000 --> 00:08:01,000
+There are multiple dependencies you can choose from on this stage.
+
+96
+00:08:01,000 --> 00:08:05,000
+Don't worry, you can always add dependencies later.
+
+97
+00:08:05,000 --> 00:08:11,000
+For the sake of the demo, I just added spring boot dev tools and spring lab.
+
+98
+00:08:11,000 --> 00:08:19,000
+Spring lab is important dependency in order to have embedded tomcat web server and the spring boot dev
+
+99
+00:08:19,000 --> 00:08:27,000
+tools is a dependency that enhance development experience like fast application restarts and life reload
+
+100
+00:08:27,000 --> 00:08:31,000
+without need to recompile and restart application.
+
+101
+00:08:32,000 --> 00:08:36,000
+You can click Explore button to review the source code.
+
+102
+00:08:36,000 --> 00:08:43,000
+Just in case you want to configure the project manually and you want to copy and paste content of files
+
+103
+00:08:43,000 --> 00:08:47,000
+or or you just want to take a look at the structure.
+
+104
+00:08:47,000 --> 00:08:51,000
+Anyway, that is not something what we are interested in right now.
+
+105
+00:08:51,000 --> 00:08:56,000
+Instead, let's close this view and click Generate button.
+
+106
+00:08:56,000 --> 00:08:58,000
+It will download a zip archive.
+
+107
+00:08:59,000 --> 00:09:07,000
+The next thing what we have to do is to extract the project from archive and import it into our IDE.
+
+108
+00:09:08,000 --> 00:09:13,000
+For example, I extracted the content of the archive in the workspace folder.
+
+109
+00:09:13,000 --> 00:09:15,000
+Now let me open the eclipse ide.
+
+110
+00:09:16,000 --> 00:09:25,000
+I click file import existing Maven project and I select the project that was generated by Spring Initializer
+
+111
+00:09:25,000 --> 00:09:26,000
+Tool.
+
+112
+00:09:26,000 --> 00:09:28,000
+And that's it.
+
+113
+00:09:28,000 --> 00:09:33,000
+I already imported Spring Boot demo project into Eclipse IDE.
+
+114
+00:09:33,000 --> 00:09:38,000
+That's why I can see a conflict in the namespace here.
+
+115
+00:09:39,000 --> 00:09:40,000
+But you can do this.
+
+116
+00:09:40,000 --> 00:09:43,000
+Similar steps and everything will be okay for you.
+
+117
+00:09:44,000 --> 00:09:49,000
+That's how you can generate your first spring boot project with spring initializer tool.
+
+118
+00:09:50,000 --> 00:09:55,000
+Now let me show you another way to generate your first spring boot project directly from the Eclipse
+
+119
+00:09:55,000 --> 00:09:56,000
+IDE.
+
+120
+00:09:56,000 --> 00:10:01,000
+First of all, we need to install extension into our eclipse.
+
+121
+00:10:01,000 --> 00:10:02,000
+Click help.
+
+122
+00:10:03,000 --> 00:10:08,000
+Then eclipse marketplace in the search bar type spring tools.
+
+123
+00:10:14,000 --> 00:10:20,000
+In this list, I select Spring Tools for and click install button.
+
+124
+00:10:20,000 --> 00:10:23,000
+Taking into account it is already installed.
+
+125
+00:10:23,000 --> 00:10:29,000
+I don't have installed button, but you are going to see install button here.
+
+126
+00:10:29,000 --> 00:10:32,000
+Just click it and follow the instructions.
+
+127
+00:10:33,000 --> 00:10:37,000
+After installation you would be asked to restart the eclipse.
+
+128
+00:10:37,000 --> 00:10:40,000
+Follow these instructions and restart it.
+
+129
+00:10:41,000 --> 00:10:49,000
+Once it is installed, you can click file new and just search for spring starter project.
+
+130
+00:10:49,000 --> 00:10:56,000
+And here you can see literally the similar configurations that we saw on the web application.
+
+131
+00:10:56,000 --> 00:11:04,000
+Let's configure the application in the similar way, but let's just change the artifact name and add
+
+132
+00:11:04,000 --> 00:11:10,000
+two at the end of the artifact name in order to not have conflicts in names.
+
+133
+00:11:11,000 --> 00:11:15,000
+On the next page you can configure dependencies and spring boot version.
+
+134
+00:11:16,000 --> 00:11:25,000
+Let's add spring boot devtools and Spring Web similarly to the way we did when we generated our application
+
+135
+00:11:25,000 --> 00:11:27,000
+where spring initializer web app.
+
+136
+00:11:28,000 --> 00:11:32,000
+Then just click, finish and project will be generated.
+
+137
+00:11:32,000 --> 00:11:34,000
+It is super easy.
+
+138
+00:11:34,000 --> 00:11:35,000
+Don't you think so?
+
+139
+00:11:36,000 --> 00:11:37,000
+So what to do now?
+
+140
+00:11:37,000 --> 00:11:40,000
+Let's just run it and see.
+
+141
+00:11:40,000 --> 00:11:47,000
+Anyway, I recommend you to install Spring Tools because it adds a lot of different integrations for
+
+142
+00:11:47,000 --> 00:11:49,000
+spring boot applications.
+
+143
+00:11:49,000 --> 00:11:56,000
+For example, you don't need to build your application where console in order to run it because you
+
+144
+00:11:56,000 --> 00:12:00,000
+have nice button run as spring boot app.
+
+145
+00:12:00,000 --> 00:12:07,000
+By default, spring application is deployed in the root of the server and available at localhost at
+
+146
+00:12:07,000 --> 00:12:12,000
+port 8080 the default port of tomcat server.
+
+147
+00:12:12,000 --> 00:12:15,000
+Let's check it in the browser.
+
+148
+00:12:15,000 --> 00:12:19,000
+Taking into account we don't have any mappings or resources configured.
+
+149
+00:12:19,000 --> 00:12:27,000
+We see error page, but the fact that server replies us with the error page is enough to understand
+
+150
+00:12:27,000 --> 00:12:30,000
+that our application is up and running.
+
+151
+00:12:30,000 --> 00:12:36,000
+Congratulations you created and started your first spring boot application.
+
+152
+00:12:37,000 --> 00:12:44,000
+And in order to make this lesson complete, let's create at least one simple controller that would redirect
+
+153
+00:12:44,000 --> 00:12:50,000
+us to the home page, and we'll get rid of this error page specially for this lesson.
+
+154
+00:12:50,000 --> 00:12:56,000
+I already prepared source code example in attachments to the video lesson.
+
+155
+00:12:56,000 --> 00:13:02,000
+You can find the reference to the git repository where you can find the source code of example that
+
+156
+00:13:02,000 --> 00:13:04,000
+I prepared for you.
+
+157
+00:13:04,000 --> 00:13:12,000
+You can just clone the repository locally and run it on your computer or explore the source code in
+
+158
+00:13:12,000 --> 00:13:13,000
+details.
+
+159
+00:13:13,000 --> 00:13:17,000
+And right now I will walk you through the prepared source code examples.
+
+160
+00:13:18,000 --> 00:13:25,000
+In case you watched my previous lessons about spring and you are familiar with spring MVC, there will
+
+161
+00:13:25,000 --> 00:13:27,000
+be nothing new for you.
+
+162
+00:13:27,000 --> 00:13:34,000
+In case you are not familiar with spring MVC, then, like I already said in the first theoretical lesson
+
+163
+00:13:34,000 --> 00:13:40,000
+about Spring Boot, make sure you learn spring framework first before learning Spring Boot.
+
+164
+00:13:40,000 --> 00:13:45,000
+You can check my lessons about spring MVC in my course Java from zero to first job.
+
+165
+00:13:46,000 --> 00:13:50,000
+So let's start an overview of the example.
+
+166
+00:13:50,000 --> 00:13:51,000
+Here it is.
+
+167
+00:13:52,000 --> 00:13:58,000
+I added simple controller in controllers package that is called Home Controller.
+
+168
+00:13:58,000 --> 00:14:02,000
+I configured mapping using get mapping annotation.
+
+169
+00:14:03,000 --> 00:14:09,000
+The next thing in application properties that are located in the resources source folder.
+
+170
+00:14:10,000 --> 00:14:18,000
+I added few details for the view resolver, namely I specified spring MVC view prefix and suffix.
+
+171
+00:14:18,000 --> 00:14:19,000
+That's it.
+
+172
+00:14:20,000 --> 00:14:26,000
+I don't need to configure view resolver separately like we did in spring MVC because Spring Boot will
+
+173
+00:14:26,000 --> 00:14:32,000
+configure view resolver automatically based on our configurations provided.
+
+174
+00:14:32,000 --> 00:14:40,000
+In general, this file application properties we are going to use a lot in order to pass required configuration
+
+175
+00:14:40,000 --> 00:14:41,000
+for the spring boot.
+
+176
+00:14:42,000 --> 00:14:45,000
+Also I added web app folder.
+
+177
+00:14:45,000 --> 00:14:52,000
+I believe you remember that all our web resources should be placed in the separate folder by default
+
+178
+00:14:52,000 --> 00:14:53,000
+in spring boot.
+
+179
+00:14:53,000 --> 00:15:00,000
+You should put your web resources in web app folder under src main sub folder.
+
+180
+00:15:01,000 --> 00:15:04,000
+I created here Web-inf folder.
+
+181
+00:15:04,000 --> 00:15:11,000
+And we also already learned that content of the Web-inf is not accessible directly from the outside
+
+182
+00:15:11,000 --> 00:15:13,000
+of the application.
+
+183
+00:15:13,000 --> 00:15:21,000
+That's why clients won't be able to access the resource in the web in folder directly.
+
+184
+00:15:21,000 --> 00:15:29,000
+Instead, according to the MVC pattern, client will be able to access only the controller and on the
+
+185
+00:15:29,000 --> 00:15:36,000
+server side controller will forward the request to the resource in the web in folder if needed.
+
+186
+00:15:37,000 --> 00:15:41,000
+And here in Views folder, I created two JSP files.
+
+187
+00:15:42,000 --> 00:15:43,000
+The first one is home.
+
+188
+00:15:43,000 --> 00:15:52,000
+It contains simple HTML markup and just the text to indicate that we are on the home page and error
+
+189
+00:15:52,000 --> 00:15:53,000
+page.
+
+190
+00:15:53,000 --> 00:16:01,000
+Here request will be forwarded in case of any errors, even despite the fact we didn't create any specific
+
+191
+00:16:01,000 --> 00:16:04,000
+controller or exception handler.
+
+192
+00:16:04,000 --> 00:16:11,000
+There is a spring boot internal error handling mechanism which is automatically applied if no custom
+
+193
+00:16:11,000 --> 00:16:13,000
+error handling is defined.
+
+194
+00:16:13,000 --> 00:16:19,000
+Again, this is something what we talked about in the first lesson about Spring Boot.
+
+195
+00:16:19,000 --> 00:16:22,000
+Convention over configuration.
+
+196
+00:16:22,000 --> 00:16:27,000
+And during the course we are going to learn such conventions and agreements.
+
+197
+00:16:27,000 --> 00:16:34,000
+In a minute I'm going to show you how Error page is resolved and just in case I will make an overview
+
+198
+00:16:34,000 --> 00:16:36,000
+of POM XML.
+
+199
+00:16:36,000 --> 00:16:43,000
+But in case you selected spring web tools during the project generation, you should be good and nothing
+
+200
+00:16:43,000 --> 00:16:45,000
+should be added manually on top of that.
+
+201
+00:16:45,000 --> 00:16:47,000
+Basically, that's it.
+
+202
+00:16:48,000 --> 00:16:54,000
+Let's make sure that our previous web server and previous spring boot application is stopped and let's
+
+203
+00:16:54,000 --> 00:16:56,000
+run this one.
+
+204
+00:17:00,000 --> 00:17:08,000
+Once application is started, I open the web browser and when I hit the root resource, I see the content
+
+205
+00:17:08,000 --> 00:17:15,000
+of my home page that proves that request was forwarded to the home JSP page.
+
+206
+00:17:15,000 --> 00:17:22,000
+In case I tried to reach non-existent resource, you can see that I am redirected to the error page.
+
+207
+00:17:22,000 --> 00:17:30,000
+This proves that default error handler that is present in spring boot resolves error view automatically.
+
+208
+00:17:31,000 --> 00:17:35,000
+Congratulations with your first spring boot application.
+
+209
+00:17:36,000 --> 00:17:42,000
+This is just a beginning and we still have a lot of things to learn, but we already did significant
+
+210
+00:17:42,000 --> 00:17:43,000
+progress.
+
+211
+00:17:43,000 --> 00:17:47,000
+Let's recap what we have learned in the lesson.
+
+212
+00:17:48,000 --> 00:17:52,000
+Today we learned what spring initializer tool is and how to use it.
+
+213
+00:17:53,000 --> 00:18:00,000
+We generated our first spring boot project with the help of the spring initializer tool and directly
+
+214
+00:18:00,000 --> 00:18:06,000
+from the Eclipse IDE with the help of Spring Tools extension that we installed during the lesson.
+
+215
+00:18:07,000 --> 00:18:15,000
+We created simple MVC controller in our first spring boot application and we saw how all this works
+
+216
+00:18:15,000 --> 00:18:21,000
+in practice because we reviewed the source code and run our spring boot application.
+
+217
+00:18:22,000 --> 00:18:24,000
+That's all for this lesson.
+
+218
+00:18:24,000 --> 00:18:26,000
+Thanks a lot for your attention.
+
+219
+00:18:26,000 --> 00:18:29,000
+Have a great day and see you in the next lesson.
+
diff --git a/92 - Spring Boot/003 Source-code-of-examples-commit-with-changes-.url b/92 - Spring Boot/003 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..0e00acdde94f7e282108d64c3dfc4b15b90e9fe0
--- /dev/null
+++ b/92 - Spring Boot/003 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/4b8bea15fe2262ce27a63fc8a0c9059549e39c4c
\ No newline at end of file
diff --git a/92 - Spring Boot/003 Spring Boot Starters_en.srt b/92 - Spring Boot/003 Spring Boot Starters_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..dc0104794b34abf5cf20a2a1b3dca33f166eae31
--- /dev/null
+++ b/92 - Spring Boot/003 Spring Boot Starters_en.srt
@@ -0,0 +1,1612 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:10,000
+In this video lesson, we are going to learn more about spring boot starters.
+
+3
+00:00:11,000 --> 00:00:15,000
+Today we are going to have mixed lesson, some theory and practical examples.
+
+4
+00:00:15,000 --> 00:00:18,000
+In order you can understand the topic.
+
+5
+00:00:18,000 --> 00:00:24,000
+We'll start the lesson from learning and understanding what starters are and why do we need them.
+
+6
+00:00:24,000 --> 00:00:31,000
+I will explain benefits and advantages that we as developers expect to get by using them.
+
+7
+00:00:31,000 --> 00:00:38,000
+We'll review the list of starters that you potentially may use in your spring boot applications.
+
+8
+00:00:38,000 --> 00:00:45,000
+And after learning some theory about starters, we'll jump to practical exercises and review real life
+
+9
+00:00:45,000 --> 00:00:46,000
+examples.
+
+10
+00:00:47,000 --> 00:00:52,000
+I'm going to show you how you can add Spring Boot starter into your application.
+
+11
+00:00:52,000 --> 00:00:56,000
+We'll review web starter and create Rest API.
+
+12
+00:00:57,000 --> 00:00:59,000
+I'm going to show you test starter.
+
+13
+00:00:59,000 --> 00:01:06,000
+We'll create few tests and we will also review data starter for the GPA.
+
+14
+00:01:06,000 --> 00:01:12,000
+I will show you how built in support of H2 database is configured in Spring boot.
+
+15
+00:01:12,000 --> 00:01:18,000
+And then I will also show you how to configure data source for MySQL database.
+
+16
+00:01:18,000 --> 00:01:21,000
+And at the end of the lesson we'll learn security starter.
+
+17
+00:01:22,000 --> 00:01:23,000
+Let's start our lesson.
+
+18
+00:01:24,000 --> 00:01:27,000
+Let's first learn the definition.
+
+19
+00:01:27,000 --> 00:01:30,000
+What are spring boot starters?
+
+20
+00:01:30,000 --> 00:01:31,000
+I will explain you what.
+
+21
+00:01:31,000 --> 00:01:35,000
+Spring boot starters is with simple real life scenario.
+
+22
+00:01:36,000 --> 00:01:42,000
+Imagine that you need to start development of rest service instead of adding dependencies of spring
+
+23
+00:01:42,000 --> 00:01:50,000
+context, Spring MVC, Tomcat, Jackson select proper versions and check compatibility.
+
+24
+00:01:50,000 --> 00:01:57,000
+Why don't you just add one dependency that is called web starter and spring wood will do the rest.
+
+25
+00:01:57,000 --> 00:02:00,000
+This should be much easier and great.
+
+26
+00:02:00,000 --> 00:02:09,000
+So we can say that in the context of spring boot starters are set of opinionated dependencies, dependencies,
+
+27
+00:02:09,000 --> 00:02:18,000
+descriptors that provide a convenient way to add commonly used frameworks, libraries and features to
+
+28
+00:02:18,000 --> 00:02:20,000
+your spring boot application.
+
+29
+00:02:20,000 --> 00:02:30,000
+They help simplify the configuration and setup process by providing predefined dependencies and configurations,
+
+30
+00:02:30,000 --> 00:02:37,000
+allowing you to focus more on developing your application logic rather than managing dependencies.
+
+31
+00:02:37,000 --> 00:02:45,000
+Spring boot starters follows the principle of convention over configuration, providing sensible defaults
+
+32
+00:02:45,000 --> 00:02:49,000
+and reducing the need for manual configuration.
+
+33
+00:02:49,000 --> 00:02:57,000
+Each starter is focused on a specific aspect of application development, such as web development,
+
+34
+00:02:57,000 --> 00:03:02,000
+data, access, security, messaging, testing, etcetera.
+
+35
+00:03:02,000 --> 00:03:10,000
+By including a starter dependency in your spring boot project, you automatically bring in all the necessary
+
+36
+00:03:10,000 --> 00:03:16,000
+dependencies and configurations required for that specific feature or functionality.
+
+37
+00:03:16,000 --> 00:03:24,000
+For example, including the Spring Boot starter Web starter will automatically configure the web related
+
+38
+00:03:24,000 --> 00:03:31,000
+dependencies such as Embedded Tomcat Server, Spring MVC and other related components.
+
+39
+00:03:31,000 --> 00:03:39,000
+Starters are designed to work together seamlessly and you can combine multiple starters in your project
+
+40
+00:03:39,000 --> 00:03:41,000
+to incorporate various features.
+
+41
+00:03:41,000 --> 00:03:50,000
+They help promote modularization and maintain a consistent and standardized approach to building spring
+
+42
+00:03:50,000 --> 00:03:52,000
+boot applications.
+
+43
+00:03:52,000 --> 00:03:59,000
+Starters not only simplifies the initial project setup, but also provides ongoing maintenance benefits
+
+44
+00:03:59,000 --> 00:04:04,000
+when new versions of libraries or frameworks are released.
+
+45
+00:04:04,000 --> 00:04:11,000
+The Spring Boot team ensures that the starters are up to date and compatible, making it easier to keep
+
+46
+00:04:11,000 --> 00:04:13,000
+your dependencies up to date.
+
+47
+00:04:14,000 --> 00:04:21,000
+So spring boot starters provide a convenient and efficient way to bootstrap your spring boot projects
+
+48
+00:04:21,000 --> 00:04:28,000
+by reducing the complexity of dependency management and configuration, enabling you to quickly build
+
+49
+00:04:28,000 --> 00:04:32,000
+applications with the desired features and functionalities.
+
+50
+00:04:33,000 --> 00:04:38,000
+Now it is time for us to understand why do we need spring boot starters?
+
+51
+00:04:39,000 --> 00:04:40,000
+Efficiently?
+
+52
+00:04:40,000 --> 00:04:47,000
+Managing dependencies is crucial in complex projects, and manual management can be suboptimal as it
+
+53
+00:04:47,000 --> 00:04:54,000
+consumes valuable time as it could be spent on other essential project aspects.
+
+54
+00:04:54,000 --> 00:05:00,000
+I believe if you already watch this lesson of the course, then you are not completely beginner in Java
+
+55
+00:05:00,000 --> 00:05:01,000
+development.
+
+56
+00:05:01,000 --> 00:05:09,000
+Thus you had cases in your life when you specified dependencies that are not comparable because of different
+
+57
+00:05:09,000 --> 00:05:17,000
+versions or you forget to specify some dependency and Java applications throws class not found exception
+
+58
+00:05:17,000 --> 00:05:18,000
+during the runtime.
+
+59
+00:05:19,000 --> 00:05:25,000
+With spring boot starters, you reduce chances of doing mistake during the dependency management.
+
+60
+00:05:25,000 --> 00:05:30,000
+Spring boot starters were specifically developed to tackle this issue.
+
+61
+00:05:30,000 --> 00:05:36,000
+Let's summarize advantages that we expect to get by using spring boot starters.
+
+62
+00:05:36,000 --> 00:05:42,000
+Spring boot starters are designed to simplify the process of setting up and configuring spring boot
+
+63
+00:05:42,000 --> 00:05:43,000
+applications.
+
+64
+00:05:43,000 --> 00:05:50,000
+Here are a few reasons why we need spring boot starters and what advantages we get when we use spring
+
+65
+00:05:50,000 --> 00:05:51,000
+boot starters.
+
+66
+00:05:51,000 --> 00:05:59,000
+The first one Convenience starters provide a convenient way to add commonly used frameworks, libraries
+
+67
+00:05:59,000 --> 00:06:03,000
+and features to your spring boot application.
+
+68
+00:06:03,000 --> 00:06:10,000
+They package together all necessary dependencies, configurations and auto configurations related to
+
+69
+00:06:10,000 --> 00:06:13,000
+a specific functionality or feature.
+
+70
+00:06:13,000 --> 00:06:20,000
+This saves you from manually searching for and adding individual dependencies, reducing the setup time
+
+71
+00:06:20,000 --> 00:06:22,000
+and complexity.
+
+72
+00:06:22,000 --> 00:06:30,000
+Opinionated configuration Spring boot starters Follow an opinionated approach to configuration, providing
+
+73
+00:06:30,000 --> 00:06:35,000
+sensible defaults and reducing the need for extensive manual configuration.
+
+74
+00:06:35,000 --> 00:06:42,000
+They encapsulate best practices and predefined configurations for specific use cases, allowing you
+
+75
+00:06:42,000 --> 00:06:48,000
+to get started quickly without spending time on boilerplate configuration.
+
+76
+00:06:48,000 --> 00:06:54,000
+Modularization Starters Promote modularization in your application.
+
+77
+00:06:54,000 --> 00:07:02,000
+By using starters, you can easily include all the dependencies and features that your application requires.
+
+78
+00:07:02,000 --> 00:07:09,000
+This helps keep the application lightweight, improves maintainability and reduces the risk of including
+
+79
+00:07:09,000 --> 00:07:11,000
+unnecessary dependencies.
+
+80
+00:07:12,000 --> 00:07:14,000
+Compatibility and version management.
+
+81
+00:07:15,000 --> 00:07:21,000
+Starters are designed to work together seamlessly ensuring compatibility between different dependencies.
+
+82
+00:07:22,000 --> 00:07:30,000
+Rapid development With starters, you can focus more on writing, application logic and implementing
+
+83
+00:07:30,000 --> 00:07:36,000
+business requirements rather than spending time on dependency management and configuration.
+
+84
+00:07:37,000 --> 00:07:44,000
+They provide a streamlined development experience by abstracting away the complexities of dependency
+
+85
+00:07:44,000 --> 00:07:44,000
+management.
+
+86
+00:07:45,000 --> 00:07:47,000
+Community support.
+
+87
+00:07:47,000 --> 00:07:51,000
+Spring boot starters have a great community and ecosystem around them.
+
+88
+00:07:52,000 --> 00:08:00,000
+You can find extensive documentation, tutorials and resources related to each starter as well as commonly
+
+89
+00:08:00,000 --> 00:08:05,000
+support through forums, blogs and stack overflow.
+
+90
+00:08:05,000 --> 00:08:12,000
+This makes it easier to find help and guidance when working with specific functionalities or features.
+
+91
+00:08:12,000 --> 00:08:17,000
+Probably you might be wondering which spring boot starters you can use.
+
+92
+00:08:17,000 --> 00:08:20,000
+There are more than 30 spring boot starters.
+
+93
+00:08:20,000 --> 00:08:25,000
+Let me present you the most common and popular ones in my opinion.
+
+94
+00:08:26,000 --> 00:08:27,000
+Starter web.
+
+95
+00:08:28,000 --> 00:08:31,000
+Starter for building web applications using spring MVC.
+
+96
+00:08:33,000 --> 00:08:34,000
+Starter data GPA.
+
+97
+00:08:35,000 --> 00:08:40,000
+This starter is for using spring data JPA for database access.
+
+98
+00:08:40,000 --> 00:08:42,000
+Start the security.
+
+99
+00:08:42,000 --> 00:08:48,000
+Obviously, this one for adding spring security to secure your application.
+
+100
+00:08:48,000 --> 00:08:50,000
+Starter test.
+
+101
+00:08:50,000 --> 00:08:57,000
+Based on the name, you can guess that this one is for writing unit tests and integration tests for
+
+102
+00:08:57,000 --> 00:09:00,000
+your spring boot application starter seam.
+
+103
+00:09:02,000 --> 00:09:08,000
+This starter is for using the seam lift templating engine for server side rendering.
+
+104
+00:09:08,000 --> 00:09:15,000
+If you don't know, seam leave is a modern server side Java template engine that is commonly used in
+
+105
+00:09:15,000 --> 00:09:20,000
+web applications, especially in conjunction with Spring Framework and Spring Boot.
+
+106
+00:09:20,000 --> 00:09:28,000
+It aims to bring natural templating capabilities to HTML by providing a seamless integration with Java
+
+107
+00:09:28,000 --> 00:09:29,000
+ecosystem.
+
+108
+00:09:29,000 --> 00:09:31,000
+Starter actuator.
+
+109
+00:09:32,000 --> 00:09:37,000
+This starter for monitoring and managing your application in production.
+
+110
+00:09:38,000 --> 00:09:41,000
+We're going to have a separate lesson about actuator to.
+
+111
+00:09:42,000 --> 00:09:44,000
+Starter Amqp.
+
+112
+00:09:45,000 --> 00:09:52,000
+This starter for using spring advanced message queuing protocol for messaging.
+
+113
+00:09:53,000 --> 00:09:57,000
+Startup data MongoDB startup for using spring data.
+
+114
+00:09:57,000 --> 00:10:01,000
+MongoDB for MongoDB database access starter login.
+
+115
+00:10:02,000 --> 00:10:12,000
+This one is for login using a server and Logback libraries Starter validation for using bean validation
+
+116
+00:10:12,000 --> 00:10:21,000
+API Starter cache for using spring's caching support Starter mail for Send an email using Javamail.
+
+117
+00:10:22,000 --> 00:10:28,000
+The rest of the popular starters and their description you can find on the slide.
+
+118
+00:10:28,000 --> 00:10:33,000
+But in reality, there are even more spring boot starters.
+
+119
+00:10:33,000 --> 00:10:38,000
+Just take a look at this repository with the source code of spring boot starters.
+
+120
+00:10:39,000 --> 00:10:42,000
+I'm sure you will be able to find the ones that you need.
+
+121
+00:10:43,000 --> 00:10:46,000
+Important thing is that you can create custom spring boot starter.
+
+122
+00:10:46,000 --> 00:10:51,000
+And as I already said, spring community is huge.
+
+123
+00:10:51,000 --> 00:10:57,000
+And before developing your own spring boot starter, just check whether such spring boot starter already
+
+124
+00:10:57,000 --> 00:11:00,000
+exists in the attachments to the lesson.
+
+125
+00:11:00,000 --> 00:11:02,000
+I will leave a link to the GitHub.
+
+126
+00:11:02,000 --> 00:11:09,000
+The links that I present right now on the screen here you can find a list of spring boot starters and
+
+127
+00:11:09,000 --> 00:11:14,000
+also a list of the custom spring boot starters created by the community.
+
+128
+00:11:15,000 --> 00:11:19,000
+So we learned a lot about spring boot starters.
+
+129
+00:11:19,000 --> 00:11:21,000
+I believe that now you understand.
+
+130
+00:11:21,000 --> 00:11:22,000
+What are they?
+
+131
+00:11:22,000 --> 00:11:26,000
+The only thing that is left is to learn how to use them.
+
+132
+00:11:26,000 --> 00:11:31,000
+Let me start the screen sharing and review practical examples with you.
+
+133
+00:11:31,000 --> 00:11:38,000
+The first and probably the most logical question from you is how to add starter into your spring boot
+
+134
+00:11:38,000 --> 00:11:38,000
+project.
+
+135
+00:11:39,000 --> 00:11:40,000
+Everything is simple.
+
+136
+00:11:41,000 --> 00:11:47,000
+You just need to add dependency into your form XML and that's it.
+
+137
+00:11:47,000 --> 00:11:54,000
+You can find the required dependency in the open repositories like Maven Repository, for example.
+
+138
+00:11:54,000 --> 00:11:58,000
+The group ID would be org spring framework boot.
+
+139
+00:11:59,000 --> 00:12:06,000
+The artifact ID would usually follow the pattern spring boot starter followed by the name of functionality
+
+140
+00:12:06,000 --> 00:12:08,000
+or feature you want to include.
+
+141
+00:12:09,000 --> 00:12:15,000
+Once the starter is added to your project's dependencies, Spring Boot will automatically configure
+
+142
+00:12:15,000 --> 00:12:20,000
+the required components, dependencies and defaults for that specific functionality.
+
+143
+00:12:21,000 --> 00:12:27,000
+In today's practical exercise, we are going to review different starters and we'll configure different
+
+144
+00:12:27,000 --> 00:12:29,000
+spring features.
+
+145
+00:12:29,000 --> 00:12:32,000
+Let's start with you from the web starter.
+
+146
+00:12:33,000 --> 00:12:35,000
+I opened my pom.xml.
+
+147
+00:12:35,000 --> 00:12:42,000
+In this file we specify all the required dependencies and MAVEN will handle the download of all the
+
+148
+00:12:42,000 --> 00:12:48,000
+required dependencies, including additional transitive dependencies if required.
+
+149
+00:12:48,000 --> 00:12:51,000
+Here you can see spring boot starter web.
+
+150
+00:12:52,000 --> 00:13:00,000
+What features are added into my spring boot project after I added the starter support of web MVC Framework.
+
+151
+00:13:00,000 --> 00:13:08,000
+Embedded Servlet Container Apache Tomcat Dispatcher Servlet configuration Auto configuration of web
+
+152
+00:13:08,000 --> 00:13:15,000
+related dependencies such as HTTP message converters, error handling, static resource handling and
+
+153
+00:13:15,000 --> 00:13:16,000
+session management.
+
+154
+00:13:17,000 --> 00:13:25,000
+Support for restful APIs by including features like request response, conversion to JSON, XML and
+
+155
+00:13:25,000 --> 00:13:29,000
+HTTP method mapping to not repeat myself.
+
+156
+00:13:29,000 --> 00:13:35,000
+I will not repeat the example of the simple MVC controller because that's what we did in the previous
+
+157
+00:13:35,000 --> 00:13:38,000
+lesson when we created our first spring boot project.
+
+158
+00:13:38,000 --> 00:13:46,000
+You can check all the details there, but just to remind you, here we have simple home controller and
+
+159
+00:13:46,000 --> 00:13:47,000
+application properties.
+
+160
+00:13:47,000 --> 00:13:56,000
+I configure prefix and suffix for your resolver and create a web app folder in the main insight web
+
+161
+00:13:56,000 --> 00:13:57,000
+app folder.
+
+162
+00:13:57,000 --> 00:14:04,000
+Created web in folder views and put the home JSP file and error JSP file.
+
+163
+00:14:05,000 --> 00:14:05,000
+Error.
+
+164
+00:14:05,000 --> 00:14:12,000
+JSP view is resolved automatically because spring boot configured error handler automatically.
+
+165
+00:14:12,000 --> 00:14:16,000
+That's in short what we have learned in previous lesson.
+
+166
+00:14:16,000 --> 00:14:22,000
+Even in case you still have any questions, you are welcome to ask your questions below the video in
+
+167
+00:14:22,000 --> 00:14:25,000
+the comments and I will be happy to answer them.
+
+168
+00:14:26,000 --> 00:14:33,000
+If you are a student of my course Java from zero to first job, then you remember that we have module
+
+169
+00:14:33,000 --> 00:14:39,000
+about rest architecture and I showed you how to implement rest API with spring.
+
+170
+00:14:40,000 --> 00:14:42,000
+The same story in spring boot.
+
+171
+00:14:42,000 --> 00:14:48,000
+So just to make it clear, spring boot is not something completely different.
+
+172
+00:14:48,000 --> 00:14:51,000
+It is the same spring framework and everything.
+
+173
+00:14:51,000 --> 00:14:57,000
+What we have learned in previous lessons about spring framework and about its different projects is
+
+174
+00:14:57,000 --> 00:15:00,000
+absolutely applicable in spring boot.
+
+175
+00:15:01,000 --> 00:15:08,000
+As you can see, we just added Spring Boot Starter Web and you can proceed with implementation of Rest
+
+176
+00:15:08,000 --> 00:15:11,000
+API and how to implement Rest API.
+
+177
+00:15:11,000 --> 00:15:17,000
+We learned in separate lessons and there is no need for me to repeat the lessons about Rest Architecture
+
+178
+00:15:17,000 --> 00:15:19,000
+and Rest API.
+
+179
+00:15:19,000 --> 00:15:25,000
+If you would like to learn more about rest then please refer to the separate module about rest architecture.
+
+180
+00:15:25,000 --> 00:15:32,000
+And in this lesson I'm going to show you just a simple example of rest endpoint developed in spring
+
+181
+00:15:32,000 --> 00:15:33,000
+boot application.
+
+182
+00:15:34,000 --> 00:15:36,000
+I created class as it is called.
+
+183
+00:15:36,000 --> 00:15:37,000
+Rest Demo Controller.
+
+184
+00:15:37,000 --> 00:15:39,000
+Let me open it.
+
+185
+00:15:39,000 --> 00:15:46,000
+As you can see, I marked this class with rest controller annotation from the lesson about Rest API.
+
+186
+00:15:46,000 --> 00:15:47,000
+With Spring framework.
+
+187
+00:15:47,000 --> 00:15:54,000
+You remember that rest controller is a combination of controller annotation with response body.
+
+188
+00:15:54,000 --> 00:16:01,000
+In order to not make this example super complex, I don't use database connections here.
+
+189
+00:16:01,000 --> 00:16:08,000
+I use the in-memory storage which is my array list in order to store demo entities.
+
+190
+00:16:08,000 --> 00:16:15,000
+Demo entity is simple entity type with only two fields ID and label.
+
+191
+00:16:15,000 --> 00:16:16,000
+That's it.
+
+192
+00:16:17,000 --> 00:16:26,000
+I implemented three end points to fetch all entities, to add entity and to fetch entity by ID.
+
+193
+00:16:27,000 --> 00:16:35,000
+Again, we already learned naming convention for sources in Rest API and all related annotations, including
+
+194
+00:16:35,000 --> 00:16:37,000
+path variable annotation.
+
+195
+00:16:37,000 --> 00:16:40,000
+That's why don't stop too much on this.
+
+196
+00:16:41,000 --> 00:16:45,000
+Let's now just check and make sure that everything works as expected.
+
+197
+00:16:46,000 --> 00:16:49,000
+I can open Postman and send few requests.
+
+198
+00:16:52,000 --> 00:17:00,000
+When I fetch all entities, I receive two entities that I added during the initialization of the list.
+
+199
+00:17:00,000 --> 00:17:10,000
+Then I send post requests and add one more entity with ID three and we can see that it is added.
+
+200
+00:17:11,000 --> 00:17:18,000
+I can fetch all entities one more time and we can see that entity with ID number three is added at the
+
+201
+00:17:18,000 --> 00:17:19,000
+end of the list.
+
+202
+00:17:20,000 --> 00:17:25,000
+And the certain point that we created it is fetching entity by ID.
+
+203
+00:17:26,000 --> 00:17:29,000
+As you can see, it also works as expected.
+
+204
+00:17:30,000 --> 00:17:37,000
+So as you can see, this is how easily we can boost development of Rest API with Spring boot.
+
+205
+00:17:37,000 --> 00:17:44,000
+In case you want to learn more about Rest API, I invite you to check separate section about rest API
+
+206
+00:17:44,000 --> 00:17:45,000
+in this course.
+
+207
+00:17:45,000 --> 00:17:47,000
+At the meantime, we continue.
+
+208
+00:17:48,000 --> 00:17:51,000
+Let me show you this starter in action now.
+
+209
+00:17:51,000 --> 00:17:55,000
+What dependencies do we usually need for testing?
+
+210
+00:17:55,000 --> 00:17:56,000
+Spring tests.
+
+211
+00:17:56,000 --> 00:17:58,000
+JUnit Hamcrest.
+
+212
+00:17:58,000 --> 00:17:59,000
+Mockito.
+
+213
+00:17:59,000 --> 00:18:05,000
+By the way, there is a separate module about testing for software engineers in my course Java from
+
+214
+00:18:05,000 --> 00:18:06,000
+zero to first job.
+
+215
+00:18:06,000 --> 00:18:14,000
+If you want to learn more, I invite you to check that module so we can use Spring boot starter to include
+
+216
+00:18:14,000 --> 00:18:19,000
+all required dependencies for testing automatically in the POM XML.
+
+217
+00:18:19,000 --> 00:18:22,000
+I added dependency for spring boot starter test.
+
+218
+00:18:23,000 --> 00:18:29,000
+And by the way, pay attention that you don't need to specify a version of the dependency.
+
+219
+00:18:29,000 --> 00:18:30,000
+Why?
+
+220
+00:18:30,000 --> 00:18:37,000
+Because during the generation of Spring boot project we also generated this POM with a declaration of
+
+221
+00:18:37,000 --> 00:18:42,000
+the spring boot starter parent as a parent for this project.
+
+222
+00:18:42,000 --> 00:18:44,000
+And we specified version here.
+
+223
+00:18:45,000 --> 00:18:48,000
+After that, spring boot will take care of versions compatible.
+
+224
+00:18:49,000 --> 00:18:52,000
+So I added this starter.
+
+225
+00:18:52,000 --> 00:19:00,000
+Also, pay attention that I specified scope of the dependency to test because I don't need these dependencies
+
+226
+00:19:00,000 --> 00:19:02,000
+in my production ready archive.
+
+227
+00:19:03,000 --> 00:19:06,000
+I just need these dependencies for the test phase.
+
+228
+00:19:07,000 --> 00:19:12,000
+Let's now test the controller that we created in the previous example.
+
+229
+00:19:12,000 --> 00:19:14,000
+Under Test Java folder.
+
+230
+00:19:14,000 --> 00:19:18,000
+I created class that is called Demo Controller test.
+
+231
+00:19:19,000 --> 00:19:21,000
+Everything is simple here.
+
+232
+00:19:21,000 --> 00:19:27,000
+That is because Spring Boot provides excellent integration with five out of the box.
+
+233
+00:19:27,000 --> 00:19:36,000
+JUnit five has its own built in test runner called JUnit platform, which is automatically used when
+
+234
+00:19:36,000 --> 00:19:39,000
+running tests in a spring boot application.
+
+235
+00:19:39,000 --> 00:19:46,000
+This means that you don't need to explicitly specify a custom runner using run with for your spring
+
+236
+00:19:46,000 --> 00:19:53,000
+boot tests in spring boot test configuration and setup can be achieved using annotations like Spring
+
+237
+00:19:53,000 --> 00:19:58,000
+Boot Test, Web MVC test or data test.
+
+238
+00:19:59,000 --> 00:20:07,000
+These annotations, along with other specialized annotations, provide a streamlined approach to configuring
+
+239
+00:20:07,000 --> 00:20:10,000
+and running tests in different contexts.
+
+240
+00:20:10,000 --> 00:20:15,000
+Web database without the need for a custom test Runner.
+
+241
+00:20:15,000 --> 00:20:22,000
+The Spring Boot test annotation is used to specify that a particular class or classes should be treated
+
+242
+00:20:22,000 --> 00:20:29,000
+as a test class, and it triggers the setup of the spring boot testing infrastructure.
+
+243
+00:20:29,000 --> 00:20:37,000
+The specified class serves as an entry point for building the context, including scanning for components,
+
+244
+00:20:37,000 --> 00:20:41,000
+setting up configurations and initializing the necessary beans.
+
+245
+00:20:42,000 --> 00:20:50,000
+And you can see here I used enable web MVC annotation using enable weapon can be beneficial in certain
+
+246
+00:20:50,000 --> 00:20:57,000
+scenarios when you need to customize the web configuration specifically for your tests.
+
+247
+00:20:57,000 --> 00:21:06,000
+By using enable web MVC, you can ensure that the complete MVC infrastructure is enabled for your tests,
+
+248
+00:21:06,000 --> 00:21:10,000
+giving you access to the full range of MVC capabilities.
+
+249
+00:21:10,000 --> 00:21:17,000
+In the properties, you can see that I declared web application context and mock MVC.
+
+250
+00:21:17,000 --> 00:21:23,000
+Mock MVC is a special type that would allow us to test spring MVC behavior.
+
+251
+00:21:23,000 --> 00:21:25,000
+Before each test.
+
+252
+00:21:25,000 --> 00:21:27,000
+I will configure Mock MVC.
+
+253
+00:21:27,000 --> 00:21:34,000
+I would use Mock MVC Builders and web application contexts to build mock MVC.
+
+254
+00:21:34,000 --> 00:21:38,000
+What I recommend you to do is to download the source code.
+
+255
+00:21:39,000 --> 00:21:46,000
+I would leave a link in attachments to the lesson and just spend some time up to 30 minutes just by
+
+256
+00:21:46,000 --> 00:21:50,000
+reading the documentation and looking through the API of these types.
+
+257
+00:21:50,000 --> 00:21:55,000
+For example, mock MVC Builder's class has just two methods.
+
+258
+00:21:56,000 --> 00:22:01,000
+It wouldn't take too much time for reading, but will be useful for you.
+
+259
+00:22:01,000 --> 00:22:03,000
+The same story with other classes.
+
+260
+00:22:04,000 --> 00:22:08,000
+Taking into account scope and agenda of the lesson, I would continue.
+
+261
+00:22:08,000 --> 00:22:15,000
+But even in case you have any questions, you can always leave your questions in comments below the
+
+262
+00:22:15,000 --> 00:22:17,000
+video and I will be happy to answer.
+
+263
+00:22:18,000 --> 00:22:23,000
+So I configured mock MVC and here is example of the test.
+
+264
+00:22:23,000 --> 00:22:33,000
+The test verifies that when we send requests to the entities endpoint, we receive status of 200 and
+
+265
+00:22:33,000 --> 00:22:41,000
+we receive response with expected content type, which is application JSON, and that there are two
+
+266
+00:22:41,000 --> 00:22:43,000
+items in the JSON.
+
+267
+00:22:44,000 --> 00:22:51,000
+Just to remind you two items, because by default, I initialize the state of the list with two items.
+
+268
+00:22:52,000 --> 00:22:57,000
+Json.parse is a static method from MVC result matchers.
+
+269
+00:22:57,000 --> 00:23:03,000
+I recommend you to check the documentation about these matches to the different matchers that can be
+
+270
+00:23:03,000 --> 00:23:07,000
+useful for testing purposes in json.parse.
+
+271
+00:23:07,000 --> 00:23:14,000
+I pass expression and matcher in the context of the Json.parse method in spring boots mock and we see
+
+272
+00:23:14,000 --> 00:23:16,000
+result matches.
+
+273
+00:23:16,000 --> 00:23:21,000
+The dollar sign represents the root element of the JSON document.
+
+274
+00:23:22,000 --> 00:23:30,000
+When using Json.parse to perform assertions on the JSON response of a mock MVC test, the dollar sign
+
+275
+00:23:30,000 --> 00:23:35,000
+is used to specify the starting point for the JSON parse expression.
+
+276
+00:23:35,000 --> 00:23:40,000
+It allows you to navigate and extract values from the JSON structure.
+
+277
+00:23:40,000 --> 00:23:49,000
+But in this case we just referred to the root element, namely the array of elements and confirmed that
+
+278
+00:23:49,000 --> 00:23:51,000
+there are two elements.
+
+279
+00:23:52,000 --> 00:23:58,000
+When I run this test, I can see that my test is passed successfully.
+
+280
+00:23:58,000 --> 00:24:00,000
+So you have the source code.
+
+281
+00:24:00,000 --> 00:24:07,000
+I recommend you to play with it, read documentation, and think about potentially other scenarios.
+
+282
+00:24:07,000 --> 00:24:11,000
+Please let me know in case you would have any questions.
+
+283
+00:24:11,000 --> 00:24:14,000
+Let's continue and check another starter.
+
+284
+00:24:15,000 --> 00:24:19,000
+Also in the course we learned how to work with Spring Data JPA.
+
+285
+00:24:20,000 --> 00:24:27,000
+Again, this is not a lesson about spring data JPA because I had dedicated module for that, so feel
+
+286
+00:24:27,000 --> 00:24:30,000
+free to refer to those lessons.
+
+287
+00:24:30,000 --> 00:24:38,000
+In this video I will just hold the demo and overview of Spring Boot Starter Data JPA because all the
+
+288
+00:24:38,000 --> 00:24:44,000
+principles that we learned in lessons about spring data JPA are applied for Spring Boot to.
+
+289
+00:24:45,000 --> 00:24:52,000
+So in the POM maximum I added starter data GPA and I also added H2 database.
+
+290
+00:24:52,000 --> 00:24:59,000
+H2 is an in-memory database engine written in Java that provides several advantages for development
+
+291
+00:24:59,000 --> 00:25:01,000
+and testing purposes.
+
+292
+00:25:01,000 --> 00:25:08,000
+I used H2 database because it is lightweight and I don't want to over complicate this example.
+
+293
+00:25:08,000 --> 00:25:16,000
+H2 supports an in-memory mode allowing you to create and run databases entirely in memory.
+
+294
+00:25:16,000 --> 00:25:24,000
+This eliminates the need for disk input output operations, resulting in faster data access.
+
+295
+00:25:24,000 --> 00:25:32,000
+Additionally, H2 can be embedded within your application, making it ideal for unit tests or scenarios
+
+296
+00:25:32,000 --> 00:25:37,000
+where you don't want to set up separate database server.
+
+297
+00:25:37,000 --> 00:25:44,000
+But in case there is a need in database server, again, just for the reference, there is a section
+
+298
+00:25:44,000 --> 00:25:48,000
+about databases in my course Java from zero to first job.
+
+299
+00:25:48,000 --> 00:25:56,000
+I am going to show you example with H2 database in order, you could see how easily you can create development
+
+300
+00:25:56,000 --> 00:25:58,000
+environment and start testing.
+
+301
+00:25:58,000 --> 00:26:03,000
+And then I'm going to show you another example with the MySQL integration.
+
+302
+00:26:03,000 --> 00:26:06,000
+So let's start from H2 database example.
+
+303
+00:26:06,000 --> 00:26:12,000
+First I added dependency and that's it really.
+
+304
+00:26:12,000 --> 00:26:17,000
+Now you can use H2 database for testing or development purposes.
+
+305
+00:26:17,000 --> 00:26:22,000
+Let's declare GP repository in the package repositories.
+
+306
+00:26:22,000 --> 00:26:27,000
+You can see that I created class that is called Demo Entity Repository.
+
+307
+00:26:27,000 --> 00:26:34,000
+We already learned the concept of repositories in the spring data module of the course, so I wouldn't
+
+308
+00:26:34,000 --> 00:26:37,000
+stop too much on this repeating myself.
+
+309
+00:26:38,000 --> 00:26:45,000
+I specified that this repository is for demo entity type that we created and primary key has integer
+
+310
+00:26:45,000 --> 00:26:45,000
+type.
+
+311
+00:26:46,000 --> 00:26:50,000
+I also introduced some changes in the entity itself.
+
+312
+00:26:50,000 --> 00:26:58,000
+I added entity annotation and specified ID because each managed entity should have a field for ID.
+
+313
+00:26:59,000 --> 00:27:00,000
+Basically.
+
+314
+00:27:00,000 --> 00:27:00,000
+That's it.
+
+315
+00:27:01,000 --> 00:27:03,000
+Let's test our repository.
+
+316
+00:27:03,000 --> 00:27:09,000
+I created separate test in the repositories package that is called demo Entity Repository test.
+
+317
+00:27:09,000 --> 00:27:11,000
+Nothing special here.
+
+318
+00:27:11,000 --> 00:27:18,000
+I injected been of my repository that is under the test and I have one test case just for the sake of
+
+319
+00:27:18,000 --> 00:27:19,000
+example.
+
+320
+00:27:20,000 --> 00:27:26,000
+I created demo entity object and as you can see, I use my repository to save it.
+
+321
+00:27:26,000 --> 00:27:35,000
+Then I use repository to extract the entity that was just saved by ID and in assertion part.
+
+322
+00:27:35,000 --> 00:27:42,000
+I just want to be sure that founded entity is not null and that label of the entity that I found is
+
+323
+00:27:42,000 --> 00:27:46,000
+the same as the label of entity that I saved.
+
+324
+00:27:46,000 --> 00:27:54,000
+No need to test the quality of IDs because I used this ID to extract the entity from the database.
+
+325
+00:27:55,000 --> 00:27:56,000
+Let me run the test.
+
+326
+00:28:02,000 --> 00:28:05,000
+And you can see that it is passed as expected.
+
+327
+00:28:05,000 --> 00:28:13,000
+As you saw, we didn't specify user username or password database URL, literally nothing.
+
+328
+00:28:14,000 --> 00:28:19,000
+That is because springboot has out of the box support of H2O database.
+
+329
+00:28:20,000 --> 00:28:25,000
+But what to do in case you need to integrate with other database.
+
+330
+00:28:25,000 --> 00:28:26,000
+You can do it easily.
+
+331
+00:28:26,000 --> 00:28:29,000
+Let me show you the steps.
+
+332
+00:28:29,000 --> 00:28:35,000
+First of all, you need to add the required connector driver into the classpath.
+
+333
+00:28:35,000 --> 00:28:38,000
+In our case I would comment now.
+
+334
+00:28:38,000 --> 00:28:40,000
+Dependency of H2O database.
+
+335
+00:28:40,000 --> 00:28:47,000
+You know, the spring boot wouldn't configure it automatically and I would uncomment my SQL dependency.
+
+336
+00:28:48,000 --> 00:28:55,000
+Then I need to configure data source and you already know that all configurations for Spring boot should
+
+337
+00:28:55,000 --> 00:28:58,000
+be placed in the application properties file.
+
+338
+00:28:58,000 --> 00:29:02,000
+Here you can find configurations for the MySQL database.
+
+339
+00:29:03,000 --> 00:29:07,000
+It is just a URL to the database that I created before this lesson.
+
+340
+00:29:08,000 --> 00:29:10,000
+Username Password.
+
+341
+00:29:10,000 --> 00:29:14,000
+Driver Class Name and Auto Generation Strategy.
+
+342
+00:29:14,000 --> 00:29:22,000
+Update strategy means to update the tables that already were created and it will create tables in case
+
+343
+00:29:22,000 --> 00:29:23,000
+it was absent.
+
+344
+00:29:25,000 --> 00:29:28,000
+I also created an end point in the demo controller.
+
+345
+00:29:29,000 --> 00:29:34,000
+It is endpoint that accepts JSON and saves entity to the database.
+
+346
+00:29:35,000 --> 00:29:37,000
+Let me run the application.
+
+347
+00:29:38,000 --> 00:29:43,000
+I open Postman and I send request to this endpoint.
+
+348
+00:29:44,000 --> 00:29:45,000
+In the body.
+
+349
+00:29:45,000 --> 00:29:49,000
+I send the entity that I want to save in the database.
+
+350
+00:29:49,000 --> 00:29:50,000
+In response.
+
+351
+00:29:50,000 --> 00:29:54,000
+I see message is that entity was saved successfully.
+
+352
+00:29:54,000 --> 00:30:03,000
+Let me open now the MySQL workbench and you can see that I have a table created and entity with a three
+
+353
+00:30:03,000 --> 00:30:05,000
+was created successfully.
+
+354
+00:30:05,000 --> 00:30:06,000
+That's it.
+
+355
+00:30:06,000 --> 00:30:08,000
+Congratulations.
+
+356
+00:30:08,000 --> 00:30:11,000
+That's how easily we can integrate MySQL.
+
+357
+00:30:11,000 --> 00:30:16,000
+In case you want to connect any other database, the algorithm is the same.
+
+358
+00:30:17,000 --> 00:30:21,000
+Also, I wanted to show you security starter in action.
+
+359
+00:30:21,000 --> 00:30:28,000
+And again, just for the reference, remember that we have separate module about spring security, where
+
+360
+00:30:28,000 --> 00:30:35,000
+I covered a lot of possible configurations of spring security and we also did practical activities and
+
+361
+00:30:35,000 --> 00:30:36,000
+home tasks.
+
+362
+00:30:36,000 --> 00:30:42,000
+So in this video we don't have a goal to learn spring security from scratch.
+
+363
+00:30:42,000 --> 00:30:47,000
+I just want to show you how you can easily enable spring security in your application.
+
+364
+00:30:47,000 --> 00:30:54,000
+As you may already notice and understand, most of the required dependencies are easily imported by
+
+365
+00:30:54,000 --> 00:30:55,000
+using starters.
+
+366
+00:30:55,000 --> 00:31:00,000
+So the first thing that we need to do is to add security starter.
+
+367
+00:31:00,000 --> 00:31:07,000
+After that, all required dependencies will be present in the classpath and you can jump to the configuration
+
+368
+00:31:07,000 --> 00:31:08,000
+of security rules.
+
+369
+00:31:09,000 --> 00:31:16,000
+After adding this starter, all endpoints are secured by default and in case you would run the application
+
+370
+00:31:16,000 --> 00:31:23,000
+just with this starter and would try to reach out any endpoint, you are going to see 401.
+
+371
+00:31:23,000 --> 00:31:26,000
+Unauthorized response status code.
+
+372
+00:31:27,000 --> 00:31:32,000
+In order to avoid this, it is recommended you to configure security filter chain.
+
+373
+00:31:33,000 --> 00:31:33,000
+Here.
+
+374
+00:31:33,000 --> 00:31:36,000
+I have class with security configuration.
+
+375
+00:31:36,000 --> 00:31:44,000
+I marked it with configuration annotation and enable web security, and I declared the bin of security
+
+376
+00:31:44,000 --> 00:31:45,000
+filter chain.
+
+377
+00:31:45,000 --> 00:31:51,000
+And then I configured security filter chain in order to allow access to all resources.
+
+378
+00:31:52,000 --> 00:31:59,000
+But I believe that you remember that you can configure access based on roles and privileges to the different
+
+379
+00:31:59,000 --> 00:31:59,000
+resources.
+
+380
+00:32:00,000 --> 00:32:06,000
+So everything that you have learned in spring Security module is applied in spring boot to.
+
+381
+00:32:07,000 --> 00:32:10,000
+That's all what I wanted to share with you in this lesson.
+
+382
+00:32:10,000 --> 00:32:16,000
+The main thing that I want you to learn from this lesson is that in case you are familiar with different
+
+383
+00:32:16,000 --> 00:32:23,000
+projects of spring framework, it takes you almost nothing to be familiar with Spring Boot, as you
+
+384
+00:32:23,000 --> 00:32:24,000
+saw today.
+
+385
+00:32:24,000 --> 00:32:30,000
+We worked with different starters and configured many different things using the knowledge that we already
+
+386
+00:32:30,000 --> 00:32:32,000
+learned in previous lessons.
+
+387
+00:32:32,000 --> 00:32:41,000
+Moreover, taking into account spring boot, automate a lot of things, more things left in the shadow
+
+388
+00:32:41,000 --> 00:32:47,000
+and you can even understand what is happening on the background in order to be able to troubleshoot
+
+389
+00:32:47,000 --> 00:32:54,000
+issues in case of any and search for required property name in the documentation if needed in order
+
+390
+00:32:54,000 --> 00:32:57,000
+to add it in application properties.
+
+391
+00:32:57,000 --> 00:33:01,000
+Let's recap now what we have learned in the lesson.
+
+392
+00:33:02,000 --> 00:33:04,000
+We learned what starters in Spring Boot are.
+
+393
+00:33:05,000 --> 00:33:11,000
+I hope that you understood why we need them and what advantages of spring boot starters are.
+
+394
+00:33:11,000 --> 00:33:19,000
+We reviewed a list of spring boot starters that you potentially can use in your projects on real examples.
+
+395
+00:33:19,000 --> 00:33:23,000
+We reviewed and learned how to add Spring boot starter.
+
+396
+00:33:23,000 --> 00:33:29,000
+We learned web starter and developed our rest API in Spring boot.
+
+397
+00:33:30,000 --> 00:33:34,000
+I showed you Test starter Spring data JPA starter.
+
+398
+00:33:34,000 --> 00:33:41,000
+We configured H2 database for our spring boot application and we also learned how to declare a data
+
+399
+00:33:41,000 --> 00:33:43,000
+source for my SQL database.
+
+400
+00:33:43,000 --> 00:33:47,000
+And at the end of the lesson we learned security starter.
+
+401
+00:33:47,000 --> 00:33:49,000
+That's all for this lesson.
+
+402
+00:33:49,000 --> 00:33:51,000
+Thanks a lot for your attention.
+
+403
+00:33:51,000 --> 00:33:54,000
+Have a great day and see you in the next lesson.
+
diff --git a/92 - Spring Boot/003 Spring-Boot-Starters-on-Github.url b/92 - Spring Boot/003 Spring-Boot-Starters-on-Github.url
new file mode 100644
index 0000000000000000000000000000000000000000..0c82b64949eeb1dec6d3114e90f350e177169e85
--- /dev/null
+++ b/92 - Spring Boot/003 Spring-Boot-Starters-on-Github.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-starters
\ No newline at end of file
diff --git a/92 - Spring Boot/004 Common-Spring-Boot-Application-Properties.url b/92 - Spring Boot/004 Common-Spring-Boot-Application-Properties.url
new file mode 100644
index 0000000000000000000000000000000000000000..9bef9efc352f74d293d900c4ef2ca71bb679dcb5
--- /dev/null
+++ b/92 - Spring Boot/004 Common-Spring-Boot-Application-Properties.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html
\ No newline at end of file
diff --git a/92 - Spring Boot/004 Source-code-of-examples-commit-with-changes-.url b/92 - Spring Boot/004 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..d784836e71bbe0b802c7a4d98ead55ab6de954cd
--- /dev/null
+++ b/92 - Spring Boot/004 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/1ca891ad59a291a71a5ba1df5ae4c91b87dc2734
\ No newline at end of file
diff --git a/92 - Spring Boot/004 Spring Boot Configurations & Application Properties_en.srt b/92 - Spring Boot/004 Spring Boot Configurations & Application Properties_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..c64f2983c41786e94e4f0decf6dd1b412f1eb7aa
--- /dev/null
+++ b/92 - Spring Boot/004 Spring Boot Configurations & Application Properties_en.srt
@@ -0,0 +1,1448 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, Tim.
+
+2
+00:00:06,000 --> 00:00:10,000
+By this moment in our course, we already learned what a spring boot is.
+
+3
+00:00:10,000 --> 00:00:17,000
+We learned spring boot starters, and we did practical exercises by running our spring boot application
+
+4
+00:00:17,000 --> 00:00:19,000
+with different starters.
+
+5
+00:00:19,000 --> 00:00:26,000
+In this video, we are going to extend our understanding of spring boot configurations and application
+
+6
+00:00:26,000 --> 00:00:27,000
+properties.
+
+7
+00:00:28,000 --> 00:00:34,000
+I know that you already watched previous lessons and you saw me configuring Spring Boot with the help
+
+8
+00:00:34,000 --> 00:00:36,000
+of application Properties file.
+
+9
+00:00:36,000 --> 00:00:44,000
+But in this lesson, let's go deeper and understand more about this configuration file.
+
+10
+00:00:44,000 --> 00:00:51,000
+We will start the lesson from the brief overview of what application properties are in Spring boot and
+
+11
+00:00:51,000 --> 00:00:52,000
+why we need them.
+
+12
+00:00:52,000 --> 00:00:59,000
+Then we'll review different use cases about precedence order of properties from different sources.
+
+13
+00:00:59,000 --> 00:01:05,000
+This is kind of advanced level, but I believe this can help you in real life.
+
+14
+00:01:05,000 --> 00:01:10,000
+You are going to understand how to override properties in case it would be needed.
+
+15
+00:01:11,000 --> 00:01:17,000
+We are going to review some default spring boot properties and least of the most common spring boot
+
+16
+00:01:17,000 --> 00:01:18,000
+properties.
+
+17
+00:01:19,000 --> 00:01:24,000
+After we reviewed everything, what I have just mentioned, we will jump to practical examples.
+
+18
+00:01:24,000 --> 00:01:29,000
+I will start screen sharing and we will learn how to change web server port.
+
+19
+00:01:29,000 --> 00:01:37,000
+Yes, this is simple example, but it will help you to understand how to work with application properties.
+
+20
+00:01:37,000 --> 00:01:39,000
+File a little bit more.
+
+21
+00:01:39,000 --> 00:01:42,000
+Complex topic would be to configure SSL.
+
+22
+00:01:42,000 --> 00:01:48,000
+TLS in the spring boot will generate Self-signed certificate.
+
+23
+00:01:48,000 --> 00:01:50,000
+I'm going to show you how to do this.
+
+24
+00:01:50,000 --> 00:01:57,000
+Also, I will teach you how to change the context path of the application and configure login level.
+
+25
+00:01:57,000 --> 00:02:04,000
+And at the end of the lesson I am going to explain you when and how we can use configuration properties.
+
+26
+00:02:04,000 --> 00:02:05,000
+Annotation.
+
+27
+00:02:05,000 --> 00:02:07,000
+Let's start our lesson.
+
+28
+00:02:08,000 --> 00:02:12,000
+Let's start from learning more details about application properties.
+
+29
+00:02:12,000 --> 00:02:19,000
+It seems to be easy and straightforward at the first glance, but I bet that in this lesson you are
+
+30
+00:02:19,000 --> 00:02:21,000
+going to learn something new.
+
+31
+00:02:22,000 --> 00:02:29,000
+Spring boot application Properties file is an essential part of configuring and customizing spring boot
+
+32
+00:02:29,000 --> 00:02:30,000
+applications.
+
+33
+00:02:30,000 --> 00:02:39,000
+It provides a convenient way to externalize configuration settings and modify the behavior of your application
+
+34
+00:02:39,000 --> 00:02:42,000
+without modifying the application code.
+
+35
+00:02:42,000 --> 00:02:48,000
+So basically, if you watched previous lessons, you should be aware that application properties file
+
+36
+00:02:48,000 --> 00:02:57,000
+in Spring Boot is a text file that contains key value pairs used to configure various aspects of the
+
+37
+00:02:57,000 --> 00:02:58,000
+application.
+
+38
+00:02:58,000 --> 00:03:06,000
+It follows a specific naming convention and can be written in various formats such as properties or
+
+39
+00:03:06,000 --> 00:03:07,000
+YAML.
+
+40
+00:03:08,000 --> 00:03:10,000
+Where files should be located.
+
+41
+00:03:10,000 --> 00:03:16,000
+By default, spring boot looks for application properties file in the classpath root.
+
+42
+00:03:17,000 --> 00:03:18,000
+See main resources.
+
+43
+00:03:19,000 --> 00:03:28,000
+But you can also specify a custom location using the spring config name and spring config location properties.
+
+44
+00:03:29,000 --> 00:03:33,000
+In spring boot, you may have multiple sources of application properties.
+
+45
+00:03:33,000 --> 00:03:39,000
+All configurations are merged together based on the predefined precedence order.
+
+46
+00:03:40,000 --> 00:03:41,000
+Why is this is needed?
+
+47
+00:03:42,000 --> 00:03:49,000
+Because sometimes we don't have access to the application properties file itself or we don't want to
+
+48
+00:03:49,000 --> 00:03:50,000
+adjust it.
+
+49
+00:03:50,000 --> 00:03:57,000
+For example, we create deployment scripts and we want to automate deployment of our application in
+
+50
+00:03:57,000 --> 00:04:01,000
+different environments and we need to override some properties.
+
+51
+00:04:02,000 --> 00:04:05,000
+Also, there can be security concern.
+
+52
+00:04:05,000 --> 00:04:13,000
+It is best practice to externalize sensitive information such as passwords or API keys from the application
+
+53
+00:04:13,000 --> 00:04:14,000
+code.
+
+54
+00:04:14,000 --> 00:04:18,000
+Springboot supports the use of environment variables.
+
+55
+00:04:18,000 --> 00:04:26,000
+Command line arguments or external configuration files to provide these sensitive values.
+
+56
+00:04:26,000 --> 00:04:34,000
+This helps in maintaining a separation of configuration and code and improves security by supporting
+
+57
+00:04:34,000 --> 00:04:35,000
+multiple sources.
+
+58
+00:04:35,000 --> 00:04:43,000
+Springboot provides flexibility in configuring and customizing applications based on specific requirements
+
+59
+00:04:43,000 --> 00:04:44,000
+and environments.
+
+60
+00:04:45,000 --> 00:04:52,000
+Properties specified in files with high precedence overrides those with lower precedence.
+
+61
+00:04:52,000 --> 00:04:57,000
+The order of precedence from highest to lowest is the following.
+
+62
+00:04:58,000 --> 00:05:03,000
+The highest precedence have properties specified through command line arguments.
+
+63
+00:05:04,000 --> 00:05:10,000
+For example, instead of specifying server port in the application properties file, you can pass it
+
+64
+00:05:10,000 --> 00:05:15,000
+as a command line argument like you can see in the example on the slide.
+
+65
+00:05:16,000 --> 00:05:23,000
+Not so often you will run your application manually, but your DevOps will create deployment scripts
+
+66
+00:05:23,000 --> 00:05:29,000
+that supposed to run your application on different environments or on the same environments but with
+
+67
+00:05:29,000 --> 00:05:37,000
+different configurations and DevOps will not extract your archive and adjust your application properties.
+
+68
+00:05:37,000 --> 00:05:44,000
+So property will be passed from the outside of the archive and will have higher precedence.
+
+69
+00:05:44,000 --> 00:05:45,000
+Is it clear?
+
+70
+00:05:45,000 --> 00:05:49,000
+Can you understand now the business case when this can be helpful?
+
+71
+00:05:50,000 --> 00:05:57,000
+The next properties specified using spring application JSON environment variable.
+
+72
+00:05:57,000 --> 00:06:03,000
+Do you remember like we created Javahome environment variable in the similar way you can create spring
+
+73
+00:06:03,000 --> 00:06:10,000
+application JSON environment variable by setting the spring application JSON environment variable,
+
+74
+00:06:10,000 --> 00:06:16,000
+you can provide custom configuration properties to your spring boot application without modifying the
+
+75
+00:06:16,000 --> 00:06:18,000
+applications properties files.
+
+76
+00:06:19,000 --> 00:06:26,000
+These properties will take precedence over properties defined in other sources such as properties,
+
+77
+00:06:26,000 --> 00:06:28,000
+files or system properties.
+
+78
+00:06:28,000 --> 00:06:31,000
+It may look like you can see on the slide.
+
+79
+00:06:32,000 --> 00:06:35,000
+Properties specified in the Java system properties.
+
+80
+00:06:36,000 --> 00:06:40,000
+System properties can be specified in various ways, but one common method.
+
+81
+00:06:40,000 --> 00:06:46,000
+Is by using the D flag when running the Java application.
+
+82
+00:06:46,000 --> 00:06:51,000
+On this slide you can see how you can specify system properties.
+
+83
+00:06:51,000 --> 00:06:53,000
+By using the D flag.
+
+84
+00:06:54,000 --> 00:06:58,000
+You can set a specific system property for your spring boot application.
+
+85
+00:06:59,000 --> 00:07:02,000
+These properties will be available through the system.
+
+86
+00:07:02,000 --> 00:07:03,000
+Get property method.
+
+87
+00:07:03,000 --> 00:07:05,000
+In your application code.
+
+88
+00:07:05,000 --> 00:07:12,000
+In the context of Spring boot, this system properties can be used to configure and customize various
+
+89
+00:07:12,000 --> 00:07:16,000
+aspects of your application based on the specific requirements.
+
+90
+00:07:17,000 --> 00:07:21,000
+Properties in the config directory of the current directory.
+
+91
+00:07:21,000 --> 00:07:23,000
+Here is how it works.
+
+92
+00:07:23,000 --> 00:07:31,000
+Create a directory named config in the current directory where you are running your spring boot application.
+
+93
+00:07:31,000 --> 00:07:38,000
+Inside the config directory place a properties file with the desired configuration properties.
+
+94
+00:07:38,000 --> 00:07:42,000
+The file should typically have a properties or YAML extension.
+
+95
+00:07:43,000 --> 00:07:50,000
+Start your spring boot application by placing a properties file in the config directory.
+
+96
+00:07:50,000 --> 00:07:55,000
+Spring boot will automatically load and merge the properties from that file.
+
+97
+00:07:55,000 --> 00:08:02,000
+This allows you to provide additional or overriding configuration properties specific to the deployment,
+
+98
+00:08:02,000 --> 00:08:06,000
+environment or machine where the application is running.
+
+99
+00:08:06,000 --> 00:08:14,000
+The config directory serves as a externalized configuration location that is considered during the configuration
+
+100
+00:08:14,000 --> 00:08:16,000
+merging process.
+
+101
+00:08:16,000 --> 00:08:23,000
+It provides a way to externalize configuration files separate from the applications classpath or packaged
+
+102
+00:08:23,000 --> 00:08:24,000
+jar file.
+
+103
+00:08:26,000 --> 00:08:28,000
+Properties specified in the class pass route.
+
+104
+00:08:29,000 --> 00:08:37,000
+For example, in SRC main resources in a standard spring boot project structure, the SRC main resources
+
+105
+00:08:37,000 --> 00:08:42,000
+directory is where you would typically place your application properties files.
+
+106
+00:08:43,000 --> 00:08:47,000
+Properties specified using spring config name environment variable.
+
+107
+00:08:48,000 --> 00:08:54,000
+The spring config name environment variable allows you to specify the name of the configuration file
+
+108
+00:08:54,000 --> 00:09:00,000
+without the file extension by setting the spring config name environment variable.
+
+109
+00:09:00,000 --> 00:09:06,000
+You can override the default name of the configuration file used by spring boot.
+
+110
+00:09:07,000 --> 00:09:11,000
+The default configuration file name is application.
+
+111
+00:09:11,000 --> 00:09:15,000
+So setting spring config name to a different value.
+
+112
+00:09:15,000 --> 00:09:23,000
+For example, custom config will make spring boot look for custom config properties or custom config
+
+113
+00:09:23,000 --> 00:09:26,000
+yaml instead of application properties.
+
+114
+00:09:27,000 --> 00:09:32,000
+Properties specified using the spring config location environment variable.
+
+115
+00:09:33,000 --> 00:09:39,000
+The spring config location environment variable allows you to specify the location of the configuration
+
+116
+00:09:39,000 --> 00:09:41,000
+file or directory.
+
+117
+00:09:42,000 --> 00:09:49,000
+By setting the spring config location environment variable, you can override the default location where
+
+118
+00:09:49,000 --> 00:09:52,000
+spring boot searches for the configuration files.
+
+119
+00:09:53,000 --> 00:09:59,000
+The default location is the classpath root src main resources.
+
+120
+00:10:00,000 --> 00:10:01,000
+And the last but not the least.
+
+121
+00:10:01,000 --> 00:10:07,000
+And the configuration precedents are default properties provided by Spring Boot.
+
+122
+00:10:07,000 --> 00:10:10,000
+We are going to learn what is a on the separate slide.
+
+123
+00:10:11,000 --> 00:10:18,000
+The default properties provided by Spring Boot refer to the built in default configuration properties.
+
+124
+00:10:18,000 --> 00:10:24,000
+That spring boot automatically applies if no explicit configuration is provided.
+
+125
+00:10:24,000 --> 00:10:32,000
+These default properties are part of spring boot opinionated configuration approach and are designed
+
+126
+00:10:32,000 --> 00:10:38,000
+to provide sensible and convenient defaults for common application configurations.
+
+127
+00:10:38,000 --> 00:10:45,000
+Here are a few examples of default properties provided by Spring Boot Server port.
+
+128
+00:10:45,000 --> 00:10:51,000
+The default port on which the embedded web server listens is 8080.
+
+129
+00:10:52,000 --> 00:10:54,000
+Spring application admin enabled.
+
+130
+00:10:54,000 --> 00:11:00,000
+Whether to enable admin features for the application is false by default.
+
+131
+00:11:01,000 --> 00:11:02,000
+Spring config name.
+
+132
+00:11:03,000 --> 00:11:05,000
+This is the file name with configuration.
+
+133
+00:11:05,000 --> 00:11:11,000
+By default, it is application spring task Execution Pool.
+
+134
+00:11:11,000 --> 00:11:12,000
+Core size.
+
+135
+00:11:13,000 --> 00:11:14,000
+Core number of threads.
+
+136
+00:11:14,000 --> 00:11:16,000
+The default value is eight.
+
+137
+00:11:17,000 --> 00:11:19,000
+These are just few of them.
+
+138
+00:11:19,000 --> 00:11:23,000
+You are going to learn more default spring boot properties soon.
+
+139
+00:11:23,000 --> 00:11:31,000
+These default properties are automatically loaded and applied by spring boot unless overridden by explicit
+
+140
+00:11:31,000 --> 00:11:39,000
+configuration provided through other means such as application properties, files, command line arguments
+
+141
+00:11:39,000 --> 00:11:41,000
+or environment variables.
+
+142
+00:11:41,000 --> 00:11:48,000
+The default properties provided by Spring Boot help streamline the development process by offering sensible
+
+143
+00:11:48,000 --> 00:11:55,000
+and opinionated defaults, allowing developers to quickly bootstrap and configure their applications
+
+144
+00:11:55,000 --> 00:12:00,000
+without explicitly specifying every configuration property.
+
+145
+00:12:01,000 --> 00:12:06,000
+Let me start screen sharing and we'll review more interesting configurations on examples.
+
+146
+00:12:07,000 --> 00:12:10,000
+Here is the page from the Spring Boot documentation.
+
+147
+00:12:10,000 --> 00:12:14,000
+It is used to list common application properties.
+
+148
+00:12:14,000 --> 00:12:22,000
+You can find property name description to understand what it is about and default value in case of any.
+
+149
+00:12:23,000 --> 00:12:29,000
+On the left, you can find groups of properties, so you can start from searching through the group
+
+150
+00:12:29,000 --> 00:12:33,000
+of properties or just use search on the web page.
+
+151
+00:12:33,000 --> 00:12:39,000
+I will leave this link in attachments to the video and I recommend you to watch it.
+
+152
+00:12:39,000 --> 00:12:43,000
+Just spend from 10 to 15 minutes looking through this page.
+
+153
+00:12:44,000 --> 00:12:45,000
+Definitely.
+
+154
+00:12:45,000 --> 00:12:52,000
+You will not be able to learn all possible properties at once, but the goal of this exercise is to
+
+155
+00:12:52,000 --> 00:13:00,000
+understand on the high level which properties do we have and what group of properties we can spend hours
+
+156
+00:13:00,000 --> 00:13:03,000
+during the video learning each property.
+
+157
+00:13:03,000 --> 00:13:10,000
+But the truth is that you will not be able to remember them all until you start using them.
+
+158
+00:13:10,000 --> 00:13:16,000
+So I really encourage you to look through these properties and be ready for development.
+
+159
+00:13:17,000 --> 00:13:24,000
+In case you have any questions, please put your questions below the video and I will be happy to answer.
+
+160
+00:13:25,000 --> 00:13:29,000
+And now let me switch to the eclipse workspace.
+
+161
+00:13:29,000 --> 00:13:34,000
+I am going to show you a real life example of changing properties.
+
+162
+00:13:34,000 --> 00:13:35,000
+Definitely.
+
+163
+00:13:35,000 --> 00:13:41,000
+I don't have any plans to show you each property, but just some key sayings that will help you to work
+
+164
+00:13:41,000 --> 00:13:44,000
+with other properties by analogy.
+
+165
+00:13:45,000 --> 00:13:47,000
+Port number by default.
+
+166
+00:13:47,000 --> 00:13:53,000
+Applications that are deployed on Tomcat web server are accessible via default.
+
+167
+00:13:53,000 --> 00:13:54,000
+Port 8080.
+
+168
+00:13:55,000 --> 00:13:59,000
+We can easily configure spring boot to use a different port.
+
+169
+00:14:00,000 --> 00:14:06,000
+I open application properties and here I have section with examples for our today's lesson.
+
+170
+00:14:07,000 --> 00:14:12,000
+I will share with you the link to the source code in attachments to the video and you will be able to
+
+171
+00:14:12,000 --> 00:14:17,000
+check it if you wish and run examples on your local computer.
+
+172
+00:14:17,000 --> 00:14:23,000
+In this particular case, our web server will be started at the port 8888.
+
+173
+00:14:24,000 --> 00:14:25,000
+That was easy.
+
+174
+00:14:26,000 --> 00:14:33,000
+And just in case you work in Eclipse, there is Autocompletion available for spring boot properties.
+
+175
+00:14:34,000 --> 00:14:41,000
+Just feel free to use control and space simultaneously as usual in order to see Autocompletion suggestions
+
+176
+00:14:41,000 --> 00:14:42,000
+for properties.
+
+177
+00:14:44,000 --> 00:14:46,000
+SSL class configuration.
+
+178
+00:14:46,000 --> 00:14:52,000
+Another important and interesting set of properties is related to SSL, TLS configuration.
+
+179
+00:14:53,000 --> 00:14:56,000
+Just few words about semantics here.
+
+180
+00:14:56,000 --> 00:15:05,000
+Both SSL, which stands for Secure Sockets Layer and TLS, which stands for Transport Layer Security
+
+181
+00:15:05,000 --> 00:15:11,000
+are cryptographic protocols used to secure network communications.
+
+182
+00:15:11,000 --> 00:15:19,000
+It is more accurate and up to date to refer to the current standard as TLS rather than SSL.
+
+183
+00:15:19,000 --> 00:15:28,000
+SSL was the predecessor of TLS and is now considered insecure and deprecated due to security vulnerabilities.
+
+184
+00:15:29,000 --> 00:15:35,000
+So let me review with you properties that are required for SSL, TLS configuration.
+
+185
+00:15:36,000 --> 00:15:43,000
+The first one server SSL Keystore Type Pkcs12.
+
+186
+00:15:43,000 --> 00:15:50,000
+This property specifies the type of keystore file used for SSL TLS configuration.
+
+187
+00:15:50,000 --> 00:16:00,000
+In this case it is set to Pkcs12, which is a popular format for storing cryptographic objects such
+
+188
+00:16:00,000 --> 00:16:04,000
+as private keys, certificates and certificate chains.
+
+189
+00:16:05,000 --> 00:16:10,000
+The next property server SSL keystore.
+
+190
+00:16:10,000 --> 00:16:14,000
+It is equal to root dot P12.
+
+191
+00:16:14,000 --> 00:16:20,000
+This property specifies the path or location of the keystore file.
+
+192
+00:16:20,000 --> 00:16:29,000
+The file name Root Point P12 indicates that the Keystore file is named Root P12.
+
+193
+00:16:29,000 --> 00:16:37,000
+This file contains the necessary cryptographic material, including the private key and associated certificates
+
+194
+00:16:37,000 --> 00:16:40,000
+used for SSL TLS encryption.
+
+195
+00:16:40,000 --> 00:16:46,000
+In this particular example, I'm going to use Self-signed certificate for development purposes.
+
+196
+00:16:46,000 --> 00:16:47,000
+What is it?
+
+197
+00:16:48,000 --> 00:16:54,000
+A Self-signed certificate is a type of digital certificate that is signed by the entity to which it
+
+198
+00:16:54,000 --> 00:16:55,000
+belongs.
+
+199
+00:16:56,000 --> 00:17:03,000
+Unlike certificates issued by a trusted third party certificate authority, Self-signed certificates
+
+200
+00:17:03,000 --> 00:17:07,000
+are not validated or verified by an external party.
+
+201
+00:17:07,000 --> 00:17:12,000
+Instead, the entity generates and signs the certificate itself.
+
+202
+00:17:13,000 --> 00:17:20,000
+You can't get trusted certificate just for an IP address and your home server.
+
+203
+00:17:20,000 --> 00:17:24,000
+You should have some domain name, but for development purposes.
+
+204
+00:17:24,000 --> 00:17:29,000
+Like I already said, you can use self-signed certificates.
+
+205
+00:17:29,000 --> 00:17:37,000
+And taking into account we already touched this topic, let's also review how to generate key for TLS
+
+206
+00:17:37,000 --> 00:17:39,000
+for Self-signed certificate.
+
+207
+00:17:40,000 --> 00:17:46,000
+To generate a Pkcs 12 key using the Java Key two command line tool.
+
+208
+00:17:46,000 --> 00:17:49,000
+Follow these instructions.
+
+209
+00:17:50,000 --> 00:17:58,000
+Open a command prompt or terminal run the following Keytool command to generate a new keystore and key
+
+210
+00:17:58,000 --> 00:17:59,000
+pair.
+
+211
+00:17:59,000 --> 00:18:02,000
+You can find command on the screen.
+
+212
+00:18:03,000 --> 00:18:05,000
+Explanation of the options used.
+
+213
+00:18:06,000 --> 00:18:09,000
+Jan Keypair generates a new key pair.
+
+214
+00:18:10,000 --> 00:18:15,000
+Alice My LHS specifies the alias for the key pair.
+
+215
+00:18:16,000 --> 00:18:17,000
+Key algorithm.
+
+216
+00:18:17,000 --> 00:18:24,000
+RSA specifies the algorithm to use for the key pair RSA in this case.
+
+217
+00:18:25,000 --> 00:18:26,000
+He sighs.
+
+218
+00:18:26,000 --> 00:18:31,000
+2048 specifies the key size in bits.
+
+219
+00:18:32,000 --> 00:18:33,000
+Keystore.
+
+220
+00:18:33,000 --> 00:18:34,000
+Keystore.
+
+221
+00:18:34,000 --> 00:18:39,000
+P12 specifies the name of the Keystore file to be generated.
+
+222
+00:18:40,000 --> 00:18:43,000
+Store type Pkcs12.
+
+223
+00:18:43,000 --> 00:18:49,000
+Specifies the type of the Keystore as Pkcs12.
+
+224
+00:18:49,000 --> 00:18:56,000
+Follow the prompts to enter the required information such as keystore, password, name, organization,
+
+225
+00:18:56,000 --> 00:18:57,000
+key, etcetera.
+
+226
+00:18:57,000 --> 00:19:00,000
+Provide the necessary details as prompted.
+
+227
+00:19:01,000 --> 00:19:09,000
+Once process is complete, the Keystore P12 file will be generated containing the private key and the
+
+228
+00:19:09,000 --> 00:19:11,000
+corresponding certificate.
+
+229
+00:19:11,000 --> 00:19:19,000
+You now have pkcs12 keystore file containing the private key and certificate.
+
+230
+00:19:19,000 --> 00:19:27,000
+This format allows you to store both the private key and the associated certificate in a single file.
+
+231
+00:19:27,000 --> 00:19:35,000
+Please make sure to keep the Keystore file secure and protect it with a strong password as it contains
+
+232
+00:19:35,000 --> 00:19:37,000
+sensitive information.
+
+233
+00:19:37,000 --> 00:19:46,000
+So I generated the key following these instructions and put it in the keys folder under src main resources.
+
+234
+00:19:46,000 --> 00:19:48,000
+Here it is.
+
+235
+00:19:48,000 --> 00:19:55,000
+And in the application properties specify the path to the file using the class pass reference.
+
+236
+00:19:56,000 --> 00:19:59,000
+Let's review the next properties from this list.
+
+237
+00:20:00,000 --> 00:20:02,000
+Server SSL Keystore.
+
+238
+00:20:02,000 --> 00:20:03,000
+Password.
+
+239
+00:20:04,000 --> 00:20:04,000
+Root.
+
+240
+00:20:04,000 --> 00:20:05,000
+Root.
+
+241
+00:20:05,000 --> 00:20:13,000
+This property defines the password required to access and unlock the keystore file specified earlier.
+
+242
+00:20:13,000 --> 00:20:16,000
+In this case, the password is set to root.
+
+243
+00:20:16,000 --> 00:20:17,000
+Root.
+
+244
+00:20:17,000 --> 00:20:22,000
+This is the one I used during the generation of my certificate.
+
+245
+00:20:23,000 --> 00:20:29,000
+It is important to choose a strong and secure password to protect the Keystore file.
+
+246
+00:20:30,000 --> 00:20:33,000
+Seven SSL key route.
+
+247
+00:20:34,000 --> 00:20:39,000
+Again, this is another property that is specified on the generation stage.
+
+248
+00:20:40,000 --> 00:20:46,000
+This property identifies the UN name for the key entry within the Keystore file.
+
+249
+00:20:46,000 --> 00:20:54,000
+The key entry represents the specific cryptographic key pair, private key and associated public key
+
+250
+00:20:54,000 --> 00:20:59,000
+that the server will use for SSL TLS connections.
+
+251
+00:20:59,000 --> 00:21:03,000
+In this case, the key is set to root.
+
+252
+00:21:04,000 --> 00:21:10,000
+These properties are used to configure SSL, TLS settings for a server.
+
+253
+00:21:10,000 --> 00:21:17,000
+Specifically related to the Keystore file, its type password and the alias of the key entry.
+
+254
+00:21:18,000 --> 00:21:25,000
+By properly configuring these properties, the server can establish secure connections using SSL, TLS
+
+255
+00:21:25,000 --> 00:21:31,000
+protocols and protect the confidentiality and integrity of the transmitted data.
+
+256
+00:21:32,000 --> 00:21:35,000
+I'm going to show you how it works in a minute.
+
+257
+00:21:35,000 --> 00:21:42,000
+Let me just add a few more configurations and we'll run the application and we'll check all adjustments
+
+258
+00:21:42,000 --> 00:21:43,000
+at once.
+
+259
+00:21:44,000 --> 00:21:45,000
+Context sparse.
+
+260
+00:21:45,000 --> 00:21:50,000
+Let's learn how to change context sparse by default.
+
+261
+00:21:50,000 --> 00:21:53,000
+Our application is available at root.
+
+262
+00:21:53,000 --> 00:21:56,000
+If you need to change it, you can do it too.
+
+263
+00:21:57,000 --> 00:21:57,000
+Why?
+
+264
+00:21:57,000 --> 00:22:00,000
+You may need to change context Sparse.
+
+265
+00:22:00,000 --> 00:22:03,000
+There can be several reasons for that.
+
+266
+00:22:03,000 --> 00:22:11,000
+For example, you have multiple applications on the same server or SEO optimization, Search engine
+
+267
+00:22:11,000 --> 00:22:13,000
+optimization.
+
+268
+00:22:13,000 --> 00:22:20,000
+You might want to include keywords or relevant information in the URL path to improve search engine
+
+269
+00:22:20,000 --> 00:22:21,000
+rankings.
+
+270
+00:22:22,000 --> 00:22:24,000
+Compliance with organization standards.
+
+271
+00:22:25,000 --> 00:22:29,000
+It also can be a reason anyway, in case you need to change the context.
+
+272
+00:22:29,000 --> 00:22:33,000
+Plus, you can easily do this like you can see on the screen.
+
+273
+00:22:33,000 --> 00:22:37,000
+In this case, my context path would be spring boot demo.
+
+274
+00:22:39,000 --> 00:22:42,000
+Configure the login levels if you want.
+
+275
+00:22:42,000 --> 00:22:47,000
+You can easily configure login levels in spring boot application.
+
+276
+00:22:47,000 --> 00:22:54,000
+Probably you saw many times the crazy amount of logs in our console during the execution of spring boot
+
+277
+00:22:54,000 --> 00:22:55,000
+application.
+
+278
+00:22:55,000 --> 00:23:02,000
+You can configure many different properties related to login and you can check them using the link I
+
+279
+00:23:02,000 --> 00:23:03,000
+provided.
+
+280
+00:23:03,000 --> 00:23:11,000
+I mean the link from the documentation with the list of common spring boot application properties.
+
+281
+00:23:11,000 --> 00:23:17,000
+But in this particular example, let's just change lock level to warn.
+
+282
+00:23:17,000 --> 00:23:25,000
+So basically right now we are supposed to see only warn and high levels like error and fatal.
+
+283
+00:23:26,000 --> 00:23:30,000
+Pay attention that you may have many different loggers in your application.
+
+284
+00:23:30,000 --> 00:23:37,000
+You can configure level for each of them, but for the sake of the demo, I will set warn level for
+
+285
+00:23:37,000 --> 00:23:39,000
+the root logger.
+
+286
+00:23:39,000 --> 00:23:47,000
+The root logger is a top level logger in the login hierarchy and it provides a default configuration
+
+287
+00:23:47,000 --> 00:23:50,000
+for logging in an application.
+
+288
+00:23:50,000 --> 00:23:58,000
+If no other loggers explicitly defined when will run application, you are going to see only logs from
+
+289
+00:23:58,000 --> 00:24:00,000
+warn level in the console.
+
+290
+00:24:01,000 --> 00:24:07,000
+All other possible configurations like for example, registering of the file with properties with the
+
+291
+00:24:07,000 --> 00:24:14,000
+help of properties, source annotation error handling, using a value, annotation and everything.
+
+292
+00:24:14,000 --> 00:24:20,000
+What we have learned in the Spring framework course is applicable in the same way in the spring boot.
+
+293
+00:24:21,000 --> 00:24:23,000
+That's why I will not repeat myself.
+
+294
+00:24:24,000 --> 00:24:30,000
+I believe that you understand how to use application properties for configuration of your spring boot
+
+295
+00:24:30,000 --> 00:24:31,000
+application.
+
+296
+00:24:31,000 --> 00:24:39,000
+The last and interesting things that I want to show you in this lesson is how to use configuration properties
+
+297
+00:24:39,000 --> 00:24:40,000
+with beans.
+
+298
+00:24:40,000 --> 00:24:48,000
+Imagine the case that you have set body component that is outside of your control and you need to bind
+
+299
+00:24:48,000 --> 00:24:50,000
+your custom properties to it.
+
+300
+00:24:51,000 --> 00:24:52,000
+What to do in this case?
+
+301
+00:24:53,000 --> 00:24:59,000
+In this case, we can use configuration properties annotation with bin configuration.
+
+302
+00:24:59,000 --> 00:25:07,000
+The configuration properties, annotation and spring boot is used to bind external configuration properties
+
+303
+00:25:07,000 --> 00:25:08,000
+to a Java object.
+
+304
+00:25:09,000 --> 00:25:12,000
+It allows you to map properties from various sources.
+
+305
+00:25:12,000 --> 00:25:17,000
+Do you remember that we have demo entity in our project here?
+
+306
+00:25:17,000 --> 00:25:25,000
+In the entities package, let's imagine that I need to bind properties to the bin of demo entity type.
+
+307
+00:25:26,000 --> 00:25:29,000
+I created separate class that is called bin configuration.
+
+308
+00:25:30,000 --> 00:25:32,000
+In this class I want to configure one bin.
+
+309
+00:25:33,000 --> 00:25:37,000
+You can see that I use bin annotation as usual.
+
+310
+00:25:37,000 --> 00:25:41,000
+And here is configuration properties annotation bin.
+
+311
+00:25:41,000 --> 00:25:45,000
+I specify prefix what this prefix for.
+
+312
+00:25:45,000 --> 00:25:48,000
+Let me now open application properties.
+
+313
+00:25:48,000 --> 00:25:52,000
+Here you can see properties that are started from the entity verb.
+
+314
+00:25:53,000 --> 00:25:59,000
+And after the point, I specified the name of the objects property.
+
+315
+00:26:00,000 --> 00:26:01,000
+In entity.
+
+316
+00:26:01,000 --> 00:26:09,000
+I have ID and label fields and here is a SO spring is smart enough to bind the properties with a similar
+
+317
+00:26:09,000 --> 00:26:10,000
+names.
+
+318
+00:26:10,000 --> 00:26:11,000
+That's it.
+
+319
+00:26:11,000 --> 00:26:20,000
+In beans configuration I do nothing more, but when the bean will be created, spring will make sure
+
+320
+00:26:20,000 --> 00:26:26,000
+that properties values are equal to the one provided in the application properties file.
+
+321
+00:26:27,000 --> 00:26:34,000
+For the sake of the demo, I also created an endpoint in the class demo entity Properties controller.
+
+322
+00:26:34,000 --> 00:26:41,000
+I will just request this resource and we are going to see the state of the demo entity Bean, namely
+
+323
+00:26:41,000 --> 00:26:48,000
+its ID and label to make sure that these properties have value as it is specified in the properties
+
+324
+00:26:48,000 --> 00:26:49,000
+file.
+
+325
+00:26:50,000 --> 00:26:53,000
+So now we are ready to run the application.
+
+326
+00:26:55,000 --> 00:26:56,000
+The server is started.
+
+327
+00:26:57,000 --> 00:26:59,000
+Take a look at console output.
+
+328
+00:27:00,000 --> 00:27:03,000
+You can see only worn logs.
+
+329
+00:27:03,000 --> 00:27:07,000
+That is because we configured login level for root logger.
+
+330
+00:27:08,000 --> 00:27:13,000
+Now let's open the browser and check all our configurations.
+
+331
+00:27:14,000 --> 00:27:21,000
+The first time you open the web page using the Self-signed certificate browser will ask you whether
+
+332
+00:27:21,000 --> 00:27:29,000
+you really trust the certificate because browser understands that the certificate used for TLS connection
+
+333
+00:27:29,000 --> 00:27:32,000
+is not issued by trusted authority.
+
+334
+00:27:32,000 --> 00:27:40,000
+You just need to expand for additional details and click this hyper reference in order to tell the browser
+
+335
+00:27:40,000 --> 00:27:42,000
+that you are agreed to.
+
+336
+00:27:42,000 --> 00:27:43,000
+Proceed with the connection.
+
+337
+00:27:44,000 --> 00:27:48,000
+And then we can proceed to the root of our application.
+
+338
+00:27:48,000 --> 00:27:57,000
+Pay attention that our application is available at the Spring Boot demo context with the port 8888.
+
+339
+00:27:58,000 --> 00:28:02,000
+Also, you can see that I use HTTPS protocol for connection.
+
+340
+00:28:02,000 --> 00:28:05,000
+That is because we configured TLS SSL.
+
+341
+00:28:05,000 --> 00:28:13,000
+It shows that it is not protected because I use Self-signed certificate, but not the certificate from
+
+342
+00:28:13,000 --> 00:28:14,000
+the trusted authority.
+
+343
+00:28:14,000 --> 00:28:17,000
+But for development purposes that is fine.
+
+344
+00:28:17,000 --> 00:28:23,000
+In production you are going to substitute the certificate itself, but configurations will remain the
+
+345
+00:28:23,000 --> 00:28:24,000
+same.
+
+346
+00:28:24,000 --> 00:28:31,000
+And now let me reach our test endpoint in order to check the state of the demo entity object.
+
+347
+00:28:32,000 --> 00:28:41,000
+And here we can see that ID of our entity is 100 and label is test label as it was configured in application
+
+348
+00:28:41,000 --> 00:28:42,000
+properties.
+
+349
+00:28:43,000 --> 00:28:46,000
+So that's all what I wanted to share with you today.
+
+350
+00:28:46,000 --> 00:28:50,000
+Let's recap what we have learned in the lesson.
+
+351
+00:28:50,000 --> 00:28:54,000
+We learned more about application properties.
+
+352
+00:28:54,000 --> 00:29:01,000
+Now you know the precedence order of properties and how to override properties in case this will be
+
+353
+00:29:01,000 --> 00:29:01,000
+needed.
+
+354
+00:29:02,000 --> 00:29:08,000
+We learned list of the most common spring boot properties and default values for some of them.
+
+355
+00:29:09,000 --> 00:29:16,000
+Now you know how to change port number, how to configure SSL, TLS and spring boot application.
+
+356
+00:29:17,000 --> 00:29:24,000
+On real example, you saw how you can generate Self-signed certificate with changed context pass of
+
+357
+00:29:24,000 --> 00:29:25,000
+the application.
+
+358
+00:29:25,000 --> 00:29:32,000
+Also, we configured login level and at the end of the lesson we learned how to work with configuration
+
+359
+00:29:32,000 --> 00:29:34,000
+properties annotation.
+
+360
+00:29:34,000 --> 00:29:35,000
+That's it.
+
+361
+00:29:35,000 --> 00:29:37,000
+Thanks a lot for your attention.
+
+362
+00:29:37,000 --> 00:29:40,000
+Have a great day and see you in the next lesson.
+
diff --git a/92 - Spring Boot/005 Source-code-of-examples-commit-with-changes-.url b/92 - Spring Boot/005 Source-code-of-examples-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..f56c46c8620e1641edde6269b7456e5a57961031
--- /dev/null
+++ b/92 - Spring Boot/005 Source-code-of-examples-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/94ba22d51d1e1413056b7fc6bd1f4722ef39c0f5
\ No newline at end of file
diff --git a/92 - Spring Boot/005 Spring Boot Actuator - Monitoring Tools_en.srt b/92 - Spring Boot/005 Spring Boot Actuator - Monitoring Tools_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..56d52f0637260b581981299f7101464303d93ea3
--- /dev/null
+++ b/92 - Spring Boot/005 Spring Boot Actuator - Monitoring Tools_en.srt
@@ -0,0 +1,1184 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:10,000
+In this video lesson we are going to learn spring boot actuator.
+
+3
+00:00:10,000 --> 00:00:15,000
+We are going to start this lesson from understanding of what spring boot actuator is.
+
+4
+00:00:16,000 --> 00:00:23,000
+I will explain you the key features of actuator and what benefits we expect to get by using it in our
+
+5
+00:00:23,000 --> 00:00:25,000
+spring boot application.
+
+6
+00:00:25,000 --> 00:00:32,000
+Then we will hold an overview of the existing predefined and points in spring boot actuator.
+
+7
+00:00:32,000 --> 00:00:37,000
+After learning the theory, we are going to have a practical examples and demo.
+
+8
+00:00:37,000 --> 00:00:44,000
+I will start screen sharing and will show you everything you need to know in order to start work with
+
+9
+00:00:44,000 --> 00:00:46,000
+spring boot actuator from scratch.
+
+10
+00:00:47,000 --> 00:00:52,000
+We will add required dependency will expose actuator and points.
+
+11
+00:00:52,000 --> 00:00:58,000
+And in case you would like to exclude some end points, I will also show you how you can do this.
+
+12
+00:00:58,000 --> 00:01:06,000
+We will learn how to change base parts of the actuator and see how we can actually read different application
+
+13
+00:01:06,000 --> 00:01:07,000
+metrics.
+
+14
+00:01:07,000 --> 00:01:13,000
+And at the end of the lesson as a summary, we are going to learn best practices of working with Spring
+
+15
+00:01:13,000 --> 00:01:14,000
+boot actuator.
+
+16
+00:01:15,000 --> 00:01:17,000
+Let's start our lesson.
+
+17
+00:01:17,000 --> 00:01:20,000
+Let's understand first what is spring boot?
+
+18
+00:01:20,000 --> 00:01:29,000
+Actuator actuator plays a crucial role in enhancing our application with production ready capabilities.
+
+19
+00:01:29,000 --> 00:01:38,000
+By integrating actuator, we gain the ability to monitor our application, collect metrics, gain insights
+
+20
+00:01:38,000 --> 00:01:42,000
+into traffic, and assess the status of our database.
+
+21
+00:01:42,000 --> 00:01:50,000
+The primary advantage of utilizing this feature is that we can leverage enterprise grade tools without
+
+22
+00:01:50,000 --> 00:01:53,000
+the need to develop these functionalities from scratch.
+
+23
+00:01:53,000 --> 00:02:01,000
+Actuator serves to expose essential operational details about our running application, including health
+
+24
+00:02:01,000 --> 00:02:08,000
+status metrics, information on data dumps, environment configurations and more.
+
+25
+00:02:08,000 --> 00:02:15,000
+It offers various methods for interaction such as HTTP endpoints and jmax beans.
+
+26
+00:02:16,000 --> 00:02:18,000
+What are Jmax beans, by the way?
+
+27
+00:02:19,000 --> 00:02:22,000
+Jmax stands for Java Management Extensions.
+
+28
+00:02:22,000 --> 00:02:27,000
+Beans, also known as beans Managed beans.
+
+29
+00:02:28,000 --> 00:02:36,000
+They are Java objects that are exposed from management and monitoring purposes through the technology.
+
+30
+00:02:36,000 --> 00:02:44,000
+Jmax is a standard Java technology for managing and monitoring applications, devices and services in
+
+31
+00:02:44,000 --> 00:02:46,000
+a distributed environment.
+
+32
+00:02:46,000 --> 00:02:53,000
+Once actuator is included in our classpath, a set of preconfigured endpoints become available to us.
+
+33
+00:02:53,000 --> 00:03:02,000
+As is typical with spring modules, actuator can be easily customized and extended to meet our specific
+
+34
+00:03:02,000 --> 00:03:05,000
+requirements in many different ways.
+
+35
+00:03:05,000 --> 00:03:12,000
+So to sum it up, Spring boot Actuator is a sub project of spring boot that provides production ready
+
+36
+00:03:12,000 --> 00:03:18,000
+features to monitor, manage and interact with spring boot applications.
+
+37
+00:03:18,000 --> 00:03:25,000
+It offers a wide range of built in endpoints that expose various operational information and statistics
+
+38
+00:03:25,000 --> 00:03:33,000
+about the application, allowing developers and system administrators to gain insights into the applications,
+
+39
+00:03:33,000 --> 00:03:37,000
+health metrics, configuration, logging and more.
+
+40
+00:03:38,000 --> 00:03:43,000
+Let's now review the key features and benefits of spring boot actuator in order.
+
+41
+00:03:43,000 --> 00:03:47,000
+You can understand why you may need to use it.
+
+42
+00:03:47,000 --> 00:03:55,000
+Some key features and benefits of spring boot actuator include health monitoring Actuator includes a
+
+43
+00:03:55,000 --> 00:04:01,000
+health endpoint that provides a simple way to check the health status of the application.
+
+44
+00:04:01,000 --> 00:04:07,000
+It can indicate whether the application is running properly or if there are any issues.
+
+45
+00:04:08,000 --> 00:04:15,000
+Metrics gathering actuator collects and exposes application level metrics through the metrics and point.
+
+46
+00:04:15,000 --> 00:04:23,000
+It provides valuable insights into important metrics such as request response rates, CPU and memory
+
+47
+00:04:23,000 --> 00:04:28,000
+usage, database connections and other custom defined metrics.
+
+48
+00:04:29,000 --> 00:04:37,000
+Configuration management Actuator offers an environment endpoint that displays the application's current
+
+49
+00:04:37,000 --> 00:04:40,000
+environment, properties and configurations.
+
+50
+00:04:40,000 --> 00:04:47,000
+It enables easy inspection and troubleshooting of the application's configuration at runtime.
+
+51
+00:04:47,000 --> 00:04:55,000
+The login management actuator provides a logger endpoint that allows dynamic modification of the application's
+
+52
+00:04:55,000 --> 00:04:57,000
+logging levels.
+
+53
+00:04:57,000 --> 00:05:03,000
+It enables runtime control over logging levels without requiring application restarts.
+
+54
+00:05:04,000 --> 00:05:12,000
+Request tracing the trace point captures and displays, request tracing information, providing visibility
+
+55
+00:05:12,000 --> 00:05:16,000
+into the flow of requests through the application.
+
+56
+00:05:16,000 --> 00:05:21,000
+It can be useful for debugging and understanding request related issues.
+
+57
+00:05:22,000 --> 00:05:31,000
+Auditing actuator includes an audit events endpoint that shows auditing related events such as user
+
+58
+00:05:31,000 --> 00:05:36,000
+authentication and authorization events logged by the application.
+
+59
+00:05:36,000 --> 00:05:41,000
+It assists in monitoring and tracking security related activities.
+
+60
+00:05:42,000 --> 00:05:50,000
+Extensibility Actuator allows the creation of custom endpoints to expose application specific information
+
+61
+00:05:50,000 --> 00:05:53,000
+or perform custom management tasks.
+
+62
+00:05:53,000 --> 00:06:00,000
+It provides flexibility to integrate additional functionality based on specific application requirements.
+
+63
+00:06:00,000 --> 00:06:07,000
+Spring boot actuator integrates seamlessly with spring boot applications and can be easily configured
+
+64
+00:06:07,000 --> 00:06:10,000
+through properties or annotations.
+
+65
+00:06:10,000 --> 00:06:17,000
+It enhances the operational capabilities of spring boot applications, making them easier to monitor,
+
+66
+00:06:17,000 --> 00:06:21,000
+manage and maintain in production environments.
+
+67
+00:06:21,000 --> 00:06:28,000
+So you can see that spring boot actuator simplifies the task of managing and monitoring spring boot
+
+68
+00:06:28,000 --> 00:06:36,000
+applications by providing a comprehensive set of out-of-the-box features and endpoints, allowing developers
+
+69
+00:06:36,000 --> 00:06:43,000
+and administrators to gain valuable insights into application health, performance and configuration
+
+70
+00:06:43,000 --> 00:06:44,000
+details.
+
+71
+00:06:44,000 --> 00:06:51,000
+Before we jump to practical examples, let me make an overview of some of the predefined endpoints that
+
+72
+00:06:51,000 --> 00:06:54,000
+you can use to monitor your application.
+
+73
+00:06:54,000 --> 00:07:00,000
+We are going to learn Siri now and then we'll jump to practical examples.
+
+74
+00:07:00,000 --> 00:07:07,000
+As you can see on the slide, all actuators and points are located on the actuator pass.
+
+75
+00:07:08,000 --> 00:07:13,000
+You can use this information to configure security rules for these end points.
+
+76
+00:07:13,000 --> 00:07:16,000
+In order to restrict public access to them.
+
+77
+00:07:16,000 --> 00:07:22,000
+Also, I'm going to show you today how to change this base pass, if you wish.
+
+78
+00:07:22,000 --> 00:07:30,000
+Helsing Point provides information about the health status of the application indicating if it's running
+
+79
+00:07:30,000 --> 00:07:33,000
+properly or if there are any issues.
+
+80
+00:07:34,000 --> 00:07:38,000
+Info endpoint displays custom application information.
+
+81
+00:07:38,000 --> 00:07:44,000
+You can configure and customize the details exposed by this endpoint.
+
+82
+00:07:44,000 --> 00:07:53,000
+Metrics and point offers access to a wide range of application metrics such as request response rates,
+
+83
+00:07:53,000 --> 00:07:58,000
+CPU and memory usage, database connections and more.
+
+84
+00:07:58,000 --> 00:08:06,000
+Environment endpoint shows the application's current environment properties and configurations providing
+
+85
+00:08:06,000 --> 00:08:09,000
+insights into the runtime configuration of the application.
+
+86
+00:08:10,000 --> 00:08:17,000
+Login endpoint allows dynamic modification of the login levels of the application at runtime.
+
+87
+00:08:17,000 --> 00:08:23,000
+It enables controlling the log output without requiring application restarts.
+
+88
+00:08:23,000 --> 00:08:31,000
+Trace and point, captures and displays, request tracing information, providing visibility into the
+
+89
+00:08:31,000 --> 00:08:35,000
+flow of requests through the application.
+
+90
+00:08:35,000 --> 00:08:38,000
+It aids in debugging and troubleshooting.
+
+91
+00:08:39,000 --> 00:08:47,000
+Audit events, endpoint presents auditing related events such as user authentication and authorization
+
+92
+00:08:47,000 --> 00:08:49,000
+events logged by the application.
+
+93
+00:08:50,000 --> 00:08:57,000
+Beans and point provides information about spring beans registered in the application context, including
+
+94
+00:08:57,000 --> 00:09:00,000
+their dependencies and configurations.
+
+95
+00:09:01,000 --> 00:09:02,000
+Conditions.
+
+96
+00:09:02,000 --> 00:09:09,000
+End Point displays the conditions that influence the autoconfiguration of the applications bins.
+
+97
+00:09:10,000 --> 00:09:17,000
+Mappings endpoint shows a detailed mapping of all the request mappings defined in the application,
+
+98
+00:09:17,000 --> 00:09:21,000
+including the controller methods and their respective URLs.
+
+99
+00:09:22,000 --> 00:09:28,000
+Shut down endpoint enables graceful shutdown of the application by default.
+
+100
+00:09:28,000 --> 00:09:33,000
+It is not enabled and requires explicit configuration for security reasons.
+
+101
+00:09:34,000 --> 00:09:40,000
+Some other predefined endpoints and their descriptions you can see on the slide.
+
+102
+00:09:40,000 --> 00:09:45,000
+Feel free to press pause for a minute to explore the slide slowly.
+
+103
+00:09:45,000 --> 00:09:50,000
+I believe there is no need for me to read all the slides out loud.
+
+104
+00:09:50,000 --> 00:09:58,000
+Please note that availability and visibility of these endpoints may vary based on the actuator configuration
+
+105
+00:09:58,000 --> 00:10:02,000
+and any security settings in place today.
+
+106
+00:10:02,000 --> 00:10:10,000
+During the demo we are going to configure everything what we need to get access to mentioned endpoints.
+
+107
+00:10:10,000 --> 00:10:16,000
+I believe that we learned enough theory and now we are ready to jump to practical examples in order
+
+108
+00:10:16,000 --> 00:10:19,000
+to see spring boot actuator in action.
+
+109
+00:10:19,000 --> 00:10:25,000
+So let me show you how to configure actuator in your spring boot project.
+
+110
+00:10:25,000 --> 00:10:32,000
+I open Pom.xml file and I add spring boot starter actuator dependency.
+
+111
+00:10:32,000 --> 00:10:36,000
+That's all what you have to add from the dependency side.
+
+112
+00:10:36,000 --> 00:10:40,000
+Now let me open application properties.
+
+113
+00:10:40,000 --> 00:10:41,000
+Don't worry.
+
+114
+00:10:41,000 --> 00:10:46,000
+As usual, I will share with you a link to the source code in attachments to the video.
+
+115
+00:10:46,000 --> 00:10:52,000
+So by default, not all endpoints of the actuator are exposed.
+
+116
+00:10:52,000 --> 00:11:00,000
+In case you want to expose all endpoints, you need to specify this property management endpoints Web
+
+117
+00:11:00,000 --> 00:11:04,000
+exposure include and asterisk as a value.
+
+118
+00:11:05,000 --> 00:11:08,000
+Asterisk means all endpoints.
+
+119
+00:11:08,000 --> 00:11:15,000
+If you don't want to expose all endpoints, then you can list end points separated by commas like you
+
+120
+00:11:15,000 --> 00:11:18,000
+can see in this commanded example.
+
+121
+00:11:18,000 --> 00:11:22,000
+But I will keep all endpoints exposed for the sake of the demo.
+
+122
+00:11:23,000 --> 00:11:30,000
+In case you want to exclude some end points, you need to use exposure, exclude property.
+
+123
+00:11:30,000 --> 00:11:37,000
+And in the similar way, in case you need to exclude multiple end points, you can pass comma separated
+
+124
+00:11:37,000 --> 00:11:41,000
+list of values like you can see in this commanded example.
+
+125
+00:11:42,000 --> 00:11:45,000
+The next property here is health.
+
+126
+00:11:45,000 --> 00:11:46,000
+Show details.
+
+127
+00:11:47,000 --> 00:11:49,000
+Let me tell you more about it.
+
+128
+00:11:50,000 --> 00:11:56,000
+This property in spring boot actuator controls the level of detail displayed in the health endpoint
+
+129
+00:11:56,000 --> 00:11:57,000
+response.
+
+130
+00:11:57,000 --> 00:12:06,000
+It determines whether or not to include detailed information about the health status of individual components
+
+131
+00:12:06,000 --> 00:12:07,000
+or subsystems.
+
+132
+00:12:07,000 --> 00:12:12,000
+The possible values for this property are always.
+
+133
+00:12:12,000 --> 00:12:20,000
+This value indicates the detailed health information should always be shown in the health endpoint response.
+
+134
+00:12:20,000 --> 00:12:27,000
+It includes information about the health status of each individual component or subsystem, along with
+
+135
+00:12:27,000 --> 00:12:33,000
+additional details such as error messages or diagnostic information.
+
+136
+00:12:33,000 --> 00:12:35,000
+When authorized.
+
+137
+00:12:35,000 --> 00:12:43,000
+This value specifies the detailed health information should only be shown when the requester is authorized
+
+138
+00:12:43,000 --> 00:12:44,000
+to access it.
+
+139
+00:12:44,000 --> 00:12:52,000
+This allows you to restrict access to detailed health information based on authentication and authorization
+
+140
+00:12:52,000 --> 00:12:53,000
+rules.
+
+141
+00:12:53,000 --> 00:12:54,000
+Never.
+
+142
+00:12:54,000 --> 00:13:01,000
+This value means that detailed health information should never be shown in the health endpoint response.
+
+143
+00:13:01,000 --> 00:13:06,000
+Only the high level health status, such as up or down, will be returned.
+
+144
+00:13:07,000 --> 00:13:14,000
+By setting management and point health show details to always you ensure that health endpoint response
+
+145
+00:13:14,000 --> 00:13:20,000
+includes detailed information regardless of the requesters authorization.
+
+146
+00:13:20,000 --> 00:13:26,000
+This can be helpful during the development or troubleshooting scenarios when you need more visibility
+
+147
+00:13:26,000 --> 00:13:29,000
+into the health status of individual components.
+
+148
+00:13:30,000 --> 00:13:35,000
+The next commanded property here is management endpoints, web based POS.
+
+149
+00:13:36,000 --> 00:13:43,000
+It determines the common prefix that is added to the POS of each actuator endpoint.
+
+150
+00:13:43,000 --> 00:13:51,000
+You already learned that base POS for all API in actuator is basically actuator, but you can change
+
+151
+00:13:51,000 --> 00:13:52,000
+it if you wish.
+
+152
+00:13:53,000 --> 00:14:01,000
+So in case I would uncomment this property, the base POS would be management by customizing the base
+
+153
+00:14:01,000 --> 00:14:01,000
+paths.
+
+154
+00:14:01,000 --> 00:14:10,000
+You can align the actuator endpoints URL structure with the rest of your application API or match your
+
+155
+00:14:10,000 --> 00:14:12,000
+desired POS conventions.
+
+156
+00:14:12,000 --> 00:14:16,000
+Another interesting thing is creation of groups.
+
+157
+00:14:16,000 --> 00:14:23,000
+We can organize health indicators into groups and apply the same configuration to all the group members.
+
+158
+00:14:23,000 --> 00:14:30,000
+For example, we can create a health group named Custom by adding this to our application properties
+
+159
+00:14:30,000 --> 00:14:32,000
+like you can see here on the screen.
+
+160
+00:14:33,000 --> 00:14:39,000
+In this case, the custom group contains the disk space and pink health indicators.
+
+161
+00:14:40,000 --> 00:14:47,000
+We can configure the group to show more details in the similar way we already did with the health endpoint.
+
+162
+00:14:47,000 --> 00:14:51,000
+And few more words about show components property.
+
+163
+00:14:51,000 --> 00:14:58,000
+When you create custom health indicators in your application, they can be included in the details group
+
+164
+00:14:58,000 --> 00:15:00,000
+by default.
+
+165
+00:15:00,000 --> 00:15:08,000
+However, by setting management end point health group custom show components to always you are instructing
+
+166
+00:15:08,000 --> 00:15:16,000
+actuator to include the components of the custom group in the response of the health end point regardless
+
+167
+00:15:16,000 --> 00:15:19,000
+of their individual health status.
+
+168
+00:15:19,000 --> 00:15:26,000
+This property is useful when you want to expose specific components or aspects of your applications.
+
+169
+00:15:26,000 --> 00:15:33,000
+Health status in the actuator health endpoint response even if they're in custom group.
+
+170
+00:15:33,000 --> 00:15:42,000
+By setting it to always you ensure that the components of the custom group will always be visible regardless
+
+171
+00:15:42,000 --> 00:15:44,000
+of their individual health status.
+
+172
+00:15:45,000 --> 00:15:48,000
+Basically that's all configuration that we had to do.
+
+173
+00:15:48,000 --> 00:15:51,000
+So now you can run your server.
+
+174
+00:15:51,000 --> 00:15:54,000
+My server is up and running already.
+
+175
+00:15:54,000 --> 00:15:58,000
+Let me switch to the Chrome browser to make some demo.
+
+176
+00:15:58,000 --> 00:16:05,000
+Spring Boot includes a discovery endpoint that provides links to all available actuator endpoints,
+
+177
+00:16:05,000 --> 00:16:10,000
+simplifying the process of discovering the endpoints and their associated URLs.
+
+178
+00:16:10,000 --> 00:16:18,000
+By default, this discovery endpoint can be accessed through the actuator endpoint and you already know
+
+179
+00:16:18,000 --> 00:16:20,000
+how to change this basic path.
+
+180
+00:16:20,000 --> 00:16:23,000
+We have just reviewed configuration for that.
+
+181
+00:16:24,000 --> 00:16:31,000
+The JSON shows a collection of available actuator endpoints along with their corresponding URLs.
+
+182
+00:16:32,000 --> 00:16:35,000
+Let's now check some specific endpoints.
+
+183
+00:16:35,000 --> 00:16:38,000
+For example, let's check how endpoint.
+
+184
+00:16:38,000 --> 00:16:45,000
+It provides information about the health status of various components or subsystems in the application.
+
+185
+00:16:45,000 --> 00:16:51,000
+And just to remind you that in case you want to have more readable view of this information, there
+
+186
+00:16:51,000 --> 00:16:55,000
+are multiple JSON beautifier tools that you can find online.
+
+187
+00:16:56,000 --> 00:17:03,000
+You can copy JSON response and paste it in another tool in order to see readable format and explore
+
+188
+00:17:03,000 --> 00:17:04,000
+the content.
+
+189
+00:17:04,000 --> 00:17:12,000
+Here is what the response shows Status, the overall health status of the application which is indicated
+
+190
+00:17:12,000 --> 00:17:13,000
+as app.
+
+191
+00:17:13,000 --> 00:17:19,000
+In this case, it signifies that the application is functioning properly.
+
+192
+00:17:19,000 --> 00:17:20,000
+Components.
+
+193
+00:17:20,000 --> 00:17:27,000
+It contains detailed information about individual components or subsystems and their health status.
+
+194
+00:17:28,000 --> 00:17:36,000
+DB represents a component named DB and its health status, which is up in this example.
+
+195
+00:17:36,000 --> 00:17:44,000
+It also includes additional details about the component, such as the database being used and the validation
+
+196
+00:17:44,000 --> 00:17:44,000
+query.
+
+197
+00:17:45,000 --> 00:17:54,000
+Disk space represents a component named disk space and its health status, which is up in this case.
+
+198
+00:17:54,000 --> 00:18:02,000
+It provides details about the disk space, including the total space free space threshold file path
+
+199
+00:18:02,000 --> 00:18:04,000
+and whether it exists.
+
+200
+00:18:05,000 --> 00:18:13,000
+Pink represents a component named Pink and its health status, which is up in this example groups.
+
+201
+00:18:13,000 --> 00:18:17,000
+Do you remember we configured custom group in application properties.
+
+202
+00:18:17,000 --> 00:18:24,000
+So here is a confirmation of the fact that we have custom group and we can send requests to the endpoint
+
+203
+00:18:24,000 --> 00:18:28,000
+of the group to see the state of only preconfigured components.
+
+204
+00:18:29,000 --> 00:18:36,000
+Overall, the actuator health endpoint provides a snapshot of the health status of various components
+
+205
+00:18:36,000 --> 00:18:43,000
+in the application, allowing you to monitor and assess the overall health and availability of your
+
+206
+00:18:43,000 --> 00:18:43,000
+system.
+
+207
+00:18:44,000 --> 00:18:50,000
+Taking into account we have the group configured, we can send requests to the health custom endpoint
+
+208
+00:18:50,000 --> 00:18:54,000
+and explore the details in the application properties.
+
+209
+00:18:54,000 --> 00:18:59,000
+We configure it only two components for this group disk space and ping.
+
+210
+00:18:59,000 --> 00:19:02,000
+And here we can see only two components.
+
+211
+00:19:03,000 --> 00:19:05,000
+Now let's check metrics endpoint.
+
+212
+00:19:06,000 --> 00:19:11,000
+As you can see, this endpoint replies us with a list of metrics that we can check.
+
+213
+00:19:12,000 --> 00:19:17,000
+You can select the metrics that you are interested in and put it into the URL.
+
+214
+00:19:18,000 --> 00:19:22,000
+For example, let's check amount of current sessions.
+
+215
+00:19:22,000 --> 00:19:31,000
+We take the metric name, which is Tomcat sessions, active current and put it into the URL and we can
+
+216
+00:19:31,000 --> 00:19:34,000
+see the response with the details.
+
+217
+00:19:34,000 --> 00:19:38,000
+We can see that there is one active session currently.
+
+218
+00:19:38,000 --> 00:19:45,000
+By monitoring this metric, you can gain insights into the workload and utilization of session related
+
+219
+00:19:45,000 --> 00:19:48,000
+resources in your Tomcat server.
+
+220
+00:19:48,000 --> 00:19:56,000
+It can help you understand the current session activity, track the usage of several resources and identify
+
+221
+00:19:56,000 --> 00:20:04,000
+any potential issues related to session management, such as an excessive session creation or improper
+
+222
+00:20:04,000 --> 00:20:05,000
+session handling.
+
+223
+00:20:06,000 --> 00:20:12,000
+Or let's now check another metric metric that is called gvm info.
+
+224
+00:20:12,000 --> 00:20:16,000
+The metric provides information about the Gvm version.
+
+225
+00:20:16,000 --> 00:20:20,000
+The available tags provide additional details about the vendor.
+
+226
+00:20:21,000 --> 00:20:29,000
+Eclipse Adoption Runtime, OpenGL runtime, environment and version associated with the gvm.
+
+227
+00:20:29,000 --> 00:20:36,000
+This metric can be useful for monitoring and understanding the Gvm environment in which your application
+
+228
+00:20:36,000 --> 00:20:37,000
+is running.
+
+229
+00:20:37,000 --> 00:20:41,000
+Using the similar approach, you can check other metrics.
+
+230
+00:20:41,000 --> 00:20:44,000
+I believe you understood how it works.
+
+231
+00:20:44,000 --> 00:20:48,000
+Just spend some time checking different metrics.
+
+232
+00:20:48,000 --> 00:20:50,000
+I bet that you can find it useful.
+
+233
+00:20:51,000 --> 00:20:55,000
+Those are the key things that I wanted to show you during the demo.
+
+234
+00:20:55,000 --> 00:21:01,000
+Also wanted to make a note that you can create custom endpoints in spring boot actuator.
+
+235
+00:21:02,000 --> 00:21:10,000
+Actuator allows you to extend its functionality by adding your own custom endpoints to expose additional
+
+236
+00:21:10,000 --> 00:21:15,000
+management or monitoring information specific to your application.
+
+237
+00:21:15,000 --> 00:21:18,000
+We reviewed what Spring boot actuator is.
+
+238
+00:21:19,000 --> 00:21:21,000
+Now you have a better understanding.
+
+239
+00:21:22,000 --> 00:21:29,000
+And before I wrap up this lesson, let's discuss best practices for leveraging actuator effectively.
+
+240
+00:21:30,000 --> 00:21:36,000
+When discussing best practices for leveraging actuators effectively, there are several key considerations
+
+241
+00:21:36,000 --> 00:21:38,000
+to keep in mind.
+
+242
+00:21:38,000 --> 00:21:41,000
+Secure actuator endpoints.
+
+243
+00:21:42,000 --> 00:21:46,000
+Actuator endpoints provide sensitive information about your application.
+
+244
+00:21:46,000 --> 00:21:51,000
+It's crucial to secure these endpoints to prevent unauthorized access.
+
+245
+00:21:51,000 --> 00:21:58,000
+You can configure authentication and authorization mechanisms in our spring boot application.
+
+246
+00:21:58,000 --> 00:22:05,000
+We have spring security enabled already, and I believe you watched spring security lessons and you
+
+247
+00:22:05,000 --> 00:22:10,000
+already can imagine how to secure these endpoints knowing the basic pass.
+
+248
+00:22:11,000 --> 00:22:17,000
+You can basically just secure actuator pass and all child pass and that's it.
+
+249
+00:22:18,000 --> 00:22:20,000
+Limit exposed endpoints.
+
+250
+00:22:21,000 --> 00:22:27,000
+It's recommended to limit the exposed end points to only those that are necessary for monitoring and
+
+251
+00:22:27,000 --> 00:22:29,000
+management purposes.
+
+252
+00:22:29,000 --> 00:22:36,000
+This helps reduce the attack surface and minimizes the risk of exposing sensitive information.
+
+253
+00:22:36,000 --> 00:22:38,000
+How to limit Exposed endpoints.
+
+254
+00:22:38,000 --> 00:22:41,000
+We also learned on examples.
+
+255
+00:22:42,000 --> 00:22:50,000
+Customize and point pass activate endpoints have default paths such as actuator has or actuator info.
+
+256
+00:22:50,000 --> 00:22:59,000
+It's advisable to customize these paths to make them less predictable and less susceptible to potential
+
+257
+00:22:59,000 --> 00:23:00,000
+security vulnerabilities.
+
+258
+00:23:00,000 --> 00:23:04,000
+And we already learned how to adjust the base path.
+
+259
+00:23:05,000 --> 00:23:12,000
+Monitor Essential Metrics Actuator provides various metrics to monitor the health and performance of
+
+260
+00:23:12,000 --> 00:23:14,000
+your application.
+
+261
+00:23:14,000 --> 00:23:22,000
+It identifies the most critical metrics for your specific use case and ensure they're actively monitored.
+
+262
+00:23:22,000 --> 00:23:32,000
+This can include metrics related to request rates, response times, error rates, CPU and memory usage,
+
+263
+00:23:32,000 --> 00:23:39,000
+database connections, and any other relevant metrics specific to your application's behavior.
+
+264
+00:23:40,000 --> 00:23:47,000
+Leverage custom end points Actuator allows you to create custom endpoints to expose application specific
+
+265
+00:23:47,000 --> 00:23:49,000
+monitoring and management information.
+
+266
+00:23:50,000 --> 00:23:57,000
+Consider creating custom endpoints tailored to your applications requirements, providing insights into
+
+267
+00:23:57,000 --> 00:24:03,000
+specific aspects of your system or exposing custom management operations.
+
+268
+00:24:04,000 --> 00:24:11,000
+Utilize health indicators, actuators, health and point provides information about the health of your
+
+269
+00:24:11,000 --> 00:24:12,000
+application.
+
+270
+00:24:12,000 --> 00:24:19,000
+Implement Custom Health indicators to incorporate additional checks specific to your applications,
+
+271
+00:24:19,000 --> 00:24:22,000
+dependencies and critical components.
+
+272
+00:24:22,000 --> 00:24:29,000
+This allows you to have a comprehensive view of the overall health status and proactively address any
+
+273
+00:24:29,000 --> 00:24:31,000
+potential issues.
+
+274
+00:24:32,000 --> 00:24:35,000
+Integrate with monitoring and alerting systems.
+
+275
+00:24:36,000 --> 00:24:43,000
+Actuator complements, monitoring and alerting systems by exposing valuable information about your application.
+
+276
+00:24:44,000 --> 00:24:52,000
+Integrate actuator with your preferred monitoring and alerting tools such as Prometheus, Grafana or
+
+277
+00:24:52,000 --> 00:24:53,000
+Elastic Logstash.
+
+278
+00:24:53,000 --> 00:25:00,000
+Kibana Stack To gain a centralized view of your applications, health metrics and logs.
+
+279
+00:25:01,000 --> 00:25:07,000
+Document, exit and points document the available exit and points.
+
+280
+00:25:07,000 --> 00:25:10,000
+The purpose and the information they provide.
+
+281
+00:25:10,000 --> 00:25:19,000
+This documentation helps both developers and operations teams to understand the capabilities and usage
+
+282
+00:25:19,000 --> 00:25:27,000
+of actuate and points, facilitating effective monitoring, troubleshooting and management of the application.
+
+283
+00:25:28,000 --> 00:25:35,000
+By following these best practices, you can leverage actuator effectively to gain insights into your
+
+284
+00:25:35,000 --> 00:25:42,000
+applications, health metrics and management aspects, enabling efficient monitoring, troubleshooting
+
+285
+00:25:42,000 --> 00:25:45,000
+and optimization of your spring boot applications.
+
+286
+00:25:46,000 --> 00:25:49,000
+That's all what I wanted to review with you today.
+
+287
+00:25:49,000 --> 00:25:52,000
+Let's recap what we have learned in the lesson.
+
+288
+00:25:53,000 --> 00:25:56,000
+We learned what spring boot actuator is.
+
+289
+00:25:57,000 --> 00:26:01,000
+Now you know the key features and benefits of spring boot actuator.
+
+290
+00:26:02,000 --> 00:26:08,000
+I showed you existing predefined endpoints that are available in spring boot actuator.
+
+291
+00:26:08,000 --> 00:26:15,000
+On real examples, you saw how to configure spring boot actuator in your application and how to read
+
+292
+00:26:15,000 --> 00:26:17,000
+applications metrics.
+
+293
+00:26:18,000 --> 00:26:23,000
+And at the end of the lesson, we learned best practices of working with Spring Boot Actuator.
+
+294
+00:26:24,000 --> 00:26:25,000
+That's it.
+
+295
+00:26:25,000 --> 00:26:27,000
+Thanks a lot for your attention.
+
+296
+00:26:27,000 --> 00:26:30,000
+Have a great day and see you in the next lesson.
+
diff --git a/92 - Spring Boot/external-links.txt b/92 - Spring Boot/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0e55464f1288e57e76a0f7b3c5af5166d2bf9bd6
--- /dev/null
+++ b/92 - Spring Boot/external-links.txt
@@ -0,0 +1,21 @@
+
+002 Spring-Initializr-Tool
+https://start.spring.io/
+
+002 Source-code-of-the-first-Spring-Boot-project-from-the-lesson-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/ed97cff607917d923b693146b5fcdc08d507d422
+
+003 Spring-Boot-Starters-on-Github
+https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-starters
+
+003 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/4b8bea15fe2262ce27a63fc8a0c9059549e39c4c
+
+004 Common-Spring-Boot-Application-Properties
+https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html
+
+004 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/1ca891ad59a291a71a5ba1df5ae4c91b87dc2734
+
+005 Source-code-of-examples-commit-with-changes-
+https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/94ba22d51d1e1413056b7fc6bd1f4722ef39c0f5
diff --git a/93 - ===== EXAM Spring Boot, Spring Framework & REST API =====/001 Exam Task Description and Solution.html b/93 - ===== EXAM Spring Boot, Spring Framework & REST API =====/001 Exam Task Description and Solution.html
new file mode 100644
index 0000000000000000000000000000000000000000..92a68c129cc9daaed929d4ff9a7828b4f7b5e4ed
--- /dev/null
+++ b/93 - ===== EXAM Spring Boot, Spring Framework & REST API =====/001 Exam Task Description and Solution.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Exam Task Description and Solution
+
+
+
+
+
+
+
Exam Task Description and Solution
+
Introduction
Hello team,
If you read this exam task this means that you completed Spring Framework section and has significant experience in Java. And that’s why, this exam task wouldn’t be the regular one like you had previously in the course.
This exam task will be super close to your future job and real work environment. Just imagine that you are given task at your job, and you have nothing else to do but implement it. Very oftne at your job you will hear words that you don’t know what are they about - you need to google them. Where often you would deal with things that you don’t know how to deal with - you need to google again and find answers. The thing is, that in real life, you don’t always have the API that you worked with before. And usually, each new task - it is a new research.
So, with this exam task I want you to challenge yourself. With this task you need to prove yourself that you are not simply good in Java, Spring, or anything else. Completion of this task will mean that you are true Software Engineer. Because today, in most companies, it is not enough just to know Java. It is important how fast you can learn new things. And understanding the core principles of web development will help you to learn new things faster.
That’s why be prepared that for completion of this exam task you would need to make your own research on external API. Of course, I will provide you with the detailed review of solution. But it is better you implemented the solution on your own, and only then you would check my solution. So, let me jump to the task description.
Exam Task Description
Video of the application that you need to develop - https://youtu.be/W4vBlMhelVE
The description of the app from the video is below.
You need to create web application, that would handle “onMention” events from Slack messenger. On “onMention” event, web app should use GPT Capabilities to process the request. This may include the following behavior:
Integration with ChatGPT and sending the response to the end user from the ChatGPT
Invocation of required functions to get necessary data, and then pass it to the ChatGPT with original request to analyze data and provide end-user with the answer.
Like it is shown in the video you need to use Slack messenger interface in order to submit requests to our web application. The end user expects to get relevant answers and behavior for such scenarios:
Analysis of Data from Jira:
how many work items do we have in Jira?
how many work items <USER NAME> has assigned now in Jira?
how many work items with the type “bug” we have now in not completed status?
can you group these bugs by status, please?
check, please, due dates of not completed bugs that you referred to, and tell me, when is the latest due date?
and who is the bug with the latest due date assigned to?
can you remind me of the issue ID, please, in the scope of which we planned to implement a persistent cart state across multiple browsers for the same account?
can you group all items from Jira by assignee, please?
can you group all items by issue type, please?
can you create a story in Jira about <USER STORY DESCRIPTION>, assign it to <USER NAME> and set due date <DUE DATE>
Other scenario to implement:
Solution
The repository with the solution - https://github.com/AndriiPiatakha/openai-learnit
If you want to hear explanation of each line from the solution, please, continue watching the course, namely the sections:
OpenAI API
Slack API
Jira API
ChatGPT API
Inside the lessons we develop the application using the requirements shared above.
+
+
+
+
diff --git a/94 - ===== Spring Interview Preparation =====/001 Part 1 Spring Interview - Questions and Answers.html b/94 - ===== Spring Interview Preparation =====/001 Part 1 Spring Interview - Questions and Answers.html
new file mode 100644
index 0000000000000000000000000000000000000000..37c2ba24982064a0a22be4cc4e9cc125db86e565
--- /dev/null
+++ b/94 - ===== Spring Interview Preparation =====/001 Part 1 Spring Interview - Questions and Answers.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Part 1 Spring Interview - Questions and Answers
+
+
+
+
+
+
+
Part 1 Spring Interview - Questions and Answers
+
Dependency injection (DI) is a design pattern and architectural model also known as Inversion of Control (IoC). DI describes the situation when one object implements its functionality through another object. For example, a database connection is passed to the object's constructor as an argument, instead of the constructor itself establishing the connection. There are three forms of dependency injection: setter, constructor, and interface injection.
DI is a way to achieve loose coupling. IoC provides the ability for an object to obtain references to its dependencies. This is usually implemented through the lookup method. The advantage of IoC is that this model allows you to separate objects from the implementation of the mechanisms that it uses. As a result, we gain greater flexibility in both application development and application testing.
The benefits of DI include:
Reducing the amount of glue code. One of the biggest benefits of DI is the ability to greatly reduce the amount of code that must be written to tie together the various components of an application. Often this code is very simple - when you create a dependency, a new instance of the corresponding object must be created.
Simplified application configuration. By using DI, the process of configuring an application is greatly simplified. Annotations or XML files can be used to configure classes that can be injected into other classes.
Ability to manage common dependencies in a single repository. With the traditional approach of managing dependencies in shared services, such as data source connection, transaction, remote services, etc., you instantiate (or get them from defined factory classes) the dependencies where they are needed - inside the dependent class. This causes dependencies to be propagated across many classes in the application, which can make them difficult to change. In the case of using DI, all information about common dependencies is contained in a single repository (Spring has the ability to store this information in XML files or Java classes).
Improved testing capability. When classes are designed for DI, it becomes possible to easily replace dependencies. This is especially useful when testing an application.
Stimulation of quality design solutions for applications. Generally speaking, designing for DI means designing with interfaces. With Spring, you have a range of DI tools at your disposal and can focus on building the application logic rather than on a DI-enabled platform.
Spring is an IoC container. In addition to it, there are HiveMind, Avalon, PicoContainer, etc.
The implementation of DI in Spring is based on two key Java concepts - JavaBeans and interfaces. When using Spring as a DI provider, you have the flexibility to define dependency configuration within your applications in a variety of ways (i.e. externally in XML files, via Spring's Java configuration classes, or via Java annotations in your code). JavaBeans (also called POJOs (Plain Old Java Objects)) provide a standard mechanism for creating Java resources that are configurable in a variety of ways. Through the use of DI, the amount of code that is required when designing an application based on interfaces is reduced to almost zero. Also, interfaces are the best way to get the most out of DI because beans can use any implementation of an interface to satisfy their dependency.
Spring is an open source framework designed to simplify the development of enterprise applications. One of the main advantages of Spring is its layered architecture, which allows you to define which components will be used in your application. Spring modules are built around a core container that defines the creation, configuration, and management of beans.
Main modules are:
Main Container - Provides the core functionality of Spring. The main component of a container is the BeanFactory, an implementation of the Factory pattern. BeanFactory allows you to separate application configuration and dependency information from code.
Spring context is a configuration file that provides environment information for Spring. This includes enterprise services such as JNDI, EJB, internationalization, validation, and so on.
Spring AOP - responsible for integrating aspect-oriented programming into the framework. Spring AOP provides a transaction management service for a Spring application.
Spring DAO - The abstract layer of Spring JDBC DAO provides an exception hierarchy and many error messages for different DBs. This hierarchy simplifies exception handling and greatly reduces the amount of code you would need to write for operations such as opening and closing a connection.
Spring ORM - Responsible for integrating Spring and popular ORM frameworks such as Hibernate, iBatis, and JDO.
Spring Web module - classes that help simplify Web development (authorization, access to Spring beans from the web).
Spring MVC framework is an implementation of the MVC pattern for building Web applications.
The Spring Framework uses many design patterns, for example:
Singleton Pattern: Creating beans with default scope.
Factory Pattern: Bean Factory classes
Prototype Pattern: Bean scopes
Adapter Pattern: Spring Web and Spring MVC
Proxy Pattern: Spring Aspect Oriented Programming support
Template Method Pattern: JdbcTemplate, HibernateTemplate etc
Front Controller: Spring MVC DispatcherServlet
Data Access Object: Spring DAO support
Dependency Injection and Aspect Oriented Programming
etc.
The Spring Framework provides solutions to many of the challenges faced by Java developers and organizations that want to build an information system based on the Java platform. Due to the wide functionality, it is difficult to determine the most significant structural elements of which it consists. The Spring Framework is not entirely tied to the Java Enterprise platform, despite its extensive integration with it, which is an important reason for its popularity.
Relative ease in learning and using the framework in developing and maintaining an application.
Dependency Injection (DI) and Inversion of Control (IoC) allow you to write components that are independent of each other, which gives advantages in team development, module portability, etc.
The Spring IoC container manages the life cycle of a Spring Bean and is configured like a JNDI lookup.
The Spring project contains many sub-projects that cover important parts of software development such as web services, web programming, working with databases, loading files, error handling, and more. All this is configured in a single format and simplifies application support.
To simplify the process of developing Spring-based applications in Eclipse (the most commonly used IDE for developing Java applications), the Spring IDE project has been created within Spring. The project is free. It is integrated into Eclipse IDE, Spring IDE, Mylyn (task based development environment in Eclipse), Maven for Eclipse, AspectJ Development Tool.
Aspect-Oriented Programming (AOP) is a programming paradigm based on the idea of separation of functionality in order to better break down a program into modules. AOP and Spring are complementary technologies that allow you to solve complex problems by separating functionality into separate modules. AOP provides the ability to implement end-to-end logic - i.e. logic that applies to many parts of the application in one place and ensure that this logic is automatically applied throughout the application. Spring's approach to AOP is to create "dynamic proxies" for the target objects and "attach" the objects to a configured “advice” to perform pass-through logic.
Basic concepts of AOP:
Aspect is a module or class that implements end-to-end functionality. The aspect modifies the behavior of the rest of the code by applying the hint at join points defined by some slice.
Advice is a piece of code that must be executed on a single connection point. There are several types of advices, the advice can be executed before, after or instead of the join point.
A joinpoint is a well-defined point in a running program where advice should be applied. Common examples of joinpoints include method invocation, class initialization, and object instantiation. Many AOP implementations allow you to use method calls and object field accesses as join points.
Pointcut - a set of connection points. The slice determines whether a given connection point matches a given advice. The most convenient implementations of AOP use the syntax of the host language to define slices (for example, AspectJ uses Java signatures) and allow them to be reused through renaming and combining.
Weaving is the process of actually inserting aspects at a specific point in the application code. For compile-time AOP solutions, this is done at compile time, usually as an additional step in the build process. Similarly, for runtime AOP solutions, the binding happens dynamically at runtime. AspectJ supports another binding mechanism called load-time weaving (LTW), which intercepts the underlying JVM classloader and provides binding to the bytecode when it is loaded by the classloader.
A target is an object whose execution flow is modified by some AOP process. The target object is often referred to as a advice-equipped object.
Introduction - is a process by which you can change the structure of an object by introducing additional methods or fields into it, changing the inheritance hierarchy to add aspect functionality to foreign code. Usually implemented using some metaobject protocol (MOP).
AspectJ is the de facto standard for implementing AOP. Spring's implementation of AOP has some differences:
Spring AOP is a bit simpler because there is no need to monitor the linking process.
Spring AOP supports AspectJ annotations, so we can work in a spring project in a similar way to an AspectJ project.
Spring AOP only supports proxy-based AOP and can only use one type of join point - Method Invocation. AspectJ supports all kinds of join points.
The disadvantage of Spring AOP is that it only works with its own beans that exist in the Spring Context.
At its core, IoC, and therefore DI, aims to offer a simple mechanism for exposing component dependencies (often referred to as object collaborators) and managing those dependencies throughout their lifecycle. A component that requires certain dependencies is often referred to as a dependent object or, in the case of IoC, a target object. IoC provides services through which components can access their dependencies and services for interacting with dependencies during their lifetime. In general, IoC can be split into two subtypes: Dependency Injection and Dependency Lookup.
Inversion of control is a big part of what Spring does, and the core implementation of Spring is based on inversion of control, although Dependency Lookup facilities are also provided. When the Spring framework automatically provides collaborators to a dependent object, it does so using Inversion of Control (Dependency Injection). In a Spring-based application, it is always preferable to use Dependency Injection to pass collaborators to dependent objects instead of forcing dependent objects to get collaborators via lookup.
The term bean is used in Spring to refer to any bean managed by a container. Usually, beans adhere to the JavaBean specification at some level, but this is not necessary, especially if you plan to use Constructor Injection to bind the beans to each other. The ApplicationContext is used to get the bean instance. The IoC container manages the spring bean's life cycle, scope, and injection.
The spring configuration file defines all the beans that will be initialized in the Spring Context. When an instance of the Spring ApplicationContext is created, the configuration xml file will be read and the necessary initializations specified in it will be performed. Apart from the basic configuration, the file may contain descriptions of interceptors, view resolvers, localization settings, etc.
singleton (default) - Single bean instance per Spring IoC container.
prototype - A new bean instance is created every time a bean is requested.
request - Only a single instance will be created and available during the complete lifecycle of an HTTP request. Only valid in the context of a web-aware Spring ApplicationContext.
session - Only a single instance will be created and available during the complete lifecycle of an HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext.
application - Only a single instance will be created and available during the complete lifecycle of ServletContext. Only valid in the context of a web-aware Spring ApplicationContext.
websocket - Only a single instance will be created and available during the complete lifecycle of WebSocket. Only valid in the context of a web-aware Spring ApplicationContext.
+
+
+
+
diff --git a/94 - ===== Spring Interview Preparation =====/002 Part 2 Spring Interview - Questions and Answers.html b/94 - ===== Spring Interview Preparation =====/002 Part 2 Spring Interview - Questions and Answers.html
new file mode 100644
index 0000000000000000000000000000000000000000..f57b4081de6477cb05699512140653d81a6571c8
--- /dev/null
+++ b/94 - ===== Spring Interview Preparation =====/002 Part 2 Spring Interview - Questions and Answers.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Part 2 Spring Interview - Questions and Answers
+
+
+
+
+
+
+
Part 2 Spring Interview - Questions and Answers
+
The life cycle of a Spring bean is the lifetime of a object. Spring beans are initialized when the Spring container is initialized and all dependencies are injected. When the container is destroyed, the entire contents are destroyed as well. If we need to set some action when initializing and destroying the bean, then we need to use the init () and destroy () methods. You can use the @PostConstruct and @PreDestroy() annotations for this. Or xml configuration.
BeanFactory is an implementation of the Factory pattern, its functionality covers the creation of beans. Because this factory knows a lot about the application's objects, it can create relationships between objects during the instantiation phase. There are several BeanFactory implementations, the most commonly used is
After this, the factory knows about the beans, but their instances have not yet been created. To instantiate a bean, you need to call the getBean() method.
There are two ways to get the main container objects inside a bean:
Implement one of the Spring*Aware (ApplicationContextAware, ServletContextAware, ServletConfigAware, etc.) interfaces.
Use @Autowired in the class to inject ServletContext
While BeanFactory is used in simple applications, Application Context is a more complex container. Like BeanFactory it can be used to load and bind beans, but it also provides:
the ability to receive text messages, including support for internationalization;
general mechanism for working with resources;
events for beans that are registered as listeners.
Due to more functionality, it is recommended to use Application Context instead of BeanFactory. The latter is used only in cases where resources are scarce, such as when developing for mobile devices.
The process of injecting dependencies into beans during initialization is called Spring Bean Wiring. It's considered good practice to explicitly wire dependencies, but Spring provides an additional @Autowired binding mechanism. An annotation can be used on a field or method to bind by type. For the annotation to work, you need to specify small settings in the spring configuration file using the context:annotation-config element.
There are four types of binding in a spring:
@Controller is a front controller class in a Spring MVC project.
@RequestMapping - allows you to set the URI mapping template in the controller handler method.
@ResponseBody - allows you to send an Object in the response. Typically used to send XML or JSON data.
@PathVariable - Specifies the dynamic mapping of values from the URI inside the handler method arguments.
@Autowired - Used to automatically wire dependencies in spring beans.
@Qualifier - used in conjunction with @Autowired to qualify the binding data when collisions are possible (e.g. identical names/types).
@Service - indicates that the class implements service functions.
@Scope - Specifies the scope of a spring bean.
@Configuration, @ComponentScan and @Bean - for java based configurations.
AspectJ annotations to customize aspects and advices, @Aspect, @Before, @After, @Around, @Pointcut, etc.
Yes it is possible. For this, the @ResponseBody annotation is used. This is how you can send responses in the form of JSON, XML in restful web services.
By default, the bean is set as a singleton in Spring. Thus, all public variables of a class can be changed simultaneously from different places. So - no, it is not. However, by changing the scope of the bean to request, prototype, session, it will become thread-safe, but this will affect performance.
In a standalone Java program, an ApplicationContext can be created like this:
AnnotationConfigApplicationContext - When using Spring as a standalone application, you can create an initialize container using annotations.
ClassPathXmlApplicationContext - Gets information from an xml file located on the classpath.
FileSystemXmlApplicationContext - receives information from an xml file, but with the ability to load a configuration file from anywhere in the file system.
XmlWebApplicationContext - Gets information from an xml file outside of the web application.
You can specify multiple Spring configuration files by specifying contextConfigLocation. Parameters are specified separated by commas or spaces.
The ability to specify multiple root Spring configuration files is supported.
Using datasource "org.springframework.jdbc.datasource.DriverManagerDataSource".
Using "org.springframework.jndi.JndiObjectFactoryBean".
Transactions in Spring are managed using Declarative Transaction Management (programmatically managed). The @Transactional annotation is used to describe the need to manage a transaction. In the configuration file, you need to add the transactionManager setting for the DataSource.
Spring DAO provides the ability to work with data access using technologies like JDBC, Hibernate in a convenient way. There are special classes: JdbcDaoSupport, HibernateDaoSupport, JdoDaoSupport, JpaDaoSupport.
The HibernateDaoSupport class is a suitable superclass for Hibernate DAO. It contains methods for getting a session or session factory. The most popular method is getHibernateTemplate() which returns a HibernateTemplate. This template wraps Hibernate checked exceptions into runtime exceptions, allowing your DAOs to remain independent of Hibernate exceptions.
To integrate Hibernate into Spring, you need to include dependencies, as well as set up a Spring configuration file. Because settings differ slightly between projects and versions, see the official Spring and Hibernate documentation for technology-specific settings.
It is enough to simply specify the ContextLoaderListener in the web.xml file of the application.
ContextLoaderListener is a ServletContextListener that is initialized when your web application starts up. By default, it loads the WEB-INF/applicationContext.xml file. You can change the default value by specifying the contextConfigLocation parameter.
+
+
+
+
diff --git a/94 - ===== Spring Interview Preparation =====/003 Part 3 Spring Interview - Questions and Answers.html b/94 - ===== Spring Interview Preparation =====/003 Part 3 Spring Interview - Questions and Answers.html
new file mode 100644
index 0000000000000000000000000000000000000000..21077349bd1919d96b1bc94925e8499bb986f748
--- /dev/null
+++ b/94 - ===== Spring Interview Preparation =====/003 Part 3 Spring Interview - Questions and Answers.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Part 3 Spring Interview - Questions and Answers
+
+
+
+
+
+
+
Part 3 Spring Interview - Questions and Answers
+
The key interface in Spring MVC is the Controller. The controller processes requests for actions taken by users in the user interface, interacting with the service layer, updating the model, and directing users to the appropriate views based on the results of the execution. Controller - is a control tool, communication between the model and the view.
The main controller in Spring MVC is org.springframework.web.servlet.DispatcherServlet. It is specified by the @Controller annotation and is often used with the @RequestMapping annotation, which specifies which requests will be processed by this controller.
@Component - used to specify a class as a spring bean. When using annotation lookup, such a class will be configured as a spring bean.
@Controller is a special type of class used in MVC applications. Handles requests and is often used with the @RequestMapping annotation.
@Repository - indicates that the class is used to work with searching, getting and storing data. An annotation can be used to implement a DAO pattern.
@Service - indicates that the class is a service for implementing business logic (in fact, it does not differ from Component, but simply helps the developer to indicate the semantic load of the class).
Any of these annotations can be used to point the container to a bean class. But different names make it possible to distinguish the purpose of a particular class.
DispatcherServlet - is a servlet that parses requests and routes them to the appropriate controller for processing. In Spring MVC, the DispatcherServlet class is the central servlet that receives requests and routes them to the appropriate controllers. In a Spring MVC application, there can be an arbitrary number of DispatcherServlet instances for different purposes (for example, handling UI requests, REST web service requests, etc.). Each DispatcherServlet instance has its own WebApplicationContext configuration that defines servlet-level characteristics such as servlet-enabled controllers, handler mapping, view recognition, internationalization, validation, type conversion and formatting, and so on.
ContextLoaderListener - listener when starting and ending the Spring WebApplicationContext root class. The main purpose is to bind the life cycle of ApplicationContext and ServletContext, as well as automatic creation of ApplicationContext. You can use this class to access beans from different spring contexts. Configured in web.xml
The ViewResolver interface in Spring MVC (from the org.springframework.web.servlet package) supports view recognition based on the logical name returned by the controller. Many implementation classes are provided to support various view recognition mechanisms.
For example, the UrlBasedViewResolver class supports direct conversion of logical names to URLs. The ContentNegotiatingViewResolver class supports dynamic view recognition based on the media type supported by the client (XML, PDF, JSON, etc.). There are also several implementations to integrate with various view technologies such as FreeMarker (FreeMarkerViewResolver), Velocity (VelocityViewResolver) and JasperReports (JasperReportsViewResolver).
InternalResourceViewResolver - An implementation of the ViewResolver that allows you to find the views that the controller returns to navigate to later. Searches for the given path, prefix, suffix and name.
The MultipartResolver interface is used to download files. There are two implementations CommonsMultipartResolver and StandardServletMultipartResolver that allow the framework to upload files. By default, this interface is not included in the application and must be specified in the configuration file. Once configured, any download request will be sent to this interface.
Inside the spring, a MultipartResolver interface is provided to support file loading. What you actually need to do is set up a config file to specify the file upload handler and then set the required method in the spring controller.
In Spring MVC, the HandlerExceptionResolver interface (from the org.springframework.web.servlet package) is designed to deal with unexpected exceptions thrown during the execution of handlers. By default, the DispatcherServlet registers the DefaultHandlerExceptionResolver class (from the org.springframework.web.servlet.mvc.support package). This resolver handles certain standard Spring MVC exceptions by setting a special response status code. You can also implement your own exception handler by annotating the controller method with the @ExceptionHandler annotation and passing it the exception type as an attribute. In general, exception handling can be described as follows:
Controller Based - specify methods for handling an exception in the controller class. To do this, you need to mark such methods with the @ExceptionHandler annotation.
Global Exception Handler - To handle global exceptions, spring provides the @ControllerAdvice annotation.
HandlerExceptionResolver implementation - Generic exceptions serve static pages most of the time. The Spring Framework provides the HandlerExceptionResolver interface, which allows you to specify a global exception handler. You can use the implementation of this interface to create your own global exception handlers in your application.
To create a simple Spring MVC application, you need to go through the following steps:
Add spring-context and spring-webmvc dependencies to the project.
Specify a DispatcherServlet in web.xml to handle requests within the application.
Define spring bean definition (by annotation or in xml).
Add a view resolver definition for views.
Set up a controller class to handle client requests.
Model (Model) - acts as any Java bean in Spring. Within the class, various attributes and properties can be set for use in the view.
Presentation (View) - JSP page, HTML file, etc. serve to display the necessary information to the user. The view hands over processing of requests to the servlet dispatcher (controller).
The DispatcherServlet (Controller) is the main controller in a Spring MVC application that handles all incoming requests and passes them on to various methods in the controllers for processing.
Spring MVC provides a very simple and convenient way to localize an application. To do this, do the following:
Create a resource bundle file that will contain various options for localized information.
Define messageSource in Spring configuration using ResourceBundleMessageSource or ResourceBundleMessageSource classes.
Define a localceResolver of the CookieLocaleResolver class to enable locale switching.
Using the spring:message element, the DispatcherServlet will determine where to place the localized message in the response.
The Spring Framework allows you to create Resful web services and return data in JSON format. Spring provides integration with the Jackson JSON API to be able to send JSON responses to a resful web service. To send a response in JSON format from a Spring MVC application, you need to make the following settings:
Add Jackson JSON dependencies.
Configure the RequestMappingHandlerAdapter bean in the Spring configuration file and set the messageConverters property to use the MappingJackson2HttpMessageConverter bean.
In the controller, use the @ResponseBody annotation to return an Object
Spring supports validation annotations from JSR-303, as well as the ability to create custom implementations of validator classes.
After you configured validation rules in the bean using annotations, we can use @Validate annotation next to ModelAttribute to validate the bean. In case you specify BindingResult parameter after the bean, in the list of method parameters that process the bean from form - in this case all the errors will be in BindingResult. You can use binding result API to validate errors.
Interceptors in Spring (Spring Interceptor) are analogous to Servlet Filter and allow you to intercept client requests and process them. There are three places to intercept a client request: preHandle, postHandle, and afterCompletion.
preHandle - the method is used to handle requests that have not yet been passed to the controller's handler method. Must return true to pass to the next interceptor or handler method. False will indicate that the request is processed by the handler itself and that there is no need to pass it on. The method has the ability to throw exceptions and forward errors to the view.
postHandle - Called after the handler method but before being processed by the DispatcherServlet to be passed to the view. Can be used to add options to the ModelAndView object.
afterCompletion - Called after the view has been rendered.
To create a handler, you must extend the abstract HandlerInterceptorAdapter class or implement the HandlerInterceptor interface. You also need to specify interceptors in the Spring configuration file.
The Spring Security project provides a wide range of options for securing an application. In addition to standard settings for authentication, authorization and distribution of roles and mapping of available pages, links, etc., it provides protection against various types of attacks (for example, CSRF). It has many different settings, but remains easy to use.
+
+
+
+
diff --git a/95 - OpenAI/001 Intro to the OpenAI Section.html b/95 - OpenAI/001 Intro to the OpenAI Section.html
new file mode 100644
index 0000000000000000000000000000000000000000..80a567132a79bf245d029d4881f20a71f8feadba
--- /dev/null
+++ b/95 - OpenAI/001 Intro to the OpenAI Section.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Intro to the OpenAI Section
+
+
+
+
+
+
+
Intro to the OpenAI Section
+
In this course, we are going to develop with you application, written in Java with Spring Boot. This application will use the powerful API of OpenAI to integrate Slack Messenger with Jira and automate project governance.
Also, we are going to learn a lot of other different things and we will include them in our Application.
That’s why, we need to learn and understand the basics of OpenAI, and after that jump to the application implementation.
+
+
+
+
diff --git a/95 - OpenAI/002 GPT-4-models.url b/95 - OpenAI/002 GPT-4-models.url
new file mode 100644
index 0000000000000000000000000000000000000000..ce4770f5270f40a528d919e30dac586ea6d788ac
--- /dev/null
+++ b/95 - OpenAI/002 GPT-4-models.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/models/gpt-4
\ No newline at end of file
diff --git a/95 - OpenAI/002 GPT-4-promo-page.url b/95 - OpenAI/002 GPT-4-promo-page.url
new file mode 100644
index 0000000000000000000000000000000000000000..5bf3ec2cbc25b506283c78d54fa8e2854734a5b2
--- /dev/null
+++ b/95 - OpenAI/002 GPT-4-promo-page.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://openai.com/product/gpt-4
\ No newline at end of file
diff --git a/95 - OpenAI/002 Link-to-the-documentation-with-description-of-Models.url b/95 - OpenAI/002 Link-to-the-documentation-with-description-of-Models.url
new file mode 100644
index 0000000000000000000000000000000000000000..76c9544c57126a106ef35ef258cd4cfa42cbc8a4
--- /dev/null
+++ b/95 - OpenAI/002 Link-to-the-documentation-with-description-of-Models.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/models
\ No newline at end of file
diff --git a/95 - OpenAI/002 OpenAI Basic Concepts_en.srt b/95 - OpenAI/002 OpenAI Basic Concepts_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..c48218636cbd354b9720041db8806c34c61b27cf
--- /dev/null
+++ b/95 - OpenAI/002 OpenAI Basic Concepts_en.srt
@@ -0,0 +1,1236 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello Tim.
+
+2
+00:00:06,000 --> 00:00:13,000
+This is the first lesson about OpenAI API, ChatGPT and other AI tools.
+
+3
+00:00:13,000 --> 00:00:14,000
+Welcome to the course.
+
+4
+00:00:15,000 --> 00:00:19,000
+Taking into account this is our first lesson, it would be theoretical one.
+
+5
+00:00:20,000 --> 00:00:26,000
+In this lesson we are going to learn key terms and concepts that we need to know before we go further
+
+6
+00:00:26,000 --> 00:00:29,000
+and proceed with practical examples.
+
+7
+00:00:29,000 --> 00:00:32,000
+So today we will make some basement.
+
+8
+00:00:32,000 --> 00:00:37,000
+We are going to start from understanding of what OpenAI API is.
+
+9
+00:00:37,000 --> 00:00:40,000
+Then I will explain what ChatGPT is.
+
+10
+00:00:41,000 --> 00:00:49,000
+I bet you already know what OpenAI API and ChatGPT are at least on the high level, but we need to make
+
+11
+00:00:49,000 --> 00:00:53,000
+sure that we make strong basement for our future learning.
+
+12
+00:00:54,000 --> 00:01:02,000
+I will explain such key concepts in OpenAI API as prompt tokens and models and after that I will make
+
+13
+00:01:02,000 --> 00:01:07,000
+an overview of the key OpenAI API models.
+
+14
+00:01:07,000 --> 00:01:13,000
+Again, this will help you to understand the content of the course and how the information is going
+
+15
+00:01:13,000 --> 00:01:15,000
+to be structured.
+
+16
+00:01:15,000 --> 00:01:21,000
+Also, this will give you understanding of different features and goals that you can achieve with products
+
+17
+00:01:21,000 --> 00:01:24,000
+of OpenAI and their models.
+
+18
+00:01:24,000 --> 00:01:27,000
+So we'll review such models.
+
+19
+00:01:27,000 --> 00:01:40,000
+GPT four Model GPT 3.5 Dall-e Whisper embeddings Moderation model GPT three point E Jukebox clip Codex.
+
+20
+00:01:41,000 --> 00:01:44,000
+So we have a lot of things to learn today.
+
+21
+00:01:44,000 --> 00:01:45,000
+Let's start our lesson.
+
+22
+00:01:46,000 --> 00:01:54,000
+Even despite ChatGPT becomes a buzzword nowadays, we need to make things clear because we are going
+
+23
+00:01:54,000 --> 00:01:58,000
+to learn how to use OpenAI API in this course.
+
+24
+00:01:58,000 --> 00:02:03,000
+And GPT is just one of the models developed by OpenAI.
+
+25
+00:02:03,000 --> 00:02:05,000
+But what GPT is.
+
+26
+00:02:05,000 --> 00:02:07,000
+I will explain in a minute.
+
+27
+00:02:07,000 --> 00:02:11,000
+Let me explain you what an open AI API is.
+
+28
+00:02:11,000 --> 00:02:19,000
+Open AI is an artificial intelligence research organization and company that aims to ensure that artificial
+
+29
+00:02:19,000 --> 00:02:23,000
+general intelligence benefits all of humanity.
+
+30
+00:02:23,000 --> 00:02:31,000
+OpenAI conducts research and development in various areas of AI, including natural language processing,
+
+31
+00:02:31,000 --> 00:02:35,000
+computer vision, reinforcement, learning and robotics.
+
+32
+00:02:36,000 --> 00:02:45,000
+The OpenAI API is a programming interface provided by OpenAI that allows developers to access and utilize
+
+33
+00:02:45,000 --> 00:02:50,000
+the capabilities of Openai's language models and other AI services.
+
+34
+00:02:51,000 --> 00:02:59,000
+It enables developers to integrate Openai's advanced AI technologies into their own applications, products
+
+35
+00:02:59,000 --> 00:03:03,000
+or services by utilizing the OpenAI API.
+
+36
+00:03:03,000 --> 00:03:11,000
+Developers can send requests to the API endpoint with specific instructions and receive responses containing
+
+37
+00:03:11,000 --> 00:03:15,000
+generated texts or other relevant information.
+
+38
+00:03:15,000 --> 00:03:23,000
+The API allows customization through parameters like input prompts, output formats and model configurations,
+
+39
+00:03:23,000 --> 00:03:31,000
+enabling developers to fine tune the behavior and output of the models to suit their specific requirements.
+
+40
+00:03:31,000 --> 00:03:36,000
+And now we can answer the question what ChatGPT is.
+
+41
+00:03:37,000 --> 00:03:42,000
+I believe that if you watch this course, then you already have understanding about this tool.
+
+42
+00:03:42,000 --> 00:03:45,000
+Probably you even used it already.
+
+43
+00:03:45,000 --> 00:03:54,000
+Chat bot GPT stands for Generative Pre-trained Transformer is an advanced language model developed by
+
+44
+00:03:54,000 --> 00:03:55,000
+OpenAI.
+
+45
+00:03:55,000 --> 00:04:01,000
+It is designed to generate human like text responses based on the input it receives.
+
+46
+00:04:01,000 --> 00:04:09,000
+GPT models, including ChatGPT, are trained on a massive amount of text data from the internet to learn
+
+47
+00:04:09,000 --> 00:04:12,000
+patterns, language, structure and context.
+
+48
+00:04:12,000 --> 00:04:20,000
+They utilize deep learning techniques, especially transformer architectures, to understand and generate
+
+49
+00:04:20,000 --> 00:04:23,000
+coherent and contextually relevant responses.
+
+50
+00:04:24,000 --> 00:04:32,000
+It can assist with various tasks, including data analysis and generation of new data based on input
+
+51
+00:04:32,000 --> 00:04:33,000
+provided.
+
+52
+00:04:33,000 --> 00:04:38,000
+The model is trained to generate responses that are contextually relevant.
+
+53
+00:04:38,000 --> 00:04:45,000
+But it's important to note is that it doesn't possess real time understanding or awareness.
+
+54
+00:04:46,000 --> 00:04:54,000
+The quality of the response is can vary and the model may sometimes produce incorrect or nonsensical
+
+55
+00:04:54,000 --> 00:04:55,000
+answers.
+
+56
+00:04:55,000 --> 00:05:04,000
+So to sum it up, GPT is just a model developed by OpenAI and we are going to learn how to use ChatGPT
+
+57
+00:05:04,000 --> 00:05:06,000
+and other models.
+
+58
+00:05:06,000 --> 00:05:08,000
+Where OpenAI API.
+
+59
+00:05:08,000 --> 00:05:09,000
+Is it clear?
+
+60
+00:05:10,000 --> 00:05:18,000
+So when I would refer to open AI API in this and following lessons, that also means that I mean work
+
+61
+00:05:18,000 --> 00:05:22,000
+with GPT and other models to.
+
+62
+00:05:23,000 --> 00:05:25,000
+To understand OpenAI API better.
+
+63
+00:05:25,000 --> 00:05:32,000
+Let's understand the key terms and concepts that are used in the OpenAI API.
+
+64
+00:05:32,000 --> 00:05:39,000
+We are going to learn and understand the following concepts from tokens models.
+
+65
+00:05:40,000 --> 00:05:42,000
+Let's learn these one by one.
+
+66
+00:05:43,000 --> 00:05:47,000
+So what is a prompt in the context of ChatGPT?
+
+67
+00:05:47,000 --> 00:05:55,000
+A prompt refers to the initial text or message provided as input to the model to start a conversation
+
+68
+00:05:55,000 --> 00:05:57,000
+or request a specific response.
+
+69
+00:05:57,000 --> 00:06:04,000
+The prompt sets the context and provides guidance to the model about the desired topic or task.
+
+70
+00:06:04,000 --> 00:06:13,000
+When interacting with ChatGPT, you can begin with a prompt that provides some context or asks a question
+
+71
+00:06:13,000 --> 00:06:15,000
+to guide the model's response.
+
+72
+00:06:15,000 --> 00:06:18,000
+For example, if you want to ask about the weather.
+
+73
+00:06:18,000 --> 00:06:23,000
+Your prompt could be something like What is the weather like today?
+
+74
+00:06:24,000 --> 00:06:29,000
+The quality and relevance of the model's response are influenced by the prompt.
+
+75
+00:06:29,000 --> 00:06:37,000
+You provide a well-crafted prompt that clearly expresses your intention can help the model generate
+
+76
+00:06:37,000 --> 00:06:40,000
+more accurate and meaningful responses.
+
+77
+00:06:40,000 --> 00:06:47,000
+However, it's important to note that the model's responses are ultimately based on patterns it has
+
+78
+00:06:47,000 --> 00:06:54,000
+learned from training data and may not always be perfect or entirely contextually accurate.
+
+79
+00:06:54,000 --> 00:07:01,000
+Experimenting with different prompts and refining them can be a useful technique to get desired responses
+
+80
+00:07:01,000 --> 00:07:02,000
+from ChatGPT.
+
+81
+00:07:03,000 --> 00:07:09,000
+It allows you to guide the conversation and obtain more relevant and informative outputs.
+
+82
+00:07:09,000 --> 00:07:17,000
+Another important concept to understand while working with OpenAI API is the concept of tokens.
+
+83
+00:07:17,000 --> 00:07:23,000
+It is important to understand because different models have different limits on tokens they process.
+
+84
+00:07:23,000 --> 00:07:30,000
+Tokens refer to the individual units into which the text is divided for processing by the model.
+
+85
+00:07:30,000 --> 00:07:37,000
+Tokens are primarily used for representing and processing text data in natural language processing models
+
+86
+00:07:37,000 --> 00:07:42,000
+like GPT, Dall-e and other text based models.
+
+87
+00:07:42,000 --> 00:07:49,000
+These tokens can represent words subwords or even characters depending on the specific tokenization
+
+88
+00:07:49,000 --> 00:07:51,000
+scheme used.
+
+89
+00:07:51,000 --> 00:07:57,000
+The text is split into tokens to enable the model to process and understand it.
+
+90
+00:07:58,000 --> 00:08:04,000
+Each token carries meaning and contributes to the overall comprehension of the input.
+
+91
+00:08:05,000 --> 00:08:08,000
+For example, in the sentence I love cats.
+
+92
+00:08:08,000 --> 00:08:10,000
+The tokens could be.
+
+93
+00:08:10,000 --> 00:08:12,000
+I love cats.
+
+94
+00:08:12,000 --> 00:08:13,000
+Three tokens.
+
+95
+00:08:13,000 --> 00:08:18,000
+It's important to note that tokens can have varying lengths.
+
+96
+00:08:18,000 --> 00:08:26,000
+Some tokens may represent a single character, while others may represent entire words or even longer.
+
+97
+00:08:26,000 --> 00:08:27,000
+Subword units.
+
+98
+00:08:27,000 --> 00:08:38,000
+For instance, the word running can be tokenized as run ning or using Subword unit such as run.
+
+99
+00:08:38,000 --> 00:08:47,000
+And like you can see on the slide, the number of tokens in a given text affects the computational requirements
+
+100
+00:08:47,000 --> 00:08:49,000
+and performance of the model.
+
+101
+00:08:49,000 --> 00:08:56,000
+It is also essential to consider token limits and constraints when interacting with ChatGPT to ensure
+
+102
+00:08:56,000 --> 00:09:04,000
+that the input and output remains within the allowed token count for the model you are using.
+
+103
+00:09:04,000 --> 00:09:06,000
+And this is an important thing.
+
+104
+00:09:06,000 --> 00:09:14,000
+Both the input and output tokens count towards the token limit when you send the message or prompt to
+
+105
+00:09:14,000 --> 00:09:23,000
+the ChatGPT model, the tokens in the message account towards the token limit and tokens in the generated
+
+106
+00:09:23,000 --> 00:09:26,000
+response also count towards the limit.
+
+107
+00:09:27,000 --> 00:09:35,000
+For example, if your conversation has already accumulated 3000 tokens and you receive a response from
+
+108
+00:09:35,000 --> 00:09:43,000
+the model that consists of 100 tokens, then the total token count would be 3100 tokens.
+
+109
+00:09:43,000 --> 00:09:51,000
+It's important to consider the token usage of both input and output to ensure that your conversation
+
+110
+00:09:51,000 --> 00:09:56,000
+stays within the token limit and you receive complete responses.
+
+111
+00:09:56,000 --> 00:10:04,000
+Soon we will start learning the details of OpenAI API and when we will start learning them.
+
+112
+00:10:04,000 --> 00:10:07,000
+I'm going to show you how to limit tokens in response.
+
+113
+00:10:08,000 --> 00:10:11,000
+Now let me explain what models are.
+
+114
+00:10:11,000 --> 00:10:18,000
+Models are mathematical representations or systems that can learn from data and make predictions or
+
+115
+00:10:18,000 --> 00:10:19,000
+decisions.
+
+116
+00:10:19,000 --> 00:10:24,000
+They are designed to mimic the way humans learn and solve problems.
+
+117
+00:10:24,000 --> 00:10:29,000
+Imagine you want to teach a computer how to identify different types of fruits.
+
+118
+00:10:29,000 --> 00:10:37,000
+You would start by showing it various examples of fruits and telling it what each one is.
+
+119
+00:10:37,000 --> 00:10:44,000
+The computer then tries to identify patterns and features in the examples to learn what distinguishes
+
+120
+00:10:44,000 --> 00:10:46,000
+one fruit from another.
+
+121
+00:10:46,000 --> 00:10:54,000
+It might learn that apples are usually round and red or green, while bananas are long and yellow.
+
+122
+00:10:54,000 --> 00:11:02,000
+Once the computer has learned from these examples, it can use that knowledge to identify new fruits
+
+123
+00:11:02,000 --> 00:11:04,000
+it has never seen before.
+
+124
+00:11:04,000 --> 00:11:11,000
+You can give it an image of an unknown fruit, and the model will make a prediction based on the patterns
+
+125
+00:11:12,000 --> 00:11:13,000
+it has learned.
+
+126
+00:11:14,000 --> 00:11:19,000
+It might say, I think this is an apple because it is round and red.
+
+127
+00:11:20,000 --> 00:11:27,000
+Models can be applied to various tasks such as image recognition, language translation, speech recognition
+
+128
+00:11:27,000 --> 00:11:29,000
+and more.
+
+129
+00:11:29,000 --> 00:11:35,000
+They are built using mathematical algorithms and trained on large data sets to improve their accuracy
+
+130
+00:11:35,000 --> 00:11:37,000
+and performance.
+
+131
+00:11:37,000 --> 00:11:44,000
+The goal is to create models that can generalize from the examples they have seen and make accurate
+
+132
+00:11:44,000 --> 00:11:49,000
+predictions or decisions on new unseen data.
+
+133
+00:11:49,000 --> 00:11:53,000
+So OpenAI presents different models.
+
+134
+00:11:53,000 --> 00:11:59,000
+This course that you are watching will be constantly updated and most likely that by the moment you
+
+135
+00:11:59,000 --> 00:12:03,000
+watch this lesson, the new model is developed and released.
+
+136
+00:12:03,000 --> 00:12:09,000
+This is because the development process is dynamic and industry is evolving with fast pace.
+
+137
+00:12:09,000 --> 00:12:17,000
+I will record new video lessons about new models and updates, but please always verify the latest information
+
+138
+00:12:17,000 --> 00:12:19,000
+on official documentation.
+
+139
+00:12:19,000 --> 00:12:26,000
+For example, there is even a separate page dedicated to review of the models in attachments to the
+
+140
+00:12:26,000 --> 00:12:26,000
+video.
+
+141
+00:12:26,000 --> 00:12:29,000
+You can find the link to the documentation.
+
+142
+00:12:29,000 --> 00:12:35,000
+But anyway, let me make an overview of the models that are available based on today.
+
+143
+00:12:35,000 --> 00:12:40,000
+This will help you to understand the context naming patterns.
+
+144
+00:12:41,000 --> 00:12:45,000
+So there are following models for GPT.
+
+145
+00:12:45,000 --> 00:12:54,000
+3.5 Dall-e Whisper embeddings moderation GPT three point E Jukebox Clip codecs.
+
+146
+00:12:55,000 --> 00:12:59,000
+Let me make a brief overview of each of these models.
+
+147
+00:13:00,000 --> 00:13:02,000
+Let me start with GPT four.
+
+148
+00:13:03,000 --> 00:13:12,000
+This GPT four model is a powerful multimodal model designed to handle a variety of inputs, including
+
+149
+00:13:12,000 --> 00:13:14,000
+text and images.
+
+150
+00:13:14,000 --> 00:13:22,000
+It exhibits remarkable accuracy in solving complex problems, surpassing the capabilities of previous
+
+151
+00:13:22,000 --> 00:13:23,000
+models.
+
+152
+00:13:24,000 --> 00:13:32,000
+With its extensive general knowledge and advanced reasoning abilities, GPT four is adept at both chat
+
+153
+00:13:32,000 --> 00:13:36,000
+based interactions and traditional completion tasks.
+
+154
+00:13:36,000 --> 00:13:44,000
+It is optimized for chat applications and can be utilized effectively through the chat completions API.
+
+155
+00:13:45,000 --> 00:13:48,000
+On the screen you can see the page of the GPT four.
+
+156
+00:13:48,000 --> 00:13:55,000
+You can find links and attachments and watch the same examples, but just take a look how cool it is.
+
+157
+00:13:55,000 --> 00:14:02,000
+You ask the GPT four what you can cook with such ingredients and it provides you with an options what
+
+158
+00:14:02,000 --> 00:14:03,000
+you can cook.
+
+159
+00:14:04,000 --> 00:14:07,000
+As you already know, each model used training data.
+
+160
+00:14:07,000 --> 00:14:13,000
+There are always different versions of the model that are different in the algorithm's training data
+
+161
+00:14:13,000 --> 00:14:18,000
+set used for training, the model and limits on the screen.
+
+162
+00:14:18,000 --> 00:14:23,000
+You can see example of the GPT four models based on today.
+
+163
+00:14:23,000 --> 00:14:30,000
+But as I said, this field is evolved dynamically and most likely new versions will be released soon.
+
+164
+00:14:30,000 --> 00:14:33,000
+So just check the documentation.
+
+165
+00:14:33,000 --> 00:14:38,000
+You will find the link to the GPT four in attachments to the video.
+
+166
+00:14:38,000 --> 00:14:46,000
+So on the screen you can see max tokens per request limit and the freshness of training data.
+
+167
+00:14:47,000 --> 00:14:51,000
+Let me review the key points about GPT 3.5 with you now.
+
+168
+00:14:51,000 --> 00:15:01,000
+GPT 3.5 is optimized for chat based interactions, making it well suited for applications like conversational
+
+169
+00:15:01,000 --> 00:15:05,000
+agents, chat bots and virtual assistants.
+
+170
+00:15:05,000 --> 00:15:13,000
+It can provide detailed responses, answer questions, offer suggestions, and engage in natural and
+
+171
+00:15:13,000 --> 00:15:15,000
+coherent conversations.
+
+172
+00:15:15,000 --> 00:15:24,000
+With its large scale pre-training on diverse text data, GPT 3.5 possesses a broad understanding of
+
+173
+00:15:24,000 --> 00:15:26,000
+various topics and domains.
+
+174
+00:15:26,000 --> 00:15:32,000
+It leverages this knowledge to generate high quality, contextually appropriate responses.
+
+175
+00:15:32,000 --> 00:15:40,000
+You can see that the different models of GPT 3.5 version, but OpenAI in their documentation recommend
+
+176
+00:15:40,000 --> 00:15:46,000
+using GPT 3.5 to go over other GPT 3.5 models.
+
+177
+00:15:47,000 --> 00:15:49,000
+Few words about the Lee model.
+
+178
+00:15:49,000 --> 00:15:56,000
+The Lee is an advanced AI system that utilizes natural language descriptions to generate realistic images
+
+179
+00:15:56,000 --> 00:15:58,000
+and artwork.
+
+180
+00:15:58,000 --> 00:16:05,000
+With the Lee, you can provide a textual prompt and witness the creation of new images in the specific
+
+181
+00:16:05,000 --> 00:16:12,000
+sizes, make edits to the existing images, or explore variations based on user provided images.
+
+182
+00:16:13,000 --> 00:16:20,000
+The Lee works by training on a large dataset containing pairs of images and their corresponding textual
+
+183
+00:16:20,000 --> 00:16:21,000
+descriptions.
+
+184
+00:16:21,000 --> 00:16:29,000
+It learns to understand the relationships between text and images and can generate new image based on
+
+185
+00:16:29,000 --> 00:16:32,000
+textual prompts that it hasn't seen during the training.
+
+186
+00:16:33,000 --> 00:16:37,000
+Anyway, this will not be a lesson about the Lee model itself.
+
+187
+00:16:37,000 --> 00:16:43,000
+I'm just making an overview of models in this lesson and in the separate lessons in the course.
+
+188
+00:16:43,000 --> 00:16:46,000
+We are going to learn how to interact with the model.
+
+189
+00:16:47,000 --> 00:16:49,000
+The next model is whisper.
+
+190
+00:16:50,000 --> 00:16:54,000
+Whisper is a model designed for speech recognition tasks.
+
+191
+00:16:54,000 --> 00:17:02,000
+It has been trained on a vast and diverse audio dataset, enabling it to excel in multilingual speech
+
+192
+00:17:02,000 --> 00:17:07,000
+recognition, speech translation and language identification.
+
+193
+00:17:07,000 --> 00:17:10,000
+Model was trained on 98 languages.
+
+194
+00:17:10,000 --> 00:17:19,000
+The APIs that use Whisper model can transcribe audio into whatever language the audio is in, translate
+
+195
+00:17:19,000 --> 00:17:26,000
+and transcribe the audio into English potential use case and example of Whisper model.
+
+196
+00:17:26,000 --> 00:17:33,000
+Suppose you have a video clip in a foreign language and you want to provide subtitles or translate the
+
+197
+00:17:33,000 --> 00:17:35,000
+spoken words into a different language.
+
+198
+00:17:35,000 --> 00:17:39,000
+You can employ the whisper model for speech translation.
+
+199
+00:17:39,000 --> 00:17:47,000
+It takes the audio input, recognizes the spoken language, and then translates it into the desired
+
+200
+00:17:47,000 --> 00:17:48,000
+target language.
+
+201
+00:17:49,000 --> 00:17:56,000
+This allows you to provide multilingual subtitles or enable language translation capabilities in various
+
+202
+00:17:56,000 --> 00:17:57,000
+applications.
+
+203
+00:17:57,000 --> 00:18:01,000
+Let me explain now what embeddings are.
+
+204
+00:18:01,000 --> 00:18:08,000
+Embeddings are numerical representation of text that can be used to measure the similarity between two
+
+205
+00:18:08,000 --> 00:18:09,000
+pieces of text.
+
+206
+00:18:10,000 --> 00:18:13,000
+Let's take an example to understand embeddings better.
+
+207
+00:18:14,000 --> 00:18:18,000
+Imagine we have a set of words such as dog, cat and mouse.
+
+208
+00:18:18,000 --> 00:18:26,000
+We can represent each word as a vector in a multi-dimensional space where each dimension represents
+
+209
+00:18:26,000 --> 00:18:29,000
+a certain aspect of feature of the work.
+
+210
+00:18:29,000 --> 00:18:36,000
+For instance, one dimension could represent the animal's size and another could represent its color
+
+211
+00:18:36,000 --> 00:18:37,000
+and so on.
+
+212
+00:18:37,000 --> 00:18:44,000
+The interesting thing about embeddings is that similar words or words with similar meanings are represented
+
+213
+00:18:44,000 --> 00:18:49,000
+by vectors that are closer to each other in the high dimensional space.
+
+214
+00:18:50,000 --> 00:18:57,000
+For example, the vectors representing dog and cat would be closer together than vector representing
+
+215
+00:18:57,000 --> 00:19:04,000
+dog and mouse because dogs and cats are more similar to each other in terms of their characteristics
+
+216
+00:19:04,000 --> 00:19:07,000
+compared to dogs and mice.
+
+217
+00:19:07,000 --> 00:19:14,000
+Embeddings enable machines to understand and work with text more effectively because they provide a
+
+218
+00:19:14,000 --> 00:19:20,000
+numerical representation of words that captures the semantic relationships.
+
+219
+00:19:20,000 --> 00:19:27,000
+This makes it easier for machine learning models to perform tasks like language translation, sentiment
+
+220
+00:19:27,000 --> 00:19:31,000
+analysis or even word similarity comparisons.
+
+221
+00:19:32,000 --> 00:19:34,000
+Let's talk about moderation models.
+
+222
+00:19:34,000 --> 00:19:42,000
+The moderation models serve the purpose of evaluating content to ensure its compliance with open eyes
+
+223
+00:19:42,000 --> 00:19:43,000
+usage policies.
+
+224
+00:19:43,000 --> 00:19:50,000
+These models are equipped with classification abilities to identify various categories of content,
+
+225
+00:19:50,000 --> 00:19:58,000
+including hate speech, threatening language, self-harm, sexual content, content involving minors,
+
+226
+00:19:58,000 --> 00:20:01,000
+violence and graphic violence.
+
+227
+00:20:01,000 --> 00:20:05,000
+For more detailed information, you can refer to our Moderation guide.
+
+228
+00:20:06,000 --> 00:20:13,000
+When using the moderation models, you can input text of any length and the models automatically handle
+
+229
+00:20:13,000 --> 00:20:17,000
+breaking it down to fit within their specific context window.
+
+230
+00:20:17,000 --> 00:20:25,000
+This allows the models to effectively analyze and assess the content provided regardless of its size.
+
+231
+00:20:26,000 --> 00:20:30,000
+For example, imagine a social media platform where users can post comments.
+
+232
+00:20:31,000 --> 00:20:39,000
+The moderation system automatically scans these comments and flags any that contain hate speech threats
+
+233
+00:20:39,000 --> 00:20:41,000
+or explicit content.
+
+234
+00:20:41,000 --> 00:20:48,000
+The flagged comments are then reviewed by human moderators who decide whether to remove them or take
+
+235
+00:20:48,000 --> 00:20:49,000
+appropriate action.
+
+236
+00:20:50,000 --> 00:20:55,000
+Another example is an online forum where users can discuss various topics.
+
+237
+00:20:55,000 --> 00:21:03,000
+The Moderation Team oversees the forum and ensures the discussions remain civil and respectful.
+
+238
+00:21:03,000 --> 00:21:10,000
+They remove any posts that contain personal attacks, harassment or violate the forum's guidelines.
+
+239
+00:21:10,000 --> 00:21:16,000
+In both cases, moderation helps prevent harmful or inappropriate content from spreading.
+
+240
+00:21:16,000 --> 00:21:23,000
+Protects users from harassment or abuse and fosters a positive and inclusive community.
+
+241
+00:21:24,000 --> 00:21:26,000
+Let's now talk about GPT three.
+
+242
+00:21:26,000 --> 00:21:30,000
+Most likely you are wondering what is the sense of talking about GPT?
+
+243
+00:21:30,000 --> 00:21:41,000
+Three If the GPT 3.5 and GPT four the original GPT three base models, namely Da Vinci Courier ADA and
+
+244
+00:21:41,000 --> 00:21:47,000
+Babbage, were replaced by the more advanced GPT 3.5 generation models.
+
+245
+00:21:48,000 --> 00:21:56,000
+While the 3.5 models offer increased power and capabilities, it's important to note that only the original
+
+246
+00:21:56,000 --> 00:22:00,000
+GPT three based models are currently available for fine tuning.
+
+247
+00:22:00,000 --> 00:22:06,000
+This means that developers have the option to further refine and customize the performance of these
+
+248
+00:22:06,000 --> 00:22:10,000
+base models to suit specific tasks and requirements.
+
+249
+00:22:11,000 --> 00:22:16,000
+On the screen you can see name of different models, limits and training data used.
+
+250
+00:22:17,000 --> 00:22:20,000
+What fine tuning is and how to fine tune models.
+
+251
+00:22:20,000 --> 00:22:23,000
+We are going to learn in separate lesson.
+
+252
+00:22:24,000 --> 00:22:25,000
+Point E.
+
+253
+00:22:25,000 --> 00:22:33,000
+Point E is a powerful and versatile language model that excels in natural language, understanding and
+
+254
+00:22:33,000 --> 00:22:33,000
+generation.
+
+255
+00:22:34,000 --> 00:22:41,000
+It can comprehend complex text input and generate coherent and contextually relevant responses.
+
+256
+00:22:41,000 --> 00:22:44,000
+How it is different from GPT 3.5 model.
+
+257
+00:22:44,000 --> 00:22:45,000
+For example.
+
+258
+00:22:45,000 --> 00:22:53,000
+GPT 3.5 is a general purpose language model suitable for various language tasks, including chat based
+
+259
+00:22:53,000 --> 00:23:00,000
+interactions, while Point E is a more focused model optimized for accurate information, extraction
+
+260
+00:23:00,000 --> 00:23:01,000
+and question answering.
+
+261
+00:23:02,000 --> 00:23:08,000
+It is interesting to know and explore point because OpenAI published its source code.
+
+262
+00:23:09,000 --> 00:23:12,000
+The next interesting model is a jukebox.
+
+263
+00:23:12,000 --> 00:23:18,000
+Jukebox is an impressive model that has been trained on a vast music dataset.
+
+264
+00:23:18,000 --> 00:23:25,000
+It can compose original music in different genres and styles and even mimic the musical characteristics
+
+265
+00:23:25,000 --> 00:23:27,000
+of special artists.
+
+266
+00:23:27,000 --> 00:23:34,000
+Jukebox opens up new possibilities for generating music with creative and unique compositions.
+
+267
+00:23:34,000 --> 00:23:37,000
+Source code is also provided at the GitHub.
+
+268
+00:23:38,000 --> 00:23:47,000
+Clip clip stands for contrastive Language Image Pre-training is a groundbreaking model that combines
+
+269
+00:23:47,000 --> 00:23:49,000
+language and vision.
+
+270
+00:23:49,000 --> 00:23:56,000
+It has been trained to understand both images and their accompanying textual descriptions, enabling
+
+271
+00:23:56,000 --> 00:24:04,000
+it to perform tasks such as image classification, generation of textual descriptions for images, and
+
+272
+00:24:04,000 --> 00:24:09,000
+even finding visually similar images based on text prompts.
+
+273
+00:24:09,000 --> 00:24:16,000
+Clip's Ability to bridge the gap between language and vision opens up existing possibilities in the
+
+274
+00:24:16,000 --> 00:24:19,000
+field of multimodal AI.
+
+275
+00:24:20,000 --> 00:24:21,000
+Codex.
+
+276
+00:24:21,000 --> 00:24:28,000
+Codex models developed by OpenAI are a set of models specifically designed to understand and generate
+
+277
+00:24:28,000 --> 00:24:29,000
+code.
+
+278
+00:24:29,000 --> 00:24:36,000
+These models are trained on a vast amount of code from various programming languages and can assist
+
+279
+00:24:36,000 --> 00:24:42,000
+developers in writing code by translating natural language prompts into code snippets.
+
+280
+00:24:42,000 --> 00:24:50,000
+Codex models developed by OpenAI are a set of models specifically designed to understand and generate
+
+281
+00:24:50,000 --> 00:24:51,000
+code.
+
+282
+00:24:51,000 --> 00:24:57,000
+These models are trained on a vast amount of code from various programming languages and can assist
+
+283
+00:24:57,000 --> 00:25:05,000
+developers in writing code by translating natural language prompts into code snippets.
+
+284
+00:25:05,000 --> 00:25:13,000
+Codex models have the ability to provide intelligent code completions, generate code from user instructions
+
+285
+00:25:13,000 --> 00:25:16,000
+and assist with code related tasks.
+
+286
+00:25:16,000 --> 00:25:22,000
+They leverage the power of deep learning and natural language processing techniques to understand the
+
+287
+00:25:22,000 --> 00:25:30,000
+context and intent behind code related queries and produce relevant code outputs.
+
+288
+00:25:30,000 --> 00:25:38,000
+However, it's important to note that Codex models have been deprecated by OpenAI, which means they
+
+289
+00:25:38,000 --> 00:25:41,000
+are no longer actively supported or recommended for use.
+
+290
+00:25:41,000 --> 00:25:50,000
+OpenAI has transitioned to newer models like GPT 3.5, which offer enhanced capabilities in natural
+
+291
+00:25:50,000 --> 00:25:54,000
+language understanding and code generation.
+
+292
+00:25:54,000 --> 00:26:01,000
+By the way, during this course, we are going to write the applications for ChatGPT with the ChatGPT,
+
+293
+00:26:01,000 --> 00:26:08,000
+and I'm going to show you how code generation works and we will evaluate together whether we can rely
+
+294
+00:26:08,000 --> 00:26:11,000
+on it and whether it can be useful.
+
+295
+00:26:12,000 --> 00:26:16,000
+So basically, that's all what I wanted to share with you in this lesson.
+
+296
+00:26:16,000 --> 00:26:22,000
+We still have a lot of other things to learn, but the main thing on this stage is to build a good basement
+
+297
+00:26:22,000 --> 00:26:23,000
+for our future learning.
+
+298
+00:26:24,000 --> 00:26:26,000
+So we are on the right way.
+
+299
+00:26:26,000 --> 00:26:31,000
+Let's recap what we have learned in this lesson.
+
+300
+00:26:31,000 --> 00:26:35,000
+Today we learned what OpenAI API is also.
+
+301
+00:26:35,000 --> 00:26:42,000
+Now you know that ChatGPT is a model and we plan to interact with it and other models.
+
+302
+00:26:42,000 --> 00:26:49,000
+We are open AI API, we learn the key terms and concepts that are used in OpenAI API.
+
+303
+00:26:49,000 --> 00:26:57,000
+We learned what prompt is tokens and models and during the lesson we reviewed different models that
+
+304
+00:26:57,000 --> 00:27:01,000
+can help us with leveraging different features of OpenAI API.
+
+305
+00:27:02,000 --> 00:27:11,000
+Namely, we learned the following models GPT four Model GPT 3.5 Model Dali Whisper embeddings Moderation
+
+306
+00:27:11,000 --> 00:27:17,000
+GPT three Model Point Jukebox Clip Codex.
+
+307
+00:27:17,000 --> 00:27:19,000
+That's all for today.
+
+308
+00:27:19,000 --> 00:27:20,000
+Thanks a lot for your attention.
+
+309
+00:27:20,000 --> 00:27:23,000
+Have a great day and see you in the next lesson.
+
diff --git a/95 - OpenAI/003 OpenAI API Create & Manage Personal Account_en.srt b/95 - OpenAI/003 OpenAI API Create & Manage Personal Account_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..a0f082509c50a184f6244b8f6db374198d38311e
--- /dev/null
+++ b/95 - OpenAI/003 OpenAI API Create & Manage Personal Account_en.srt
@@ -0,0 +1,1312 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:13,000
+In this video we are going to configure our environment in order to start work with OpenAI API and we
+
+3
+00:00:13,000 --> 00:00:17,000
+will start learning the key things about OpenAI API.
+
+4
+00:00:17,000 --> 00:00:22,000
+We're going to start this lesson from the creation of account at OpenAI.
+
+5
+00:00:22,000 --> 00:00:29,000
+Today we're going to have a lot of live demo in order to prepare our environment for the next lessons.
+
+6
+00:00:29,000 --> 00:00:37,000
+I'm going to make an overview of API reference and documentation because technology evolves super fast
+
+7
+00:00:37,000 --> 00:00:43,000
+and my goal is to teach you how you can learn new things and work with documentation tool.
+
+8
+00:00:44,000 --> 00:00:47,000
+We'll review such tool as Playground.
+
+9
+00:00:47,000 --> 00:00:54,000
+Then we are going to review account settings, including usage limits and other configurations.
+
+10
+00:00:54,000 --> 00:00:55,000
+I will explain you.
+
+11
+00:00:55,000 --> 00:00:57,000
+Pricing model of OpenAI.
+
+12
+00:00:58,000 --> 00:01:05,000
+This is really important to understand in case you are going to work with OpenAI closely, you need
+
+13
+00:01:05,000 --> 00:01:12,000
+to understand related costs of interaction with OpenAI and design your application wisely.
+
+14
+00:01:12,000 --> 00:01:18,000
+We'll discuss such billing related terminology as soft and hard billing limits.
+
+15
+00:01:18,000 --> 00:01:25,000
+Another important thing to understand while planning and designing your application is rate limits that
+
+16
+00:01:25,000 --> 00:01:27,000
+we as developers should respect.
+
+17
+00:01:28,000 --> 00:01:35,000
+I will explain what RPM and TPM are also during the lesson, we will create API secret keys that we
+
+18
+00:01:35,000 --> 00:01:40,000
+are going to use in our following lessons to interact with OpenAI API.
+
+19
+00:01:40,000 --> 00:01:45,000
+I will explain what is model fine tuning is in order.
+
+20
+00:01:45,000 --> 00:01:51,000
+You can understand this topic better and at the end of the lesson I'm going to show you Service Status
+
+21
+00:01:51,000 --> 00:01:54,000
+page, which you should be aware of as a developer.
+
+22
+00:01:55,000 --> 00:01:56,000
+Let's start our lesson.
+
+23
+00:01:57,000 --> 00:02:00,000
+Let me start screen sharing and hold the demo.
+
+24
+00:02:00,000 --> 00:02:05,000
+It would be easier for you to understand the topic by repeating after me.
+
+25
+00:02:05,000 --> 00:02:14,000
+So the first thing that you need to do is to create an account on the OpenAI you need to visit openai.com.
+
+26
+00:02:14,000 --> 00:02:17,000
+And in the top right corner there is a signup button.
+
+27
+00:02:18,000 --> 00:02:19,000
+Click it.
+
+28
+00:02:19,000 --> 00:02:21,000
+This is relatively simple.
+
+29
+00:02:21,000 --> 00:02:29,000
+You can use was a Google account or Microsoft or Apple account to create OpenAI account first.
+
+30
+00:02:30,000 --> 00:02:37,000
+Taking into account I already have account registered, I just use login button instead.
+
+31
+00:02:37,000 --> 00:02:38,000
+Sign up.
+
+32
+00:02:39,000 --> 00:02:45,000
+So once you create account you will be navigated to select application.
+
+33
+00:02:45,000 --> 00:02:51,000
+You would need to select either ChatGPT application or the Li from the previous lesson.
+
+34
+00:02:51,000 --> 00:02:59,000
+We already know what this model is about, but just to remind you, this is the model for images generation.
+
+35
+00:03:00,000 --> 00:03:04,000
+If you skip previous lesson, please come back and watch it.
+
+36
+00:03:04,000 --> 00:03:05,000
+It is important.
+
+37
+00:03:05,000 --> 00:03:06,000
+And API.
+
+38
+00:03:07,000 --> 00:03:12,000
+We're interested in API, so let's select the API.
+
+39
+00:03:13,000 --> 00:03:16,000
+So let's look at what do we have here?
+
+40
+00:03:16,000 --> 00:03:21,000
+You can select GPT and get navigated to the guide about chat GPT.
+
+41
+00:03:22,000 --> 00:03:24,000
+You can learn GPT best practices.
+
+42
+00:03:25,000 --> 00:03:30,000
+We will make an overview of the GPT best practices a little bit later during the course.
+
+43
+00:03:30,000 --> 00:03:34,000
+You can be navigated to the guide about embeddings.
+
+44
+00:03:34,000 --> 00:03:37,000
+In the previous lesson we already learned what embeddings are.
+
+45
+00:03:37,000 --> 00:03:40,000
+So I will not stop on this too much.
+
+46
+00:03:40,000 --> 00:03:48,000
+Also, few hyper references to the guides about speech, to text and image generation and also reference
+
+47
+00:03:48,000 --> 00:03:50,000
+to the guide about fine tuning.
+
+48
+00:03:50,000 --> 00:03:56,000
+I believe that from previous lessons you remember that we can fine tune existing models to make them
+
+49
+00:03:56,000 --> 00:03:58,000
+satisfy our business needs.
+
+50
+00:03:59,000 --> 00:04:04,000
+Also you can find here tutorial and examples of chat plugins.
+
+51
+00:04:04,000 --> 00:04:10,000
+I believe that you don't need me to read out loud something what you can read on your own.
+
+52
+00:04:10,000 --> 00:04:17,000
+Instead, I will continue an overview of what else do we have here and we will focus and practice.
+
+53
+00:04:18,000 --> 00:04:20,000
+Also pay attention to the top navigation menu.
+
+54
+00:04:21,000 --> 00:04:24,000
+We are currently at overview section.
+
+55
+00:04:24,000 --> 00:04:32,000
+There is also documentation section that I used during the previous lesson and here is an API reference.
+
+56
+00:04:32,000 --> 00:04:39,000
+I believe that in some degree it is even more useful than guides, and I will explain you why.
+
+57
+00:04:39,000 --> 00:04:47,000
+Because guides contain examples with already written libraries and doesn't give you so deep understanding
+
+58
+00:04:47,000 --> 00:04:50,000
+about how API actually works.
+
+59
+00:04:50,000 --> 00:04:54,000
+This API reference is something what is closer to developers.
+
+60
+00:04:54,000 --> 00:05:02,000
+So my advice to you in case you just start observing the API and you want to find some more details,
+
+61
+00:05:02,000 --> 00:05:09,000
+you can start with the guide as it contains more marketing style description of the possibilities and
+
+62
+00:05:09,000 --> 00:05:18,000
+features and then jump to the API reference to get more details and have deeper insights on the API.
+
+63
+00:05:18,000 --> 00:05:26,000
+Definitely during the video lesson we will not be able to learn all of the API and check all the details,
+
+64
+00:05:26,000 --> 00:05:34,000
+but still that is something what we are going to do during the course, working with the API and exploring
+
+65
+00:05:34,000 --> 00:05:35,000
+the documentation.
+
+66
+00:05:36,000 --> 00:05:42,000
+So we'll use details from the official documentation and we'll create our application.
+
+67
+00:05:43,000 --> 00:05:50,000
+But the port of my responsibility is not just teach you one thing, but teach you how you can learn
+
+68
+00:05:50,000 --> 00:05:56,000
+new things and continue your education because new things are released fast.
+
+69
+00:05:56,000 --> 00:06:03,000
+And you should always verify latest updates in the API reference and documentation.
+
+70
+00:06:04,000 --> 00:06:10,000
+In this video lesson we are going to learn ground principles and specific examples of how to create
+
+71
+00:06:10,000 --> 00:06:12,000
+our application with the API.
+
+72
+00:06:12,000 --> 00:06:19,000
+You can see on the left that API reference covers all the essential parts of the interaction with the
+
+73
+00:06:19,000 --> 00:06:27,000
+OpenAI API, including making requests, work with completion API and all other things.
+
+74
+00:06:27,000 --> 00:06:31,000
+We will go over this gradually one after another.
+
+75
+00:06:31,000 --> 00:06:37,000
+You can also refer to the examples section and check through the existing examples.
+
+76
+00:06:37,000 --> 00:06:44,000
+You can even open an example and get navigated to the playground in order to check the example.
+
+77
+00:06:44,000 --> 00:06:51,000
+By the way, you can be navigated to the playground either from the examples section or from the top
+
+78
+00:06:51,000 --> 00:06:53,000
+navigation menu.
+
+79
+00:06:53,000 --> 00:07:00,000
+This is the playground for the generative text models that were released prior to ChatGPT model.
+
+80
+00:07:00,000 --> 00:07:10,000
+Like Vinci Courier, Babar Ada OpenAI regularly updates its models and offerings, so the availability
+
+81
+00:07:10,000 --> 00:07:15,000
+and features of models in the playground may be changed so far.
+
+82
+00:07:15,000 --> 00:07:22,000
+If you want to test chat GPT model, you can click here and the chat application will be opened.
+
+83
+00:07:22,000 --> 00:07:28,000
+But still, you may want to see examples of The Vinci created by Bosch, other models.
+
+84
+00:07:28,000 --> 00:07:31,000
+And you can do it in the playground.
+
+85
+00:07:32,000 --> 00:07:35,000
+Now let me make an overview of the account.
+
+86
+00:07:36,000 --> 00:07:42,000
+So when you click on your icon in the top right corner, there is a drop down menu.
+
+87
+00:07:42,000 --> 00:07:45,000
+Let me select manage account option.
+
+88
+00:07:45,000 --> 00:07:46,000
+And here we are.
+
+89
+00:07:47,000 --> 00:07:49,000
+Here is our organization settings page.
+
+90
+00:07:50,000 --> 00:07:55,000
+Here on this page, you can change the name of your organization.
+
+91
+00:07:55,000 --> 00:08:03,000
+For some configurations you might need organization, ID, and now you know where you can get it.
+
+92
+00:08:03,000 --> 00:08:07,000
+Usage contains information about usage of the API.
+
+93
+00:08:07,000 --> 00:08:16,000
+For example, let me select May 18th, just as an example, and you can see here is a breakdown of my
+
+94
+00:08:16,000 --> 00:08:17,000
+requests.
+
+95
+00:08:17,000 --> 00:08:25,000
+It specifies the model I used amount of tokens and why it is important because according to the pricing
+
+96
+00:08:25,000 --> 00:08:33,000
+model of OpenAI, you pay for each API call and how much you pay depends on the amount of tokens.
+
+97
+00:08:34,000 --> 00:08:38,000
+We learned what tokens are in the previous lesson.
+
+98
+00:08:38,000 --> 00:08:39,000
+That is important.
+
+99
+00:08:40,000 --> 00:08:44,000
+Now it is a good time to learn OpenAI pricing model.
+
+100
+00:08:45,000 --> 00:08:51,000
+It is important to say that after the registration you receive coupons for free usage.
+
+101
+00:08:51,000 --> 00:08:57,000
+The rules may change, but the most relevant offer based on the day allows you to start experimenting
+
+102
+00:08:57,000 --> 00:09:04,000
+with $5 in free credit that can be used during your first three months.
+
+103
+00:09:04,000 --> 00:09:06,000
+This is given to you in order.
+
+104
+00:09:06,000 --> 00:09:10,000
+You can test the API and learn how to work with it.
+
+105
+00:09:11,000 --> 00:09:19,000
+After that time, you would need to create the billing profile and you will be charged from your card
+
+106
+00:09:19,000 --> 00:09:20,000
+for the services provided.
+
+107
+00:09:21,000 --> 00:09:27,000
+So as you can see, even after registration API calls are not free.
+
+108
+00:09:27,000 --> 00:09:32,000
+You are just granted with a coupon that has its limit.
+
+109
+00:09:32,000 --> 00:09:39,000
+And that's why during the planning of your business model, in case you have an idea for a startup or
+
+110
+00:09:39,000 --> 00:09:46,000
+application, or in case you plan to work with the API in some other way, you need to be aware about
+
+111
+00:09:46,000 --> 00:09:47,000
+pricing.
+
+112
+00:09:48,000 --> 00:09:53,000
+There is a separate page and I'm going to add the reference to the attachments of the lesson.
+
+113
+00:09:54,000 --> 00:10:00,000
+And on this page, OpenAI keeps up to date information about pricing.
+
+114
+00:10:00,000 --> 00:10:08,000
+On the main page, you can see that OpenAI uses pay as you go principle, which means that you pay only
+
+115
+00:10:08,000 --> 00:10:11,000
+for the amount you actually used.
+
+116
+00:10:11,000 --> 00:10:13,000
+No fixed charges.
+
+117
+00:10:14,000 --> 00:10:18,000
+You can see that there is different pricing for different models.
+
+118
+00:10:18,000 --> 00:10:22,000
+Let's compare tax models, for example.
+
+119
+00:10:22,000 --> 00:10:31,000
+Based on the data, we can see that GPT four is more expensive than GPT, 3.5 Turbo and GPT four.
+
+120
+00:10:31,000 --> 00:10:35,000
+You can see the following criteria prompt and completion.
+
+121
+00:10:35,000 --> 00:10:37,000
+What is the difference?
+
+122
+00:10:37,000 --> 00:10:42,000
+Prompt tokens are the parts of words fed into GPT four.
+
+123
+00:10:43,000 --> 00:10:52,000
+While completion tokens as a content generated by GPT for the context alone with prompt and any generated
+
+124
+00:10:52,000 --> 00:11:00,000
+completions must fit within the maximum token limit to ensure successful API requests.
+
+125
+00:11:00,000 --> 00:11:04,000
+This maximum token limit is different for different models.
+
+126
+00:11:04,000 --> 00:11:14,000
+We are going to learn these limitations so there are different models, 8-K tokens and 32 K tokens.
+
+127
+00:11:15,000 --> 00:11:18,000
+This is related to maximum token limit.
+
+128
+00:11:19,000 --> 00:11:30,000
+So in eight K tokens, the maximum token limit is 8000 tokens, and in 32 K tokens model, the maximum
+
+129
+00:11:30,000 --> 00:11:33,000
+limit is 32,000 tokens.
+
+130
+00:11:33,000 --> 00:11:36,000
+What tokens are we learned in previous lesson?
+
+131
+00:11:36,000 --> 00:11:43,000
+So I wouldn't stop on this, but let's understand why the context is important.
+
+132
+00:11:44,000 --> 00:11:45,000
+In different text models.
+
+133
+00:11:45,000 --> 00:11:51,000
+In the API description, you are going to find such attributes as context lengths.
+
+134
+00:11:51,000 --> 00:11:54,000
+What does it mean and why it is important?
+
+135
+00:11:55,000 --> 00:12:01,000
+Basically this is an input provided to the model during the text generation process.
+
+136
+00:12:01,000 --> 00:12:08,000
+The context consists of the text or tokens that precede the desired output.
+
+137
+00:12:09,000 --> 00:12:16,000
+It helps the model understand the context and generate more relevant and coherent responses.
+
+138
+00:12:17,000 --> 00:12:21,000
+That is because one of the key principles of OpenAI API.
+
+139
+00:12:21,000 --> 00:12:26,000
+Each request is processed as an independent request.
+
+140
+00:12:26,000 --> 00:12:28,000
+Remember this?
+
+141
+00:12:28,000 --> 00:12:33,000
+So you would need to manage state on the side of your application.
+
+142
+00:12:33,000 --> 00:12:40,000
+The context plays a crucial role in influencing the output generated by the model.
+
+143
+00:12:40,000 --> 00:12:47,000
+It provides important information for the model to understand the desired task or generate text as it
+
+144
+00:12:47,000 --> 00:12:50,000
+aligns with the given context.
+
+145
+00:12:50,000 --> 00:12:58,000
+By carefully crafting and modifying the context, you can guide the model's responses and tailor the
+
+146
+00:12:58,000 --> 00:13:01,000
+generated output to your specific needs.
+
+147
+00:13:01,000 --> 00:13:07,000
+For example, during the course of one of the applications that we are going to implement is integration
+
+148
+00:13:07,000 --> 00:13:08,000
+with Slack.
+
+149
+00:13:08,000 --> 00:13:13,000
+Basically, you can fetch the context from the Slack conversation.
+
+150
+00:13:13,000 --> 00:13:19,000
+You can limit the amount of lost messages or lost characters taken as a context.
+
+151
+00:13:19,000 --> 00:13:28,000
+But all this will be implemented as a business logic inside your application, which will interact with
+
+152
+00:13:28,000 --> 00:13:30,000
+the Slack API to.
+
+153
+00:13:31,000 --> 00:13:32,000
+Another option.
+
+154
+00:13:32,000 --> 00:13:38,000
+You can create a database on the side of the application and manage state as you wish, selecting only
+
+155
+00:13:38,000 --> 00:13:44,000
+the text that matches some criteria and attach it as a context.
+
+156
+00:13:44,000 --> 00:13:51,000
+But as you may understand, the bigger context has the more relevant answers you receive.
+
+157
+00:13:52,000 --> 00:13:59,000
+Sometimes you want to pause the context of the whole conversation, and sometimes conversations are
+
+158
+00:13:59,000 --> 00:14:03,000
+long and having 4k limit like in chat.
+
+159
+00:14:03,000 --> 00:14:06,000
+GPT 3.52 model is not enough.
+
+160
+00:14:07,000 --> 00:14:14,000
+Again, back to our applications that we are going to build for some questions, we would need to parse
+
+161
+00:14:14,000 --> 00:14:18,000
+the context from the Jira in order to receive relevant answer.
+
+162
+00:14:18,000 --> 00:14:26,000
+These are questions one will ask about state of the Jira, open tasks, roadmap plans, etcetera.
+
+163
+00:14:26,000 --> 00:14:33,000
+And we would need to fetch data from Jira and pass it as a context in order GPT can provide us with
+
+164
+00:14:33,000 --> 00:14:35,000
+relevant response.
+
+165
+00:14:35,000 --> 00:14:44,000
+And imagine in case your Jira project has thousands of user stories to implement features epics.
+
+166
+00:14:44,000 --> 00:14:49,000
+All this context can be easily more than 4000 tokens limit.
+
+167
+00:14:49,000 --> 00:14:57,000
+That's why developers of the OpenAI API considered this and suggested models with the 8000 tokens,
+
+168
+00:14:57,000 --> 00:15:03,000
+context support and 32,000 tokens support in GPT four model.
+
+169
+00:15:03,000 --> 00:15:10,000
+Depending on the business needs, you would need to decide which model will work the best for you because
+
+170
+00:15:10,000 --> 00:15:15,000
+nobody besides you don't know how you are going to use this model.
+
+171
+00:15:15,000 --> 00:15:25,000
+And with what amount of data do understand what a context attribute is and why it is important, even
+
+172
+00:15:25,000 --> 00:15:31,000
+in case something is not clear, please let me know in comments to the video and I will be happy to
+
+173
+00:15:31,000 --> 00:15:32,000
+answer.
+
+174
+00:15:32,000 --> 00:15:41,000
+You can also find pricing for Instruct GPT, also separate pricing for the fine tuning models from the
+
+175
+00:15:41,000 --> 00:15:42,000
+first lesson.
+
+176
+00:15:42,000 --> 00:15:46,000
+I bet that you remember that not all models can be fine tuned.
+
+177
+00:15:47,000 --> 00:15:50,000
+A little bit later during the lesson I am going to explain more.
+
+178
+00:15:50,000 --> 00:15:58,000
+What fine tune is here is embeddings models, image models and audio models.
+
+179
+00:15:58,000 --> 00:16:02,000
+So in this page you are going to find pricing for various models.
+
+180
+00:16:03,000 --> 00:16:10,000
+But even taking into account you pay for the amount of tokens you exchanged with API, this is not the
+
+181
+00:16:10,000 --> 00:16:10,000
+end.
+
+182
+00:16:10,000 --> 00:16:14,000
+You are also limited with monthly quota.
+
+183
+00:16:14,000 --> 00:16:18,000
+This is done in order to support the stability of the system.
+
+184
+00:16:18,000 --> 00:16:25,000
+Based on the day there is $120 monthly limit and you can't exceed.
+
+185
+00:16:25,000 --> 00:16:31,000
+In separate cases, you can fill out the request in order to exceed this amount limit.
+
+186
+00:16:32,000 --> 00:16:36,000
+So now you know about usage billings and limit.
+
+187
+00:16:37,000 --> 00:16:41,000
+In your account, you have separate sections that is called billing.
+
+188
+00:16:41,000 --> 00:16:48,000
+Here you can configure your paid account once you will run out of money available with the voucher to
+
+189
+00:16:48,000 --> 00:16:55,000
+configure billing account, you need just to add credit card details to the payment method section and
+
+190
+00:16:55,000 --> 00:16:56,000
+that's it.
+
+191
+00:16:56,000 --> 00:16:59,000
+Also, you can set usage limits.
+
+192
+00:16:59,000 --> 00:17:04,000
+Just open section usage limit as we discussed.
+
+193
+00:17:04,000 --> 00:17:12,000
+Approved usage limit by default is $120 per month, but you can request increase of this limit in special
+
+194
+00:17:12,000 --> 00:17:13,000
+cases.
+
+195
+00:17:13,000 --> 00:17:15,000
+Just use the link provided.
+
+196
+00:17:16,000 --> 00:17:20,000
+Fill out the form to request increase of usage limit.
+
+197
+00:17:21,000 --> 00:17:24,000
+There is also a possibility to set hard and soft limit.
+
+198
+00:17:25,000 --> 00:17:28,000
+What are they and what is the difference?
+
+199
+00:17:28,000 --> 00:17:35,000
+The terms hard limit and soft limit refer to the different thresholds related to resource usage and
+
+200
+00:17:35,000 --> 00:17:36,000
+billing.
+
+201
+00:17:37,000 --> 00:17:44,000
+A hard limit represents a strict limit set by OpenAI on the usage of a particular resource or service.
+
+202
+00:17:44,000 --> 00:17:51,000
+When you reach the hard limit, you will typically experience a complete halt or restriction in the
+
+203
+00:17:51,000 --> 00:17:53,000
+usage of the resource.
+
+204
+00:17:53,000 --> 00:18:01,000
+It serves as a clear boundary beyond which you can't proceed without taking appropriate action.
+
+205
+00:18:01,000 --> 00:18:09,000
+On the other hand, a soft limit is a more flexible limit that provides a warning or indication that
+
+206
+00:18:09,000 --> 00:18:11,000
+you are approaching a predefined threshold.
+
+207
+00:18:12,000 --> 00:18:20,000
+It acts as a reminder or notification that you are nearing the limit, but it doesn't immediately stop
+
+208
+00:18:20,000 --> 00:18:22,000
+or restrict your usage.
+
+209
+00:18:22,000 --> 00:18:31,000
+Soft limits are designed to give you an opportunity to assess your resource usage, evaluate your needs
+
+210
+00:18:31,000 --> 00:18:35,000
+and make adjustments if necessary before reaching the hard limit.
+
+211
+00:18:36,000 --> 00:18:41,000
+These are key things that I would like to share with you about billing and pricing models.
+
+212
+00:18:42,000 --> 00:18:44,000
+Let's now discuss rate limits.
+
+213
+00:18:44,000 --> 00:18:48,000
+What are they and what do we need to know about them?
+
+214
+00:18:49,000 --> 00:18:57,000
+Rate limits is the OpenAI API refer to the restrictions imposed on the number of API calls you can make
+
+215
+00:18:57,000 --> 00:18:59,000
+within a specific time period.
+
+216
+00:19:00,000 --> 00:19:08,000
+This limits are in place to ensure a fair usage of the API and to maintain the overall performance and
+
+217
+00:19:08,000 --> 00:19:10,000
+availability of the service.
+
+218
+00:19:10,000 --> 00:19:18,000
+The rate limits typically consists of two components requests per minute that is RPM.
+
+219
+00:19:18,000 --> 00:19:24,000
+This refers to the maximum number of API calls you can make in a minute.
+
+220
+00:19:24,000 --> 00:19:32,000
+If you exceed this limit, you may receive an error indicating that you have reached the RPM limit.
+
+221
+00:19:32,000 --> 00:19:41,000
+It is important to note that the RPM limit is calculated on a rolling window basis, which means the
+
+222
+00:19:41,000 --> 00:19:47,000
+count of requests is continuously evaluated over a sliding time window.
+
+223
+00:19:47,000 --> 00:19:55,000
+Tokens per minute that a CPM for some API endpoints, including text based models.
+
+224
+00:19:55,000 --> 00:19:58,000
+The rate limit is measured in tokens per minute.
+
+225
+00:19:59,000 --> 00:20:06,000
+Each API call consumes a certain number of tokens based on the input and output lengths.
+
+226
+00:20:06,000 --> 00:20:13,000
+The exact token cost varies depending on the model and the specific API endpoint being used.
+
+227
+00:20:13,000 --> 00:20:21,000
+The token usage is counted separately from the RPM limit and is also calculated on a rolling window
+
+228
+00:20:21,000 --> 00:20:22,000
+basis.
+
+229
+00:20:23,000 --> 00:20:29,000
+You can get access to the rate limits and check rate limits for your account for different models.
+
+230
+00:20:29,000 --> 00:20:37,000
+As you may already understand, RPM stands for requests per minute and you can check this column to
+
+231
+00:20:37,000 --> 00:20:41,000
+learn the exact limit of requests per minute.
+
+232
+00:20:41,000 --> 00:20:49,000
+And TPM column stands for tokens per minute, and you can see that for different models, values are
+
+233
+00:20:49,000 --> 00:20:50,000
+also different.
+
+234
+00:20:50,000 --> 00:20:58,000
+It is important to manage your API usage within the defined rate limits to avoid disruption in service.
+
+235
+00:20:58,000 --> 00:21:06,000
+If you reach the rate limit, you may need to wait until the limits reset or consider upgrading your
+
+236
+00:21:06,000 --> 00:21:09,000
+plan to access higher rate limits.
+
+237
+00:21:09,000 --> 00:21:10,000
+Members.
+
+238
+00:21:11,000 --> 00:21:16,000
+The last one submenu that we didn't review yet is members.
+
+239
+00:21:16,000 --> 00:21:21,000
+You can invite other members into your organization using their emails.
+
+240
+00:21:21,000 --> 00:21:23,000
+You can try if needed.
+
+241
+00:21:23,000 --> 00:21:27,000
+There are different levels of access that can be granted.
+
+242
+00:21:27,000 --> 00:21:33,000
+You can grant new team members with the owner or reader role.
+
+243
+00:21:34,000 --> 00:21:37,000
+Basically, there is not so much things to add here.
+
+244
+00:21:37,000 --> 00:21:41,000
+The road names are self-explanatory.
+
+245
+00:21:41,000 --> 00:21:47,000
+Another important thing that we need to do in this lesson is to create our API key.
+
+246
+00:21:47,000 --> 00:21:56,000
+You can find the API key section here or you can click on your icon in the top right corner and click
+
+247
+00:21:56,000 --> 00:21:58,000
+view API keys.
+
+248
+00:21:58,000 --> 00:22:04,000
+You will need to use this API key during the each interaction with OpenAI API.
+
+249
+00:22:04,000 --> 00:22:09,000
+That's how OpenAI API will identify you and charge you.
+
+250
+00:22:10,000 --> 00:22:11,000
+To create a new secret key.
+
+251
+00:22:11,000 --> 00:22:13,000
+Just click on the button.
+
+252
+00:22:13,000 --> 00:22:15,000
+Create a new secret key.
+
+253
+00:22:15,000 --> 00:22:17,000
+Give it a name.
+
+254
+00:22:17,000 --> 00:22:19,000
+It can be whatever name you want.
+
+255
+00:22:19,000 --> 00:22:22,000
+And click create Secret key.
+
+256
+00:22:22,000 --> 00:22:27,000
+Now copy this key and store it in the safe place.
+
+257
+00:22:27,000 --> 00:22:33,000
+Do not share this key with anyone else because in that case, other people would be able to use your
+
+258
+00:22:34,000 --> 00:22:38,000
+key and you would be charged for the calls.
+
+259
+00:22:38,000 --> 00:22:41,000
+Pay attention that you would never see this key again.
+
+260
+00:22:41,000 --> 00:22:46,000
+In case you forget it, you would need to create another key.
+
+261
+00:22:46,000 --> 00:22:52,000
+So store this key and we are going to use it during our next lesson.
+
+262
+00:22:52,000 --> 00:22:59,000
+And now the important thing that can help you once you set up billing information and you have a paid
+
+263
+00:22:59,000 --> 00:23:02,000
+account, you need to generate a new secret key.
+
+264
+00:23:02,000 --> 00:23:09,000
+Don't expect that you would be able to access the paid services with old secret key.
+
+265
+00:23:09,000 --> 00:23:13,000
+So just generate a new one like I've just showed you.
+
+266
+00:23:13,000 --> 00:23:14,000
+That's easy.
+
+267
+00:23:14,000 --> 00:23:20,000
+And please remember, in case you have any questions or challenges, you can always ask your questions
+
+268
+00:23:20,000 --> 00:23:23,000
+below this video and I will be happy to answer.
+
+269
+00:23:24,000 --> 00:23:30,000
+So another topic that I wanted to cover in this lesson is fine tuning models.
+
+270
+00:23:30,000 --> 00:23:37,000
+Do remember that when we reviewed pricing, I promised you that I will explain more about fine tuning
+
+271
+00:23:37,000 --> 00:23:38,000
+of models.
+
+272
+00:23:39,000 --> 00:23:44,000
+Fine tuning allows you to enhance the performance of the models provided by the API.
+
+273
+00:23:44,000 --> 00:23:46,000
+In the following ways.
+
+274
+00:23:46,000 --> 00:23:48,000
+Improved quality.
+
+275
+00:23:48,000 --> 00:23:54,000
+Fine tuning yields higher quality results compared to prompt design alone.
+
+276
+00:23:55,000 --> 00:23:57,000
+Increased training data.
+
+277
+00:23:58,000 --> 00:24:05,000
+It enables training on a larger number of examples that can fit within a prompt, resulting in better
+
+278
+00:24:05,000 --> 00:24:06,000
+model performance.
+
+279
+00:24:07,000 --> 00:24:08,000
+Token efficiency.
+
+280
+00:24:09,000 --> 00:24:14,000
+Fine tuning reduces the token usage by allowing shorter prompts.
+
+281
+00:24:14,000 --> 00:24:16,000
+Reduced latency.
+
+282
+00:24:16,000 --> 00:24:22,000
+It facilitates lower latency requests, resulting in faster response times.
+
+283
+00:24:23,000 --> 00:24:31,000
+Gpt3 has been pre-trained on a vast corpus of text from the internet with just few examples provided
+
+284
+00:24:31,000 --> 00:24:32,000
+in the prompt.
+
+285
+00:24:32,000 --> 00:24:38,000
+It can often understand the task at hand and generate relevant completions.
+
+286
+00:24:38,000 --> 00:24:43,000
+Fine tuned leads to superior performance across various tasks.
+
+287
+00:24:43,000 --> 00:24:51,000
+Once a model has been fine tuned, there is no need to include examples in the prompt anymore, which
+
+288
+00:24:51,000 --> 00:24:54,000
+reduces costs and enables faster responses.
+
+289
+00:24:54,000 --> 00:24:58,000
+The fine tuning process involves the following steps.
+
+290
+00:24:58,000 --> 00:25:01,000
+Prepare and upload training data.
+
+291
+00:25:01,000 --> 00:25:06,000
+Train a new fine tuned model using the uploaded data.
+
+292
+00:25:06,000 --> 00:25:10,000
+Utilize your fine tuned model for generating responses.
+
+293
+00:25:11,000 --> 00:25:18,000
+So as you remember, the pricing for training and usage of trained models is significantly less.
+
+294
+00:25:18,000 --> 00:25:23,000
+So I would recommend you also consider this option in the separate lesson.
+
+295
+00:25:23,000 --> 00:25:26,000
+We are going to learn how to train the model and use it.
+
+296
+00:25:27,000 --> 00:25:31,000
+Currently fine tune is available only for the base models.
+
+297
+00:25:31,000 --> 00:25:35,000
+DaVinci Courier, The Bosch and other.
+
+298
+00:25:35,000 --> 00:25:41,000
+This models are the original ones without any post training instructions.
+
+299
+00:25:41,000 --> 00:25:45,000
+Unlike Tex DaVinci, zero three, for example.
+
+300
+00:25:46,000 --> 00:25:52,000
+Additionally, you can continue fine tuning an already fine tuned model by adding more data without
+
+301
+00:25:52,000 --> 00:25:54,000
+starting from scratch.
+
+302
+00:25:54,000 --> 00:26:01,000
+Another interesting thing that I wanted to show you it is relatively small thing for a separate lesson,
+
+303
+00:26:01,000 --> 00:26:03,000
+but still important for you to know.
+
+304
+00:26:03,000 --> 00:26:07,000
+So let me make an overview in this lesson.
+
+305
+00:26:07,000 --> 00:26:14,000
+At the bottom of the page at Platform Openai.com, you can find a link to the status page.
+
+306
+00:26:14,000 --> 00:26:22,000
+This is useful to track availability of the API, so in case something is going wrong or API is not
+
+307
+00:26:22,000 --> 00:26:30,000
+responding, you can check this page and get the latest updates in case there is any issues that OpenAI
+
+308
+00:26:30,000 --> 00:26:32,000
+team is working on at the moment.
+
+309
+00:26:32,000 --> 00:26:36,000
+You are going to find the notification here on this page.
+
+310
+00:26:37,000 --> 00:26:43,000
+As you can see, there was an outage on June 2nd and it was resolved.
+
+311
+00:26:43,000 --> 00:26:49,000
+You can see already time duration of the impact and other details.
+
+312
+00:26:50,000 --> 00:26:54,000
+So that's all what I wanted to share with you in this lesson.
+
+313
+00:26:54,000 --> 00:26:58,000
+We're going to continue to learn more in the next lesson.
+
+314
+00:26:58,000 --> 00:27:02,000
+And now let's recap what we have learned today.
+
+315
+00:27:02,000 --> 00:27:05,000
+We learned a lot for today.
+
+316
+00:27:05,000 --> 00:27:07,000
+We created our account at OpenAI.
+
+317
+00:27:08,000 --> 00:27:13,000
+Now you know where to find and how to read API reference and documentation.
+
+318
+00:27:13,000 --> 00:27:15,000
+We learned how to manage our account.
+
+319
+00:27:15,000 --> 00:27:21,000
+Namely, you learned how to track usage, limit, manage your billing information and configure the
+
+320
+00:27:21,000 --> 00:27:23,000
+name of your organization.
+
+321
+00:27:23,000 --> 00:27:26,000
+We learned OpenAI pricing model.
+
+322
+00:27:26,000 --> 00:27:31,000
+Also, we learned some restrictions that we need to respect.
+
+323
+00:27:31,000 --> 00:27:34,000
+We learned what RPM and TPM are.
+
+324
+00:27:35,000 --> 00:27:39,000
+We created our secret API key and ready for the next lesson.
+
+325
+00:27:40,000 --> 00:27:44,000
+At the end of the lesson, I also showed you how to check service status.
+
+326
+00:27:45,000 --> 00:27:47,000
+That's all for this lesson.
+
+327
+00:27:47,000 --> 00:27:49,000
+Thanks a lot for your attention.
+
+328
+00:27:49,000 --> 00:27:52,000
+Have a great day and see you in the next lesson.
+
diff --git a/95 - OpenAI/003 OpenAI-Pricing-Model.url b/95 - OpenAI/003 OpenAI-Pricing-Model.url
new file mode 100644
index 0000000000000000000000000000000000000000..16d135a7f326635eda7d4ecbbc67520c079b93fe
--- /dev/null
+++ b/95 - OpenAI/003 OpenAI-Pricing-Model.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://openai.com/pricing
\ No newline at end of file
diff --git a/95 - OpenAI/external-links.txt b/95 - OpenAI/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..37c7a13363a4c010dc5e6233356488e2932b3eeb
--- /dev/null
+++ b/95 - OpenAI/external-links.txt
@@ -0,0 +1,12 @@
+
+002 Link-to-the-documentation-with-description-of-Models
+https://platform.openai.com/docs/models
+
+002 GPT-4-promo-page
+https://openai.com/product/gpt-4
+
+002 GPT-4-models
+https://platform.openai.com/docs/models/gpt-4
+
+003 OpenAI-Pricing-Model
+https://openai.com/pricing
diff --git a/96 - OpenAI API ChatGPT Model/001 Chat-API-Reference.url b/96 - OpenAI API ChatGPT Model/001 Chat-API-Reference.url
new file mode 100644
index 0000000000000000000000000000000000000000..e7886db6c7199ba315fe92f52c80d6e1fdf64a56
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/001 Chat-API-Reference.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/api-reference/chat
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/001 ChatGPT Chat API_en.srt b/96 - OpenAI API ChatGPT Model/001 ChatGPT Chat API_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..87813b862f7f9e892082fb72801cf05d9556f277
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/001 ChatGPT Chat API_en.srt
@@ -0,0 +1,1456 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:10,000
+Today we are going to learn more details about Chat, GPT API.
+
+3
+00:00:10,000 --> 00:00:17,000
+We will start the lesson from understanding of what chat API and what completions API are.
+
+4
+00:00:17,000 --> 00:00:22,000
+We'll learn the difference between them and we'll try to answer when to use what.
+
+5
+00:00:22,000 --> 00:00:26,000
+After that, we'll focus our attention on chat API.
+
+6
+00:00:27,000 --> 00:00:32,000
+I'm going to explain you model endpoint compatibility and why you need to know this.
+
+7
+00:00:32,000 --> 00:00:39,000
+We're going to learn attributes of chat API like model temperature and many, many other attributes.
+
+8
+00:00:39,000 --> 00:00:46,000
+I'm going to provide you with examples and explain when you need to use each attribute in order to configure
+
+9
+00:00:46,000 --> 00:00:47,000
+chat GPT.
+
+10
+00:00:48,000 --> 00:00:50,000
+So let's start our lesson.
+
+11
+00:00:50,000 --> 00:00:57,000
+Based on my teaching experience, I know that it is easier to remember things in case we can clearly
+
+12
+00:00:57,000 --> 00:01:01,000
+understand the end goal and what we are trying to achieve.
+
+13
+00:01:01,000 --> 00:01:04,000
+So let's set the goal.
+
+14
+00:01:04,000 --> 00:01:11,000
+Our goal is to create web applications that will be integrated with different tools like Jira, Slack,
+
+15
+00:01:11,000 --> 00:01:19,000
+Salesforce Teams, Messenger, Online Shop API, whatever we need to integrate with, and the applications
+
+16
+00:01:19,000 --> 00:01:27,000
+that will use OpenAI API for different purposes while being integrated with different data sources that
+
+17
+00:01:27,000 --> 00:01:28,000
+I have already mentioned.
+
+18
+00:01:28,000 --> 00:01:35,000
+We will use OpenAI API integration for text, image generation, audio recognition, etcetera.
+
+19
+00:01:35,000 --> 00:01:42,000
+We already know that OpenAI API is not just a chat GPT, but that is something more.
+
+20
+00:01:42,000 --> 00:01:49,000
+There are much more models, so that means that we are going to have our application that would send
+
+21
+00:01:49,000 --> 00:01:55,000
+requests, pass responses and process the data according to the business logic.
+
+22
+00:01:55,000 --> 00:02:02,000
+And during the course we are going to build all these integrations and make it follow specific business
+
+23
+00:02:02,000 --> 00:02:05,000
+logic and concrete business use case.
+
+24
+00:02:06,000 --> 00:02:10,000
+And we will start from building the integration with the OpenAI API.
+
+25
+00:02:10,000 --> 00:02:17,000
+Let's start from the chat GPT integration just to ensure that we can chat with the AI and get necessary
+
+26
+00:02:17,000 --> 00:02:19,000
+help when it would be needed.
+
+27
+00:02:19,000 --> 00:02:24,000
+And for that we need to learn APIs that we need to integrate with.
+
+28
+00:02:24,000 --> 00:02:25,000
+Correct.
+
+29
+00:02:25,000 --> 00:02:32,000
+That's why in this lesson we are going to learn the APIs that we need to integrate with and then in
+
+30
+00:02:32,000 --> 00:02:38,000
+the next lessons we will jump to code implementation to implement actually the integration.
+
+31
+00:02:38,000 --> 00:02:41,000
+So we decided to integrate with chat GPT.
+
+32
+00:02:41,000 --> 00:02:47,000
+At the beginning and here again we need to choose which model to select.
+
+33
+00:02:47,000 --> 00:02:55,000
+The OpenAI API provides two main models for generating text chat models and completion models.
+
+34
+00:02:55,000 --> 00:02:59,000
+Here is breakdown of key differences between the two.
+
+35
+00:02:59,000 --> 00:03:08,000
+Let's start from the chat models Purpose chat models are specifically designed for interactive multi-turn
+
+36
+00:03:08,000 --> 00:03:09,000
+conversations.
+
+37
+00:03:09,000 --> 00:03:14,000
+They excel at generating responses in a conversational manner.
+
+38
+00:03:14,000 --> 00:03:15,000
+Input Format.
+
+39
+00:03:15,000 --> 00:03:23,000
+When using chat models, you provide a series of messages as an input where each message has a role
+
+40
+00:03:23,000 --> 00:03:27,000
+system, user assistant, a function and content.
+
+41
+00:03:27,000 --> 00:03:29,000
+The text of the message.
+
+42
+00:03:30,000 --> 00:03:36,000
+I'm going to explain you What is the difference between roles and which one to choose later when we
+
+43
+00:03:36,000 --> 00:03:40,000
+will come to the detailed API Attributes Overview.
+
+44
+00:03:40,000 --> 00:03:42,000
+Context preservation.
+
+45
+00:03:42,000 --> 00:03:47,000
+Chat models maintain context across the conversation history.
+
+46
+00:03:47,000 --> 00:03:56,000
+They can see the prior messages to generate appropriate responses, and we have the ability to set the
+
+47
+00:03:56,000 --> 00:03:56,000
+context.
+
+48
+00:03:57,000 --> 00:03:59,000
+System level instructions.
+
+49
+00:03:59,000 --> 00:04:06,000
+You can use system level instructions to guide the behavior of the assistance throughout the conversation.
+
+50
+00:04:06,000 --> 00:04:11,000
+Instructions Help set the behavior or style of the responses.
+
+51
+00:04:11,000 --> 00:04:15,000
+This can be submitted using system role.
+
+52
+00:04:16,000 --> 00:04:19,000
+Pay attention to the examples that you can see on the slide.
+
+53
+00:04:19,000 --> 00:04:23,000
+That is how we can set system level instructions.
+
+54
+00:04:23,000 --> 00:04:29,000
+Pay attention that the first message in this array is submitted with system role.
+
+55
+00:04:29,000 --> 00:04:31,000
+You are helpful assistant.
+
+56
+00:04:31,000 --> 00:04:38,000
+This instruction sets the behavior or style of the assistant throughout the conversation.
+
+57
+00:04:38,000 --> 00:04:42,000
+It informs the model that it should act as a helpful assistant.
+
+58
+00:04:43,000 --> 00:04:49,000
+The subsequent messages in the conversation include a user query and the assistance response.
+
+59
+00:04:50,000 --> 00:04:56,000
+The conversation History is preserved and passed to the model, allowing it to generate appropriate
+
+60
+00:04:56,000 --> 00:04:59,000
+responses based on the context.
+
+61
+00:04:59,000 --> 00:05:06,000
+System level instructions can be used to influence the tone, style or behavior of the assistant.
+
+62
+00:05:06,000 --> 00:05:13,000
+You can experiment with different instructions to guide the assistants responses in the desired manner.
+
+63
+00:05:14,000 --> 00:05:22,000
+It is important to note that the OpenAI API offers flexibility in how you structure conversations and
+
+64
+00:05:22,000 --> 00:05:23,000
+provide instructions.
+
+65
+00:05:23,000 --> 00:05:30,000
+You can modify the instructions and content as per your specific requirements to achieve the desired
+
+66
+00:05:30,000 --> 00:05:32,000
+conversational behavior.
+
+67
+00:05:32,000 --> 00:05:35,000
+Example Usage of chat models.
+
+68
+00:05:35,000 --> 00:05:42,000
+Chat models are ideal for building chat bots, virtual assistants, or any application where interactive
+
+69
+00:05:42,000 --> 00:05:45,000
+and dynamic conversations are required.
+
+70
+00:05:46,000 --> 00:05:49,000
+So we reviewed chart models.
+
+71
+00:05:49,000 --> 00:05:53,000
+Let's now learn what completion models are about.
+
+72
+00:05:53,000 --> 00:05:57,000
+Purpose completion models also known as text DaVinci.
+
+73
+00:05:57,000 --> 00:06:06,000
+003 models are designed for single turn tasks where you want to generate text based on a prompt.
+
+74
+00:06:06,000 --> 00:06:11,000
+They excel at generating coherent and contextually relevant completions.
+
+75
+00:06:12,000 --> 00:06:13,000
+Input format.
+
+76
+00:06:13,000 --> 00:06:21,000
+With completion models, you provide a prompt as an input which serves as an initial text to generate
+
+77
+00:06:21,000 --> 00:06:22,000
+a completion form.
+
+78
+00:06:22,000 --> 00:06:26,000
+The model generates a continuation of the provided prompt.
+
+79
+00:06:27,000 --> 00:06:29,000
+Prompt response paradigm.
+
+80
+00:06:29,000 --> 00:06:33,000
+Completion models operate on a prompt response paradigm.
+
+81
+00:06:33,000 --> 00:06:41,000
+They are suitable for generating text in response to user queries or generating long form text based
+
+82
+00:06:41,000 --> 00:06:42,000
+on a given prompt.
+
+83
+00:06:43,000 --> 00:06:45,000
+Context ignorance.
+
+84
+00:06:45,000 --> 00:06:52,000
+Unlike chart models, completion models do not maintain context or memory of prior interactions.
+
+85
+00:06:52,000 --> 00:06:59,000
+Each prompt is treated as a separate and independent input, and you don't have possibility to pass
+
+86
+00:06:59,000 --> 00:07:03,000
+an array of messages and separate them by rows.
+
+87
+00:07:03,000 --> 00:07:06,000
+Example Usage of completion models.
+
+88
+00:07:06,000 --> 00:07:13,000
+Completion models are well suited for tasks like text generation, content creation, language translation,
+
+89
+00:07:13,000 --> 00:07:16,000
+text summarization, code generation and more.
+
+90
+00:07:17,000 --> 00:07:24,000
+In summary, chat models are designed for interactive multi-channel conversations, while completion
+
+91
+00:07:24,000 --> 00:07:30,000
+models are focused on generating text based on prompts or single turn tasks.
+
+92
+00:07:30,000 --> 00:07:36,000
+The choice between two depends on the specific requirements of your application or your use case.
+
+93
+00:07:37,000 --> 00:07:40,000
+In our case, we would select chat model.
+
+94
+00:07:40,000 --> 00:07:45,000
+So let me open chat API and look through what do we have here?
+
+95
+00:07:46,000 --> 00:07:51,000
+Here on this page you can find all required information about request body.
+
+96
+00:07:52,000 --> 00:07:56,000
+I'm going to add this link in attachments to the video.
+
+97
+00:07:56,000 --> 00:07:57,000
+Please check it.
+
+98
+00:07:58,000 --> 00:08:02,000
+As you can see, model and messages are required attributes.
+
+99
+00:08:02,000 --> 00:08:10,000
+In the model, we specify the model name that we are going to use like GPT 3.5 Turbo or GPT four.
+
+100
+00:08:11,000 --> 00:08:17,000
+Regarding the endpoint, it is also important for you to know about model endpoint compatibility.
+
+101
+00:08:17,000 --> 00:08:24,000
+Model compatibility refers to the ability of different applications or services to work seamlessly with
+
+102
+00:08:24,000 --> 00:08:27,000
+specific models or endpoints.
+
+103
+00:08:27,000 --> 00:08:36,000
+It ensures that the model you intend to use is compatible with the application or endpoint you are targeting.
+
+104
+00:08:36,000 --> 00:08:44,000
+Incompatibility can lead to issues such as errors, incorrect results or limited functionality.
+
+105
+00:08:44,000 --> 00:08:51,000
+One useful resource to determine model compatibility is the model endpoint compatibility section in
+
+106
+00:08:51,000 --> 00:08:52,000
+the documentation.
+
+107
+00:08:52,000 --> 00:08:58,000
+Let's take a look at an OpenAI documentation that you can see on the screen now.
+
+108
+00:08:58,000 --> 00:09:06,000
+This section provides information about which models are compatible with specific endpoints or APIs.
+
+109
+00:09:06,000 --> 00:09:13,000
+It ensures that you select the appropriate model name when making API requests to achieve the desired
+
+110
+00:09:13,000 --> 00:09:14,000
+functionality.
+
+111
+00:09:14,000 --> 00:09:22,000
+For example, if you are using the V1 completion endpoint, you should choose a compatible model from
+
+112
+00:09:22,000 --> 00:09:24,000
+the listed options like text.
+
+113
+00:09:24,000 --> 00:09:28,000
+DaVinci 003, text DaVinci 002 and so on.
+
+114
+00:09:29,000 --> 00:09:36,000
+By knowing which models are compatible with specific endpoints, you can seamlessly integrate AI capabilities
+
+115
+00:09:36,000 --> 00:09:42,000
+into your applications or services, avoiding unnecessary issues or errors.
+
+116
+00:09:42,000 --> 00:09:45,000
+Okay, let's come back to the documentation.
+
+117
+00:09:45,000 --> 00:09:48,000
+What else should we specify in the request?
+
+118
+00:09:49,000 --> 00:09:55,000
+In the messages attribute, we pass an array of messages in order to set the context.
+
+119
+00:09:55,000 --> 00:10:00,000
+Each message should have a role as its mandatory content.
+
+120
+00:10:00,000 --> 00:10:02,000
+That is our message.
+
+121
+00:10:02,000 --> 00:10:06,000
+The name of the author of the message and function call.
+
+122
+00:10:06,000 --> 00:10:07,000
+Optionally.
+
+123
+00:10:08,000 --> 00:10:11,000
+We're going to review examples with function, role and function.
+
+124
+00:10:11,000 --> 00:10:17,000
+Call in a separate lesson because this is not the topic for our first application.
+
+125
+00:10:17,000 --> 00:10:24,000
+Also, I promised you to explain which role to select for message when we send the request.
+
+126
+00:10:25,000 --> 00:10:32,000
+So we need to select one out of four roles system user Assistant function.
+
+127
+00:10:32,000 --> 00:10:36,000
+Let's understand what is the difference between these roles?
+
+128
+00:10:36,000 --> 00:10:38,000
+Let's start from the system role.
+
+129
+00:10:39,000 --> 00:10:46,000
+The system role is typically used to provide high level instructions or set the behavior style of the
+
+130
+00:10:46,000 --> 00:10:48,000
+system throughout the conversation.
+
+131
+00:10:49,000 --> 00:10:57,000
+Instructions in the system role Guide the overall behavior of the assistant, but don't directly respond
+
+132
+00:10:57,000 --> 00:10:59,000
+to user queries.
+
+133
+00:10:59,000 --> 00:11:03,000
+System messages can help define the assistance persona.
+
+134
+00:11:03,000 --> 00:11:08,000
+Specify conversation rules or provide context for the ongoing conversation.
+
+135
+00:11:08,000 --> 00:11:15,000
+And I believe you remember on the previous slide I already showed system level instructions and how
+
+136
+00:11:15,000 --> 00:11:16,000
+they work.
+
+137
+00:11:17,000 --> 00:11:18,000
+User role.
+
+138
+00:11:18,000 --> 00:11:25,000
+The user role represents messages or queries from the user or end user interacting with the assistant.
+
+139
+00:11:26,000 --> 00:11:32,000
+User messages typically contain prompts questions or instructions for the assistant.
+
+140
+00:11:32,000 --> 00:11:39,000
+User messages are meant to trigger responses from the assistant based on the provided input.
+
+141
+00:11:40,000 --> 00:11:41,000
+Assistant role.
+
+142
+00:11:41,000 --> 00:11:47,000
+The assistant role represents the assistance, own messages or responses in the conversation.
+
+143
+00:11:48,000 --> 00:11:56,000
+In other words, when we build a history of messages, actually build the array of the messages, all
+
+144
+00:11:56,000 --> 00:12:02,000
+responses from the ChatGPT should be marked with this row with assistant row.
+
+145
+00:12:03,000 --> 00:12:10,000
+Assistant messages are generated by the model and are based on the conversation, history and preceding
+
+146
+00:12:10,000 --> 00:12:12,000
+user system messages.
+
+147
+00:12:12,000 --> 00:12:18,000
+Assistant messages aim to provide helpful or relevant responses to user queries.
+
+148
+00:12:18,000 --> 00:12:22,000
+And function role is related to function calling.
+
+149
+00:12:22,000 --> 00:12:28,000
+As already mentioned, we are going to have a separate lesson where we will discuss how to use function
+
+150
+00:12:28,000 --> 00:12:32,000
+role because this is a part of more complex topic.
+
+151
+00:12:32,000 --> 00:12:39,000
+But in short, the function role is a special role used to invoke an API level instruction or to make
+
+152
+00:12:39,000 --> 00:12:47,000
+a specific API call within the message function messages are not used for regular conversation flow,
+
+153
+00:12:47,000 --> 00:12:53,000
+but serve as explicit instructions to modify the behavior of the assistant or perform certain actions.
+
+154
+00:12:54,000 --> 00:12:58,000
+So let's get back to the API reference now.
+
+155
+00:12:59,000 --> 00:13:02,000
+What else is important for us from the configuration standpoint?
+
+156
+00:13:03,000 --> 00:13:05,000
+We skip everything function related.
+
+157
+00:13:05,000 --> 00:13:08,000
+As I said, we will learn it in a separate lesson.
+
+158
+00:13:09,000 --> 00:13:09,000
+Temperature.
+
+159
+00:13:10,000 --> 00:13:12,000
+Let me explain you what it is.
+
+160
+00:13:12,000 --> 00:13:20,000
+The temperature attribute in the API request for ChatGPT controls the randomness of the model's responses.
+
+161
+00:13:20,000 --> 00:13:27,000
+It allows you to adjust the level of creativity and variability in the generated text.
+
+162
+00:13:27,000 --> 00:13:33,000
+By default, the value is one, but you can select a value between 0 and 2.
+
+163
+00:13:33,000 --> 00:13:42,000
+A higher temperature value like 0.8 introduces more randomness into the model's responses than zero.
+
+164
+00:13:42,000 --> 00:13:49,000
+This can result in more creative but potentially less coherent or predictable output.
+
+165
+00:13:49,000 --> 00:13:56,000
+The model is more likely to generate diverse responses, including unusual or unexpected ones.
+
+166
+00:13:56,000 --> 00:14:04,000
+On the other hand, a lower temperature value like 0.2 reduces randomness and makes the output more
+
+167
+00:14:04,000 --> 00:14:07,000
+deterministic and conservative.
+
+168
+00:14:07,000 --> 00:14:13,000
+The model is more likely to generate common and safe responses based on the training data.
+
+169
+00:14:13,000 --> 00:14:18,000
+So the question is what temperature to choose and to use?
+
+170
+00:14:18,000 --> 00:14:19,000
+It depends.
+
+171
+00:14:19,000 --> 00:14:23,000
+The choice of temperature depends on the desired output.
+
+172
+00:14:24,000 --> 00:14:32,000
+Higher values encourage the generation of novel and imaginative responses, which can be useful in creative
+
+173
+00:14:32,000 --> 00:14:34,000
+writing or brainstorming scenarios.
+
+174
+00:14:35,000 --> 00:14:42,000
+Lower values help ensure more controlled and reliable responses, which may be preferred in situations
+
+175
+00:14:42,000 --> 00:14:47,000
+where accuracy and adherence to specific guidelines are crucial.
+
+176
+00:14:47,000 --> 00:14:53,000
+It's important to experiment with different temperature values, to find the balance that suits your
+
+177
+00:14:53,000 --> 00:15:00,000
+application and the desired level of randomness or determinism in the generated responses.
+
+178
+00:15:01,000 --> 00:15:01,000
+Top.
+
+179
+00:15:03,000 --> 00:15:06,000
+There is also an alternative to the temperature.
+
+180
+00:15:06,000 --> 00:15:13,000
+So you can use is a temperature or top P attribute, but it is not recommended to use them both together
+
+181
+00:15:13,000 --> 00:15:14,000
+at the same time.
+
+182
+00:15:14,000 --> 00:15:20,000
+You can experiment with different values of top P and temperature to achieve the desired balance of
+
+183
+00:15:20,000 --> 00:15:24,000
+randomness and coherence in the generated text.
+
+184
+00:15:24,000 --> 00:15:32,000
+The top P attribute, also known as nucleus sampling or P coverage, is an alternative to using temperature
+
+185
+00:15:32,000 --> 00:15:37,000
+for controlling the randomness and diversity of the model's response.
+
+186
+00:15:37,000 --> 00:15:38,000
+In the chat GPT API.
+
+187
+00:15:39,000 --> 00:15:46,000
+The top P parameter takes a value between 0 and 1 representing a probability threshold.
+
+188
+00:15:46,000 --> 00:15:53,000
+It determines the cumulative probability mass that the model considers when generating text.
+
+189
+00:15:54,000 --> 00:15:55,000
+The default is one.
+
+190
+00:15:56,000 --> 00:15:59,000
+To understand it better, let's consider the next example.
+
+191
+00:16:00,000 --> 00:16:04,000
+You can see on the slide the conversation with two messages.
+
+192
+00:16:04,000 --> 00:16:10,000
+In this example we are using the GPT 3.52 model for the conversation.
+
+193
+00:16:10,000 --> 00:16:19,000
+The top P attribute is set to 0.8, indicating that we want to consider the most likely tokens that
+
+194
+00:16:19,000 --> 00:16:26,000
+make up to 80% of the cumulative probability distribution when generating the response.
+
+195
+00:16:26,000 --> 00:16:33,000
+When the model generates the response, it uses the provided conversation, history and the given attributes.
+
+196
+00:16:33,000 --> 00:16:40,000
+The top P attribute helps to ensure that the response includes tokens that collectively make up the
+
+197
+00:16:40,000 --> 00:16:48,000
+80% of the probability distribution, thus introducing diversity in the generated responses.
+
+198
+00:16:48,000 --> 00:16:55,000
+The specific impact of the top P attribute of the conversation will depend on the model, context and
+
+199
+00:16:55,000 --> 00:16:56,000
+other factors.
+
+200
+00:16:57,000 --> 00:17:03,000
+Adjusting the top P value allows you to control the level of randomness and diversity in the generated
+
+201
+00:17:03,000 --> 00:17:06,000
+responses within the conversation.
+
+202
+00:17:06,000 --> 00:17:16,000
+So in very simple words, a lower value of top P such as zero will result in more diverse and varied
+
+203
+00:17:16,000 --> 00:17:17,000
+responses.
+
+204
+00:17:17,000 --> 00:17:24,000
+The model will consider a wider range of tokens with lower probabilities leading to potentially unexpected
+
+205
+00:17:24,000 --> 00:17:26,000
+and creative outputs.
+
+206
+00:17:26,000 --> 00:17:34,000
+On the other hand, a higher value of top P such as one will make the model more focused and deterministic.
+
+207
+00:17:34,000 --> 00:17:42,000
+It will only consider tokens with higher probabilities, resulting in more predictable and conservative
+
+208
+00:17:42,000 --> 00:17:43,000
+responses.
+
+209
+00:17:43,000 --> 00:17:46,000
+Let's now review an attribute.
+
+210
+00:17:46,000 --> 00:17:49,000
+The an attribute is pretty straightforward.
+
+211
+00:17:49,000 --> 00:17:55,000
+It sets the number of chat completion choices to generate for each input message.
+
+212
+00:17:55,000 --> 00:17:57,000
+Usually it is equal to one.
+
+213
+00:17:58,000 --> 00:18:01,000
+The next one is stream attribute.
+
+214
+00:18:01,000 --> 00:18:07,000
+The stream attribute is an optional setting that can be used in the context of working with chat GPT
+
+215
+00:18:07,000 --> 00:18:08,000
+model.
+
+216
+00:18:08,000 --> 00:18:14,000
+By default, when you make a request to the chat GPT model, you receive a complete response once the
+
+217
+00:18:14,000 --> 00:18:17,000
+model has finished generating the entire message.
+
+218
+00:18:18,000 --> 00:18:25,000
+However, if you set the stream parameter to true, you can receive partial message updates as they
+
+219
+00:18:25,000 --> 00:18:29,000
+become available rather than waiting for the complete response.
+
+220
+00:18:29,000 --> 00:18:31,000
+Here is how it works.
+
+221
+00:18:31,000 --> 00:18:38,000
+When you make a request with stream set to true, the response is not sent all at once.
+
+222
+00:18:38,000 --> 00:18:45,000
+Instead, the response is delivered incrementally, providing partial message updates in real time.
+
+223
+00:18:46,000 --> 00:18:53,000
+Each partial update or Delta, includes additional tokens of the generated message as they are produced
+
+224
+00:18:53,000 --> 00:18:54,000
+by the model.
+
+225
+00:18:55,000 --> 00:19:03,000
+These deltas are sent as a data only server send event allowing you to receive and process them as they
+
+226
+00:19:03,000 --> 00:19:04,000
+become available.
+
+227
+00:19:04,000 --> 00:19:11,000
+The stream of the deltas continues until the completion of the response to indicate the end of the stream.
+
+228
+00:19:11,000 --> 00:19:14,000
+A special data dump message is sent.
+
+229
+00:19:14,000 --> 00:19:21,000
+This can be useful if you want to display and process intermediate results or provide a more interactive
+
+230
+00:19:21,000 --> 00:19:25,000
+experience while the model is still generating the full response.
+
+231
+00:19:26,000 --> 00:19:28,000
+The next attribute is a stop.
+
+232
+00:19:28,000 --> 00:19:36,000
+The stop lets you define specific phrases or words that, when encountered in the generated text, will
+
+233
+00:19:36,000 --> 00:19:39,000
+signal the model to stop generating more text.
+
+234
+00:19:39,000 --> 00:19:46,000
+The stop parameter helps you control the length of the generated text and ensures that the model doesn't
+
+235
+00:19:46,000 --> 00:19:52,000
+continue generating unnecessary or irrelevant information beyond a certain point.
+
+236
+00:19:52,000 --> 00:19:58,000
+You can provide multiple stop sequences by passing an array of sequences to the stop parameter.
+
+237
+00:19:58,000 --> 00:20:05,000
+When any of the specified sequences is encountered in the generated text, the model will stop generating
+
+238
+00:20:05,000 --> 00:20:06,000
+further tokens.
+
+239
+00:20:06,000 --> 00:20:09,000
+Let's review an example on this slide.
+
+240
+00:20:09,000 --> 00:20:15,000
+In this example we use the GPT 3.5 Turbo model for the conversation.
+
+241
+00:20:15,000 --> 00:20:23,000
+The stop attribute is set to cents, which means that if the generated response includes the word cents,
+
+242
+00:20:23,000 --> 00:20:28,000
+the model will stop generating tokens and return the response.
+
+243
+00:20:28,000 --> 00:20:31,000
+For example, if the model generates a response.
+
+244
+00:20:31,000 --> 00:20:36,000
+Sure, Here's a joke for you Why don't scientists trust atoms?
+
+245
+00:20:36,000 --> 00:20:38,000
+Because they make up everything.
+
+246
+00:20:39,000 --> 00:20:40,000
+Thanks for chatting.
+
+247
+00:20:40,000 --> 00:20:45,000
+The presence of the word cents triggers the stopping condition.
+
+248
+00:20:45,000 --> 00:20:50,000
+The response returns by the API will include the generated tokens up to that point.
+
+249
+00:20:50,000 --> 00:20:57,000
+By using the stop attribute, you can define specific markers in the conversation where you want the
+
+250
+00:20:57,000 --> 00:21:00,000
+model to conclude its response.
+
+251
+00:21:00,000 --> 00:21:08,000
+Please note that stop attribute can be a string or an array of strings allowing you to specify multiple
+
+252
+00:21:08,000 --> 00:21:10,000
+stopping sequence if desired.
+
+253
+00:21:10,000 --> 00:21:13,000
+The next attribute is max tokens.
+
+254
+00:21:14,000 --> 00:21:20,000
+The max tokens attribute is important in my opinion, so pay extra attention now to what I say.
+
+255
+00:21:21,000 --> 00:21:28,000
+The max tokens parameter in the OpenAI API allows you to specify the maximum number of tokens you want
+
+256
+00:21:28,000 --> 00:21:31,000
+the model to generate in the chat completion.
+
+257
+00:21:32,000 --> 00:21:40,000
+A token can be as short as one character or as long as one word, depending on the language and context.
+
+258
+00:21:40,000 --> 00:21:47,000
+By setting the max tokens value, you can control the length of the generated text and limit it to a
+
+259
+00:21:47,000 --> 00:21:48,000
+specific number of tokens.
+
+260
+00:21:49,000 --> 00:21:56,000
+This can be useful when you want to generate a response of a certain length or ensure that the output
+
+261
+00:21:56,000 --> 00:21:58,000
+doesn't exceed a certain limit.
+
+262
+00:21:58,000 --> 00:22:05,000
+This is important because it will strictly impact user experience and usage of tokens, thus billing
+
+263
+00:22:06,000 --> 00:22:08,000
+in the example from the slide.
+
+264
+00:22:08,000 --> 00:22:15,000
+The max tokens attribute is set to 20, which means that the response generated by the model will contain
+
+265
+00:22:15,000 --> 00:22:17,000
+a maximum of 20 tokens.
+
+266
+00:22:17,000 --> 00:22:24,000
+Another super interesting and potentially useful attributes that can help you to make ChatGPT more creative.
+
+267
+00:22:24,000 --> 00:22:32,000
+The presence penalty parameter is a number between -2 and 2 with a default value of zero.
+
+268
+00:22:33,000 --> 00:22:37,000
+Positive values like, for example, 0.51.
+
+269
+00:22:37,000 --> 00:22:44,000
+ET cetera for the presence penalty, penalize new tokens based on whether they have already appeared
+
+270
+00:22:44,000 --> 00:22:49,000
+in the text generated so far by increasing the presence penalty.
+
+271
+00:22:49,000 --> 00:22:56,000
+You can make the model less likely to repeat or reiterate the same information it has already provided.
+
+272
+00:22:57,000 --> 00:22:59,000
+Higher presence Penalty values.
+
+273
+00:22:59,000 --> 00:23:05,000
+Encourage the model to talk about new topics or provide more diverse responses.
+
+274
+00:23:05,000 --> 00:23:13,000
+In the examples that you can see on the slide, the presence penalty attribute is set to 0.6, which
+
+275
+00:23:13,000 --> 00:23:20,000
+means that the model will be slightly encouraged to generate responses that do not explicitly repeat
+
+276
+00:23:20,000 --> 00:23:23,000
+the information provided in the conversation history.
+
+277
+00:23:23,000 --> 00:23:29,000
+For example, if the model generates the response, the capital of France is Paris.
+
+278
+00:23:29,000 --> 00:23:32,000
+It is a beautiful city known for its art and culture.
+
+279
+00:23:32,000 --> 00:23:40,000
+The presence penalty encourages the model to avoid repeating the fact that Paris is the capital of France,
+
+280
+00:23:40,000 --> 00:23:43,000
+even though it is mentioned in the user's question.
+
+281
+00:23:43,000 --> 00:23:46,000
+Instead, the model provides additional.
+
+282
+00:23:46,000 --> 00:23:47,000
+Information about the city.
+
+283
+00:23:48,000 --> 00:23:52,000
+Another related attribute is frequency penalty.
+
+284
+00:23:52,000 --> 00:23:59,000
+The frequency penalty parameter is also a number between -2 and 2 with a default value of zero.
+
+285
+00:24:00,000 --> 00:24:09,000
+Positive values like 0.51 for the frequency penalty penalized new tokens based on their existing frequency
+
+286
+00:24:09,000 --> 00:24:11,000
+within the text generated so far.
+
+287
+00:24:12,000 --> 00:24:19,000
+Applying a frequency penalty reduces the model's likelihood of repeating the same phrases or lines verbatim.
+
+288
+00:24:20,000 --> 00:24:27,000
+Higher frequency penalty values discourage the model from using previously generated content excessively
+
+289
+00:24:27,000 --> 00:24:31,000
+and encourage it to generate more variety responses.
+
+290
+00:24:32,000 --> 00:24:39,000
+In the example, the frequency penalty attribute is set to 0.8, which means that the model will be
+
+291
+00:24:39,000 --> 00:24:46,000
+slightly encouraged to avoid generating responses that are repetitive or have high token overlap with
+
+292
+00:24:46,000 --> 00:24:48,000
+the previously generated responses.
+
+293
+00:24:48,000 --> 00:24:53,000
+For example, if the model generates the response, sure he is a joke.
+
+294
+00:24:53,000 --> 00:24:56,000
+Why don't scientists trust atoms?
+
+295
+00:24:56,000 --> 00:24:58,000
+Because they make up everything.
+
+296
+00:24:58,000 --> 00:25:00,000
+That's hilarious.
+
+297
+00:25:00,000 --> 00:25:07,000
+The frequency penalty encourages the model to avoid using similar jokes or repeating phrases too frequently.
+
+298
+00:25:07,000 --> 00:25:11,000
+Promoting more diverse and varied responses.
+
+299
+00:25:12,000 --> 00:25:13,000
+Both penalties.
+
+300
+00:25:13,000 --> 00:25:16,000
+Presence, penalty and frequency penalty.
+
+301
+00:25:16,000 --> 00:25:23,000
+Provide ways to guide the model's behavior in terms of generating novel and non-repetitive text.
+
+302
+00:25:23,000 --> 00:25:29,000
+It is important to experiment with different values for these parameters to achieve the desired balance
+
+303
+00:25:29,000 --> 00:25:33,000
+in generating new content and avoiding excessive repetition.
+
+304
+00:25:34,000 --> 00:25:40,000
+The appropriate values may vary depending on your specific use case and requirements.
+
+305
+00:25:40,000 --> 00:25:47,000
+By adjusting the presence, penalty and frequency penalty, you can shape the model's responses to strike
+
+306
+00:25:47,000 --> 00:25:54,000
+the right balance between generating novel information and minimizing repetitive content.
+
+307
+00:25:54,000 --> 00:25:58,000
+Now I'm going to explain you a very interesting thing.
+
+308
+00:25:58,000 --> 00:26:00,000
+Logit bias attribute.
+
+309
+00:26:00,000 --> 00:26:04,000
+Let's understand what is it for and how to work with it.
+
+310
+00:26:04,000 --> 00:26:10,000
+And to understand it, we would need to have a concrete example because it is comparatively hard to
+
+311
+00:26:10,000 --> 00:26:13,000
+understand without example.
+
+312
+00:26:13,000 --> 00:26:18,000
+Imagine that we have a language model that generates text completions.
+
+313
+00:26:18,000 --> 00:26:25,000
+The logit bias parameter allows us to modify the likelihood of specific tokens appearing in the generated
+
+314
+00:26:25,000 --> 00:26:26,000
+completion.
+
+315
+00:26:26,000 --> 00:26:29,000
+Let's consider the following sentence.
+
+316
+00:26:29,000 --> 00:26:30,000
+I like.
+
+317
+00:26:30,000 --> 00:26:33,000
+And here goes your favorite fruit.
+
+318
+00:26:33,000 --> 00:26:40,000
+Here you have a placeholder where the model should insert a specific fruit based on the context.
+
+319
+00:26:40,000 --> 00:26:47,000
+If we want to increase the likelihood of a particular fruit being selected, we can use logit bias.
+
+320
+00:26:47,000 --> 00:26:51,000
+For example, let's say we have the following Json object.
+
+321
+00:26:52,000 --> 00:26:56,000
+Apple ten banana zero, orange minus ten.
+
+322
+00:26:56,000 --> 00:27:04,000
+In this case, we assign a positive bias value ten to Apple, indicating that we want the model to prefer
+
+323
+00:27:04,000 --> 00:27:08,000
+using Apple in the completion for banana.
+
+324
+00:27:08,000 --> 00:27:13,000
+We set the bias value to zero, meaning we don't modify its probability.
+
+325
+00:27:13,000 --> 00:27:21,000
+And for orange we assign a negative bias value minus ten, indicating that we want to decrease the likelihood
+
+326
+00:27:21,000 --> 00:27:24,000
+of orange appearing in the completion.
+
+327
+00:27:24,000 --> 00:27:32,000
+By using logit bias, the model takes this into account during the text generation and tends to favor
+
+328
+00:27:32,000 --> 00:27:34,000
+tokens with higher biases.
+
+329
+00:27:34,000 --> 00:27:41,000
+This allows you to influence the model selection and control the probabilities of specific tokens appearing
+
+330
+00:27:41,000 --> 00:27:42,000
+in the completion.
+
+331
+00:27:42,000 --> 00:27:48,000
+To understand what logit bars for super, let's continue.
+
+332
+00:27:48,000 --> 00:27:55,000
+And the last but not the least attribute that I wanted to review with you in this lesson is user attribute.
+
+333
+00:27:55,000 --> 00:28:04,000
+The end user IDs feature is a way to include user identifiers in your requests to the OpenAI API.
+
+334
+00:28:04,000 --> 00:28:12,000
+It serves as a helpful tool for OpenAI to monitor and detect any potential abuse or policy violations
+
+335
+00:28:12,000 --> 00:28:17,000
+in your application by including end user IDs.
+
+336
+00:28:17,000 --> 00:28:24,000
+OpenAI can provide more specific and actionable feedback to your team if any issues arise.
+
+337
+00:28:24,000 --> 00:28:31,000
+The IDs should be a string that uniquely identifies each user in the communication.
+
+338
+00:28:31,000 --> 00:28:38,000
+Thus recommended hash and username or email address of a user in order to avoid sending any identifying
+
+339
+00:28:38,000 --> 00:28:39,000
+information.
+
+340
+00:28:39,000 --> 00:28:48,000
+If you offer a preview of your product to non logged in users, you can send a session ID instead by
+
+341
+00:28:48,000 --> 00:28:50,000
+including the user identifier in this manner.
+
+342
+00:28:50,000 --> 00:28:59,000
+You enable OpenAI to associate the API usage with specific end users and provide you with more targeted
+
+343
+00:28:59,000 --> 00:29:01,000
+support and feedback.
+
+344
+00:29:01,000 --> 00:29:08,000
+While the API itself doesn't retain the history of interactions, OpenAI may rely on the information
+
+345
+00:29:08,000 --> 00:29:16,000
+provided, such as end user IDs to investigate and address any concerns regarding the usage of the API.
+
+346
+00:29:16,000 --> 00:29:23,000
+OpenAI has implemented a combination of automated systems and human review processes to provide feedback
+
+347
+00:29:23,000 --> 00:29:26,000
+and handle abuse detection.
+
+348
+00:29:26,000 --> 00:29:27,000
+That's it.
+
+349
+00:29:27,000 --> 00:29:28,000
+We did it.
+
+350
+00:29:29,000 --> 00:29:35,000
+We reviewed the chat API and, you know, all necessary attributes and properties in order to build
+
+351
+00:29:35,000 --> 00:29:41,000
+the ChatGPT integration and configure ChatGPT for your business needs.
+
+352
+00:29:41,000 --> 00:29:47,000
+Stay tuned because already in the next lessons, we are going to create our first application to integrate
+
+353
+00:29:47,000 --> 00:29:48,000
+with ChatGPT.
+
+354
+00:29:49,000 --> 00:29:54,000
+And in the meantime, let's just recap what we have learned in this lesson.
+
+355
+00:29:54,000 --> 00:30:01,000
+In this lesson, we learned what is the difference between chat API and completions API and when to
+
+356
+00:30:01,000 --> 00:30:02,000
+use what?
+
+357
+00:30:02,000 --> 00:30:05,000
+We learned model endpoint compatibility.
+
+358
+00:30:06,000 --> 00:30:13,000
+Now you know the difference between such roles as system, user assistant and function and you know
+
+359
+00:30:13,000 --> 00:30:18,000
+which one to use during the request and building message history.
+
+360
+00:30:18,000 --> 00:30:27,000
+And we did a detailed overview with examples of chat API attributes, such attributes as modal messages,
+
+361
+00:30:27,000 --> 00:30:31,000
+temperature, top and stream and others.
+
+362
+00:30:32,000 --> 00:30:34,000
+That's all for this lesson.
+
+363
+00:30:34,000 --> 00:30:35,000
+Thanks a lot for your attention.
+
+364
+00:30:35,000 --> 00:30:38,000
+Have a great day and see you in the next lesson.
+
diff --git a/96 - OpenAI API ChatGPT Model/001 Model-Endpoint-Compatibility.url b/96 - OpenAI API ChatGPT Model/001 Model-Endpoint-Compatibility.url
new file mode 100644
index 0000000000000000000000000000000000000000..eeb3bee1e4ee7ca890d3ded473903e7c26db75bd
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/001 Model-Endpoint-Compatibility.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/models/model-endpoint-compatibility
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/002 Deprecations.url b/96 - OpenAI API ChatGPT Model/002 Deprecations.url
new file mode 100644
index 0000000000000000000000000000000000000000..03e9503ff01f5c1d5dcc77c757991c3b68df2913
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/002 Deprecations.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/deprecations
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/002 Postman-collections.url b/96 - OpenAI API ChatGPT Model/002 Postman-collections.url
new file mode 100644
index 0000000000000000000000000000000000000000..18f592c45a91a952abebc9a1821db4f3a58f6b1b
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/002 Postman-collections.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/openai-learnit/commit/653521337332a4074e94bc8c24fcc0491d09a9fd
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/002 Send First Request to GPT API & Parse Response_en.srt b/96 - OpenAI API ChatGPT Model/002 Send First Request to GPT API & Parse Response_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..bdc603853923e54daa92fcbcfc6502b2d9b20381
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/002 Send First Request to GPT API & Parse Response_en.srt
@@ -0,0 +1,1248 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:13,000
+Today we are going to learn how to send requests to OpenAI API to interact with chat GPT model and how
+
+3
+00:00:13,000 --> 00:00:15,000
+to parse a response.
+
+4
+00:00:15,000 --> 00:00:22,000
+We are going to start the lesson from such important topic as authentication and authorization in OpenAI
+
+5
+00:00:22,000 --> 00:00:29,000
+API because without knowing this we won't be able to reach any OpenAI endpoint.
+
+6
+00:00:30,000 --> 00:00:36,000
+On real example in Postman, I'm going to show you how you need to use your secret key in order to be
+
+7
+00:00:36,000 --> 00:00:39,000
+able to access OpenAI API.
+
+8
+00:00:40,000 --> 00:00:46,000
+I'm going to teach you how you can check all available models list and we will select models that we
+
+9
+00:00:46,000 --> 00:00:47,000
+are going to use.
+
+10
+00:00:47,000 --> 00:00:54,000
+Also, I will teach you how to check deprecations and how to learn which transitions are going to happen
+
+11
+00:00:54,000 --> 00:00:55,000
+in the nearest time.
+
+12
+00:00:56,000 --> 00:01:02,000
+After that, we will send simple requests and we are going to parse the response.
+
+13
+00:01:02,000 --> 00:01:09,000
+I will focus your attention on the attributes that are returned in the response from the GPT and will
+
+14
+00:01:09,000 --> 00:01:15,000
+highlight business need of each attribute and how we are going to use them in our application.
+
+15
+00:01:15,000 --> 00:01:21,000
+This is a super important to learn before you start implementation of your own web applications that
+
+16
+00:01:21,000 --> 00:01:22,000
+uses chat.
+
+17
+00:01:22,000 --> 00:01:23,000
+GPT API.
+
+18
+00:01:24,000 --> 00:01:25,000
+Let's start our lesson.
+
+19
+00:01:26,000 --> 00:01:32,000
+So coming back to our goal, you remember that in previous lesson I showed you a high level scheme of
+
+20
+00:01:32,000 --> 00:01:37,000
+the web applications that we are going to develop, and in this lesson we are going to focus our attention
+
+21
+00:01:37,000 --> 00:01:40,000
+on the small part of that big picture.
+
+22
+00:01:40,000 --> 00:01:47,000
+Namely, we will focus our attention on the web app to OpenAI API integration.
+
+23
+00:01:47,000 --> 00:01:55,000
+Whereas on the OpenAI API side, there will be integration with chat GPT models so far and we know that
+
+24
+00:01:55,000 --> 00:02:02,000
+when I say OpenAI API, I mean all different models, including image generation, audio recognition
+
+25
+00:02:02,000 --> 00:02:05,000
+and of course text generation.
+
+26
+00:02:06,000 --> 00:02:12,000
+Today we will make requests through the Postman to the OpenAI API and in the following lessons we will
+
+27
+00:02:12,000 --> 00:02:18,000
+make this request and passing responses implemented in our web application.
+
+28
+00:02:19,000 --> 00:02:21,000
+So where to start?
+
+29
+00:02:21,000 --> 00:02:28,000
+I am going to share with you approach and will tell you how I usually do if I need to build some external
+
+30
+00:02:28,000 --> 00:02:30,000
+API integration.
+
+31
+00:02:30,000 --> 00:02:38,000
+I start with the creation of Postman collection and after I verified endpoints and I understand how
+
+32
+00:02:38,000 --> 00:02:44,000
+API works, it is like a piece of cake to translate API calls into any programming language.
+
+33
+00:02:44,000 --> 00:02:48,000
+So I start with a clarification of an API.
+
+34
+00:02:48,000 --> 00:02:51,000
+I open API reference.
+
+35
+00:02:51,000 --> 00:02:58,000
+I already did detailed overview of chat API in previous lesson, so in case you skipped previous lesson,
+
+36
+00:02:58,000 --> 00:03:00,000
+please go back and watch it.
+
+37
+00:03:00,000 --> 00:03:02,000
+It is important.
+
+38
+00:03:02,000 --> 00:03:10,000
+So we are ready to create our endpoint in Postman specially for this lesson and in order to save the
+
+39
+00:03:10,000 --> 00:03:10,000
+time.
+
+40
+00:03:10,000 --> 00:03:14,000
+During the video recording, I prepared postman collection.
+
+41
+00:03:14,000 --> 00:03:21,000
+I will add postman collection in attachments to the video and you will be able to check it on your local
+
+42
+00:03:21,000 --> 00:03:21,000
+computer.
+
+43
+00:03:22,000 --> 00:03:27,000
+I bet you know how to import postman collection into your postman.
+
+44
+00:03:27,000 --> 00:03:34,000
+If no, then just let me know in comments below the video and I will redirect you to the video where
+
+45
+00:03:34,000 --> 00:03:36,000
+I showed how to do this.
+
+46
+00:03:36,000 --> 00:03:43,000
+The only thing that you would need to substitute in all requests is your API token.
+
+47
+00:03:43,000 --> 00:03:52,000
+So let's make simple request and just say, Hey, how are you to judge GPT and see what it will answer
+
+48
+00:03:52,000 --> 00:03:52,000
+us?
+
+49
+00:03:52,000 --> 00:03:53,000
+Sounds good.
+
+50
+00:03:54,000 --> 00:03:59,000
+Here you can see the query that is called chat post messages.
+
+51
+00:03:59,000 --> 00:04:05,000
+Example number one, all the parameters are passed as Json in the request body.
+
+52
+00:04:05,000 --> 00:04:09,000
+That's why we need to review request body thoroughly.
+
+53
+00:04:09,000 --> 00:04:11,000
+So let me explain it to you.
+
+54
+00:04:11,000 --> 00:04:16,000
+In the previous lesson we did a detailed overview of endpoint and all attributes.
+
+55
+00:04:16,000 --> 00:04:21,000
+That's why I'm making an assumption that you know where to check the endpoint.
+
+56
+00:04:21,000 --> 00:04:24,000
+The answer is in API reference.
+
+57
+00:04:25,000 --> 00:04:32,000
+Also, I bet you remember that only model and messages attributes are required and all other attributes
+
+58
+00:04:32,000 --> 00:04:33,000
+are optional.
+
+59
+00:04:33,000 --> 00:04:41,000
+So the first attribute model where to take value for the model, there is a separate endpoint that you
+
+60
+00:04:41,000 --> 00:04:47,000
+can also find in the API reference and you can also find the request example in the collection.
+
+61
+00:04:47,000 --> 00:04:51,000
+Here it is called Get all available Models.
+
+62
+00:04:51,000 --> 00:04:57,000
+So the rule of thumb is before starting using some model to check the model in this list.
+
+63
+00:04:58,000 --> 00:05:05,000
+Because imagine that you copied some model from the online tutorial and it is already obsolete or some
+
+64
+00:05:05,000 --> 00:05:07,000
+model is already deprecated.
+
+65
+00:05:07,000 --> 00:05:11,000
+My recommendation always check model in this list.
+
+66
+00:05:11,000 --> 00:05:16,000
+So let's send the request to check all available models.
+
+67
+00:05:16,000 --> 00:05:21,000
+Important thing is to include your API key to each request.
+
+68
+00:05:21,000 --> 00:05:28,000
+Without API key, you won't be authorized to access any resources in OpenAI API.
+
+69
+00:05:29,000 --> 00:05:34,000
+How is the authentication and authorization is managed in OpenAI API?
+
+70
+00:05:35,000 --> 00:05:36,000
+Everything is simple.
+
+71
+00:05:36,000 --> 00:05:45,000
+You just need to add authorization header with value barrier and your key where to take your API key.
+
+72
+00:05:45,000 --> 00:05:49,000
+We already learned in previous lesson, so I don't stop on this.
+
+73
+00:05:49,000 --> 00:05:56,000
+Just to remind you it is located in your personal account in the API keys section.
+
+74
+00:05:56,000 --> 00:05:59,000
+What does bearer means in this case?
+
+75
+00:06:00,000 --> 00:06:06,000
+In this context, the word bearer is not specific to a particular language, but rather a term used
+
+76
+00:06:06,000 --> 00:06:09,000
+in web development and API authentication.
+
+77
+00:06:10,000 --> 00:06:17,000
+It is commonly used in authorization headers to specify the type of authentication token being used.
+
+78
+00:06:17,000 --> 00:06:24,000
+In this case, it means that the authentication mechanism being used is based on a token and the token
+
+79
+00:06:24,000 --> 00:06:27,000
+itself is provided after the word bearer.
+
+80
+00:06:27,000 --> 00:06:35,000
+The word bearer itself indicates that the token is being passed along with the request, allowing the
+
+81
+00:06:35,000 --> 00:06:43,000
+bearer the requester to access the protected resources or perform specific actions authorized by that
+
+82
+00:06:43,000 --> 00:06:50,000
+token, after adding this token, we can click on the send button and send the request.
+
+83
+00:06:50,000 --> 00:06:53,000
+Feel free to explore the list.
+
+84
+00:06:53,000 --> 00:06:57,000
+There are a lot of models and they will be updated over time.
+
+85
+00:06:57,000 --> 00:07:02,000
+So that's why I believe there is no need me going over each one here.
+
+86
+00:07:02,000 --> 00:07:08,000
+We agreed that we are going to use ChatGPT model in this lesson and there are different versions of
+
+87
+00:07:08,000 --> 00:07:16,000
+it, so you can just select the latest, the variations with different amount of maximum context supported.
+
+88
+00:07:16,000 --> 00:07:22,000
+So for our today's example, the maximum context size supported is not critical.
+
+89
+00:07:23,000 --> 00:07:30,000
+Once you select the model or you want to learn more about model, there is a separate endpoint that
+
+90
+00:07:30,000 --> 00:07:33,000
+allows it to fetch details only about one model.
+
+91
+00:07:34,000 --> 00:07:41,000
+As you can see, we add just the name of the model to the previous endpoint and instead of array we
+
+92
+00:07:41,000 --> 00:07:43,000
+fetch just one single model.
+
+93
+00:07:43,000 --> 00:07:46,000
+Do not forget to add authorization header.
+
+94
+00:07:47,000 --> 00:07:55,000
+I have it in each request that we are going to review today, so just don't forget to add it to another
+
+95
+00:07:55,000 --> 00:08:01,000
+important page in the documentation that I recommend you to check is the page where you can learn about
+
+96
+00:08:01,000 --> 00:08:02,000
+deprecation.
+
+97
+00:08:02,000 --> 00:08:09,000
+Here, you can learn more about what models and endpoints are being deprecated and how to transition
+
+98
+00:08:09,000 --> 00:08:10,000
+off of them.
+
+99
+00:08:10,000 --> 00:08:19,000
+There are different terms and models created in order user won't be affected and at the same time have
+
+100
+00:08:19,000 --> 00:08:22,000
+enough flexibility to start using new models earlier.
+
+101
+00:08:23,000 --> 00:08:27,000
+So just check this section time to time during the development.
+
+102
+00:08:27,000 --> 00:08:34,000
+In the deprecation log, you can find which system was replaced by which and when product or service
+
+103
+00:08:34,000 --> 00:08:37,000
+will no longer be available or supported.
+
+104
+00:08:37,000 --> 00:08:42,000
+I will add this link to the attachments of the video, so feel free to check.
+
+105
+00:08:43,000 --> 00:08:45,000
+Okay, so we selected model.
+
+106
+00:08:45,000 --> 00:08:49,000
+Let's get back to our post request and prepare it.
+
+107
+00:08:50,000 --> 00:08:55,000
+We specify model name that we selected as a value to our model attribute.
+
+108
+00:08:56,000 --> 00:08:59,000
+What else do we have in the request body?
+
+109
+00:08:59,000 --> 00:09:02,000
+The next required attribute is messages.
+
+110
+00:09:03,000 --> 00:09:05,000
+We should pass an array here.
+
+111
+00:09:06,000 --> 00:09:11,000
+I pass one system level instruction and actually the message from the user.
+
+112
+00:09:11,000 --> 00:09:15,000
+You can see that I don't use all fields.
+
+113
+00:09:15,000 --> 00:09:21,000
+For example, you have to remember that it is also possible to use name attribute for each message.
+
+114
+00:09:21,000 --> 00:09:30,000
+Object and function call, but it is just no need for the sake of this example and I don't want to overcomplicate
+
+115
+00:09:30,000 --> 00:09:31,000
+it.
+
+116
+00:09:31,000 --> 00:09:37,000
+But the things that I want to draw attention to is that when you will implement your program and you
+
+117
+00:09:37,000 --> 00:09:43,000
+would like to set the context for the model in order to receive relevant response, you would need to
+
+118
+00:09:43,000 --> 00:09:46,000
+build this array of messages.
+
+119
+00:09:46,000 --> 00:09:53,000
+I mean, building the array of messages object that will present the history of the conversation and
+
+120
+00:09:53,000 --> 00:09:55,000
+the sequence also matters.
+
+121
+00:09:55,000 --> 00:09:58,000
+The first element in array is the oldest one.
+
+122
+00:09:59,000 --> 00:10:02,000
+The latest element in the array is the newest message.
+
+123
+00:10:02,000 --> 00:10:03,000
+That's it.
+
+124
+00:10:03,000 --> 00:10:09,000
+You can also see that I have here, and which is by default is equal to one.
+
+125
+00:10:09,000 --> 00:10:13,000
+But I just decided to keep it here in the Json body in order.
+
+126
+00:10:13,000 --> 00:10:18,000
+You can reuse it if you wish and play with different values.
+
+127
+00:10:18,000 --> 00:10:22,000
+The temperature is high, the same as presence penalty.
+
+128
+00:10:22,000 --> 00:10:29,000
+So I assume that the response will be as unique as it could be to my super simple question.
+
+129
+00:10:29,000 --> 00:10:33,000
+Also, I set restriction on maximum amount of tokens.
+
+130
+00:10:33,000 --> 00:10:36,000
+The stream attribute is by default false.
+
+131
+00:10:36,000 --> 00:10:43,000
+But again, in case you would like to see how a stream feature works in the API, you can change it
+
+132
+00:10:43,000 --> 00:10:44,000
+to true and try.
+
+133
+00:10:45,000 --> 00:10:51,000
+And in general, you can spend some time playing with different attributes, asking different questions,
+
+134
+00:10:51,000 --> 00:10:58,000
+and just understand how a model will react on your requests based on different configurations.
+
+135
+00:10:58,000 --> 00:11:00,000
+Play with temperature.
+
+136
+00:11:00,000 --> 00:11:04,000
+Play with presence Penalty with max Tokens limit.
+
+137
+00:11:04,000 --> 00:11:06,000
+Try different things.
+
+138
+00:11:06,000 --> 00:11:10,000
+This will give you a better understanding of how this API works.
+
+139
+00:11:11,000 --> 00:11:15,000
+And for us right now, let me send the request.
+
+140
+00:11:16,000 --> 00:11:18,000
+And here we received the response.
+
+141
+00:11:19,000 --> 00:11:23,000
+Let me now walk you through the response and explain you.
+
+142
+00:11:23,000 --> 00:11:25,000
+What do we have here?
+
+143
+00:11:25,000 --> 00:11:31,000
+We are going to review business need and practical use cases for each of these attributes separately.
+
+144
+00:11:31,000 --> 00:11:33,000
+So let's start.
+
+145
+00:11:34,000 --> 00:11:37,000
+The first attribute here in response is ID.
+
+146
+00:11:37,000 --> 00:11:41,000
+It is a unique identifier for the chat completion request.
+
+147
+00:11:41,000 --> 00:11:42,000
+It has a string type.
+
+148
+00:11:43,000 --> 00:11:48,000
+So let's focus and understand why do we need it and how we can use this attribute.
+
+149
+00:11:48,000 --> 00:11:56,000
+You can use this ID to track or reference a specific completion in subsequent requests or for logging
+
+150
+00:11:56,000 --> 00:11:56,000
+purposes.
+
+151
+00:11:57,000 --> 00:12:04,000
+While the specific completion ID provided in the response is not directly usable for subsequent requests
+
+152
+00:12:04,000 --> 00:12:12,000
+to open the eyes API meaning that ChatGPT doesn't remember your conversation by ID, so you can't ask
+
+153
+00:12:12,000 --> 00:12:14,000
+ChatGPT about conversation.
+
+154
+00:12:14,000 --> 00:12:22,000
+You can still use this ID for tracking or referencing purposes within your own application or system.
+
+155
+00:12:22,000 --> 00:12:30,000
+I tried to come up with at least a few practical examples how you can use a G in your application login
+
+156
+00:12:30,000 --> 00:12:31,000
+and auditing.
+
+157
+00:12:32,000 --> 00:12:39,000
+You can store the completion ID along with other relevant information such as the input prompt and the
+
+158
+00:12:39,000 --> 00:12:46,000
+generated response in your own application's logs or database referencing in subsequent requests.
+
+159
+00:12:46,000 --> 00:12:52,000
+Also, the completion ID itself is not used for subsequent API requests to the GPT.
+
+160
+00:12:53,000 --> 00:13:00,000
+You can create your own system for associating the completion ID with any actions or follow up requests
+
+161
+00:13:00,000 --> 00:13:03,000
+you want to perform based on the generated completion.
+
+162
+00:13:03,000 --> 00:13:11,000
+For example, if a user responds to the assistance message, you can use the completion aid to tie the
+
+163
+00:13:11,000 --> 00:13:19,000
+user's input back to the specific completion and maintain context within your own application or use
+
+164
+00:13:19,000 --> 00:13:28,000
+completion ID to fetch the context before sending your request to the GPT tracking or monitoring by
+
+165
+00:13:28,000 --> 00:13:29,000
+storing the completion ID.
+
+166
+00:13:29,000 --> 00:13:35,000
+You can monitor various metrics or perform analytics on the generated completions.
+
+167
+00:13:35,000 --> 00:13:42,000
+For instance, you might track response times, completion quality or other relevant metrics by associating
+
+168
+00:13:42,000 --> 00:13:44,000
+them with the completion IDs.
+
+169
+00:13:45,000 --> 00:13:52,000
+The completion ID is primarily a reference point within your own application or system, allowing you
+
+170
+00:13:52,000 --> 00:13:58,000
+to organize, analyze or retrieve information related to specific completions.
+
+171
+00:13:58,000 --> 00:14:02,000
+The next attribute in response here is object.
+
+172
+00:14:02,000 --> 00:14:06,000
+It contains the type of object being returned in the response.
+
+173
+00:14:07,000 --> 00:14:14,000
+This field helps you identify the type of response you received which can be useful for parsing or handling
+
+174
+00:14:14,000 --> 00:14:16,000
+the response correctly.
+
+175
+00:14:16,000 --> 00:14:21,000
+Although it may not have immediate practical use in this specific response.
+
+176
+00:14:21,000 --> 00:14:29,000
+It serves as a helpful indicator for your code or application to identify the type of response received.
+
+177
+00:14:30,000 --> 00:14:36,000
+Here are a few scenarios where you can utilize the object field response validation.
+
+178
+00:14:36,000 --> 00:14:43,000
+When processing the API response, you can check the object field to ensure that the response is of
+
+179
+00:14:43,000 --> 00:14:45,000
+the expected type.
+
+180
+00:14:45,000 --> 00:14:52,000
+This validation step can help you catch any unexpected or incorrect responses ensuring that your code
+
+181
+00:14:52,000 --> 00:14:54,000
+is handling the data correctly.
+
+182
+00:14:55,000 --> 00:14:57,000
+A response Parsing.
+
+183
+00:14:57,000 --> 00:15:03,000
+If you have a system that handles different types or API responses, you can use the object field to
+
+184
+00:15:03,000 --> 00:15:06,000
+branch your code logic accordingly.
+
+185
+00:15:06,000 --> 00:15:13,000
+For example, you might have different parsing functions for chat completion objects compared to other
+
+186
+00:15:13,000 --> 00:15:20,000
+response types allowing you to extract and process the relevant information specific to chat completions.
+
+187
+00:15:20,000 --> 00:15:27,000
+Because imagine that you received an error and in your code you still tried to parse the content of
+
+188
+00:15:27,000 --> 00:15:32,000
+the response, which is absent and you have runtime exception.
+
+189
+00:15:32,000 --> 00:15:36,000
+That's why you can use this field to create at least if.
+
+190
+00:15:36,000 --> 00:15:39,000
+Block before starting parsing the response.
+
+191
+00:15:39,000 --> 00:15:40,000
+Is it clear?
+
+192
+00:15:41,000 --> 00:15:48,000
+Even in case something is not clear, please let me know and ask your questions below the video and
+
+193
+00:15:48,000 --> 00:15:49,000
+I will be happy to answer.
+
+194
+00:15:50,000 --> 00:15:54,000
+Error handling in the case of error responses.
+
+195
+00:15:54,000 --> 00:15:58,000
+The object field can provide valuable information.
+
+196
+00:15:58,000 --> 00:16:03,000
+For instance, if the object is set to error instead of just completion.
+
+197
+00:16:03,000 --> 00:16:10,000
+You can implement specific error handling logic based on the received response type, such as displaying
+
+198
+00:16:10,000 --> 00:16:15,000
+a user friendly error message or taking appropriate corrective actions.
+
+199
+00:16:15,000 --> 00:16:23,000
+So by incorporating the object field into your code logic, you can enhance the robustness and reliability
+
+200
+00:16:23,000 --> 00:16:26,000
+of your integration with the OpenAI API.
+
+201
+00:16:27,000 --> 00:16:30,000
+The next attribute in response is created.
+
+202
+00:16:31,000 --> 00:16:36,000
+This is a timestamp indicating when the chat completion response was created.
+
+203
+00:16:36,000 --> 00:16:42,000
+The timestamp can be used for tracking and logging purposes to determine the time of completion for
+
+204
+00:16:42,000 --> 00:16:45,000
+auditing or performance analysis.
+
+205
+00:16:45,000 --> 00:16:49,000
+Another potential use case for this field is the following.
+
+206
+00:16:50,000 --> 00:16:57,000
+Imagine that you make multiple requests simultaneously and receive different responses when multiple
+
+207
+00:16:57,000 --> 00:17:00,000
+API calls or requests are made concurrently.
+
+208
+00:17:00,000 --> 00:17:08,000
+The created timestamp can help in synchronizing or coordinating the responses by comparing the timestamp.
+
+209
+00:17:08,000 --> 00:17:14,000
+You can ensure that responses are processed and handled in the intended order.
+
+210
+00:17:15,000 --> 00:17:16,000
+The next attribute is model.
+
+211
+00:17:17,000 --> 00:17:20,000
+That is model used for generating the response.
+
+212
+00:17:20,000 --> 00:17:27,000
+And I know what you would ask why we need model in response if we submitted the model and we know the
+
+213
+00:17:27,000 --> 00:17:33,000
+model, but pay attention that we submitted one model, namely GPT 3.5 Turbo.
+
+214
+00:17:34,000 --> 00:17:41,000
+But we got clarification that our request was processed by GPT 3.5 Turbo 0301.
+
+215
+00:17:42,000 --> 00:17:49,000
+This can happen that OpenAI API will use the most relevant model that is available at the moment.
+
+216
+00:17:49,000 --> 00:17:56,000
+Knowing the specific model used can help you understand which version of the OpenAI model was responsible
+
+217
+00:17:56,000 --> 00:17:58,000
+for generating the response.
+
+218
+00:17:58,000 --> 00:18:04,000
+It is useful for reproducibility and comparing results across different model versions.
+
+219
+00:18:05,000 --> 00:18:10,000
+Usage attribute provides information about token usage for the request.
+
+220
+00:18:10,000 --> 00:18:16,000
+This field provides details about the number of tokens used in the request, including prompt tokens.
+
+221
+00:18:16,000 --> 00:18:20,000
+Tokens in the input Prompt and completion tokens.
+
+222
+00:18:20,000 --> 00:18:28,000
+Tokens in the generated completion and descending token usage can help you manage your API quota and
+
+223
+00:18:28,000 --> 00:18:31,000
+optimize the length of your requests.
+
+224
+00:18:32,000 --> 00:18:38,000
+So talking about practical use cases and how we can use data from this attribute, it's worth to mention
+
+225
+00:18:38,000 --> 00:18:39,000
+the following things.
+
+226
+00:18:40,000 --> 00:18:43,000
+Token counting and cost estimation.
+
+227
+00:18:43,000 --> 00:18:51,000
+The total tokens field tells you the total number of tokens used in the API call, including both the
+
+228
+00:18:51,000 --> 00:18:54,000
+prompt tokens and completion tokens.
+
+229
+00:18:54,000 --> 00:18:59,000
+We already learned what tokens are in previous lessons, so I wouldn't stop on this.
+
+230
+00:18:59,000 --> 00:19:07,000
+You can utilize this information to estimate the cost of the API call as pricing is often based on the
+
+231
+00:19:07,000 --> 00:19:08,000
+number of tokens processed.
+
+232
+00:19:09,000 --> 00:19:13,000
+This is probably the most important value that we can get out of this information.
+
+233
+00:19:14,000 --> 00:19:16,000
+Prompt analysis and adjustment.
+
+234
+00:19:16,000 --> 00:19:24,000
+The prompt tokens field indicates the number of tokens used for the prompt text in the API call.
+
+235
+00:19:24,000 --> 00:19:29,000
+This can help you analyze the impact of your prompt on the generated completion.
+
+236
+00:19:30,000 --> 00:19:37,000
+If you find that the prompt tokens are consuming a significant portion of token limit, you may consider
+
+237
+00:19:37,000 --> 00:19:44,000
+optimizing or adjusting your prompt to leave more tokens for the completion to generate a longer response.
+
+238
+00:19:44,000 --> 00:19:51,000
+This can be extremely beneficial for your cost management because during the implementation of your
+
+239
+00:19:51,000 --> 00:19:58,000
+application you would always have a dilemma of how much context to send with requests and is there a
+
+240
+00:19:58,000 --> 00:20:00,000
+way to optimize inputs?
+
+241
+00:20:01,000 --> 00:20:03,000
+API call optimization.
+
+242
+00:20:03,000 --> 00:20:10,000
+By analyzing the token usage, you can optimize your API calls to achieve desired results efficiently.
+
+243
+00:20:10,000 --> 00:20:17,000
+For example, if you have a specific token budget or response length requirement, you can experiment
+
+244
+00:20:17,000 --> 00:20:24,000
+with different input strategies or techniques such as providing shorter prompts or adjusting the temperature
+
+245
+00:20:24,000 --> 00:20:30,000
+setting to control the response length and maximize the utilization of available tokens.
+
+246
+00:20:31,000 --> 00:20:34,000
+The next attribute is choices.
+
+247
+00:20:34,000 --> 00:20:39,000
+This attribute contains generated completion and associated metadata.
+
+248
+00:20:40,000 --> 00:20:42,000
+It is an array of objects.
+
+249
+00:20:42,000 --> 00:20:45,000
+But when do we have multiple elements here?
+
+250
+00:20:45,000 --> 00:20:52,000
+In case an attribute in the request is more than one will have multiple array elements here.
+
+251
+00:20:52,000 --> 00:21:00,000
+So basically it contains the exact amount of items like the value of an attribute in the request.
+
+252
+00:21:00,000 --> 00:21:07,000
+The choices field contains the generated message from the assistant, along with additional information
+
+253
+00:21:07,000 --> 00:21:11,000
+such as the role of the message and the reason for finishing.
+
+254
+00:21:11,000 --> 00:21:18,000
+It is important to handle this array properly, especially if you expect multiple completions or want
+
+255
+00:21:18,000 --> 00:21:21,000
+to analyze different choices.
+
+256
+00:21:21,000 --> 00:21:24,000
+As you can see, choices is an array of objects.
+
+257
+00:21:24,000 --> 00:21:29,000
+Each object has message, finish, reason and index.
+
+258
+00:21:29,000 --> 00:21:31,000
+Let's review these properties.
+
+259
+00:21:32,000 --> 00:21:35,000
+Message with message attribute.
+
+260
+00:21:35,000 --> 00:21:36,000
+Everything is simple.
+
+261
+00:21:36,000 --> 00:21:41,000
+It contains the content of the generated message and its role.
+
+262
+00:21:42,000 --> 00:21:48,000
+Extracting the message, content and role allows you to retrieve and utilize the generated response.
+
+263
+00:21:48,000 --> 00:21:53,000
+In this case, the assistance message is provided as a response to your input.
+
+264
+00:21:53,000 --> 00:22:00,000
+You will fetch the content of this property in order to provide readable and expected response from
+
+265
+00:22:00,000 --> 00:22:02,000
+GPT to end user.
+
+266
+00:22:03,000 --> 00:22:05,000
+Everything is intuitive and simple here.
+
+267
+00:22:06,000 --> 00:22:07,000
+Let's move on.
+
+268
+00:22:08,000 --> 00:22:09,000
+Finish reason.
+
+269
+00:22:09,000 --> 00:22:13,000
+This field contains the reason why the child completion finished.
+
+270
+00:22:13,000 --> 00:22:15,000
+Finish reason can be different.
+
+271
+00:22:15,000 --> 00:22:21,000
+And I bet it would be interesting for you to learn this because based on different values of finish
+
+272
+00:22:21,000 --> 00:22:24,000
+reason, you can build different business logic.
+
+273
+00:22:24,000 --> 00:22:27,000
+So there is a following finish reasons.
+
+274
+00:22:27,000 --> 00:22:34,000
+Stop is a completion was stopped because the stop parameter was included in the API call.
+
+275
+00:22:35,000 --> 00:22:36,000
+Timeout.
+
+276
+00:22:36,000 --> 00:22:43,000
+The completion was stopped because the call exceeded the maximum allowed time for processing.
+
+277
+00:22:44,000 --> 00:22:44,000
+Error.
+
+278
+00:22:45,000 --> 00:22:50,000
+The completion was stopped due to an error or issue encountered during the processing.
+
+279
+00:22:51,000 --> 00:22:55,000
+Additional details about the error may be provided in the response.
+
+280
+00:22:56,000 --> 00:22:57,000
+Prompt error.
+
+281
+00:22:57,000 --> 00:23:03,000
+The completion was stopped because there was an error or issue with the prompt provided.
+
+282
+00:23:04,000 --> 00:23:05,000
+Length.
+
+283
+00:23:05,000 --> 00:23:11,000
+The completion was stopped because the generated response reached the maximum token limit allowed for
+
+284
+00:23:11,000 --> 00:23:14,000
+the API call user.
+
+285
+00:23:14,000 --> 00:23:21,000
+The completion was stopped due to the user intervention or action such as the user, ending the conversation
+
+286
+00:23:21,000 --> 00:23:24,000
+or providing specific instructions to stop.
+
+287
+00:23:25,000 --> 00:23:30,000
+Understanding the Finnish reason can help you determine why the completion ended.
+
+288
+00:23:30,000 --> 00:23:36,000
+Whether it reached the length limit and encountered an error or other possible reasons.
+
+289
+00:23:37,000 --> 00:23:41,000
+And knowing this, you can build your business logic on top of it.
+
+290
+00:23:42,000 --> 00:23:43,000
+Index.
+
+291
+00:23:43,000 --> 00:23:47,000
+Index property is just the index of the choice in the choices array.
+
+292
+00:23:48,000 --> 00:23:54,000
+This index can be useful if you have multiple completions and need to identify or reference a specific
+
+293
+00:23:54,000 --> 00:23:56,000
+choice within the array.
+
+294
+00:23:57,000 --> 00:23:58,000
+So that's it.
+
+295
+00:23:59,000 --> 00:24:00,000
+That's all for this lesson.
+
+296
+00:24:01,000 --> 00:24:03,000
+We did a request to ChatGPT.
+
+297
+00:24:03,000 --> 00:24:05,000
+We did an overview of the response.
+
+298
+00:24:05,000 --> 00:24:10,000
+Now you know how we can use response in order to build our business logic.
+
+299
+00:24:10,000 --> 00:24:12,000
+And we know how to parse the response.
+
+300
+00:24:12,000 --> 00:24:19,000
+Now we are ready to create our first application and write the code, but we will do it in the next
+
+301
+00:24:19,000 --> 00:24:19,000
+lesson.
+
+302
+00:24:19,000 --> 00:24:23,000
+And now let's recap what we have learned in this lesson.
+
+303
+00:24:24,000 --> 00:24:29,000
+We learned today authentication and authorization in OpenAI API.
+
+304
+00:24:29,000 --> 00:24:33,000
+Now you know where and how to use your secret API key.
+
+305
+00:24:34,000 --> 00:24:37,000
+I showed you how to fetch a list of all available models.
+
+306
+00:24:38,000 --> 00:24:43,000
+We learned where you can find information about deprecations on real examples.
+
+307
+00:24:43,000 --> 00:24:49,000
+I showed you how we can send requests to the OpenAI API GPT model via Postman.
+
+308
+00:24:49,000 --> 00:24:57,000
+We parse the response from the GPT model and we learned the business need of each attribute in the response
+
+309
+00:24:57,000 --> 00:25:00,000
+and how we are going to use them during the development.
+
+310
+00:25:00,000 --> 00:25:02,000
+That's all for today.
+
+311
+00:25:02,000 --> 00:25:04,000
+Thanks a lot for your attention.
+
+312
+00:25:04,000 --> 00:25:07,000
+Have a great day and see you in the next lesson.
+
diff --git a/96 - OpenAI API ChatGPT Model/003 Community-libraries.url b/96 - OpenAI API ChatGPT Model/003 Community-libraries.url
new file mode 100644
index 0000000000000000000000000000000000000000..74c091ca8f477118fc7c690f32aff0ba7a1436ba
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/003 Community-libraries.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/libraries/community-libraries
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/003 First Web Application with ChatGPT_en.srt b/96 - OpenAI API ChatGPT Model/003 First Web Application with ChatGPT_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..9ecf6e5a4fe6d4542c6633e9b38a1220a6f1ad4b
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/003 First Web Application with ChatGPT_en.srt
@@ -0,0 +1,1204 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, team.
+
+2
+00:00:06,000 --> 00:00:13,000
+Finally, we learned enough theory in our previous lessons and we are ready to create our first application
+
+3
+00:00:13,000 --> 00:00:16,000
+with chat GPT model and using OpenAI API.
+
+4
+00:00:16,000 --> 00:00:19,000
+That would be the main goal of this lesson.
+
+5
+00:00:20,000 --> 00:00:24,000
+We're going to start this lesson from selection of programming language that we are going to use for
+
+6
+00:00:24,000 --> 00:00:31,000
+creation of our first web application that is integrated with OpenAI API and chat GPT model.
+
+7
+00:00:32,000 --> 00:00:37,000
+I will make an overview of official libraries and frameworks supported by OpenAI.
+
+8
+00:00:37,000 --> 00:00:43,000
+Besides official libraries, I am also going to make an overview of community libraries that you can
+
+9
+00:00:43,000 --> 00:00:44,000
+also use.
+
+10
+00:00:45,000 --> 00:00:48,000
+And today we are going to have a lot of practical examples.
+
+11
+00:00:48,000 --> 00:00:54,000
+After selecting the programming language and platforms that we are going to use for development, we
+
+12
+00:00:54,000 --> 00:00:58,000
+are going to create our first web application for chat GPT Integration.
+
+13
+00:00:59,000 --> 00:01:05,000
+I'm going to share with you the source code of my example and we'll walk you through the solution.
+
+14
+00:01:05,000 --> 00:01:12,000
+I will explain not only the details of the OpenAI API integration, but we'll also share with you best
+
+15
+00:01:12,000 --> 00:01:19,000
+practices and explain applications architecture because we are going to improve this application.
+
+16
+00:01:19,000 --> 00:01:19,000
+Each lesson.
+
+17
+00:01:20,000 --> 00:01:25,000
+That's why questions of scalability and clean code design are so important.
+
+18
+00:01:25,000 --> 00:01:27,000
+Let's start our lesson.
+
+19
+00:01:27,000 --> 00:01:34,000
+We already learned how to send requests to the chat GPT and we learned how we can process the response
+
+20
+00:01:34,000 --> 00:01:36,000
+from GPT in the previous lesson.
+
+21
+00:01:36,000 --> 00:01:43,000
+Today we will develop the skeleton of our web application and will create an endpoint where we can pass
+
+22
+00:01:43,000 --> 00:01:44,000
+our query.
+
+23
+00:01:44,000 --> 00:01:49,000
+Then the request will be sent to OpenAI API to chat GPT model.
+
+24
+00:01:49,000 --> 00:01:55,000
+Our application will receive response, will parse the response and will return back.
+
+25
+00:01:55,000 --> 00:02:02,000
+Only a readable response, but not all the Json super simple that the web applications that we are going
+
+26
+00:02:02,000 --> 00:02:05,000
+to develop today taking into account.
+
+27
+00:02:05,000 --> 00:02:07,000
+This is our first application.
+
+28
+00:02:07,000 --> 00:02:13,000
+I believe this is enough to understand the concept and we will continue to build the application around
+
+29
+00:02:13,000 --> 00:02:15,000
+this integration in the following lessons.
+
+30
+00:02:15,000 --> 00:02:23,000
+So in the next lesson we will add new features and will add new details on top of the applications that
+
+31
+00:02:23,000 --> 00:02:24,000
+we are going to create today.
+
+32
+00:02:25,000 --> 00:02:30,000
+But before starting the development, we need to select programming, language and framework that we
+
+33
+00:02:30,000 --> 00:02:32,000
+are going to use.
+
+34
+00:02:32,000 --> 00:02:38,000
+Most likely the first time you have a thought to develop an application that works with OpenAI API,
+
+35
+00:02:38,000 --> 00:02:46,000
+you ask yourself what programming language to choose because as you know, the same task in programming
+
+36
+00:02:46,000 --> 00:02:52,000
+can be solved with different programming languages, but it can be done in different ways, less painful
+
+37
+00:02:52,000 --> 00:02:54,000
+and more painful.
+
+38
+00:02:54,000 --> 00:03:02,000
+Probably you heard that OpenAI API developed using Python, but that doesn't necessarily mean that you
+
+39
+00:03:02,000 --> 00:03:05,000
+also need to use Python to develop your application.
+
+40
+00:03:06,000 --> 00:03:14,000
+OpenAI provides an official python library called OpenAI that simplifies the process of making API requests
+
+41
+00:03:14,000 --> 00:03:16,000
+and interacting with their models.
+
+42
+00:03:16,000 --> 00:03:23,000
+This library is well documented and offers convenient masses for integrating Openai's language models
+
+43
+00:03:23,000 --> 00:03:25,000
+into Python applications.
+
+44
+00:03:26,000 --> 00:03:33,000
+On this screen you can see the guide how to install the Python library and start using it among other
+
+45
+00:03:33,000 --> 00:03:34,000
+official OpenAI libraries.
+
+46
+00:03:34,000 --> 00:03:40,000
+It worth to mention the library for NodeJS and Azure OpenAI Client libraries for.
+
+47
+00:03:40,000 --> 00:03:43,000
+Net JavaScript and Java.
+
+48
+00:03:43,000 --> 00:03:51,000
+So as you may already understand, it is important to note that while OpenAI API is primarily developed
+
+49
+00:03:51,000 --> 00:03:56,000
+using Python, it can be used with other programming languages as well.
+
+50
+00:03:56,000 --> 00:04:03,000
+You can make Http requests to the OpenAI API endpoints using any language that supports Http requests
+
+51
+00:04:03,000 --> 00:04:05,000
+and Json parsing.
+
+52
+00:04:05,000 --> 00:04:12,000
+OpenAI provides example and documentation for various programming languages to help developers integrate
+
+53
+00:04:12,000 --> 00:04:14,000
+with the API effectively.
+
+54
+00:04:14,000 --> 00:04:21,000
+When interacting with the OpenAI API, you have the flexibility to choose from several programming languages
+
+55
+00:04:21,000 --> 00:04:24,000
+based on your preference and requirements.
+
+56
+00:04:24,000 --> 00:04:32,000
+The OpenAI API is language agnostic and can be integrated into applications developed in various programming
+
+57
+00:04:32,000 --> 00:04:32,000
+languages.
+
+58
+00:04:32,000 --> 00:04:35,000
+Some popular options include.
+
+59
+00:04:35,000 --> 00:04:36,000
+Python.
+
+60
+00:04:36,000 --> 00:04:42,000
+Python is widely used language for machine learning and has excellent support for OpenAI libraries and
+
+61
+00:04:42,000 --> 00:04:43,000
+frameworks.
+
+62
+00:04:44,000 --> 00:04:51,000
+OpenAI provides official Python libraries such as OpenAI Python Library, which simplifies the process
+
+63
+00:04:51,000 --> 00:04:52,000
+of integration with the API.
+
+64
+00:04:53,000 --> 00:04:54,000
+JavaScript.
+
+65
+00:04:54,000 --> 00:04:56,000
+Node.js.
+
+66
+00:04:56,000 --> 00:05:03,000
+If you prefer working with JavaScript, you can use the OpenAI API with Node.js allowing you to build
+
+67
+00:05:03,000 --> 00:05:06,000
+applications for the web or server side environments.
+
+68
+00:05:07,000 --> 00:05:14,000
+The Axios library or the official OpenAI JavaScript library can help you make API requests.
+
+69
+00:05:14,000 --> 00:05:15,000
+Rabi.
+
+70
+00:05:15,000 --> 00:05:24,000
+Rabi Developers can also interact with the OpenAI API using Rabi libraries like Http Party or Faraday
+
+71
+00:05:25,000 --> 00:05:28,000
+to make API requests and handle responses.
+
+72
+00:05:29,000 --> 00:05:30,000
+Java.
+
+73
+00:05:30,000 --> 00:05:38,000
+If you are developing applications in Java, you can utilize libraries like Http or Http client to integrate
+
+74
+00:05:38,000 --> 00:05:40,000
+with the OpenAI API.
+
+75
+00:05:41,000 --> 00:05:46,000
+Go go is known for its simplicity and efficiency.
+
+76
+00:05:46,000 --> 00:05:54,000
+You can use packages like net Http or third party libraries like Gorgias to interact with the OpenAI
+
+77
+00:05:54,000 --> 00:06:03,000
+API in Go C sharp, developers working with C sharp can use libraries like Http client or rest sharp
+
+78
+00:06:03,000 --> 00:06:06,000
+to communicate with the OpenAI API.
+
+79
+00:06:07,000 --> 00:06:13,000
+These are just a few examples, and there are many more programming languages with libraries and tools
+
+80
+00:06:13,000 --> 00:06:17,000
+that can facilitate interaction with the OpenAI API.
+
+81
+00:06:17,000 --> 00:06:24,000
+Consider the strengths and familiarity of your development team and choose a language that aligns with
+
+82
+00:06:24,000 --> 00:06:26,000
+your project requirements and goals.
+
+83
+00:06:26,000 --> 00:06:32,000
+There is a development community who built and maintain libraries for different languages.
+
+84
+00:06:32,000 --> 00:06:39,000
+The fact that you need to remember that OpenAI doesn't verify the correctness and security of these
+
+85
+00:06:39,000 --> 00:06:40,000
+libraries.
+
+86
+00:06:40,000 --> 00:06:43,000
+So you use them at your own risk.
+
+87
+00:06:44,000 --> 00:06:51,000
+As you can see here, libraries for different languages, even something for C plus plus for Java,
+
+88
+00:06:51,000 --> 00:06:59,000
+Kotlin, a lot of libraries for NodeJS, PHP, Scala, Swift, so you can select whatever you need.
+
+89
+00:06:59,000 --> 00:07:04,000
+So what would we do and what language we want to select?
+
+90
+00:07:05,000 --> 00:07:12,000
+Really, I can make OpenAI API integration with any programming language because like I already said,
+
+91
+00:07:12,000 --> 00:07:17,000
+it is only a matter of sending requests and passing Json responses.
+
+92
+00:07:17,000 --> 00:07:18,000
+That's it.
+
+93
+00:07:18,000 --> 00:07:21,000
+And you can do this in any modern language.
+
+94
+00:07:22,000 --> 00:07:29,000
+But taking into account I am fan of Java and I can name hundreds of reasons why Java is the best programming
+
+95
+00:07:29,000 --> 00:07:34,000
+language and platform nowadays for web development, we would select Java.
+
+96
+00:07:34,000 --> 00:07:41,000
+You can check my course Java from zero to first job where I explain all benefits and where together
+
+97
+00:07:41,000 --> 00:07:47,000
+with my students, we develop from scratch huge enterprise application adding and learning new feature
+
+98
+00:07:47,000 --> 00:07:55,000
+each lesson and we build this online shop using Java in my course Java from zero to first job.
+
+99
+00:07:56,000 --> 00:08:05,000
+And in this course I will use Java two because it is like English language among other programming languages.
+
+100
+00:08:05,000 --> 00:08:08,000
+It is intuitive and clear for understanding for everyone.
+
+101
+00:08:08,000 --> 00:08:12,000
+Also, I will use spring boot framework for implementation.
+
+102
+00:08:12,000 --> 00:08:19,000
+If you also want to learn more about Java and Spring Boot, you are welcome to enroll in my course Java
+
+103
+00:08:19,000 --> 00:08:20,000
+from zero to first job.
+
+104
+00:08:20,000 --> 00:08:24,000
+Some other reasons of selecting Java are.
+
+105
+00:08:24,000 --> 00:08:27,000
+Java has strong and mature ecosystem.
+
+106
+00:08:27,000 --> 00:08:29,000
+It is robust and scalable.
+
+107
+00:08:30,000 --> 00:08:35,000
+Wide community support, security and many, many other different things.
+
+108
+00:08:36,000 --> 00:08:43,000
+That's why nowadays Java is a popular choice for enterprise applications and just want to highlight
+
+109
+00:08:43,000 --> 00:08:52,000
+one more time all the principles algorithms of interaction with OpenAI API will be the same no matter
+
+110
+00:08:52,000 --> 00:08:54,000
+what language you are going to use.
+
+111
+00:08:54,000 --> 00:08:57,000
+The only difference is just language syntax.
+
+112
+00:08:57,000 --> 00:09:00,000
+But all concepts are the same.
+
+113
+00:09:00,000 --> 00:09:04,000
+Programming language is just a brush in the hands of master.
+
+114
+00:09:04,000 --> 00:09:08,000
+So I am sure you will handle it too with any language.
+
+115
+00:09:09,000 --> 00:09:16,000
+And one more important note we will not rely on open source Java library because of the security and
+
+116
+00:09:16,000 --> 00:09:24,000
+correctness of work reasons and also will not use Azure OpenAI client because it contains elements related
+
+117
+00:09:24,000 --> 00:09:27,000
+to the Azure specifics and infrastructure.
+
+118
+00:09:27,000 --> 00:09:33,000
+And I want to be completely independent from any platform and be able to deploy my application in any
+
+119
+00:09:33,000 --> 00:09:35,000
+infrastructure that I want.
+
+120
+00:09:36,000 --> 00:09:42,000
+So we'll write our own application in Java and we will learn OpenAI API better.
+
+121
+00:09:43,000 --> 00:09:49,000
+Before we start, I want to highlight that all source code examples you can find in attachments to the
+
+122
+00:09:49,000 --> 00:09:49,000
+video.
+
+123
+00:09:49,000 --> 00:09:56,000
+Examples are available for learning purposes so you can clone repository locally and look through the
+
+124
+00:09:56,000 --> 00:10:01,000
+source code and touch it by playing with the code changing different parameters.
+
+125
+00:10:01,000 --> 00:10:05,000
+It would be easier for you to understand how it works.
+
+126
+00:10:05,000 --> 00:10:12,000
+So the first thing that I did in the application I generated Spring boot project using Spring initializer
+
+127
+00:10:12,000 --> 00:10:12,000
+tool.
+
+128
+00:10:13,000 --> 00:10:18,000
+I have a separate lesson about spring initializer tool in my course Java from zero to first job.
+
+129
+00:10:18,000 --> 00:10:21,000
+If you want to learn more, you can watch that lesson.
+
+130
+00:10:22,000 --> 00:10:28,000
+If you selected as a programming language to create your ChatGPT integration, you can continue watching
+
+131
+00:10:28,000 --> 00:10:33,000
+because we are going to learn key principles of building this integration in a minute.
+
+132
+00:10:34,000 --> 00:10:41,000
+Also, I want to give you a heads up that we are going to use all approach clean code design principles
+
+133
+00:10:41,000 --> 00:10:43,000
+and clean software architecture.
+
+134
+00:10:43,000 --> 00:10:50,000
+I know that my students who never worked with Java before or worked with Java but not familiar with
+
+135
+00:10:50,000 --> 00:10:56,000
+clean architecture approach would prefer to write all code in one file and they believe that it would
+
+136
+00:10:56,000 --> 00:10:58,000
+be simpler and better.
+
+137
+00:10:59,000 --> 00:11:05,000
+But I want to warn you that during the course we are going to develop powerful application and one of
+
+138
+00:11:05,000 --> 00:11:11,000
+our goals is to ensure its scalability and code reusability.
+
+139
+00:11:11,000 --> 00:11:17,000
+In other words, to make sure that adding new feature would take predictable amount of time and introducing
+
+140
+00:11:17,000 --> 00:11:21,000
+some improvements wouldn't cause rework of all application.
+
+141
+00:11:22,000 --> 00:11:26,000
+That's why I would also give comments regarding architecture as we go.
+
+142
+00:11:27,000 --> 00:11:33,000
+Let me start overview from the dependencies and libraries that we need for our today's lesson.
+
+143
+00:11:33,000 --> 00:11:42,000
+I open Pom.xml file, I added spring boot starter web dev Tools starter test from non spring libraries.
+
+144
+00:11:42,000 --> 00:11:44,000
+I added Google Sun.
+
+145
+00:11:44,000 --> 00:11:50,000
+We are going to use it when we will work with Json and apache Http client to make requests.
+
+146
+00:11:50,000 --> 00:11:53,000
+That's all what we need from dependencies.
+
+147
+00:11:53,000 --> 00:11:58,000
+Now let me open the main class where our application will be started.
+
+148
+00:11:58,000 --> 00:12:00,000
+Our entry point to the program.
+
+149
+00:12:00,000 --> 00:12:04,000
+The file is called OpenAI Application.
+
+150
+00:12:04,000 --> 00:12:09,000
+As you can see, there is regular main method like in other spring boot projects.
+
+151
+00:12:10,000 --> 00:12:14,000
+But another thing where I wanted to draw attention to is located here.
+
+152
+00:12:15,000 --> 00:12:19,000
+You can see that I added two properties files.
+
+153
+00:12:19,000 --> 00:12:24,000
+So in the first one I'm going to declare application related properties.
+
+154
+00:12:24,000 --> 00:12:25,000
+We are going to review it.
+
+155
+00:12:26,000 --> 00:12:29,000
+And another one is just for secrets.
+
+156
+00:12:29,000 --> 00:12:35,000
+Of course it is better to use secret management tools, but in order to not complicate the example with
+
+157
+00:12:35,000 --> 00:12:41,000
+cloud infrastructure and cloud API, I keep it here in properties for the sake of the demo.
+
+158
+00:12:42,000 --> 00:12:49,000
+This file in git ignore because I don't want to share my secret keys with all world.
+
+159
+00:12:49,000 --> 00:12:55,000
+So when you download my examples, you would need to add your secret keys by yourself.
+
+160
+00:12:55,000 --> 00:12:56,000
+Attention.
+
+161
+00:12:56,000 --> 00:12:58,000
+This is important.
+
+162
+00:12:58,000 --> 00:13:05,000
+I would just repeat, I'm going to share these code examples with you in order you can run them on your
+
+163
+00:13:05,000 --> 00:13:12,000
+local computer in learning purposes, but you would need to add your secret keys manually when needed.
+
+164
+00:13:12,000 --> 00:13:14,000
+During the lessons.
+
+165
+00:13:14,000 --> 00:13:17,000
+I would also make a separate note about this.
+
+166
+00:13:18,000 --> 00:13:21,000
+Now let's review my app properties file.
+
+167
+00:13:21,000 --> 00:13:28,000
+The rule of thumb is to keep all the configurations and variables outside of the source code.
+
+168
+00:13:28,000 --> 00:13:33,000
+In this file, we'll put all our non spring related configurations.
+
+169
+00:13:33,000 --> 00:13:41,000
+You can see ChatGPT configurations here and values that we'll use during requests to the ChatGPT model.
+
+170
+00:13:41,000 --> 00:13:49,000
+Basically, you can change model name temperature presence, penalty max tokens, API URL.
+
+171
+00:13:49,000 --> 00:13:58,000
+Also the two new properties for the sake of the error handling retry attempts and wait for a try seconds.
+
+172
+00:13:58,000 --> 00:14:04,000
+So in case there will be some error like timeout or endpoint is unavailable at some moment.
+
+173
+00:14:04,000 --> 00:14:12,000
+In this case we would make three more attempts and each attempt after four seconds wait time taking
+
+174
+00:14:12,000 --> 00:14:15,000
+into account these are just properties.
+
+175
+00:14:15,000 --> 00:14:22,000
+You can change them if you wish, but the current solution implemented considers the possibility of
+
+176
+00:14:22,000 --> 00:14:23,000
+retry attempts.
+
+177
+00:14:23,000 --> 00:14:31,000
+In general, this is good practice during the integration with external API because network may be down
+
+178
+00:14:31,000 --> 00:14:38,000
+or some other issues and in order to not stop processing clients requests after first attempt, we can
+
+179
+00:14:38,000 --> 00:14:40,000
+implement retry attempts.
+
+180
+00:14:41,000 --> 00:14:45,000
+The next files that I would like to review with you is beans configuration.
+
+181
+00:14:45,000 --> 00:14:49,000
+We are going to store beans configuration in this file.
+
+182
+00:14:49,000 --> 00:14:55,000
+For example, for the sake of today's demo, I have two beans configured here.
+
+183
+00:14:55,000 --> 00:15:02,000
+The first one is Sun Gson is library from Google to work with Json.
+
+184
+00:15:02,000 --> 00:15:08,000
+It has its own pros and cons and you can use other library to work with Json.
+
+185
+00:15:08,000 --> 00:15:12,000
+It's up to you, but this is the one that I selected.
+
+186
+00:15:12,000 --> 00:15:19,000
+You can see that I set field naming policy here to lowercase with underscores because we are going to
+
+187
+00:15:19,000 --> 00:15:26,000
+convert our Java objects into the request body and you saw that in GPT API.
+
+188
+00:15:26,000 --> 00:15:34,000
+We use underscores instead of Java style camel case, for example, we don't need to specify presence
+
+189
+00:15:34,000 --> 00:15:37,000
+penalty as one word in the request.
+
+190
+00:15:37,000 --> 00:15:43,000
+Instead we need presence underscore penalty with underscore in the Json.
+
+191
+00:15:43,000 --> 00:15:46,000
+The same applies for parsing the response.
+
+192
+00:15:46,000 --> 00:15:53,000
+For example finish reason attribute that we learned in previous lesson from the API response is also
+
+193
+00:15:53,000 --> 00:15:58,000
+written with underscore and it should be converted to the finish.
+
+194
+00:15:58,000 --> 00:16:00,000
+Reason Java property.
+
+195
+00:16:00,000 --> 00:16:08,000
+Here you can see commended lines where I describe the examples of the use case and remember team in
+
+196
+00:16:08,000 --> 00:16:15,000
+case something is not clear, please feel free to ask any questions below the video and I will be happy
+
+197
+00:16:15,000 --> 00:16:16,000
+to answer.
+
+198
+00:16:16,000 --> 00:16:18,000
+Let's continue.
+
+199
+00:16:18,000 --> 00:16:24,000
+The next file that I would like to review with you is GPT API Integration controller.
+
+200
+00:16:24,000 --> 00:16:31,000
+For the sake of this demo, we are going to implement simple controller that receives query, send it
+
+201
+00:16:31,000 --> 00:16:35,000
+to ChatGPT and prints the response from ChatGPT in response body.
+
+202
+00:16:35,000 --> 00:16:37,000
+You can see here get mapping.
+
+203
+00:16:37,000 --> 00:16:42,000
+That means that this endpoint is only available using get method.
+
+204
+00:16:43,000 --> 00:16:50,000
+You can also see that I used rest controller annotation just to remind you that rest controller annotation
+
+205
+00:16:50,000 --> 00:16:53,000
+is a combination of controller and response.
+
+206
+00:16:53,000 --> 00:16:58,000
+Body annotation in other responses would be written directly into the response body.
+
+207
+00:16:59,000 --> 00:17:05,000
+You can see that we have required request parameter query that should be passed by client.
+
+208
+00:17:05,000 --> 00:17:12,000
+By default, all request parameters are required until specified otherwise in the configurations here
+
+209
+00:17:13,000 --> 00:17:17,000
+and you can see that I just delegate the request to the GPT service.
+
+210
+00:17:17,000 --> 00:17:25,000
+You can see that I used auto wired annotation in order to inject bin of GPT service type here and implementation
+
+211
+00:17:25,000 --> 00:17:28,000
+of GPT service is marked as a service.
+
+212
+00:17:29,000 --> 00:17:30,000
+So let me show it to you.
+
+213
+00:17:31,000 --> 00:17:37,000
+GPT service is just an interface that declares the contract for just one method.
+
+214
+00:17:37,000 --> 00:17:42,000
+So far it receives a single question and returns the response.
+
+215
+00:17:43,000 --> 00:17:45,000
+Everything is pretty straightforward.
+
+216
+00:17:45,000 --> 00:17:49,000
+We have default implementation of this interface.
+
+217
+00:17:49,000 --> 00:17:52,000
+Let me open default GPT service class.
+
+218
+00:17:53,000 --> 00:17:59,000
+This is the class that contains the main logic of sending request parsing response.
+
+219
+00:18:00,000 --> 00:18:01,000
+Let's learn.
+
+220
+00:18:01,000 --> 00:18:02,000
+What do we have here?
+
+221
+00:18:03,000 --> 00:18:10,000
+First of all, you can see that I inject all required properties, model temperature, maximum amount
+
+222
+00:18:10,000 --> 00:18:16,000
+of tokens, literally all properties that I need for interaction with GPT model.
+
+223
+00:18:16,000 --> 00:18:23,000
+Pay attention that in case you would use my solution for testing purposes, you would need to inject
+
+224
+00:18:23,000 --> 00:18:25,000
+your own API key.
+
+225
+00:18:25,000 --> 00:18:29,000
+Also, you can see that I injected gaisen and Http client.
+
+226
+00:18:30,000 --> 00:18:34,000
+So let's jump to the implementation of get answer to single query method.
+
+227
+00:18:35,000 --> 00:18:39,000
+You can see here that I create GPT request object.
+
+228
+00:18:39,000 --> 00:18:43,000
+As I already mentioned, we are going to use our approach.
+
+229
+00:18:43,000 --> 00:18:50,000
+This will be super helpful and beneficial for us in the future when we will scale our application.
+
+230
+00:18:50,000 --> 00:18:57,000
+In our today's example, we'll convert Java, object to Json and Json to Java object.
+
+231
+00:18:58,000 --> 00:18:59,000
+In the entities package.
+
+232
+00:18:59,000 --> 00:19:02,000
+You can see that I have GP2 request type.
+
+233
+00:19:02,000 --> 00:19:06,000
+GP2 response and GP2 message types.
+
+234
+00:19:06,000 --> 00:19:11,000
+All of them reflects the data structure of the relevant entities that we already learned.
+
+235
+00:19:12,000 --> 00:19:17,000
+Take your time to review these types, but these are pure data structures.
+
+236
+00:19:18,000 --> 00:19:25,000
+Coming back to the default GP2 service class, you can see that we create GP2 request object.
+
+237
+00:19:25,000 --> 00:19:27,000
+I set the model to request.
+
+238
+00:19:27,000 --> 00:19:29,000
+Is it a mandatory attribute?
+
+239
+00:19:29,000 --> 00:19:33,000
+And another mandatory attribute is messages.
+
+240
+00:19:33,000 --> 00:19:39,000
+I create list of GPG message type and add messages to the list.
+
+241
+00:19:39,000 --> 00:19:46,000
+If you watched previous lesson, you remember that I also set system level instruction, but here it
+
+242
+00:19:46,000 --> 00:19:47,000
+is commanded.
+
+243
+00:19:47,000 --> 00:19:53,000
+So it is just to show you that you can easily add any amount of messages that you want.
+
+244
+00:19:53,000 --> 00:19:59,000
+This is exactly what we will do when we will prepare the history of the conversation.
+
+245
+00:19:59,000 --> 00:20:05,000
+But taking into account the goal of our today's lesson, we just need to send one query.
+
+246
+00:20:06,000 --> 00:20:10,000
+I will add just one question from our user and that's it.
+
+247
+00:20:10,000 --> 00:20:14,000
+Then I will set the list of messages to our request.
+
+248
+00:20:14,000 --> 00:20:19,000
+I also set temperature, presence, penalty and maximum amount of tokens.
+
+249
+00:20:19,000 --> 00:20:25,000
+Then using Json, I convert the object easily to Json and that's it.
+
+250
+00:20:26,000 --> 00:20:33,000
+To follow clean code practices, I separate the code into multiple methods and here we can see another
+
+251
+00:20:33,000 --> 00:20:37,000
+private message that would actually be in charge of sending the request.
+
+252
+00:20:37,000 --> 00:20:39,000
+Let's check it now.
+
+253
+00:20:40,000 --> 00:20:45,000
+Here you can see I create headers, authorization header and content type header.
+
+254
+00:20:45,000 --> 00:20:52,000
+Then I create http post request set headers and set my request body.
+
+255
+00:20:52,000 --> 00:20:55,000
+Then you can see for loop.
+
+256
+00:20:55,000 --> 00:21:01,000
+It is created to implement exception handling and implement retry attempts.
+
+257
+00:21:01,000 --> 00:21:08,000
+You can see that I have try catch block and in case I caught an exception, I wait for the specified
+
+258
+00:21:08,000 --> 00:21:11,000
+amount of second and try to send request.
+
+259
+00:21:11,000 --> 00:21:12,000
+One more time.
+
+260
+00:21:12,000 --> 00:21:15,000
+Sending request and passing.
+
+261
+00:21:15,000 --> 00:21:21,000
+The response is happening inside the private method that is called extract response content.
+
+262
+00:21:22,000 --> 00:21:25,000
+I pass my http post request there.
+
+263
+00:21:26,000 --> 00:21:29,000
+You can see that we call execute method here.
+
+264
+00:21:29,000 --> 00:21:35,000
+If we received some response from server, then we parse response body.
+
+265
+00:21:36,000 --> 00:21:40,000
+Additionally, I do check for bad request status code.
+
+266
+00:21:41,000 --> 00:21:48,000
+For example, in case you missed mandatory attributes or did other mistakes during the request, you
+
+267
+00:21:48,000 --> 00:21:55,000
+will enter this block and in this case, code will return the whole response body of the error.
+
+268
+00:21:55,000 --> 00:22:03,000
+If there were no any bad request status code, we pass the response directly into the response object.
+
+269
+00:22:04,000 --> 00:22:10,000
+It is done easily with the help of the sun by passing Json and mapping class.
+
+270
+00:22:11,000 --> 00:22:18,000
+Definitely there is a room for handling other edge cases and other exception scenarios, but we will
+
+271
+00:22:18,000 --> 00:22:25,000
+implement them gradually during the course as we go because we can't implement everything in one single
+
+272
+00:22:25,000 --> 00:22:25,000
+lesson.
+
+273
+00:22:26,000 --> 00:22:31,000
+So taking into account we didn't specify any other value for an attribute.
+
+274
+00:22:31,000 --> 00:22:36,000
+That means that we expect one element in choices array.
+
+275
+00:22:36,000 --> 00:22:40,000
+That's why I get the first element from the choices array.
+
+276
+00:22:40,000 --> 00:22:47,000
+I get message from the object and from message I get value of content property and send it back as a
+
+277
+00:22:47,000 --> 00:22:48,000
+response.
+
+278
+00:22:48,000 --> 00:22:51,000
+Basically, that's the whole flow.
+
+279
+00:22:52,000 --> 00:22:56,000
+The only thing that is left is to hold the demo end to end.
+
+280
+00:22:56,000 --> 00:23:00,000
+The server is up and running and spring boot application is started.
+
+281
+00:23:01,000 --> 00:23:05,000
+So I open web browser and send request to the GPT talent.
+
+282
+00:23:05,000 --> 00:23:07,000
+Hey, how are you?
+
+283
+00:23:07,000 --> 00:23:10,000
+And I receive response.
+
+284
+00:23:10,000 --> 00:23:14,000
+Remember that we set restriction for response tokens.
+
+285
+00:23:14,000 --> 00:23:17,000
+I'm talking about max tokens property.
+
+286
+00:23:17,000 --> 00:23:24,000
+So in case you wouldn't receive the whole response, you need to check finish reason and probably not
+
+287
+00:23:24,000 --> 00:23:28,000
+all response was generated because of the length restriction.
+
+288
+00:23:28,000 --> 00:23:35,000
+What finish reason is we learned in previous lesson, but as you can see, I received the whole response
+
+289
+00:23:35,000 --> 00:23:37,000
+and everything is okay.
+
+290
+00:23:37,000 --> 00:23:40,000
+So everything works as expected.
+
+291
+00:23:40,000 --> 00:23:42,000
+That's all what I have for you for today.
+
+292
+00:23:42,000 --> 00:23:46,000
+Let's recap what we have learned in this lesson.
+
+293
+00:23:46,000 --> 00:23:52,000
+Today we learned how to select programming language for OpenAI API integration.
+
+294
+00:23:52,000 --> 00:23:56,000
+We reviewed official libraries and frameworks for OpenAI API.
+
+295
+00:23:57,000 --> 00:24:00,000
+Also, we learned community libraries.
+
+296
+00:24:00,000 --> 00:24:06,000
+After selecting language and platform, we created the first web application for ChatGPT integration.
+
+297
+00:24:07,000 --> 00:24:13,000
+During the implementation, we learned architecture of the application and how clean code design practices
+
+298
+00:24:13,000 --> 00:24:14,000
+are applied.
+
+299
+00:24:15,000 --> 00:24:17,000
+That's all for this lesson.
+
+300
+00:24:17,000 --> 00:24:18,000
+Thanks a lot for your attention.
+
+301
+00:24:19,000 --> 00:24:22,000
+Have a great day and see you in the next lesson.
+
diff --git a/96 - OpenAI API ChatGPT Model/003 Official-OpenAI-Libraries.url b/96 - OpenAI API ChatGPT Model/003 Official-OpenAI-Libraries.url
new file mode 100644
index 0000000000000000000000000000000000000000..40f86af50d220ec81b1aedbf49d7f7677627d277
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/003 Official-OpenAI-Libraries.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://platform.openai.com/docs/libraries
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/003 Source-code-of-examples-from-the-lesson-commit-with-changes-.url b/96 - OpenAI API ChatGPT Model/003 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..7e22148abcea365190aa156bd7a6fb404ff2cbf1
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/003 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/openai-learnit/commit/e70e6fad019b81da4d7a3ff6bb890c0c1a82fddb
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/004 Function calling in ChatGPT_en.srt b/96 - OpenAI API ChatGPT Model/004 Function calling in ChatGPT_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..f2f901d8e618e03a2cc3b71d5ad3dd2879266489
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/004 Function calling in ChatGPT_en.srt
@@ -0,0 +1,1728 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:12,000
+Today we are going to have a lesson about the features that I extremely like in ChatGPT API.
+
+3
+00:00:12,000 --> 00:00:17,000
+Today we are going to review such feature in GPT as function calling.
+
+4
+00:00:17,000 --> 00:00:22,000
+We are going to start the lesson from understanding of what function calling is.
+
+5
+00:00:22,000 --> 00:00:27,000
+I will explain the real business need of function Calling on specific use cases.
+
+6
+00:00:27,000 --> 00:00:33,000
+I am going to explain you the algorithm of how function calling feature works.
+
+7
+00:00:33,000 --> 00:00:36,000
+We are going to review OpenAI chat API.
+
+8
+00:00:36,000 --> 00:00:41,000
+Do you remember that when we just started review of OpenAI chat GPT API?
+
+9
+00:00:42,000 --> 00:00:48,000
+I told you that we are going to review all function calling related attributes in a separate lesson.
+
+10
+00:00:48,000 --> 00:00:51,000
+So this is exactly that one lesson.
+
+11
+00:00:52,000 --> 00:00:58,000
+I am going to explain you different ways to control how GPT will respond to function calls.
+
+12
+00:00:58,000 --> 00:01:03,000
+We will review auto prompt name non configurations.
+
+13
+00:01:03,000 --> 00:01:10,000
+You are going to understand how exactly GPT model will let us know about request for a function call
+
+14
+00:01:11,000 --> 00:01:13,000
+specially for this lesson.
+
+15
+00:01:13,000 --> 00:01:19,000
+I prepared code examples that will help you understand how this feature works and how it can be useful
+
+16
+00:01:19,000 --> 00:01:20,000
+for you.
+
+17
+00:01:20,000 --> 00:01:22,000
+Let's start our lesson.
+
+18
+00:01:23,000 --> 00:01:28,000
+So let's first understand what function calling is in an API call.
+
+19
+00:01:28,000 --> 00:01:37,000
+You can specify functions for the GPT 3.5206 18 and GPT 406 18 models.
+
+20
+00:01:37,000 --> 00:01:43,000
+The model will intelligently generate a Json object containing the function arguments.
+
+21
+00:01:43,000 --> 00:01:50,000
+However, it is important to note that the chat completions API doesn't directly execute the function.
+
+22
+00:01:50,000 --> 00:01:58,000
+Instead it generates Json that you can use to call the function within your own code.
+
+23
+00:01:58,000 --> 00:02:05,000
+The latest models have been specifically fine tuned to recognize when a function should be called based
+
+24
+00:02:05,000 --> 00:02:11,000
+on the input and provide a Json response that adheres to the function's signature.
+
+25
+00:02:11,000 --> 00:02:18,000
+While this functionality opens up new possibilities, it also introduces potential risks.
+
+26
+00:02:18,000 --> 00:02:25,000
+Therefore, in the documentation, you can find a warning and recommendation to incorporate user confirmation
+
+27
+00:02:25,000 --> 00:02:33,000
+flows before taking any actions that may have real world consequences, such as sending emails, posting
+
+28
+00:02:33,000 --> 00:02:36,000
+content online, making purchases and so on.
+
+29
+00:02:37,000 --> 00:02:43,000
+If you understand in the high level what function calling is, let's understand now what are the use
+
+30
+00:02:43,000 --> 00:02:50,000
+cases of function calling and when we expect to get some business value from this feature with function
+
+31
+00:02:50,000 --> 00:02:55,000
+calling, you can enhance the reliability of obtaining structured data from the model.
+
+32
+00:02:55,000 --> 00:02:59,000
+Here are some examples of how it can be utilized.
+
+33
+00:02:59,000 --> 00:03:08,000
+Building chat bots that utilize external APIs, You can define functions like send email or get current
+
+34
+00:03:08,000 --> 00:03:16,000
+weather to enable chat bots to answer questions by calling external APIs similar to chat GPT plugins.
+
+35
+00:03:16,000 --> 00:03:24,000
+Converting natural language into API calls, you can convert queries such as who are my top customers
+
+36
+00:03:24,000 --> 00:03:32,000
+into get customers function, Call and make calls to your internal API, allowing natural language to
+
+37
+00:03:32,000 --> 00:03:35,000
+be transformed into actionable API requests.
+
+38
+00:03:36,000 --> 00:03:44,000
+Extracting structured data from text defining functions like extract data or SQL query enables you to
+
+39
+00:03:44,000 --> 00:03:51,000
+extract structured data from unstructured text, providing valuable insights or performing database
+
+40
+00:03:51,000 --> 00:03:52,000
+queries.
+
+41
+00:03:53,000 --> 00:03:57,000
+These are just few examples and the possibilities are vast.
+
+42
+00:03:57,000 --> 00:04:04,000
+Function calling empowers you to leverage the model for a wide range of applications, making it easier
+
+43
+00:04:04,000 --> 00:04:08,000
+to obtain structured data and perform specific tasks efficiently.
+
+44
+00:04:09,000 --> 00:04:15,000
+Today, I'm going to show you a real example of how function calling works, because usually with real
+
+45
+00:04:15,000 --> 00:04:18,000
+examples it is easier to understand how things work.
+
+46
+00:04:19,000 --> 00:04:26,000
+But before we jump to real example, let's review the high level algorithm of our actions in order you
+
+47
+00:04:26,000 --> 00:04:29,000
+can understand the real example better.
+
+48
+00:04:29,000 --> 00:04:36,000
+On this slide, you can see sequence diagram here, you can see function calling feature step by step.
+
+49
+00:04:37,000 --> 00:04:43,000
+The first step initiate a model call by providing the user query and the set of predefined functions
+
+50
+00:04:43,000 --> 00:04:45,000
+in the functions parameter.
+
+51
+00:04:45,000 --> 00:04:50,000
+Imagine that we asked ChatGPT What is the weather like today in our city?
+
+52
+00:04:51,000 --> 00:04:55,000
+The model can choose to call a function or not.
+
+53
+00:04:55,000 --> 00:05:02,000
+The calling function ChatGPT will analyze whether it can reply your question without external help or
+
+54
+00:05:02,000 --> 00:05:02,000
+no.
+
+55
+00:05:03,000 --> 00:05:07,000
+Also, it will check the information about functions that you have available.
+
+56
+00:05:08,000 --> 00:05:11,000
+I am going to explain you details later.
+
+57
+00:05:11,000 --> 00:05:19,000
+But in short, together with the original request, we send a list of functions available on our site
+
+58
+00:05:19,000 --> 00:05:26,000
+and if the model makes decision to call a function, the response content will be a stringified Json
+
+59
+00:05:26,000 --> 00:05:30,000
+object that conforms to your custom schema.
+
+60
+00:05:30,000 --> 00:05:37,000
+This schema should be parsed on your side in order to get arguments required to call a request function.
+
+61
+00:05:38,000 --> 00:05:46,000
+It is important to note that the generated Json may contain invalid syntax or hallucinated parameters.
+
+62
+00:05:46,000 --> 00:05:52,000
+In this particular example, we can see that GPT asks us to call get weather function with location
+
+63
+00:05:52,000 --> 00:05:53,000
+argument.
+
+64
+00:05:54,000 --> 00:05:59,000
+In your code you have to parse the string response in Json format.
+
+65
+00:05:59,000 --> 00:06:06,000
+If the provided arguments exist, call your designated function using those arguments.
+
+66
+00:06:06,000 --> 00:06:11,000
+You can see that my application sends requests to external API to get temperature for Paris.
+
+67
+00:06:12,000 --> 00:06:15,000
+External API provides us with some response.
+
+68
+00:06:15,000 --> 00:06:20,000
+Let's imagine it replied us that the temperature is 23 degrees.
+
+69
+00:06:21,000 --> 00:06:24,000
+The first process and summarize the results.
+
+70
+00:06:24,000 --> 00:06:28,000
+Make another model call by including the function response as a new message.
+
+71
+00:06:28,000 --> 00:06:34,000
+This allows the model to generate a summary or response to be presented back to the user.
+
+72
+00:06:34,000 --> 00:06:42,000
+Because this time model would have the question and enough information to reply the understand the algorithm.
+
+73
+00:06:43,000 --> 00:06:45,000
+And this is just one simple example.
+
+74
+00:06:45,000 --> 00:06:49,000
+Imagine the same algorithm but with different systems.
+
+75
+00:06:49,000 --> 00:06:57,000
+Imagine integrating with Jira, Azure, DevOps, Salesforce or any other system or integrating with
+
+76
+00:06:57,000 --> 00:06:58,000
+them simultaneously.
+
+77
+00:06:58,000 --> 00:07:06,000
+Based on your request, GPT will tell you which function you need to call and you can build your application.
+
+78
+00:07:06,000 --> 00:07:08,000
+Considering this.
+
+79
+00:07:08,000 --> 00:07:09,000
+Isn't this cool?
+
+80
+00:07:10,000 --> 00:07:12,000
+Really love this feature.
+
+81
+00:07:12,000 --> 00:07:18,000
+By following these steps, you can effectively utilize function calling to incorporate custom functions
+
+82
+00:07:18,000 --> 00:07:26,000
+into the models responses, enhancing the interactive experience and tailoring the output to specific
+
+83
+00:07:26,000 --> 00:07:27,000
+user queries.
+
+84
+00:07:27,000 --> 00:07:33,000
+Do you remember in the lesson about review of the chat API, I promised you to review function, call
+
+85
+00:07:33,000 --> 00:07:36,000
+and related attributes in the separate lesson.
+
+86
+00:07:36,000 --> 00:07:38,000
+So now it is time to review them.
+
+87
+00:07:39,000 --> 00:07:43,000
+Pay attention that in the request body you can pass functions.
+
+88
+00:07:43,000 --> 00:07:45,000
+It has a rate data type.
+
+89
+00:07:46,000 --> 00:07:52,000
+Basically that is list of functions that model may generate Json inputs for.
+
+90
+00:07:52,000 --> 00:07:55,000
+Let me say it in simpler words.
+
+91
+00:07:55,000 --> 00:08:02,000
+I tell ChatGPT model listen in my code on my side, I have such functions.
+
+92
+00:08:02,000 --> 00:08:08,000
+For each function I specify details saying to ChatGPT something like this.
+
+93
+00:08:08,000 --> 00:08:10,000
+I have this function.
+
+94
+00:08:10,000 --> 00:08:15,000
+It is called in this way and I pass the name of the function.
+
+95
+00:08:15,000 --> 00:08:23,000
+Also, this function is for these purposes and I specify this in description and in order I can call
+
+96
+00:08:23,000 --> 00:08:25,000
+this function on my side.
+
+97
+00:08:25,000 --> 00:08:27,000
+You need to give me such arguments.
+
+98
+00:08:27,000 --> 00:08:36,000
+So now ChatGPT is aware that in case there will be need in additional data or other kind of data processing
+
+99
+00:08:36,000 --> 00:08:37,000
+would be required.
+
+100
+00:08:37,000 --> 00:08:45,000
+Model can count on the fact that I have such functions on my side and in response, ChatGPT may ask
+
+101
+00:08:45,000 --> 00:08:50,000
+me to call the function and will provide me with necessary parameters for call.
+
+102
+00:08:50,000 --> 00:08:51,000
+Is it clear?
+
+103
+00:08:52,000 --> 00:08:58,000
+On this slide you can see how example of the functions may look like in Json format.
+
+104
+00:08:58,000 --> 00:09:05,000
+This is the function that we are going to send to the to the ChatGPT together with our request in request
+
+105
+00:09:05,000 --> 00:09:06,000
+body.
+
+106
+00:09:06,000 --> 00:09:08,000
+We already discussed.
+
+107
+00:09:08,000 --> 00:09:10,000
+What is the name and description for?
+
+108
+00:09:10,000 --> 00:09:17,000
+I bet you can understand that this function is for requesting the visa in a given location.
+
+109
+00:09:17,000 --> 00:09:24,000
+So in case ChatGPT model will identify that there is a need to check the weather, it will ask us to
+
+110
+00:09:24,000 --> 00:09:27,000
+use this function in parameters.
+
+111
+00:09:27,000 --> 00:09:33,000
+I specify what I need to have in order to execute the function.
+
+112
+00:09:33,000 --> 00:09:36,000
+I specify type of the parameters.
+
+113
+00:09:36,000 --> 00:09:40,000
+It is the way how I want to receive these parameters.
+
+114
+00:09:40,000 --> 00:09:47,000
+I will receive from GPT the object that will contain two properties location and unit.
+
+115
+00:09:47,000 --> 00:09:55,000
+Location will be string type and should be a city and unit will specify the expected measurement unit.
+
+116
+00:09:56,000 --> 00:10:03,000
+It will be of string type and one out of two possible values is a Celsius or Fahrenheit.
+
+117
+00:10:03,000 --> 00:10:10,000
+Also, as part of the parameters section, I specify that mandatory information that they need to call
+
+118
+00:10:10,000 --> 00:10:14,000
+this function is location s.h.a.p.e.
+
+119
+00:10:14,000 --> 00:10:20,000
+That in case it can't identify the measurement unit expected, no worries.
+
+120
+00:10:20,000 --> 00:10:21,000
+I will handle it.
+
+121
+00:10:21,000 --> 00:10:23,000
+Just provide me with location.
+
+122
+00:10:24,000 --> 00:10:28,000
+Is it clear for you what is the function property in the request body?
+
+123
+00:10:28,000 --> 00:10:29,000
+Super.
+
+124
+00:10:30,000 --> 00:10:31,000
+Let's move on.
+
+125
+00:10:31,000 --> 00:10:36,000
+But can we control when the model will decide to request a function call?
+
+126
+00:10:37,000 --> 00:10:38,000
+Yes we can.
+
+127
+00:10:38,000 --> 00:10:42,000
+There is a property that is called function call.
+
+128
+00:10:42,000 --> 00:10:43,000
+By default.
+
+129
+00:10:43,000 --> 00:10:50,000
+This value is none, meaning that no request for a function call will be raised by a model.
+
+130
+00:10:51,000 --> 00:10:59,000
+In case you provided any function, at least one in functions array, the default value will be auto.
+
+131
+00:11:00,000 --> 00:11:06,000
+Auto means that model will decide whether function call is required or not.
+
+132
+00:11:07,000 --> 00:11:09,000
+The data type is a string or object.
+
+133
+00:11:10,000 --> 00:11:13,000
+On this slide, you can see function call example.
+
+134
+00:11:14,000 --> 00:11:22,000
+You pass the object where you have attribute with name value and you pass actually the value there.
+
+135
+00:11:23,000 --> 00:11:25,000
+Taking into account this is default.
+
+136
+00:11:25,000 --> 00:11:31,000
+When we have functions, we will not use it during our live demo today because auto value is enough
+
+137
+00:11:31,000 --> 00:11:33,000
+for us in today's demo.
+
+138
+00:11:34,000 --> 00:11:37,000
+What are the possible values for function call?
+
+139
+00:11:37,000 --> 00:11:38,000
+We can pass.
+
+140
+00:11:38,000 --> 00:11:40,000
+We can use prompt value.
+
+141
+00:11:40,000 --> 00:11:47,000
+You can use a prompt to guide the model to generate a response that includes a function call.
+
+142
+00:11:48,000 --> 00:11:52,000
+You can specify name of specific function to be called.
+
+143
+00:11:53,000 --> 00:11:58,000
+Includes the function name in your conversation prompt or as part of a message.
+
+144
+00:11:58,000 --> 00:12:06,000
+When the model processes the input, it detects the function name and generates a response that is tailored
+
+145
+00:12:06,000 --> 00:12:08,000
+to the specified function.
+
+146
+00:12:08,000 --> 00:12:13,000
+The response may include a Json object containing arguments for the function call.
+
+147
+00:12:14,000 --> 00:12:18,000
+You can also find the examples with name on the slide.
+
+148
+00:12:19,000 --> 00:12:26,000
+And of course you can specify non explicitly even if you pass functions, which doesn't make sense,
+
+149
+00:12:26,000 --> 00:12:27,000
+but you can.
+
+150
+00:12:28,000 --> 00:12:30,000
+I hope that this is clear.
+
+151
+00:12:30,000 --> 00:12:31,000
+Let's continue.
+
+152
+00:12:32,000 --> 00:12:34,000
+I'm believe you still have a question.
+
+153
+00:12:34,000 --> 00:12:37,000
+How chat GPT will ask us to call a function.
+
+154
+00:12:38,000 --> 00:12:45,000
+Let's answer this question in case chat GPT would decide to ask us to make a function call.
+
+155
+00:12:45,000 --> 00:12:51,000
+Then in response we would receive a function call property as a part of a response.
+
+156
+00:12:51,000 --> 00:12:56,000
+According to the documentation message object can have function call.
+
+157
+00:12:56,000 --> 00:13:03,000
+We already had such property, but on the level of the request body and this function call is on the
+
+158
+00:13:03,000 --> 00:13:05,000
+level of the message.
+
+159
+00:13:05,000 --> 00:13:10,000
+This attribute contains the name and arguments of a function that should be called.
+
+160
+00:13:11,000 --> 00:13:18,000
+Let's review the response from ChatGPT on our simple question What is the weather like today in London
+
+161
+00:13:18,000 --> 00:13:19,000
+in Fahrenheit?
+
+162
+00:13:20,000 --> 00:13:25,000
+Pay attention to the slide to see what was the response from the model.
+
+163
+00:13:25,000 --> 00:13:29,000
+You can notice that the content of the message is now.
+
+164
+00:13:29,000 --> 00:13:37,000
+But instead I received a function call to call the function with such arguments as London and then parallel
+
+165
+00:13:37,000 --> 00:13:40,000
+Measurement unit, which is also called Fahrenheit.
+
+166
+00:13:40,000 --> 00:13:47,000
+And by the way, this is a good example of how you can't rely on ChatGPT even in such scenario.
+
+167
+00:13:47,000 --> 00:13:54,000
+Because when I send a request, I described the function and I bet you remember because we reviewed
+
+168
+00:13:54,000 --> 00:13:56,000
+it on previous slide.
+
+169
+00:13:56,000 --> 00:14:03,000
+And if you remember when I described function, I said that the second argument of a function is a measurement
+
+170
+00:14:03,000 --> 00:14:09,000
+unit, which is one out of enum values is a Celsius or Fahrenheit.
+
+171
+00:14:09,000 --> 00:14:17,000
+But GPT model didn't take the name of the property in a very seriously and it decided to put in response
+
+172
+00:14:17,000 --> 00:14:25,000
+in parallel instead of Fahrenheit, which is also fine for us as a people to understand, but not fine
+
+173
+00:14:25,000 --> 00:14:32,000
+in case we are going to use third party API because third party API will expect the values either Celsius
+
+174
+00:14:32,000 --> 00:14:36,000
+or Fahrenheit and not any other synonyms.
+
+175
+00:14:36,000 --> 00:14:38,000
+Looks interesting isn't it?
+
+176
+00:14:38,000 --> 00:14:43,000
+Is it is something that you should be aware about because in case you would build your function call
+
+177
+00:14:43,000 --> 00:14:51,000
+based on this argument, I mean in parallel, third party API may not understand it if it is developed
+
+178
+00:14:51,000 --> 00:14:53,000
+just to work with Celsius and Fahrenheit.
+
+179
+00:14:54,000 --> 00:15:00,000
+That's why my recommendation is to use description property always for each property.
+
+180
+00:15:00,000 --> 00:15:03,000
+When you submit function, let me show you something.
+
+181
+00:15:04,000 --> 00:15:06,000
+Imagine that for unit property.
+
+182
+00:15:06,000 --> 00:15:14,000
+I also added description attribute and I specified that the value should be one out of two and that's
+
+183
+00:15:14,000 --> 00:15:15,000
+it.
+
+184
+00:15:15,000 --> 00:15:17,000
+Pay attention to my request.
+
+185
+00:15:17,000 --> 00:15:18,000
+Example on the slide.
+
+186
+00:15:19,000 --> 00:15:22,000
+Can you see me adding description to the unit property?
+
+187
+00:15:22,000 --> 00:15:29,000
+And now it is enough information for the ChatGPT model in order to understand that it should provide
+
+188
+00:15:29,000 --> 00:15:34,000
+one out of two possible values and not any other synonyms.
+
+189
+00:15:34,000 --> 00:15:42,000
+And this time in response, I received Fahrenheit, which is super cool because now I can meet the requirements
+
+190
+00:15:42,000 --> 00:15:47,000
+of external visa API and handle requests for a function call properly.
+
+191
+00:15:47,000 --> 00:15:54,000
+Also pay attention that in case of request for a function, call finish reason is equal to function,
+
+192
+00:15:54,000 --> 00:15:56,000
+call and content is null.
+
+193
+00:15:56,000 --> 00:16:03,000
+In general, we removed function call and I believe that now you understand how to parse the response.
+
+194
+00:16:03,000 --> 00:16:07,000
+The only thing that is left is implementation.
+
+195
+00:16:07,000 --> 00:16:12,000
+As usual, you can find the link to the source code in attachments to the video.
+
+196
+00:16:12,000 --> 00:16:18,000
+There you can find link to the specific commit with changes to track what exactly was changed from the
+
+197
+00:16:18,000 --> 00:16:19,000
+previous lesson.
+
+198
+00:16:20,000 --> 00:16:26,000
+Even in case you would have any questions, please leave your questions below the video and I will be
+
+199
+00:16:26,000 --> 00:16:27,000
+happy to answer.
+
+200
+00:16:28,000 --> 00:16:35,000
+Anyway, I will walk you through all the changes that I did in order to implement function calling support.
+
+201
+00:16:35,000 --> 00:16:37,000
+Let's start with you from the controller.
+
+202
+00:16:38,000 --> 00:16:43,000
+I believe you watched previous lesson and remember our skeleton of the application.
+
+203
+00:16:43,000 --> 00:16:50,000
+If you didn't watch previous lesson, please get back and watch previous lesson in order to not lose
+
+204
+00:16:50,000 --> 00:16:51,000
+the context.
+
+205
+00:16:52,000 --> 00:16:53,000
+I added new endpoint.
+
+206
+00:16:54,000 --> 00:16:58,000
+This one created specially to demo how function call works.
+
+207
+00:16:58,000 --> 00:17:04,000
+Pay attention that I improved our interface a little bit in order to reuse existing code.
+
+208
+00:17:04,000 --> 00:17:09,000
+I call the same method, but something is different in comparison with the previous lesson.
+
+209
+00:17:10,000 --> 00:17:11,000
+I pass here.
+
+210
+00:17:11,000 --> 00:17:12,000
+GPT function.
+
+211
+00:17:12,000 --> 00:17:16,000
+Does it mean that this method is overloaded?
+
+212
+00:17:16,000 --> 00:17:21,000
+Because in the previous endpoint I keep using method without the second parameter.
+
+213
+00:17:21,000 --> 00:17:25,000
+And in the new endpoint I use method with two parameters.
+
+214
+00:17:25,000 --> 00:17:28,000
+Now the method is not overloaded.
+
+215
+00:17:28,000 --> 00:17:30,000
+Let me show you the source code of this method.
+
+216
+00:17:30,000 --> 00:17:35,000
+And after that we'll get back to the question what GPT function is.
+
+217
+00:17:36,000 --> 00:17:42,000
+So the implementation of this method is located in the class with name default, GPT service.
+
+218
+00:17:43,000 --> 00:17:46,000
+In Java we have such thing as variable arguments.
+
+219
+00:17:47,000 --> 00:17:55,000
+It is called so because this method can take variable number of values of GPT function type from zero
+
+220
+00:17:55,000 --> 00:18:00,000
+to the amount limited only by integer value inside the method.
+
+221
+00:18:00,000 --> 00:18:03,000
+I will work with it as with an array.
+
+222
+00:18:03,000 --> 00:18:07,000
+As you can see here, nothing is changed from the previous lesson.
+
+223
+00:18:07,000 --> 00:18:14,000
+I create object of my request and in message temperature, presence, penalty, max tokens.
+
+224
+00:18:14,000 --> 00:18:21,000
+And here I added if statement, I check if there are any functions passed to the method.
+
+225
+00:18:21,000 --> 00:18:28,000
+And if yes, then I convert array to list and set them to my GPT request.
+
+226
+00:18:29,000 --> 00:18:35,000
+So as you may already guess, I added functions property to the request entity.
+
+227
+00:18:35,000 --> 00:18:37,000
+Everything is standard.
+
+228
+00:18:37,000 --> 00:18:40,000
+I added property getters and setters.
+
+229
+00:18:40,000 --> 00:18:42,000
+I will not step on this too much.
+
+230
+00:18:42,000 --> 00:18:44,000
+Everything is pretty straightforward here.
+
+231
+00:18:44,000 --> 00:18:47,000
+But let's finally understand what GPT.
+
+232
+00:18:47,000 --> 00:18:48,000
+Function is.
+
+233
+00:18:49,000 --> 00:18:56,000
+GPT function class is data structure object representation of the function from the functions array
+
+234
+00:18:56,000 --> 00:18:58,000
+from our request body.
+
+235
+00:18:58,000 --> 00:19:02,000
+Do you remember I showed you on the slides function?
+
+236
+00:19:02,000 --> 00:19:07,000
+So basically this is it's object oriented representation.
+
+237
+00:19:07,000 --> 00:19:11,000
+You can see here is name, attribute, description and parameters.
+
+238
+00:19:11,000 --> 00:19:17,000
+And if you remember, parameters are described as type of the parameter and properties.
+
+239
+00:19:18,000 --> 00:19:24,000
+I know and completely understand that this may sound confusing and of course if I would develop this
+
+240
+00:19:24,000 --> 00:19:33,000
+API, I wouldn't name attribute in plural and have object data type because plural attributes are always
+
+241
+00:19:33,000 --> 00:19:39,000
+for collection of elements, but it is what it is and we have to follow this naming convention.
+
+242
+00:19:39,000 --> 00:19:47,000
+So parameters is an object and you specify type is that you expect ChatGPT would generate for you in
+
+243
+00:19:47,000 --> 00:19:48,000
+order.
+
+244
+00:19:48,000 --> 00:19:51,000
+You can run the function and properties that you need.
+
+245
+00:19:52,000 --> 00:20:00,000
+In our specific example you can see parameters is an inner class and it uses parameter properties according
+
+246
+00:20:00,000 --> 00:20:01,000
+to our architecture.
+
+247
+00:20:01,000 --> 00:20:09,000
+Parameter properties is a marker interface and in the future, when we will scale our application and
+
+248
+00:20:09,000 --> 00:20:15,000
+when we will add new functions, we can create different parameter properties implementation and set
+
+249
+00:20:15,000 --> 00:20:21,000
+them here For our today's demo we have only one implementation of parameter properties.
+
+250
+00:20:21,000 --> 00:20:24,000
+It is called weather parameter Properties.
+
+251
+00:20:24,000 --> 00:20:26,000
+Let me show it to you.
+
+252
+00:20:26,000 --> 00:20:29,000
+I open class was a parameter properties.
+
+253
+00:20:29,000 --> 00:20:34,000
+Here you can see on the two properties location and measurement unit.
+
+254
+00:20:34,000 --> 00:20:39,000
+These are two attributes that we would need to run the function on our end.
+
+255
+00:20:39,000 --> 00:20:43,000
+I'm going to show you the function that we are going to execute in a few minutes.
+
+256
+00:20:44,000 --> 00:20:45,000
+Nothing special here.
+
+257
+00:20:45,000 --> 00:20:52,000
+Again, if you follow the video lesson attentively, I bet you remember that I showed you this data
+
+258
+00:20:52,000 --> 00:20:54,000
+structure in Json on the slides.
+
+259
+00:20:55,000 --> 00:20:59,000
+My measurement unit has type description and enum values.
+
+260
+00:21:00,000 --> 00:21:07,000
+Do not forget to add descriptions in order to avoid some possible misinterpretations of the GPT model.
+
+261
+00:21:07,000 --> 00:21:13,000
+So we have data structures and it looks like we have everything what we need.
+
+262
+00:21:13,000 --> 00:21:15,000
+But we're actually in my application.
+
+263
+00:21:15,000 --> 00:21:20,000
+I create a GPT function, objects that we will set into GP2 request.
+
+264
+00:21:21,000 --> 00:21:24,000
+I open bins configuration class.
+
+265
+00:21:24,000 --> 00:21:31,000
+I decided to declare a function as a bin and believes this is more convenient than declare the function
+
+266
+00:21:31,000 --> 00:21:32,000
+during the request preparation.
+
+267
+00:21:33,000 --> 00:21:37,000
+In this way I can reuse this bin whenever I need.
+
+268
+00:21:37,000 --> 00:21:40,000
+You can see that in the bins configuration class.
+
+269
+00:21:40,000 --> 00:21:43,000
+I have separate bin configuration.
+
+270
+00:21:43,000 --> 00:21:46,000
+I create an object of function type.
+
+271
+00:21:46,000 --> 00:21:49,000
+I set function name description.
+
+272
+00:21:49,000 --> 00:21:51,000
+I create parameters object.
+
+273
+00:21:51,000 --> 00:21:54,000
+I set type and required parameters.
+
+274
+00:21:54,000 --> 00:21:58,000
+In our example, we are going to have only location as required parameter.
+
+275
+00:21:58,000 --> 00:22:02,000
+Now create object of weather parameter properties.
+
+276
+00:22:02,000 --> 00:22:09,000
+I set location property with description and measurement unit property with description and enum values.
+
+277
+00:22:10,000 --> 00:22:12,000
+Now we are all good.
+
+278
+00:22:12,000 --> 00:22:14,000
+Our function is ready.
+
+279
+00:22:14,000 --> 00:22:21,000
+And coming back to the GPT API integration controller, you can see that I inject my GPT function in
+
+280
+00:22:21,000 --> 00:22:29,000
+this class and in case client reaches demo function calling GPT endpoint, I pass this function to our
+
+281
+00:22:29,000 --> 00:22:30,000
+GPT service.
+
+282
+00:22:30,000 --> 00:22:38,000
+You can see that I used qualifier GPT weather function in order to inject here the function that I need
+
+283
+00:22:38,000 --> 00:22:45,000
+because theoretically in the future I may have multiple functions and I want to have control over which
+
+284
+00:22:45,000 --> 00:22:47,000
+function I add to request.
+
+285
+00:22:48,000 --> 00:22:54,000
+And then in GPT, service happened everything like we reviewed today and in the previous lesson.
+
+286
+00:22:54,000 --> 00:22:59,000
+So basically I just added functions to the original GPT request.
+
+287
+00:22:59,000 --> 00:23:03,000
+Probably now it is time to understand what happens next.
+
+288
+00:23:03,000 --> 00:23:07,000
+What happens when we receive response from the ChatGPT?
+
+289
+00:23:07,000 --> 00:23:09,000
+Let's review it together.
+
+290
+00:23:09,000 --> 00:23:16,000
+As you remember from the previous lesson, we send requests and parse response from GPT in the extract
+
+291
+00:23:16,000 --> 00:23:18,000
+GPT response content method.
+
+292
+00:23:18,000 --> 00:23:27,000
+Here I added improvements to I get function call from the message and in case it is not null, that
+
+293
+00:23:27,000 --> 00:23:31,000
+means that GPT model has a request for a function call.
+
+294
+00:23:31,000 --> 00:23:34,000
+In this case I create function.
+
+295
+00:23:34,000 --> 00:23:39,000
+I use function factory that generates function based on the name of the function.
+
+296
+00:23:40,000 --> 00:23:44,000
+By the way, do you remember how this architecture design pattern is called?
+
+297
+00:23:44,000 --> 00:23:50,000
+Puts the video on pause for a minute and try to remember if you are a student of my course Java from
+
+298
+00:23:50,000 --> 00:23:54,000
+zero to first job and you already learned Gof design patterns.
+
+299
+00:23:54,000 --> 00:23:59,000
+You should remember that this is implementation of factory method pattern.
+
+300
+00:23:59,000 --> 00:24:02,000
+But let's understand how it is implemented.
+
+301
+00:24:02,000 --> 00:24:06,000
+Function factory is injected with auto wired annotation.
+
+302
+00:24:07,000 --> 00:24:09,000
+Let's open its source code.
+
+303
+00:24:10,000 --> 00:24:12,000
+I opened the source code of function factory.
+
+304
+00:24:12,000 --> 00:24:19,000
+We are going to review this class first and then we'll review function interface and its implementation.
+
+305
+00:24:19,000 --> 00:24:26,000
+You can see that function factory is marked with service annotation during the instantiation of the
+
+306
+00:24:26,000 --> 00:24:27,000
+object of this type.
+
+307
+00:24:27,000 --> 00:24:35,000
+I also create annotation config application context object based on the beans configuration class and
+
+308
+00:24:35,000 --> 00:24:38,000
+my factory method looks as simple as follows.
+
+309
+00:24:38,000 --> 00:24:42,000
+I extract beans from the context by its name.
+
+310
+00:24:42,000 --> 00:24:46,000
+Looks good, so no switch case statements?
+
+311
+00:24:46,000 --> 00:24:46,000
+No.
+
+312
+00:24:46,000 --> 00:24:49,000
+If else blocks just one line.
+
+313
+00:24:50,000 --> 00:24:51,000
+How this works.
+
+314
+00:24:52,000 --> 00:24:59,000
+The thing is that in the context I can have multiple beans of function type and I just give them a name.
+
+315
+00:25:00,000 --> 00:25:02,000
+Let me open beans configuration class.
+
+316
+00:25:03,000 --> 00:25:05,000
+Can you see this configuration?
+
+317
+00:25:05,000 --> 00:25:10,000
+I declared bean with the name Get weather info in location function.
+
+318
+00:25:10,000 --> 00:25:17,000
+Theoretically, you can create any amount of functions like this and give names to them and make sure
+
+319
+00:25:17,000 --> 00:25:23,000
+that when you describe function to GPC, you specify the correct name.
+
+320
+00:25:23,000 --> 00:25:27,000
+In this case you will be able to get the beans that you need.
+
+321
+00:25:27,000 --> 00:25:33,000
+So function factory allows us to get the reference to the bean of function.
+
+322
+00:25:33,000 --> 00:25:37,000
+Let's learn what a function is in our application.
+
+323
+00:25:37,000 --> 00:25:39,000
+Function is an interface.
+
+324
+00:25:39,000 --> 00:25:44,000
+It has just one method execute that takes a string of arguments.
+
+325
+00:25:45,000 --> 00:25:50,000
+This a string of arguments in Json format that is generated for us by ChatGPT model.
+
+326
+00:25:51,000 --> 00:25:58,000
+Pay attention that we also return string in such way we can return Json representation of any data structure
+
+327
+00:25:58,000 --> 00:25:59,000
+we want.
+
+328
+00:26:00,000 --> 00:26:06,000
+This works for us just perfect because we would need to send results of the function back to the ChatGPT.
+
+329
+00:26:07,000 --> 00:26:11,000
+So the string data type works just perfect for us.
+
+330
+00:26:12,000 --> 00:26:15,000
+Currently we have only one implementation of this interface.
+
+331
+00:26:15,000 --> 00:26:20,000
+Let me open class that is called get weather info in location function.
+
+332
+00:26:21,000 --> 00:26:27,000
+The first important thing to mention you have to understand that functions by their definition from
+
+333
+00:26:27,000 --> 00:26:29,000
+computer science.
+
+334
+00:26:29,000 --> 00:26:31,000
+They are stateless.
+
+335
+00:26:31,000 --> 00:26:33,000
+They just process the data.
+
+336
+00:26:33,000 --> 00:26:37,000
+That's it and don't have any state.
+
+337
+00:26:37,000 --> 00:26:44,000
+This is important to understand because we declared this function as a bean with singleton scope and
+
+338
+00:26:44,000 --> 00:26:49,000
+not prototype scope and web application is a multithreading environment.
+
+339
+00:26:49,000 --> 00:26:57,000
+So in case there will be some state in this bean, you would need either to set prototype scope during
+
+340
+00:26:57,000 --> 00:27:04,000
+the instantiation of this bean or to accept that the state would be changed by different threads which
+
+341
+00:27:04,000 --> 00:27:05,000
+you don't want.
+
+342
+00:27:05,000 --> 00:27:09,000
+But anyway, we can design function in the stateless manner.
+
+343
+00:27:09,000 --> 00:27:12,000
+Let's explore what do we have in this class?
+
+344
+00:27:13,000 --> 00:27:15,000
+Pay attention that I left.
+
+345
+00:27:15,000 --> 00:27:18,000
+Example of function call response from the ChatGPT.
+
+346
+00:27:19,000 --> 00:27:25,000
+So as you can see the arguments data type is string, but we can see that this is Json.
+
+347
+00:27:26,000 --> 00:27:33,000
+That means that we can parse this Json and extract values that we need to execute our function.
+
+348
+00:27:34,000 --> 00:27:36,000
+And this is the first thing that I do here.
+
+349
+00:27:37,000 --> 00:27:39,000
+This is some API here.
+
+350
+00:27:39,000 --> 00:27:49,000
+So basically you need to create type and then using Json call from Json method to map the Json to map
+
+351
+00:27:49,000 --> 00:27:51,000
+parameterized by string and string.
+
+352
+00:27:51,000 --> 00:27:57,000
+So each implementation of the function will be designed for specific purposes, right?
+
+353
+00:27:57,000 --> 00:28:04,000
+And there is an assumption that by implementing execute method in each function, you know which arguments
+
+354
+00:28:04,000 --> 00:28:05,000
+you need to parse.
+
+355
+00:28:05,000 --> 00:28:06,000
+Correct.
+
+356
+00:28:06,000 --> 00:28:11,000
+So it is up to implementation to consider the portion of the arguments.
+
+357
+00:28:11,000 --> 00:28:17,000
+And I know that according to the function description I expect to see in the arguments is a location
+
+358
+00:28:17,000 --> 00:28:19,000
+parameter or unit parameter.
+
+359
+00:28:19,000 --> 00:28:22,000
+And I get these values.
+
+360
+00:28:22,000 --> 00:28:28,000
+Then get weather info method and pass the location and measurement unit.
+
+361
+00:28:28,000 --> 00:28:35,000
+This is just hardcoded method, but theoretically you can implement any third party API integrations
+
+362
+00:28:35,000 --> 00:28:35,000
+here.
+
+363
+00:28:35,000 --> 00:28:40,000
+For now I just hardcoded some values here for the sake of example.
+
+364
+00:28:41,000 --> 00:28:49,000
+So return weather info from this method and then convert it to Json string in order to meet the requirements
+
+365
+00:28:49,000 --> 00:28:51,000
+of contract of interface.
+
+366
+00:28:51,000 --> 00:28:52,000
+That's it.
+
+367
+00:28:52,000 --> 00:28:53,000
+End team.
+
+368
+00:28:53,000 --> 00:29:00,000
+Please remember in case you have any questions, do not hesitate to post your questions below the video.
+
+369
+00:29:00,000 --> 00:29:02,000
+I will be happy to answer those.
+
+370
+00:29:03,000 --> 00:29:07,000
+So now let's get back to the GP2 service here.
+
+371
+00:29:07,000 --> 00:29:09,000
+Factory return this function.
+
+372
+00:29:09,000 --> 00:29:16,000
+Now you understand how factory works and what function is in this context.
+
+373
+00:29:16,000 --> 00:29:21,000
+I call execute method on my function and get results of work of function.
+
+374
+00:29:22,000 --> 00:29:24,000
+What I have to do next.
+
+375
+00:29:24,000 --> 00:29:27,000
+I need to create message with function role.
+
+376
+00:29:27,000 --> 00:29:30,000
+As you can see, I set function role here.
+
+377
+00:29:31,000 --> 00:29:34,000
+I set the name of the function to the name attribute.
+
+378
+00:29:34,000 --> 00:29:41,000
+I set the function response as a content to the message and now pay attention to one more change that
+
+379
+00:29:41,000 --> 00:29:44,000
+I implemented in comparison to the previous lesson.
+
+380
+00:29:45,000 --> 00:29:51,000
+I passed GP2 request to the method not just request body but GP2 request.
+
+381
+00:29:51,000 --> 00:29:53,000
+Why I do so?
+
+382
+00:29:53,000 --> 00:30:00,000
+Because after receiving function results I need to send request to ChatGPT one more time.
+
+383
+00:30:00,000 --> 00:30:07,000
+And in order to not build GP2 request and message history, again I just add message to the messages
+
+384
+00:30:07,000 --> 00:30:10,000
+array and in such way I build history.
+
+385
+00:30:10,000 --> 00:30:16,000
+As a result, I have message history, the history of our conversation.
+
+386
+00:30:16,000 --> 00:30:19,000
+Pay attention that this time I set function to null.
+
+387
+00:30:20,000 --> 00:30:21,000
+Why I do so?
+
+388
+00:30:21,000 --> 00:30:30,000
+It is an example of tokens usage optimization internally in OpenAI API functions are included in the
+
+389
+00:30:30,000 --> 00:30:34,000
+system message using a syntax that the model has been trained on.
+
+390
+00:30:34,000 --> 00:30:42,000
+It's important to remember that functions count towards the models context limit and are built as input
+
+391
+00:30:42,000 --> 00:30:43,000
+tokens.
+
+392
+00:30:43,000 --> 00:30:50,000
+So keep this in mind in case you want to send hundreds of functions with each GPT request.
+
+393
+00:30:50,000 --> 00:30:51,000
+This is important.
+
+394
+00:30:52,000 --> 00:30:57,000
+So to sum it up, let me show you in this slide how our second request will look like.
+
+395
+00:30:58,000 --> 00:30:59,000
+Pay attention.
+
+396
+00:30:59,000 --> 00:31:01,000
+Preserve message history.
+
+397
+00:31:01,000 --> 00:31:04,000
+I added function result and I removed function.
+
+398
+00:31:05,000 --> 00:31:08,000
+Please press a pause for a minute.
+
+399
+00:31:08,000 --> 00:31:13,000
+Take a look at this data structure and seeing whether you have some questions.
+
+400
+00:31:14,000 --> 00:31:16,000
+If no, then let's continue.
+
+401
+00:31:17,000 --> 00:31:20,000
+So I need to send request one more time.
+
+402
+00:31:20,000 --> 00:31:28,000
+That's why I make recursive call to the get response from GPT and it will end up skipping this if block
+
+403
+00:31:28,000 --> 00:31:35,000
+during the next response because we will not have function call and extracting the content and sending
+
+404
+00:31:35,000 --> 00:31:37,000
+the response back to the client.
+
+405
+00:31:37,000 --> 00:31:39,000
+Let's check how it works.
+
+406
+00:31:39,000 --> 00:31:40,000
+End to end.
+
+407
+00:31:41,000 --> 00:31:47,000
+I open the browser and send the request to the ChatGPT asking What is the weather like today in Paris
+
+408
+00:31:47,000 --> 00:31:48,000
+in Celsius?
+
+409
+00:31:49,000 --> 00:31:51,000
+And I receive response.
+
+410
+00:31:51,000 --> 00:31:58,000
+The response is based on our function call, and I believe that you already can understand what is happening
+
+411
+00:31:58,000 --> 00:31:59,000
+on the background.
+
+412
+00:31:59,000 --> 00:32:07,000
+What will be in case I would remove in Celsius, take into account we have only location required attribute
+
+413
+00:32:07,000 --> 00:32:14,000
+GPT model would still request us to call the function on our end because it can provide us with the
+
+414
+00:32:14,000 --> 00:32:15,000
+location.
+
+415
+00:32:15,000 --> 00:32:22,000
+In this case, GPT model is smart enough to apply Celsius automatically because in France people use
+
+416
+00:32:22,000 --> 00:32:23,000
+Celsius.
+
+417
+00:32:24,000 --> 00:32:31,000
+But what will happen in case I wouldn't specify location, what will happen in case, I would just ask
+
+418
+00:32:31,000 --> 00:32:33,000
+what is the weather like today?
+
+419
+00:32:34,000 --> 00:32:41,000
+And as you can see, GPT model will not request me to invoke the function because it can't provide me
+
+420
+00:32:41,000 --> 00:32:43,000
+with necessary arguments.
+
+421
+00:32:43,000 --> 00:32:44,000
+Isn't this cool?
+
+422
+00:32:45,000 --> 00:32:47,000
+ChatGPT is really smart.
+
+423
+00:32:47,000 --> 00:32:54,000
+So today we didn't have the easiest lesson, but I'm sure you learned a lot of useful things.
+
+424
+00:32:54,000 --> 00:32:57,000
+Let's recap what we have learned today.
+
+425
+00:32:57,000 --> 00:33:01,000
+Today we learned what a function calling in ChatGPT model is.
+
+426
+00:33:02,000 --> 00:33:07,000
+I explained business need and real use cases of using this feature.
+
+427
+00:33:07,000 --> 00:33:12,000
+I believe that after this lesson you have understanding of function calling algorithm.
+
+428
+00:33:13,000 --> 00:33:20,000
+We learned OpenAI chat API, namely all the attributes that are related to the function calling.
+
+429
+00:33:20,000 --> 00:33:26,000
+And at the end of the lesson we learned and reviewed real code examples with function calling feature.
+
+430
+00:33:27,000 --> 00:33:29,000
+That's all what I have for you for today.
+
+431
+00:33:29,000 --> 00:33:31,000
+Thanks a lot for your attention.
+
+432
+00:33:31,000 --> 00:33:34,000
+Have a great day and see you in the next lesson.
+
diff --git a/96 - OpenAI API ChatGPT Model/004 Source-code-of-examples-from-the-lesson-commit-with-changes-.url b/96 - OpenAI API ChatGPT Model/004 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..0c9ea502ac6f394e8997bab01bfdc26130930218
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/004 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/openai-learnit/commit/2e89c25855024e06a88df66f08a1811d07419dad
\ No newline at end of file
diff --git a/96 - OpenAI API ChatGPT Model/005 GPT Best Practices_en.srt b/96 - OpenAI API ChatGPT Model/005 GPT Best Practices_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..17dd728f74bfeeec054c080c36e97133d51faf36
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/005 GPT Best Practices_en.srt
@@ -0,0 +1,1636 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:10,000
+In this lesson we are going to discuss best practices of using ChatGPT.
+
+3
+00:00:10,000 --> 00:00:17,000
+In this lesson I'm going to discuss with you various strategies and tactics aimed at maximizing the
+
+4
+00:00:17,000 --> 00:00:19,000
+performance of GPT models.
+
+5
+00:00:20,000 --> 00:00:28,000
+You can use methods from this lesson to achieve enhanced results, but still, I highly encourage experimentation
+
+6
+00:00:28,000 --> 00:00:35,000
+to identify the approaches that will provide you with the best outcomes for your specific business case.
+
+7
+00:00:35,000 --> 00:00:41,000
+Please be aware that some of the strategies that I'm going to discuss with you today and examples provided
+
+8
+00:00:41,000 --> 00:00:48,000
+in this lesson are currently compatible exclusively with the most advanced model based on today GPT
+
+9
+00:00:48,000 --> 00:00:49,000
+four.
+
+10
+00:00:49,000 --> 00:00:53,000
+Today we are going to review six strategies for getting better results with GPT.
+
+11
+00:00:54,000 --> 00:01:03,000
+They are right Clear instructions provide reference text split complex tasks into simpler subtasks.
+
+12
+00:01:03,000 --> 00:01:05,000
+Give GPT its time to sing.
+
+13
+00:01:05,000 --> 00:01:11,000
+Use external tools test changes systematically for each strategy.
+
+14
+00:01:11,000 --> 00:01:17,000
+There is a set of tactics that would help us to implement strategy and of course we are going to review
+
+15
+00:01:17,000 --> 00:01:20,000
+a lot of different examples today.
+
+16
+00:01:20,000 --> 00:01:22,000
+Let's start our lesson.
+
+17
+00:01:22,000 --> 00:01:27,000
+So let's jump straight to the topic and review each strategy one by one.
+
+18
+00:01:28,000 --> 00:01:30,000
+We're going to start with the first strategy.
+
+19
+00:01:30,000 --> 00:01:32,000
+Write clear instructions.
+
+20
+00:01:32,000 --> 00:01:37,000
+It sounds logical and probably the question that you have in your head.
+
+21
+00:01:37,000 --> 00:01:41,000
+What we are going to talk about is the name of the strategy is Self-describing.
+
+22
+00:01:41,000 --> 00:01:47,000
+So just wait for a few minutes and you will understand how deep is the rabbit hole?
+
+23
+00:01:47,000 --> 00:01:53,000
+GPT models don't possess mind reading abilities to ensure desired outputs.
+
+24
+00:01:53,000 --> 00:01:59,000
+You can follow these guidelines if the responses are excessively lengthy.
+
+25
+00:01:59,000 --> 00:02:01,000
+Request shorter replies.
+
+26
+00:02:01,000 --> 00:02:07,000
+If the responses seem to basic, ask for expert level writing.
+
+27
+00:02:07,000 --> 00:02:13,000
+If you are dissatisfied with the format, provide an example of the desired format.
+
+28
+00:02:13,000 --> 00:02:20,000
+The more explicit you are about your expectations, the higher the chances of receiving the desired
+
+29
+00:02:20,000 --> 00:02:22,000
+output from GPT models.
+
+30
+00:02:22,000 --> 00:02:25,000
+So that's how strategy looks like.
+
+31
+00:02:25,000 --> 00:02:27,000
+But each strategy has tactics.
+
+32
+00:02:27,000 --> 00:02:28,000
+Agree.
+
+33
+00:02:28,000 --> 00:02:35,000
+Strategy refers to a high level plan or approach designed to achieve a specific objective or goal.
+
+34
+00:02:35,000 --> 00:02:43,000
+But tactics are specific actions, methods, or techniques used to execute a strategy and achieve short
+
+35
+00:02:43,000 --> 00:02:44,000
+term objectives.
+
+36
+00:02:44,000 --> 00:02:50,000
+They are practical and tangible steps taken to implement the broader strategy.
+
+37
+00:02:50,000 --> 00:02:55,000
+So tactics for this strategy includes the following.
+
+38
+00:02:55,000 --> 00:02:59,000
+Include details in your query to get more relevant answers.
+
+39
+00:03:00,000 --> 00:03:02,000
+Ask the model to adopt a persona.
+
+40
+00:03:02,000 --> 00:03:07,000
+Use delimiters to clearly indicate distinct parts of the input.
+
+41
+00:03:07,000 --> 00:03:11,000
+Specify the steps required to complete a task.
+
+42
+00:03:11,000 --> 00:03:13,000
+Provide examples.
+
+43
+00:03:13,000 --> 00:03:16,000
+Specify the desired length of the output.
+
+44
+00:03:17,000 --> 00:03:20,000
+Let's learn and understand each of these one by one.
+
+45
+00:03:21,000 --> 00:03:23,000
+You need to understand one simple thing.
+
+46
+00:03:24,000 --> 00:03:28,000
+GPT will never tell you that it doesn't know something.
+
+47
+00:03:28,000 --> 00:03:31,000
+That is the biggest danger of using chat GPT.
+
+48
+00:03:31,000 --> 00:03:33,000
+It never replies.
+
+49
+00:03:33,000 --> 00:03:35,000
+It doesn't know something.
+
+50
+00:03:35,000 --> 00:03:40,000
+Instead, it always answers all your questions with no doubt.
+
+51
+00:03:40,000 --> 00:03:47,000
+And in case you also don't know the answer and you don't verify GPT, you have a risk to get in troubles
+
+52
+00:03:47,000 --> 00:03:50,000
+because of wrong answers from GPT site.
+
+53
+00:03:50,000 --> 00:03:57,000
+That's why it is super important to include all details in request if you want to get relevant and correct
+
+54
+00:03:57,000 --> 00:03:58,000
+answer.
+
+55
+00:03:58,000 --> 00:04:01,000
+Take a look at examples on this slide.
+
+56
+00:04:01,000 --> 00:04:03,000
+We have two columns here.
+
+57
+00:04:03,000 --> 00:04:05,000
+What is worse and what is better?
+
+58
+00:04:05,000 --> 00:04:10,000
+You can see that in general it is better to add as much details as you can.
+
+59
+00:04:11,000 --> 00:04:16,000
+Press the pause for a minute, take a look at examples and try to understand them.
+
+60
+00:04:16,000 --> 00:04:21,000
+In case you would have any questions, please do not hesitate to ask your questions below the video
+
+61
+00:04:21,000 --> 00:04:23,000
+and I will be happy to answer.
+
+62
+00:04:24,000 --> 00:04:25,000
+Let's move on.
+
+63
+00:04:25,000 --> 00:04:33,000
+The next tactic is to ask model to adopt a persona, and this feature stays undervalued very often.
+
+64
+00:04:33,000 --> 00:04:42,000
+If you watch my course about Open API, you already saw us using system level instructions and you know
+
+65
+00:04:42,000 --> 00:04:48,000
+that you can submit messages to the GPT with different roles, including system role.
+
+66
+00:04:48,000 --> 00:04:52,000
+So use system role to adopt the persona.
+
+67
+00:04:52,000 --> 00:04:56,000
+Before you get to your question, you can check examples on the slide.
+
+68
+00:04:57,000 --> 00:05:03,000
+In this example, I give instructions how documents should be written that it should contain at least
+
+69
+00:05:03,000 --> 00:05:06,000
+one joke or playful comment in every paragraph.
+
+70
+00:05:07,000 --> 00:05:12,000
+I instructed GPT how to reply and only after that I submit prompt.
+
+71
+00:05:13,000 --> 00:05:17,000
+Once you finish review of example, we can move to the next slide.
+
+72
+00:05:18,000 --> 00:05:24,000
+And believes that tactics to use the limiters to clearly indicate distinct parts of the input is obvious
+
+73
+00:05:24,000 --> 00:05:25,000
+by its name.
+
+74
+00:05:26,000 --> 00:05:31,000
+Don't make GPT work to understand exactly what you are asking of it.
+
+75
+00:05:31,000 --> 00:05:33,000
+You can use different delimiters.
+
+76
+00:05:33,000 --> 00:05:42,000
+You can use delimiters such as triple quotation marks, XML tags, section titles or other similar markers
+
+77
+00:05:42,000 --> 00:05:49,000
+to indicate distinct sections of text that should be treated differently or have specific format and
+
+78
+00:05:49,000 --> 00:05:50,000
+applied to them.
+
+79
+00:05:51,000 --> 00:05:59,000
+In the example you can see how I use XML tag in system level instruction to warn GPT that I'm going
+
+80
+00:05:59,000 --> 00:06:01,000
+to use XML tags as delimiters.
+
+81
+00:06:02,000 --> 00:06:09,000
+The next tactic is to specify the steps required to complete a task specifying certain tasks as a sequence
+
+82
+00:06:09,000 --> 00:06:18,000
+of explicit steps can greatly facilitate the model's understanding and adherence to the intended process.
+
+83
+00:06:18,000 --> 00:06:26,000
+Breaking down tasks into distinct steps provides clear guidance for the model, enabling smoother execution
+
+84
+00:06:26,000 --> 00:06:28,000
+and more accurate results.
+
+85
+00:06:29,000 --> 00:06:34,000
+Pay attention to the slide and look how I utilized the system level command.
+
+86
+00:06:35,000 --> 00:06:40,000
+I describe the algorithm and only then goes user input.
+
+87
+00:06:40,000 --> 00:06:48,000
+In most cases, it is more efficient to provide general instructions that apply to all examples rather
+
+88
+00:06:48,000 --> 00:06:51,000
+than demonstrating every possible variation of a task.
+
+89
+00:06:51,000 --> 00:06:58,000
+However, there are instances where often specific examples can be easier and more effective.
+
+90
+00:06:58,000 --> 00:07:06,000
+For instance, when you want the model to emulate a specific style of responding to user queries, that
+
+91
+00:07:06,000 --> 00:07:08,000
+is challenging to describe explicitly.
+
+92
+00:07:08,000 --> 00:07:11,000
+Providing examples becomes valuable.
+
+93
+00:07:11,000 --> 00:07:18,000
+This approach is referred to as few shot prompting, whereas the model learns from a limited set of
+
+94
+00:07:18,000 --> 00:07:21,000
+examples to generalize its behavior.
+
+95
+00:07:21,000 --> 00:07:24,000
+Feel free to explore examples on the slide.
+
+96
+00:07:24,000 --> 00:07:30,000
+In the first example, I asked to write a review in the style of a passionate fan.
+
+97
+00:07:30,000 --> 00:07:37,000
+And in the second example, I asked to compose a poem about nature in the style of Robert Frost.
+
+98
+00:07:37,000 --> 00:07:38,000
+Pay attention.
+
+99
+00:07:38,000 --> 00:07:46,000
+I didn't submit all poems of Robert Frost in order ChatGPT would analyze the style, but I provided
+
+100
+00:07:46,000 --> 00:07:50,000
+general instructions that apply to all examples.
+
+101
+00:07:51,000 --> 00:07:55,000
+The next tactic is about setting the limit of the output.
+
+102
+00:07:55,000 --> 00:07:58,000
+You can specify the desired length of the output.
+
+103
+00:07:58,000 --> 00:08:06,000
+This is extremely useful when you understand that in the chat environment, long answers are not applicable
+
+104
+00:08:06,000 --> 00:08:14,000
+because sometimes ChatGPT loves to talk and it generates really long answers and a lot of paragraphs.
+
+105
+00:08:14,000 --> 00:08:20,000
+But you have the flexibility to instruct the model to generate outputs of desired lengths.
+
+106
+00:08:20,000 --> 00:08:27,000
+The lengths can be defined based on word count, sentence count, paragraph, count, bullet points
+
+107
+00:08:27,000 --> 00:08:28,000
+and more.
+
+108
+00:08:28,000 --> 00:08:36,000
+It's important to note that while specifying the number of words may not give you precise result, the
+
+109
+00:08:36,000 --> 00:08:43,000
+model is generally more accurate when generating a specific number of paragraphs or bullet points.
+
+110
+00:08:43,000 --> 00:08:46,000
+Please explore examples on the slide.
+
+111
+00:08:47,000 --> 00:08:51,000
+So we reviewed just first strategies this code right?
+
+112
+00:08:51,000 --> 00:08:52,000
+Clear instructions.
+
+113
+00:08:52,000 --> 00:08:59,000
+I believe that now your understanding is deeper than before, and we reviewed a lot of different examples.
+
+114
+00:08:59,000 --> 00:09:02,000
+So let's continue with the next strategy.
+
+115
+00:09:02,000 --> 00:09:08,000
+Now, the next strategy from our agenda is called provide reference Text.
+
+116
+00:09:08,000 --> 00:09:16,000
+I already said that the biggest danger of ChatGPT is that it can confidently invent fake answers.
+
+117
+00:09:16,000 --> 00:09:22,000
+It can do it so good that you wouldn't even have a doubt that it doesn't know the right answer.
+
+118
+00:09:22,000 --> 00:09:26,000
+If you are not very familiar with the topic of your question.
+
+119
+00:09:26,000 --> 00:09:33,000
+That's why providing reference text to GPT can help in answering with a few fabrications.
+
+120
+00:09:34,000 --> 00:09:38,000
+In scope of this strategy, I would like to discuss with you the following two tactics.
+
+121
+00:09:38,000 --> 00:09:42,000
+Instruct the model to answer using a reference text.
+
+122
+00:09:42,000 --> 00:09:46,000
+Instruct the model to answer with citations from a reference text.
+
+123
+00:09:47,000 --> 00:09:48,000
+Let's review tactics.
+
+124
+00:09:48,000 --> 00:09:55,000
+That is called Instruct the model to answer using a reference text by supplying the model with relevant
+
+125
+00:09:55,000 --> 00:09:58,000
+and trusted information related to the current query.
+
+126
+00:09:58,000 --> 00:10:04,000
+We can guide the model to utilize that information in formulating its response.
+
+127
+00:10:04,000 --> 00:10:11,000
+This allows us to leverage the provided data to enhance the accuracy of the model's answers.
+
+128
+00:10:11,000 --> 00:10:13,000
+Take a look at the example on the slide.
+
+129
+00:10:14,000 --> 00:10:22,000
+In the system level instruction I specified vividly in case answer can't be found in the article, then
+
+130
+00:10:22,000 --> 00:10:28,000
+tell me that there is no answer to the question where specific in the definition of the behavior.
+
+131
+00:10:29,000 --> 00:10:36,000
+The next tactic is called Instruct the model to answer with citations from a reference text.
+
+132
+00:10:36,000 --> 00:10:40,000
+In this case, we use GPT for text data analysis.
+
+133
+00:10:40,000 --> 00:10:48,000
+When additional relevant information is provided along with the input, it is easy to ask the model
+
+134
+00:10:48,000 --> 00:10:56,000
+to include citations in its answers by referring to specific passages from the provided documents.
+
+135
+00:10:56,000 --> 00:11:02,000
+It is important to note that these citations can be programmatically verified by comparing the output
+
+136
+00:11:02,000 --> 00:11:08,000
+text with the content of the provided documents using string matching techniques.
+
+137
+00:11:08,000 --> 00:11:11,000
+Please explore examples on the slide.
+
+138
+00:11:11,000 --> 00:11:19,000
+I used delimiters in request and also set system instruction in order to get as much accurate answer
+
+139
+00:11:19,000 --> 00:11:21,000
+as it is possible.
+
+140
+00:11:21,000 --> 00:11:27,000
+Basically, these are two tactics in scope of the provider reference text strategy.
+
+141
+00:11:28,000 --> 00:11:30,000
+Let's review the next strategy.
+
+142
+00:11:31,000 --> 00:11:38,000
+The next strategy is that we are going to talk about is called split complex tasks into simpler subtasks
+
+143
+00:11:39,000 --> 00:11:46,000
+similar to the best practices in software engineering, where a complex system is broken down into modular
+
+144
+00:11:46,000 --> 00:11:46,000
+components.
+
+145
+00:11:46,000 --> 00:11:51,000
+It is equally beneficial to decompose tasks given to GPT.
+
+146
+00:11:51,000 --> 00:11:58,000
+Complex tasks typically result in higher error rates compared to simpler tasks.
+
+147
+00:11:58,000 --> 00:12:06,000
+Moreover, these complex tasks can often be restructured as a series of simpler tasks, forming a workflow
+
+148
+00:12:06,000 --> 00:12:11,000
+where outputs from earlier stages serve as inputs for later stages.
+
+149
+00:12:12,000 --> 00:12:17,000
+This approach can enhance the overall performance and accuracy of the system.
+
+150
+00:12:18,000 --> 00:12:25,000
+In scope of this strategy, we are going to review the following three tactics Use intent classification
+
+151
+00:12:25,000 --> 00:12:28,000
+to identify the most relevant instructions for a user.
+
+152
+00:12:28,000 --> 00:12:34,000
+Query for dialogue Application patterns that require very long conversations.
+
+153
+00:12:34,000 --> 00:12:37,000
+Summarize or filter previous dialogue.
+
+154
+00:12:38,000 --> 00:12:43,000
+Summarize long documents piecewise and construct a full summary recursively.
+
+155
+00:12:44,000 --> 00:12:50,000
+Let's review the first tactic that is called use Intent classification to identify the most relevant
+
+156
+00:12:50,000 --> 00:12:53,000
+instructions for a user query.
+
+157
+00:12:53,000 --> 00:13:00,000
+When dealing with tasks that require multiple sets of instructions to handle different cases, it can
+
+158
+00:13:00,000 --> 00:13:07,000
+be better to first classify the type of query and use that classification to determine the relevant
+
+159
+00:13:07,000 --> 00:13:08,000
+instructions.
+
+160
+00:13:08,000 --> 00:13:15,000
+This can be achieved by defining fixed categories and including hardcoded instructions specific to each
+
+161
+00:13:15,000 --> 00:13:16,000
+category.
+
+162
+00:13:16,000 --> 00:13:23,000
+This approach can also be applied recursively to break down a task into a series of stages.
+
+163
+00:13:23,000 --> 00:13:30,000
+The benefit of this approach is that each query will only contains instructions necessary for the next
+
+164
+00:13:30,000 --> 00:13:38,000
+stage of the task leading to lower error rates compared to using a single query for the entire task.
+
+165
+00:13:38,000 --> 00:13:45,000
+It can also result in cost savings as logic prompts are associated with higher costs.
+
+166
+00:13:45,000 --> 00:13:53,000
+For instance, let's imagine the case that we have service support and we want to use our chat bot in
+
+167
+00:13:53,000 --> 00:13:55,000
+order to classify incoming requests.
+
+168
+00:13:55,000 --> 00:14:02,000
+We are going to ask GPT to classify each query into a primary category and the secondary category.
+
+169
+00:14:02,000 --> 00:14:10,000
+On the example, you can see how give instructions about classification and then I provide GPT with
+
+170
+00:14:10,000 --> 00:14:11,000
+user input.
+
+171
+00:14:12,000 --> 00:14:14,000
+This is also a very useful technique.
+
+172
+00:14:14,000 --> 00:14:15,000
+Remember it?
+
+173
+00:14:16,000 --> 00:14:22,000
+Based on the classification of the customer query, a set of more specific instructions can be provided
+
+174
+00:14:22,000 --> 00:14:25,000
+to a GPT model to handle next steps.
+
+175
+00:14:25,000 --> 00:14:32,000
+For example, suppose a customer requires help with troubleshooting like you can see on the example
+
+176
+00:14:32,000 --> 00:14:39,000
+on this slide, you can provide an algorithm about how to hold a troubleshooting before connecting the
+
+177
+00:14:39,000 --> 00:14:41,000
+user with IT support.
+
+178
+00:14:41,000 --> 00:14:48,000
+It's important to note that the model has been guided to produce specific strings that signal transitions
+
+179
+00:14:48,000 --> 00:14:51,000
+in the conversations state.
+
+180
+00:14:51,000 --> 00:14:59,000
+This allows us to transform our system into a state machine where each state governs the instructions
+
+181
+00:14:59,000 --> 00:15:03,000
+that are introduced by effectively managing the state.
+
+182
+00:15:03,000 --> 00:15:12,000
+It then defines the instructions related to each state and optionally define and permissible state transitions.
+
+183
+00:15:12,000 --> 00:15:18,000
+We can establish boundaries around the user experience that would be challenging to achieve with a less
+
+184
+00:15:18,000 --> 00:15:20,000
+structured method.
+
+185
+00:15:20,000 --> 00:15:26,000
+This structured approach enables us to create a more controlled and guided interaction.
+
+186
+00:15:27,000 --> 00:15:30,000
+The next tactic we are going to talk about sounds like this.
+
+187
+00:15:30,000 --> 00:15:38,000
+For dialogue applications that require very long conversations summarize or filter previous dialogue
+
+188
+00:15:39,000 --> 00:15:46,000
+due to the fixed context length of GPT, ongoing dialogue between a user and an assistant can't be sustained
+
+189
+00:15:46,000 --> 00:15:48,000
+indefinitely.
+
+190
+00:15:48,000 --> 00:15:53,000
+To overcome this limitation, there are several approaches that can be used.
+
+191
+00:15:54,000 --> 00:16:02,000
+One option is to summarize past interactions in the conversation when the input size reaches a predetermined
+
+192
+00:16:02,000 --> 00:16:03,000
+threshold.
+
+193
+00:16:03,000 --> 00:16:10,000
+A query can be triggered to generate a summary of the preceding conversation, which can then be included
+
+194
+00:16:10,000 --> 00:16:12,000
+as part of the system message.
+
+195
+00:16:12,000 --> 00:16:19,000
+Alternatively, the prior conversation can be asynchronously Summarize in the background throughout
+
+196
+00:16:19,000 --> 00:16:21,000
+the ongoing conversation.
+
+197
+00:16:21,000 --> 00:16:27,000
+Another solution is to dynamically select the most relevant portions of the previous conversation in
+
+198
+00:16:27,000 --> 00:16:29,000
+relation to the current query.
+
+199
+00:16:30,000 --> 00:16:37,000
+This can be achieved by utilizing an embeddings based search approach which enables efficient retrieval
+
+200
+00:16:37,000 --> 00:16:39,000
+of relevant knowledge.
+
+201
+00:16:40,000 --> 00:16:46,000
+By utilizing these techniques, the conversation can be effectively managed within the constraints of
+
+202
+00:16:46,000 --> 00:16:52,000
+the context length, ensuring a more seamless and productive user assistant interaction.
+
+203
+00:16:53,000 --> 00:16:57,000
+The description of the next tactic sounds like this.
+
+204
+00:16:57,000 --> 00:17:03,000
+Summarize long documents piecewise and construct a full summary recursively.
+
+205
+00:17:03,000 --> 00:17:10,000
+When working with GPT, it is important to note that the fixed context length restricts the ability
+
+206
+00:17:10,000 --> 00:17:18,000
+to summarize texts longer than context length minus the generated summary length within a single query.
+
+207
+00:17:18,000 --> 00:17:24,000
+To tackle the challenge of summarizing lengthy documents such as books, we can employ a sequence of
+
+208
+00:17:24,000 --> 00:17:32,000
+queries to summarize each section individually by concatenating and summarizing these section summaries.
+
+209
+00:17:32,000 --> 00:17:35,000
+We can generate summaries of summaries.
+
+210
+00:17:35,000 --> 00:17:40,000
+This recursive process can continue until the entire document is summarized.
+
+211
+00:17:41,000 --> 00:17:48,000
+In cases where information from earlier sections is necessary to comprehend later sections, an additional
+
+212
+00:17:48,000 --> 00:17:50,000
+technique can be used.
+
+213
+00:17:50,000 --> 00:17:57,000
+This involves including a running summary of the text preceding a particular point in the book while
+
+214
+00:17:57,000 --> 00:17:59,000
+summarizing the content at that point.
+
+215
+00:18:00,000 --> 00:18:07,000
+By incorporating contextual summaries, the reader gains a better understanding of the overall narrative.
+
+216
+00:18:08,000 --> 00:18:14,000
+The effectiveness of this approach for summarizing books has been the subject of previous research conducted
+
+217
+00:18:14,000 --> 00:18:16,000
+by OpenAI.
+
+218
+00:18:16,000 --> 00:18:22,000
+Utilizing various iterations of the GPT three model, let's discuss the next strategy.
+
+219
+00:18:22,000 --> 00:18:25,000
+We give GPT time to sing.
+
+220
+00:18:25,000 --> 00:18:34,000
+When faced with a multiplication problem like 23 multiplied by 37, you may not have an immediate answer,
+
+221
+00:18:34,000 --> 00:18:37,000
+but given some time, you can figure it out.
+
+222
+00:18:37,000 --> 00:18:38,000
+Correct.
+
+223
+00:18:38,000 --> 00:18:47,000
+Similarly, GPT tends to make more reasoning errors when pressured to respond quickly compared to when
+
+224
+00:18:47,000 --> 00:18:50,000
+it is given time to sing and work out a solution.
+
+225
+00:18:50,000 --> 00:18:59,000
+By requesting a step by step reasoning process before receiving an answer, GPT can improve its ability
+
+226
+00:18:59,000 --> 00:19:04,000
+to reason and arrive at correct answers with greater reliability.
+
+227
+00:19:04,000 --> 00:19:09,000
+In scope of learning of this strategy, we are going to review the following three tactics.
+
+228
+00:19:09,000 --> 00:19:15,000
+Instruct the model to work out its own solution before rushing to a conclusion.
+
+229
+00:19:15,000 --> 00:19:21,000
+Use inner monologue or a sequence of queries to hide the model's reasoning process.
+
+230
+00:19:21,000 --> 00:19:25,000
+Ask the model if it missed anything on previous passes.
+
+231
+00:19:25,000 --> 00:19:28,000
+So let's review the first tactic from the list.
+
+232
+00:19:29,000 --> 00:19:34,000
+Instruct the model to work out its own solution before rushing to a conclusion.
+
+233
+00:19:34,000 --> 00:19:41,000
+Sometimes we can achieve better outcomes by explicitly guiding the model to use first principles reasoning
+
+234
+00:19:41,000 --> 00:19:43,000
+prior to reaching a conclusion.
+
+235
+00:19:44,000 --> 00:19:51,000
+For example, let's consider the scenario where we desire the model to evaluate a student's solution
+
+236
+00:19:51,000 --> 00:19:52,000
+to a math problem.
+
+237
+00:19:53,000 --> 00:19:58,000
+The conventional approach would involve asking the model directly whether the student's solution is
+
+238
+00:19:58,000 --> 00:20:00,000
+correct or not.
+
+239
+00:20:00,000 --> 00:20:07,000
+And as you can see in the example on this slide, GPT can say the solution is correct, but in reality
+
+240
+00:20:07,000 --> 00:20:09,000
+it is not correct.
+
+241
+00:20:09,000 --> 00:20:15,000
+So let's pay attention at an easy example and understand how potentially we could avoid such issue.
+
+242
+00:20:16,000 --> 00:20:18,000
+Pay attention to the system level instruction.
+
+243
+00:20:19,000 --> 00:20:25,000
+I ask GPT to work out own solution to the problem and then compare.
+
+244
+00:20:25,000 --> 00:20:31,000
+And this time, GPT admits that student's solution is incorrect.
+
+245
+00:20:31,000 --> 00:20:38,000
+The sense of the next tactic is to use inner monologue or a sequence of queries to hide the model's
+
+246
+00:20:38,000 --> 00:20:39,000
+reasoning process.
+
+247
+00:20:39,000 --> 00:20:46,000
+The previous tactic that we removed highlights the importance of the model engaging in detailed reasoning
+
+248
+00:20:46,000 --> 00:20:49,000
+before providing specific answers.
+
+249
+00:20:49,000 --> 00:20:56,000
+However, in certain applications, the model's complete reasoning process may not be suitable to share
+
+250
+00:20:56,000 --> 00:20:57,000
+with the user.
+
+251
+00:20:57,000 --> 00:21:04,000
+For example, in tutoring applications, it is preferable to encourage students to work through problems
+
+252
+00:21:04,000 --> 00:21:09,000
+on their own rather than revealing the answers through the model's reasoning process.
+
+253
+00:21:10,000 --> 00:21:11,000
+To address this.
+
+254
+00:21:11,000 --> 00:21:14,000
+The tactic of inner monologue can be used.
+
+255
+00:21:15,000 --> 00:21:22,000
+The concept involves instructing the model to structure the output in a way that certain parts intended
+
+256
+00:21:22,000 --> 00:21:29,000
+to be hidden from the user are hardly identifiable prior to presenting the output to the user.
+
+257
+00:21:29,000 --> 00:21:37,000
+The output is sparse and only the relevant portion is made visible, ensuring that sensitive information
+
+258
+00:21:37,000 --> 00:21:39,000
+remains concealed.
+
+259
+00:21:40,000 --> 00:21:46,000
+The detailed instructions on the slide shows you how I can configure algorithm in order to hide the
+
+260
+00:21:46,000 --> 00:21:50,000
+solution and just to give a hint to a student.
+
+261
+00:21:50,000 --> 00:21:52,000
+Let's review the next tactic.
+
+262
+00:21:53,000 --> 00:21:57,000
+Ask the model if it missed anything on previous passes.
+
+263
+00:21:57,000 --> 00:22:03,000
+Let's say we have a model that helps us find relevant information from a long book.
+
+264
+00:22:03,000 --> 00:22:09,000
+Our goal is to extract excerpts of sources that are related to a specific question.
+
+265
+00:22:09,000 --> 00:22:17,000
+However, due to the size of the book, the model might not find all the relevant excerpts in one go
+
+266
+00:22:17,000 --> 00:22:19,000
+and stop too early.
+
+267
+00:22:19,000 --> 00:22:24,000
+To overcome this, we can use a strategy called follow up queries.
+
+268
+00:22:24,000 --> 00:22:31,000
+Instead of relying solely on the initial query, we can prompt the model with additional questions to
+
+269
+00:22:31,000 --> 00:22:36,000
+help it it identify any missed excerpts from previous attempts.
+
+270
+00:22:36,000 --> 00:22:40,000
+It's like giving the model a second chance to find more relevant information.
+
+271
+00:22:41,000 --> 00:22:48,000
+For example, let's say we ask the model to find passages about the history of astronomy in a book.
+
+272
+00:22:48,000 --> 00:22:53,000
+In the first pass, the model might identify a few relevant excerpts.
+
+273
+00:22:53,000 --> 00:23:01,000
+However, it could miss some important information so we can follow up with more specific queries like
+
+274
+00:23:01,000 --> 00:23:05,000
+Are there any notable astronomers mentioned?
+
+275
+00:23:05,000 --> 00:23:09,000
+Or what major discoveries in astronomy are discussed?
+
+276
+00:23:09,000 --> 00:23:17,000
+These additional queries help the model to dig deeper and find any relevant excerpts it might have missed
+
+277
+00:23:17,000 --> 00:23:18,000
+initially.
+
+278
+00:23:18,000 --> 00:23:24,000
+By using follow up queries, we give the model more opportunities to find all the relevant information,
+
+279
+00:23:24,000 --> 00:23:28,000
+even if it didn't capture everything in the first attempt.
+
+280
+00:23:28,000 --> 00:23:36,000
+It's like a way of guiding the model to explore further and ensure we get a comprehensive set of excerpts
+
+281
+00:23:36,000 --> 00:23:38,000
+from the source material.
+
+282
+00:23:38,000 --> 00:23:42,000
+Let's review the next strategy that is called Use External Tools.
+
+283
+00:23:43,000 --> 00:23:50,000
+This strategy is about addressing the limitations of GPT by leveraging the outputs of complementary
+
+284
+00:23:50,000 --> 00:23:50,000
+tools.
+
+285
+00:23:51,000 --> 00:23:57,000
+By incorporating the results from other tools, we can compensate for the weaknesses of GPT.
+
+286
+00:23:58,000 --> 00:24:06,000
+For example, a text retrieval system can provide GPT with information from relevant documents, while
+
+287
+00:24:06,000 --> 00:24:13,000
+a code execution engine can assist GPT in performing mathematical calculations and running code user
+
+288
+00:24:13,000 --> 00:24:20,000
+tasks that can be handled more effectively or efficiently by specialized tools instead of relying solely
+
+289
+00:24:20,000 --> 00:24:20,000
+on GPT.
+
+290
+00:24:21,000 --> 00:24:28,000
+It is advisable to offload those tasks to achieve optimal results by combining the strengths of both
+
+291
+00:24:28,000 --> 00:24:29,000
+approaches.
+
+292
+00:24:30,000 --> 00:24:32,000
+Let's use the following three tactics.
+
+293
+00:24:32,000 --> 00:24:37,000
+Use embeddings based search to implement efficient knowledge retrieval.
+
+294
+00:24:37,000 --> 00:24:43,000
+Use code execution to perform more accurate calculations or call external APIs.
+
+295
+00:24:44,000 --> 00:24:47,000
+Give the model access to specific functions.
+
+296
+00:24:47,000 --> 00:24:50,000
+Let's start from the first one in the list.
+
+297
+00:24:50,000 --> 00:24:55,000
+Use embeddings based search to implement efficient knowledge retrieval.
+
+298
+00:24:56,000 --> 00:25:03,000
+A model can enhance its responses by utilizing external sources of information provided as part of its
+
+299
+00:25:03,000 --> 00:25:03,000
+input.
+
+300
+00:25:04,000 --> 00:25:10,000
+The integration enables the model to generate more knowledgeable and up to date answers.
+
+301
+00:25:10,000 --> 00:25:18,000
+For example, when a user inquires about a specific movie incorporating high quality details such as
+
+302
+00:25:18,000 --> 00:25:26,000
+actors and directors into the model's input can be beneficial to facilitate efficient knowledge retrieval.
+
+303
+00:25:26,000 --> 00:25:31,000
+Text embeddings can be used to help you understand how it works.
+
+304
+00:25:31,000 --> 00:25:33,000
+Let's review the example.
+
+305
+00:25:34,000 --> 00:25:40,000
+Suppose you have a conversational AI system that interacts with users and provides information about
+
+306
+00:25:40,000 --> 00:25:43,000
+various cities around the world.
+
+307
+00:25:43,000 --> 00:25:50,000
+To enhance the AI's responses, you can incorporate a knowledge base that contains detailed descriptions
+
+308
+00:25:50,000 --> 00:25:56,000
+of different cities, including their attractions, landmarks and cultural aspects.
+
+309
+00:25:56,000 --> 00:25:58,000
+Here is how the process might work.
+
+310
+00:25:59,000 --> 00:26:01,000
+Create a text corpus.
+
+311
+00:26:01,000 --> 00:26:07,000
+Gather a collection of documents or articles that describe various cities.
+
+312
+00:26:07,000 --> 00:26:13,000
+Each document should focus on a specific city and provide a relevant details.
+
+313
+00:26:13,000 --> 00:26:14,000
+The next step.
+
+314
+00:26:14,000 --> 00:26:17,000
+Generate text embeddings.
+
+315
+00:26:17,000 --> 00:26:24,000
+Use an embedding algorithm to convert the text descriptions of cities into dense vector representations,
+
+316
+00:26:24,000 --> 00:26:29,000
+capturing the semantic meaning and relatedness of the text.
+
+317
+00:26:30,000 --> 00:26:37,000
+Stores, embedded corpus stores, the embedded representations of the city, descriptions in a database
+
+318
+00:26:37,000 --> 00:26:41,000
+or an index making it easily accessible for querying.
+
+319
+00:26:42,000 --> 00:26:44,000
+User query and knowledge retrieval.
+
+320
+00:26:45,000 --> 00:26:52,000
+When a user asks a question about a particular city, embed the query text and perform a vector search
+
+321
+00:26:52,000 --> 00:26:55,000
+against the stored embedded corpus.
+
+322
+00:26:55,000 --> 00:27:01,000
+Retrieve the closest matching embedded city descriptions based on their similarity to the query.
+
+323
+00:27:02,000 --> 00:27:08,000
+Incorporate Retrieved knowledge presents the Retrieved City descriptions to the model, allowing it
+
+324
+00:27:08,000 --> 00:27:12,000
+to leverage the additional knowledge in formulating its response.
+
+325
+00:27:13,000 --> 00:27:19,000
+This enables the model to provide more accurate and detailed information about the requested city.
+
+326
+00:27:20,000 --> 00:27:27,000
+By utilizing knowledge retrieval with text embeddings, the conversational AI system can dynamically
+
+327
+00:27:27,000 --> 00:27:32,000
+incorporate relevant information about cities based on user queries.
+
+328
+00:27:32,000 --> 00:27:39,000
+This approach helps ensure that the models response are well informed and grounded in the specific details
+
+329
+00:27:39,000 --> 00:27:40,000
+of the cities.
+
+330
+00:27:40,000 --> 00:27:43,000
+Enhancing the overall user experience.
+
+331
+00:27:43,000 --> 00:27:51,000
+The next tactic to discuss is use code execution to perform more accurate calculations or call external
+
+332
+00:27:51,000 --> 00:27:52,000
+APIs.
+
+333
+00:27:52,000 --> 00:28:00,000
+When it comes to arithmetic or lengthy calculations, GPT alone may not provide reliable accuracy.
+
+334
+00:28:00,000 --> 00:28:07,000
+However, there is a workaround to address this limitation by instructing the model to write and execute
+
+335
+00:28:07,000 --> 00:28:10,000
+code instead of performing calculations directly.
+
+336
+00:28:10,000 --> 00:28:12,000
+Here is how it can be done.
+
+337
+00:28:12,000 --> 00:28:14,000
+Instruct the model to write code.
+
+338
+00:28:14,000 --> 00:28:20,000
+Prompts the model to generate code for the desired arithmetic or calculation task.
+
+339
+00:28:20,000 --> 00:28:25,000
+The code can be enclosed within a designated format like triple quotes.
+
+340
+00:28:25,000 --> 00:28:33,000
+For example, separate code execution extracts the code generated by the model and execute it using
+
+341
+00:28:33,000 --> 00:28:37,000
+a code execution engine such as Python interpreter.
+
+342
+00:28:37,000 --> 00:28:44,000
+This step ensures that the calculations are performed accurately by a dedicated computational tool.
+
+343
+00:28:45,000 --> 00:28:46,000
+Retrieves the output.
+
+344
+00:28:47,000 --> 00:28:51,000
+Collects the output generated by the code execution engine.
+
+345
+00:28:51,000 --> 00:28:57,000
+This output contains the results of the calculations or any other desired computation.
+
+346
+00:28:58,000 --> 00:29:01,000
+Utilize the output if needed.
+
+347
+00:29:01,000 --> 00:29:08,000
+Provide the output from the code execution engine as input to the model for the next query or as part
+
+348
+00:29:08,000 --> 00:29:10,000
+of the ongoing conversation.
+
+349
+00:29:10,000 --> 00:29:17,000
+This allows the model to incorporate the computed values or information from the code execution into
+
+350
+00:29:17,000 --> 00:29:19,000
+its subsequent responses.
+
+351
+00:29:19,000 --> 00:29:26,000
+By leveraging this approach, the model can effectively handle arithmetic or complex calculations by
+
+352
+00:29:26,000 --> 00:29:29,000
+relying on external code execution engines.
+
+353
+00:29:29,000 --> 00:29:37,000
+This ensures more accurate and reliable results while utilizing the strengths of both the model and
+
+354
+00:29:37,000 --> 00:29:38,000
+the code execution tools.
+
+355
+00:29:39,000 --> 00:29:43,000
+The next tactic gives the model access to specific functions.
+
+356
+00:29:43,000 --> 00:29:50,000
+The chat completions API offers the capability to include a list of function descriptions in requests.
+
+357
+00:29:50,000 --> 00:29:56,000
+This empowers models to generate function arguments based on the provided schemas.
+
+358
+00:29:56,000 --> 00:30:04,000
+The generated function arguments are returned in Json format by the API, allowing for the execution
+
+359
+00:30:04,000 --> 00:30:05,000
+of function calls.
+
+360
+00:30:05,000 --> 00:30:13,000
+The output obtained from these function calls can then be fed back into the model in subsequent requests,
+
+361
+00:30:13,000 --> 00:30:15,000
+forming a closed loop.
+
+362
+00:30:16,000 --> 00:30:22,000
+This approach is highly recommended when utilizing GPT models to invoke external functions.
+
+363
+00:30:22,000 --> 00:30:25,000
+In my course, I have separate lessons about function calling.
+
+364
+00:30:25,000 --> 00:30:26,000
+Check it.
+
+365
+00:30:26,000 --> 00:30:28,000
+It is really useful.
+
+366
+00:30:28,000 --> 00:30:28,000
+One.
+
+367
+00:30:28,000 --> 00:30:34,000
+I created sequence diagram and code examples and reviewed with my students.
+
+368
+00:30:34,000 --> 00:30:41,000
+End to end scenario, you will learn how model can ask us to execute some functions and how we can provide
+
+369
+00:30:41,000 --> 00:30:44,000
+our model with the results of computation.
+
+370
+00:30:44,000 --> 00:30:50,000
+And the last but not the least, strategy for today is test changes systematically.
+
+371
+00:30:50,000 --> 00:30:53,000
+Let's learn what the strategy is about.
+
+372
+00:30:53,000 --> 00:30:57,000
+Measuring performance is crucial for making improvements.
+
+373
+00:30:57,000 --> 00:31:04,000
+Sometimes adjusting the prompt may give better results on few specific examples, but result in worse
+
+374
+00:31:04,000 --> 00:31:08,000
+overall performance on a broader range of examples.
+
+375
+00:31:08,000 --> 00:31:15,000
+Therefore, to ensure that a change has a positive impact on performance, it is advisable to establish
+
+376
+00:31:15,000 --> 00:31:18,000
+a comprehensive test suit also known as an eval.
+
+377
+00:31:19,000 --> 00:31:26,000
+This test suit serves as a sole evaluation mechanism to calculate the overall effectiveness of the model
+
+378
+00:31:26,000 --> 00:31:33,000
+across various scenarios and helps to find out whether a modification truly enhances performance.
+
+379
+00:31:33,000 --> 00:31:41,000
+So in scope of this strategy, we are going to discuss only one tactic evaluate model outputs with reference
+
+380
+00:31:41,000 --> 00:31:43,000
+to gold standard answers.
+
+381
+00:31:43,000 --> 00:31:47,000
+Let me explain you what this tactic is about.
+
+382
+00:31:47,000 --> 00:31:52,000
+Let's imagine a scenario where we have a language model that helps answer questions.
+
+383
+00:31:52,000 --> 00:31:57,000
+We want to improve its performance by modifying the prompts we provide to the model.
+
+384
+00:31:58,000 --> 00:32:04,000
+Suppose we make a change to the prompt that makes the model perform exceptionally well on a few specific
+
+385
+00:32:04,000 --> 00:32:05,000
+questions.
+
+386
+00:32:06,000 --> 00:32:12,000
+However, when we test it with a broader range of questions, we notice that the overall performance
+
+387
+00:32:12,000 --> 00:32:14,000
+of the model decreases.
+
+388
+00:32:14,000 --> 00:32:21,000
+This shows us that the modification might have made the model better at answering those specific questions,
+
+389
+00:32:21,000 --> 00:32:28,000
+but worse at handling the general variety of questions to ensure that our modifications truly improve
+
+390
+00:32:28,000 --> 00:32:34,000
+the model's performance, we need to create a comprehensive test suit or evaluation set.
+
+391
+00:32:35,000 --> 00:32:42,000
+This set includes a wide range of questions that are representative of the types of queries the model
+
+392
+00:32:42,000 --> 00:32:49,000
+will encounter by evaluating the model's performance on this test suit, we can get a more accurate
+
+393
+00:32:49,000 --> 00:32:56,000
+understanding of how well it performs overall, rather than just focusing on a few related examples.
+
+394
+00:32:56,000 --> 00:33:04,000
+In simple terms, it is like testing a car's performance not only on a straight road but also on curves,
+
+395
+00:33:04,000 --> 00:33:08,000
+bumpy roads and different weather conditions.
+
+396
+00:33:08,000 --> 00:33:15,000
+By evaluating its performance in various situations, we can determine if any changes we make to the
+
+397
+00:33:15,000 --> 00:33:22,000
+car actually improve its overall performance or if they only work well in specific scenarios.
+
+398
+00:33:23,000 --> 00:33:26,000
+That's all what I wanted to share with you in this lesson.
+
+399
+00:33:26,000 --> 00:33:33,000
+We have learned a lot of things, and I bet you are going to have questions, so please don't hesitate
+
+400
+00:33:33,000 --> 00:33:37,000
+to ask your questions below the video and I will be happy to answer.
+
+401
+00:33:37,000 --> 00:33:41,000
+Let's recap what we have learned in this video Today.
+
+402
+00:33:41,000 --> 00:33:45,000
+We learned six strategies and tactics for each strategy.
+
+403
+00:33:45,000 --> 00:33:48,000
+Namely, we learned such strategies.
+
+404
+00:33:48,000 --> 00:33:55,000
+Write clear instructions, provide reference texts, split complex tasks into simpler subtasks.
+
+405
+00:33:55,000 --> 00:33:57,000
+Give it time to sink.
+
+406
+00:33:58,000 --> 00:34:02,000
+Use external tools test changes systematically.
+
+407
+00:34:03,000 --> 00:34:09,000
+We removed a lot of examples and real use cases that I am sure will be useful for you.
+
+408
+00:34:10,000 --> 00:34:11,000
+Thanks a lot for your attention.
+
+409
+00:34:11,000 --> 00:34:15,000
+Have a great day and see you in the next lesson.
+
diff --git a/96 - OpenAI API ChatGPT Model/external-links.txt b/96 - OpenAI API ChatGPT Model/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..9431473f58300571f8c4722ad75d6235367734e7
--- /dev/null
+++ b/96 - OpenAI API ChatGPT Model/external-links.txt
@@ -0,0 +1,24 @@
+
+001 Chat-API-Reference
+https://platform.openai.com/docs/api-reference/chat
+
+001 Model-Endpoint-Compatibility
+https://platform.openai.com/docs/models/model-endpoint-compatibility
+
+002 Deprecations
+https://platform.openai.com/docs/deprecations
+
+002 Postman-collections
+https://github.com/AndriiPiatakha/openai-learnit/commit/653521337332a4074e94bc8c24fcc0491d09a9fd
+
+003 Source-code-of-examples-from-the-lesson-commit-with-changes-
+https://github.com/AndriiPiatakha/openai-learnit/commit/e70e6fad019b81da4d7a3ff6bb890c0c1a82fddb
+
+003 Official-OpenAI-Libraries
+https://platform.openai.com/docs/libraries
+
+003 Community-libraries
+https://platform.openai.com/docs/libraries/community-libraries
+
+004 Source-code-of-examples-from-the-lesson-commit-with-changes-
+https://github.com/AndriiPiatakha/openai-learnit/commit/2e89c25855024e06a88df66f08a1811d07419dad
diff --git a/97 - Web Hosting at Home/001 Web Hosting at Home Port Forwarding_en.srt b/97 - Web Hosting at Home/001 Web Hosting at Home Port Forwarding_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..067691919565201133bbe98cabdeb860091489e9
--- /dev/null
+++ b/97 - Web Hosting at Home/001 Web Hosting at Home Port Forwarding_en.srt
@@ -0,0 +1,808 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:13,000
+Today we are going to have a lesson dedicated to some network configurations, but it is important in
+
+3
+00:00:13,000 --> 00:00:19,000
+order you can proceed with the course and run all code examples locally on your computer.
+
+4
+00:00:19,000 --> 00:00:28,000
+We are going to start the lesson from remembering and understanding one more time what TCP IP port terms
+
+5
+00:00:28,000 --> 00:00:28,000
+are.
+
+6
+00:00:29,000 --> 00:00:30,000
+I'm going to explain you.
+
+7
+00:00:30,000 --> 00:00:37,000
+What is the difference between static and dynamic IP addresses and why we need static IP address and
+
+8
+00:00:37,000 --> 00:00:38,000
+how to request it.
+
+9
+00:00:38,000 --> 00:00:46,000
+After that, we are going to learn what port forwarding is and configure port forwarding together on
+
+10
+00:00:46,000 --> 00:00:47,000
+your router.
+
+11
+00:00:47,000 --> 00:00:53,000
+By the end of this lesson, you are going to have web application deployed on your home computer and
+
+12
+00:00:53,000 --> 00:00:57,000
+available at any point on the earth where internet connection exists.
+
+13
+00:00:58,000 --> 00:01:03,000
+I will also share with you troubleshooting hints that are supposed to help you during the configurations.
+
+14
+00:01:03,000 --> 00:01:05,000
+Let's start our lesson.
+
+15
+00:01:05,000 --> 00:01:12,000
+But first, let me start from the problem statement and explain you why I come up with the idea for
+
+16
+00:01:12,000 --> 00:01:13,000
+this lesson.
+
+17
+00:01:13,000 --> 00:01:19,000
+So together with my students in my courses, we learned how to create web applications.
+
+18
+00:01:19,000 --> 00:01:24,000
+We deployed them locally, we tested them and we learned a lot of things.
+
+19
+00:01:24,000 --> 00:01:28,000
+But how to open our applications to the whole world.
+
+20
+00:01:28,000 --> 00:01:35,000
+So in case you want that, other users would be able to reach out to your web application from different
+
+21
+00:01:35,000 --> 00:01:41,000
+parts of the earth, you need to deploy it on the hosting that would be accessible from anywhere.
+
+22
+00:01:41,000 --> 00:01:48,000
+Basically, you have two main options Deploy your application on some hosting or to the cloud.
+
+23
+00:01:48,000 --> 00:01:53,000
+This is also an option, but it will cost you some money or another option.
+
+24
+00:01:53,000 --> 00:01:59,000
+Make your own computer work like a hosting and expose its address to the world.
+
+25
+00:02:00,000 --> 00:02:06,000
+This option will cost you nothing in this particular lesson, I want to talk about configuration of
+
+26
+00:02:06,000 --> 00:02:11,000
+your local computer because any way, while you are a student and you want to show your solution to
+
+27
+00:02:11,000 --> 00:02:18,000
+someone or experiment with your application, you don't need to pay for cloud or other hosting.
+
+28
+00:02:18,000 --> 00:02:22,000
+Like I always say, start small and become big.
+
+29
+00:02:22,000 --> 00:02:30,000
+Let's start from the small home based web hosting and then we'll publish our application to the cloud.
+
+30
+00:02:30,000 --> 00:02:36,000
+Let me share with you details how you can expose your IP address publicly to the Internet.
+
+31
+00:02:36,000 --> 00:02:40,000
+For this, you need to configure port forwarding.
+
+32
+00:02:40,000 --> 00:02:46,000
+Today in this video, I'm going to explain you what port forwarding is, But before we jump to the port
+
+33
+00:02:46,000 --> 00:02:52,000
+forwarding discussion, let's remember one more time what IP address and port are.
+
+34
+00:02:52,000 --> 00:02:59,000
+If you are a student of my course Java from zero to this job, then you already know what IP and port
+
+35
+00:02:59,000 --> 00:03:00,000
+is.
+
+36
+00:03:00,000 --> 00:03:04,000
+Because we saw the detailed lesson about OSI model.
+
+37
+00:03:04,000 --> 00:03:12,000
+In case you don't remember exactly what IP and port are, let me quickly recap the key points reviewing
+
+38
+00:03:12,000 --> 00:03:14,000
+with you the following example.
+
+39
+00:03:14,000 --> 00:03:18,000
+Imagine that you need to deliver a mail to the receiver.
+
+40
+00:03:18,000 --> 00:03:21,000
+You have address written down on the envelope.
+
+41
+00:03:21,000 --> 00:03:25,000
+You know that you need to deliver mail to the specific address.
+
+42
+00:03:25,000 --> 00:03:30,000
+You know, the country city, concrete, street and concrete building.
+
+43
+00:03:30,000 --> 00:03:33,000
+This is similar to your IP address.
+
+44
+00:03:33,000 --> 00:03:39,000
+So with the help of IP address, you can find the destination for your message.
+
+45
+00:03:39,000 --> 00:03:42,000
+The concrete computer joined to the network.
+
+46
+00:03:42,000 --> 00:03:47,000
+But when you found the building, you discovered that it has a lot of apartments.
+
+47
+00:03:47,000 --> 00:03:49,000
+Where is your receiver?
+
+48
+00:03:49,000 --> 00:03:56,000
+Where you can find the number of the apartment and different apartments and building are equivalent
+
+49
+00:03:56,000 --> 00:03:59,000
+of the different applications running on the computer.
+
+50
+00:03:59,000 --> 00:04:06,000
+You need to deliver message to the specific application and the apartment number is the port number.
+
+51
+00:04:06,000 --> 00:04:10,000
+So the port number is an apartment in the building.
+
+52
+00:04:11,000 --> 00:04:12,000
+Is it clear so far?
+
+53
+00:04:13,000 --> 00:04:21,000
+Thus, the full address of your application in World Wide Web consists from the address of your computer
+
+54
+00:04:21,000 --> 00:04:26,000
+and port number of your application running on that computer.
+
+55
+00:04:26,000 --> 00:04:31,000
+Now let's understand what TCP is in this example.
+
+56
+00:04:31,000 --> 00:04:38,000
+TCP is a mailing service that delivers your message to the destination, ensures that the message has
+
+57
+00:04:38,000 --> 00:04:41,000
+been passed and confirms the delivery.
+
+58
+00:04:41,000 --> 00:04:42,000
+Is it clear?
+
+59
+00:04:43,000 --> 00:04:51,000
+That's why we often say TCP IP protocol, meaning that we deliver message to the destination With the
+
+60
+00:04:51,000 --> 00:04:53,000
+help of the TCP protocol.
+
+61
+00:04:53,000 --> 00:05:01,000
+TCP is used in conjunction with IP in order to maintain a connection between the sender and the target
+
+62
+00:05:01,000 --> 00:05:02,000
+to ensure a packet order.
+
+63
+00:05:03,000 --> 00:05:04,000
+Is it clear now?
+
+64
+00:05:05,000 --> 00:05:05,000
+Great.
+
+65
+00:05:05,000 --> 00:05:07,000
+Let's move on.
+
+66
+00:05:07,000 --> 00:05:14,000
+So based on this example, I believe you understood that you need to have a fixed address and not change
+
+67
+00:05:14,000 --> 00:05:20,000
+apartments each day because in this case, you won't be able to receive mails.
+
+68
+00:05:20,000 --> 00:05:28,000
+That means that our computer in the network should have the same web address all the times, namely
+
+69
+00:05:28,000 --> 00:05:29,000
+your machine.
+
+70
+00:05:29,000 --> 00:05:36,000
+Your computer should have the same numeric address today, tomorrow, and the day after tomorrow.
+
+71
+00:05:37,000 --> 00:05:40,000
+IP addresses may be static and dynamic.
+
+72
+00:05:40,000 --> 00:05:45,000
+Sometimes Internet providers provide you with dynamic IP address.
+
+73
+00:05:46,000 --> 00:05:54,000
+It has its own pros and cons, but dynamic IP address means that IP address is not stable and it can
+
+74
+00:05:54,000 --> 00:06:01,000
+be changed after some time passed or after router reloading, for example.
+
+75
+00:06:01,000 --> 00:06:03,000
+What to do in this case?
+
+76
+00:06:03,000 --> 00:06:10,000
+In this case, you need to call to the customer support of your internet provider and request a static
+
+77
+00:06:10,000 --> 00:06:11,000
+IP address.
+
+78
+00:06:11,000 --> 00:06:15,000
+Most of the providers provide such services.
+
+79
+00:06:15,000 --> 00:06:19,000
+Talking about me, I have multiple homes in different countries.
+
+80
+00:06:19,000 --> 00:06:23,000
+That's why I deal with internet providers too often.
+
+81
+00:06:23,000 --> 00:06:30,000
+So only at one of my places is I was dynamic IP address but provider dedicated fixed IP address for
+
+82
+00:06:30,000 --> 00:06:30,000
+me.
+
+83
+00:06:30,000 --> 00:06:37,000
+The next day after the request in my two other apartments there is a static IP address, so no problems
+
+84
+00:06:37,000 --> 00:06:38,000
+there.
+
+85
+00:06:38,000 --> 00:06:45,000
+I bet you didn't note for yourself to request static IP address in case you have dynamic IP address.
+
+86
+00:06:45,000 --> 00:06:49,000
+But how to check whether you have static or dynamic IP address.
+
+87
+00:06:49,000 --> 00:06:56,000
+The easiest possible way is to observe IP address changes, monitor the behavior of your IP address
+
+88
+00:06:56,000 --> 00:06:58,000
+over time.
+
+89
+00:06:58,000 --> 00:07:04,000
+If it remains the same for an extended period, it is likely a static IP address.
+
+90
+00:07:04,000 --> 00:07:11,000
+However, if the IP address changes periodically or after specific events such as router starts, it
+
+91
+00:07:11,000 --> 00:07:13,000
+is likely a dynamic IP address.
+
+92
+00:07:14,000 --> 00:07:19,000
+You can use different services on lines that would tell you what is your IP address.
+
+93
+00:07:19,000 --> 00:07:26,000
+Another proven way to clarify whether you have static or dynamic IP address is to make a call to your
+
+94
+00:07:26,000 --> 00:07:33,000
+Internet provider, contact your Internet service provider and inquire about the type of IP address
+
+95
+00:07:33,000 --> 00:07:35,000
+they assigned to you.
+
+96
+00:07:35,000 --> 00:07:42,000
+They can provide information on whether it is a static IP address, which remains the same over time,
+
+97
+00:07:42,000 --> 00:07:46,000
+or a dynamic IP address, which can change periodically.
+
+98
+00:07:46,000 --> 00:07:51,000
+So I believe now we can move on and learn more about port forwarding.
+
+99
+00:07:52,000 --> 00:07:59,000
+Port forwarding is a technique used in networking to redirect network traffic from one port on a device's
+
+100
+00:07:59,000 --> 00:08:04,000
+network interface to another port on a different device or network.
+
+101
+00:08:04,000 --> 00:08:10,000
+It allows incoming network connections to reach a specific port on a device that would otherwise be
+
+102
+00:08:10,000 --> 00:08:15,000
+inaccessible or hidden behind a firewall or network.
+
+103
+00:08:15,000 --> 00:08:18,000
+Address Translation Shortly called Nat.
+
+104
+00:08:18,000 --> 00:08:23,000
+Here is a simplified explanation of how port forwarding works.
+
+105
+00:08:23,000 --> 00:08:27,000
+Network communication is based on IP addresses and port numbers.
+
+106
+00:08:27,000 --> 00:08:34,000
+An IP address identifies a device on a network and port number identifies a specific application or
+
+107
+00:08:34,000 --> 00:08:36,000
+service running on that device.
+
+108
+00:08:36,000 --> 00:08:40,000
+We already learned at the beginning of the lesson how it works.
+
+109
+00:08:40,000 --> 00:08:47,000
+When a device receives network traffic, it checks the destination IP address and port number to determine
+
+110
+00:08:47,000 --> 00:08:51,000
+which application or service should handle that traffic.
+
+111
+00:08:51,000 --> 00:08:59,000
+In some cases, a device may be located behind the firewall or an RT network address translation which
+
+112
+00:08:59,000 --> 00:09:05,000
+can block incoming connections or hide internal IP addresses from the external network.
+
+113
+00:09:06,000 --> 00:09:13,000
+Port forwarding allows you to configure the firewall or Nat to redirect incoming network traffic from
+
+114
+00:09:13,000 --> 00:09:19,000
+a specific port on the external network to a different port on a specific device or network within the
+
+115
+00:09:19,000 --> 00:09:21,000
+internal network.
+
+116
+00:09:21,000 --> 00:09:26,000
+You are going to have a need to configure port forwarding in the following cases.
+
+117
+00:09:26,000 --> 00:09:34,000
+For example, for remote access, port forwarding enables remote access to devices or services within
+
+118
+00:09:34,000 --> 00:09:35,000
+a private network.
+
+119
+00:09:35,000 --> 00:09:44,000
+For example, you can forward the SSH secure shell port to remotely connect to a server or forward the
+
+120
+00:09:44,000 --> 00:09:47,000
+Http port to access a web server.
+
+121
+00:09:48,000 --> 00:09:49,000
+Hosting services.
+
+122
+00:09:49,000 --> 00:09:56,000
+If you want to host a website, web application, game server, or any other service within your local
+
+123
+00:09:56,000 --> 00:09:57,000
+network.
+
+124
+00:09:57,000 --> 00:10:03,000
+Port forwarding allows external users to reach those services by redirecting the incoming traffic to
+
+125
+00:10:03,000 --> 00:10:04,000
+the appropriate device.
+
+126
+00:10:05,000 --> 00:10:07,000
+Peer to peer applications.
+
+127
+00:10:07,000 --> 00:10:14,000
+Some peer to peer applications like BitTorrent or online gaming require incoming connections to be able
+
+128
+00:10:14,000 --> 00:10:17,000
+to connect to other peers.
+
+129
+00:10:17,000 --> 00:10:24,000
+Port forwarding ensures that incoming connections are properly directed to the requesting device.
+
+130
+00:10:24,000 --> 00:10:29,000
+It's important to note that configuring port forwarding may involve security considerations.
+
+131
+00:10:29,000 --> 00:10:37,000
+Opening ports and exposing services to the Internet can potentially increase the risk of unauthorized
+
+132
+00:10:37,000 --> 00:10:39,000
+access or attacks.
+
+133
+00:10:39,000 --> 00:10:46,000
+Therefore, it is crucial to carefully configure and secure the devices and services involved in port
+
+134
+00:10:46,000 --> 00:10:47,000
+forwarding.
+
+135
+00:10:48,000 --> 00:10:54,000
+Let me share with you how to guide, how to configure port forwarding step by step.
+
+136
+00:10:54,000 --> 00:11:02,000
+The first step open command line and learn IP address of your device on the Windows based machines.
+
+137
+00:11:02,000 --> 00:11:10,000
+You can run command ipconfig in your command prompt on the Linux based machines and mac you need to
+
+138
+00:11:10,000 --> 00:11:13,000
+execute ipconfig command in terminal.
+
+139
+00:11:14,000 --> 00:11:20,000
+Find IP version four address in the section adapter of wireless network.
+
+140
+00:11:20,000 --> 00:11:22,000
+Remember this IP address.
+
+141
+00:11:22,000 --> 00:11:30,000
+This is IP address of your computer, of your device and when you will run your web application on your
+
+142
+00:11:30,000 --> 00:11:34,000
+computer, we would need to configure port forwarding to this device.
+
+143
+00:11:35,000 --> 00:11:38,000
+The next thing, check your Wi-Fi router.
+
+144
+00:11:39,000 --> 00:11:45,000
+Usually Wi-Fi routers has sticker with the details of admin access to the configurations.
+
+145
+00:11:45,000 --> 00:11:54,000
+It consists from IP address and admin password and remember it open configurations of Wi-Fi router by
+
+146
+00:11:54,000 --> 00:12:02,000
+accessing IP address and using password that you found on the sticker on your router, check the manual
+
+147
+00:12:02,000 --> 00:12:10,000
+of your specific web router or check all possible menus and try to find port forwarding configurations.
+
+148
+00:12:10,000 --> 00:12:16,000
+When you found port forwarding menu, you need to specify the following configurations.
+
+149
+00:12:16,000 --> 00:12:18,000
+Local IP address.
+
+150
+00:12:19,000 --> 00:12:24,000
+That is the address that we found in the command line local port.
+
+151
+00:12:24,000 --> 00:12:31,000
+That is the port where your application will be running in case we want to deploy our web app to the
+
+152
+00:12:31,000 --> 00:12:35,000
+Tomcat server or run our spring boot application.
+
+153
+00:12:35,000 --> 00:12:38,000
+By default, it is port 8080.
+
+154
+00:12:38,000 --> 00:12:43,000
+In case you use any custom port, you need to specify it here.
+
+155
+00:12:43,000 --> 00:12:48,000
+External port here you can specify any port you wish.
+
+156
+00:12:48,000 --> 00:12:53,000
+This port will be used in combination with your public IP address.
+
+157
+00:12:53,000 --> 00:13:00,000
+To access your application protocol, you need to specify whether this port forwarding will be used
+
+158
+00:13:00,000 --> 00:13:04,000
+for TCP or UDP or both.
+
+159
+00:13:04,000 --> 00:13:11,000
+Some routers don't have such detailed configuration, so potentially you may not have it.
+
+160
+00:13:11,000 --> 00:13:12,000
+That's it.
+
+161
+00:13:13,000 --> 00:13:19,000
+The next thing that you need to do is to verify that you configure it properly all the settings.
+
+162
+00:13:19,000 --> 00:13:27,000
+You already know your external IP address because I believe you clarified your external IP address at
+
+163
+00:13:27,000 --> 00:13:28,000
+the beginning of this lesson.
+
+164
+00:13:29,000 --> 00:13:35,000
+Deploy your web application and make sure your web application is up and running on your computer at
+
+165
+00:13:35,000 --> 00:13:36,000
+the port.
+
+166
+00:13:36,000 --> 00:13:44,000
+Configure it in port forwarding configurations miserably to test access from external network.
+
+167
+00:13:44,000 --> 00:13:52,000
+For example, you can use your mobile phone, just turn off the Wi-Fi and turn on your 5G connection.
+
+168
+00:13:53,000 --> 00:13:56,000
+Try to send the request to the following address.
+
+169
+00:13:56,000 --> 00:14:03,000
+Your external IP address is that you found in Google or any other specific service, the port that you
+
+170
+00:14:03,000 --> 00:14:09,000
+configured in port forwarding as external and test endpoint in your web application.
+
+171
+00:14:09,000 --> 00:14:16,000
+That should return some response in case you can see that you hit endpoint and response is returned
+
+172
+00:14:16,000 --> 00:14:20,000
+to you successfully, then everything was configured properly.
+
+173
+00:14:20,000 --> 00:14:25,000
+If you see an error, then you need to check all configurations one more time.
+
+174
+00:14:25,000 --> 00:14:34,000
+Very carefully explores the slides, slowly make sure that you did the right mapping your local IP address
+
+175
+00:14:34,000 --> 00:14:41,000
+of your device, the port where your application is running mapped to your public IP address with the
+
+176
+00:14:41,000 --> 00:14:47,000
+public port configured even in case there will be some challenges, please do not.
+
+177
+00:14:47,000 --> 00:14:53,000
+Hesitate to ask your questions below the video and I will be happy to answer.
+
+178
+00:14:53,000 --> 00:14:59,000
+And just one more time, take a look at this hint that would help you during the troubleshooting of
+
+179
+00:14:59,000 --> 00:15:02,000
+your settings in case something is going wrong.
+
+180
+00:15:02,000 --> 00:15:12,000
+So imagine that your local IP address that you learned from the command line is 192 168 zero 99.
+
+181
+00:15:13,000 --> 00:15:19,000
+You deployed your application at default port 8080 in port forwarding.
+
+182
+00:15:19,000 --> 00:15:26,000
+You specified that request forwarding should happen when user requests port 8080, 99.
+
+183
+00:15:26,000 --> 00:15:33,000
+Your external IP address is 8264, 100 123.
+
+184
+00:15:33,000 --> 00:15:37,000
+Your test endpoint is Hello World.
+
+185
+00:15:37,000 --> 00:15:45,000
+That means that when you send requests from outside of your network to the IP address, 8264, 100,
+
+186
+00:15:45,000 --> 00:15:51,000
+123 and the port 8899 and endpoint.
+
+187
+00:15:51,000 --> 00:15:52,000
+Hello world.
+
+188
+00:15:52,000 --> 00:16:00,000
+The request forwarding should forward the request to the internal IP address in your network to 192
+
+189
+00:16:00,000 --> 00:16:06,000
+168 zero 99 port 8080 and then point.
+
+190
+00:16:06,000 --> 00:16:07,000
+Hello world.
+
+191
+00:16:07,000 --> 00:16:08,000
+Is it clear?
+
+192
+00:16:09,000 --> 00:16:15,000
+In case you would have any challenges, let me know in comments below the video and I will try to help
+
+193
+00:16:15,000 --> 00:16:16,000
+in case you configure it.
+
+194
+00:16:16,000 --> 00:16:21,000
+Everything is an everything is super and you are ready for the next lesson.
+
+195
+00:16:22,000 --> 00:16:25,000
+Let's recap what we have learned in this video.
+
+196
+00:16:26,000 --> 00:16:30,000
+You remembered what TCP IP and port terms mean.
+
+197
+00:16:30,000 --> 00:16:34,000
+Now you know what static and dynamic IP addresses are.
+
+198
+00:16:34,000 --> 00:16:41,000
+Also, I explained the port forwarding together with configured port forwarding on your router and at
+
+199
+00:16:41,000 --> 00:16:45,000
+the end of the lesson I shared with you troubleshooting hints.
+
+200
+00:16:46,000 --> 00:16:47,000
+That's all for this lesson.
+
+201
+00:16:48,000 --> 00:16:49,000
+Thanks a lot for your attention.
+
+202
+00:16:49,000 --> 00:16:52,000
+Have a great day and see you in the next lesson.
+
diff --git a/98 - GPT + Slack Integration/001 Create Slack Application, Configuration of Incoming & Outgoing Webhooks_en.srt b/98 - GPT + Slack Integration/001 Create Slack Application, Configuration of Incoming & Outgoing Webhooks_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..518412145fe13561612ac443b2c2a74284c34682
--- /dev/null
+++ b/98 - GPT + Slack Integration/001 Create Slack Application, Configuration of Incoming & Outgoing Webhooks_en.srt
@@ -0,0 +1,1236 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello, Tim.
+
+2
+00:00:06,000 --> 00:00:12,000
+By this moment in our course, I believe you are familiar with GPT model and you are already familiar
+
+3
+00:00:12,000 --> 00:00:14,000
+with OpenAI API.
+
+4
+00:00:14,000 --> 00:00:21,000
+Also, we created skeleton of our web application that is integrated with the OpenAI API.
+
+5
+00:00:21,000 --> 00:00:28,000
+So now it is time to start building other integrations in order to unleash all the power of the GPT.
+
+6
+00:00:28,000 --> 00:00:33,000
+In this learning module we are going to build integration with the Slack Messenger.
+
+7
+00:00:33,000 --> 00:00:39,000
+We will use Slack Messenger as a tool for exchanging requests with our web application.
+
+8
+00:00:39,000 --> 00:00:44,000
+GPT, third party services and themes that we are working with.
+
+9
+00:00:44,000 --> 00:00:50,000
+As I already told in the beginning of our course, we have the goal to create an application that will
+
+10
+00:00:50,000 --> 00:00:57,000
+help us to automate operations inside our engineering team and to start implementation of this goal.
+
+11
+00:00:57,000 --> 00:01:03,000
+We need to understand at least basic principles of Slack Messenger API.
+
+12
+00:01:03,000 --> 00:01:10,000
+That's why this lesson will be fully dedicated to Slack and Slack API and basic integration with the
+
+13
+00:01:10,000 --> 00:01:12,000
+skeleton of our web application.
+
+14
+00:01:13,000 --> 00:01:17,000
+We are going to start the lesson from the brief overview of what Slack is.
+
+15
+00:01:17,000 --> 00:01:22,000
+In order you would understand the platform that we are integrating with.
+
+16
+00:01:22,000 --> 00:01:27,000
+If you don't know this platform yet, I will help you to start with it.
+
+17
+00:01:27,000 --> 00:01:30,000
+Create account, workspace and channel.
+
+18
+00:01:30,000 --> 00:01:35,000
+These are prerequisites before we start integration with Slack.
+
+19
+00:01:35,000 --> 00:01:38,000
+Then we are going to create an application in Slack.
+
+20
+00:01:39,000 --> 00:01:46,000
+I'm going to explain you different options of creating an application from scratch or from manifest.
+
+21
+00:01:46,000 --> 00:01:53,000
+Also, during the lesson, we are going to learn the concepts of incoming and outgoing webhooks, and
+
+22
+00:01:53,000 --> 00:01:59,000
+together we will configure them in our Slack application in order to prepare everything what we need
+
+23
+00:01:59,000 --> 00:02:02,000
+to have before integration with Slack.
+
+24
+00:02:02,000 --> 00:02:07,000
+During the lesson, we are going to learn the basics of Slack Events API.
+
+25
+00:02:07,000 --> 00:02:09,000
+So let's start our lesson.
+
+26
+00:02:09,000 --> 00:02:16,000
+Let me make just a brief overview of what Slack is and why I decided to select it for this course.
+
+27
+00:02:16,000 --> 00:02:20,000
+So the first reason is its popularity.
+
+28
+00:02:20,000 --> 00:02:27,000
+Without any doubt, Slack is one of the most popular messenger, especially in corporate environment.
+
+29
+00:02:27,000 --> 00:02:33,000
+In my course, I'm going to create video tutorials for ChatGPT integration with different tools, but
+
+30
+00:02:33,000 --> 00:02:36,000
+Slack is definitely one of the most popular ones.
+
+31
+00:02:37,000 --> 00:02:42,000
+If you have never worked with Slack before, let me just explain you what it is in a few sentences.
+
+32
+00:02:43,000 --> 00:02:49,000
+Slack is a collaboration platform that allows teams to communicate and work together effectively.
+
+33
+00:02:49,000 --> 00:02:56,000
+Its integration capabilities enables seamless connections with various apps and services, consolidating
+
+34
+00:02:56,000 --> 00:03:00,000
+tools and information in one place for improved productivity.
+
+35
+00:03:00,000 --> 00:03:08,000
+Slack supports custom integrations through its API, enabling organizations to build tailored connections
+
+36
+00:03:08,000 --> 00:03:12,000
+with their own internal systems or specific applications.
+
+37
+00:03:12,000 --> 00:03:20,000
+This flexibility allows businesses to automate workflows, gather and analyze data and create custom
+
+38
+00:03:20,000 --> 00:03:24,000
+notifications or alerts all within the slack environment.
+
+39
+00:03:25,000 --> 00:03:28,000
+For this lesson, you would need to create an account in Slack.
+
+40
+00:03:28,000 --> 00:03:30,000
+Don't worry, it is free of charge.
+
+41
+00:03:30,000 --> 00:03:35,000
+But first you need to select which version of slack you are going to use.
+
+42
+00:03:35,000 --> 00:03:38,000
+There are web and desktop versions of Slack.
+
+43
+00:03:39,000 --> 00:03:45,000
+Slack Web is a web based version of Slack is accessed through a web browser.
+
+44
+00:03:45,000 --> 00:03:52,000
+You can log in to your Slack workspace by visiting the Slack website and access your workspace from
+
+45
+00:03:52,000 --> 00:03:53,000
+the browser.
+
+46
+00:03:53,000 --> 00:04:01,000
+Slack Desktop is a desktop version offers additional benefits such as faster access, better performance,
+
+47
+00:04:01,000 --> 00:04:04,000
+and offline access to your messages and files.
+
+48
+00:04:04,000 --> 00:04:10,000
+It may also have additional features like native notifications and system integrations.
+
+49
+00:04:10,000 --> 00:04:16,000
+The choice between Slack Web and Slack desktop depends on your preferences and requirements.
+
+50
+00:04:16,000 --> 00:04:23,000
+The web version offers convenience and accessibility as you can access it from any computer with an
+
+51
+00:04:23,000 --> 00:04:24,000
+Internet connection.
+
+52
+00:04:24,000 --> 00:04:30,000
+On the other hand, the desktop version provides a more integrated experience with your operating system
+
+53
+00:04:30,000 --> 00:04:35,000
+and can offer additional features and improved performance.
+
+54
+00:04:35,000 --> 00:04:40,000
+So my recommendation would be to install the desktop version of Slack.
+
+55
+00:04:40,000 --> 00:04:42,000
+You need to download the slack first.
+
+56
+00:04:43,000 --> 00:04:46,000
+There are different slack versions for different operating systems.
+
+57
+00:04:46,000 --> 00:04:50,000
+Just click the download button and follow the instructions.
+
+58
+00:04:50,000 --> 00:04:52,000
+Everything should be easy.
+
+59
+00:04:52,000 --> 00:04:58,000
+The installation flow is so smooth and so predictable that I don't see any need to write a detailed
+
+60
+00:04:58,000 --> 00:05:00,000
+guide about installation.
+
+61
+00:05:00,000 --> 00:05:03,000
+Anyway, in case you would face any.
+
+62
+00:05:03,000 --> 00:05:06,000
+Issue on any of installation steps.
+
+63
+00:05:06,000 --> 00:05:10,000
+Let me know in the comments below the video and I will be happy to answer.
+
+64
+00:05:11,000 --> 00:05:16,000
+The next thing that you have to do is to sign in or create a slack account.
+
+65
+00:05:16,000 --> 00:05:21,000
+After the installation is complete, Slack desktop will launch.
+
+66
+00:05:21,000 --> 00:05:26,000
+If you already have a Slack account, sign in using your credentials.
+
+67
+00:05:26,000 --> 00:05:33,000
+If you are new to Slack, you can create a new account by clicking on the Create an account link and
+
+68
+00:05:33,000 --> 00:05:35,000
+following the account creation steps.
+
+69
+00:05:35,000 --> 00:05:40,000
+You can also use your Google account in order to create account faster.
+
+70
+00:05:40,000 --> 00:05:45,000
+But in case you don't have Google account, you can create account using another email.
+
+71
+00:05:45,000 --> 00:05:47,000
+So no problem at all.
+
+72
+00:05:48,000 --> 00:05:49,000
+After you signed in.
+
+73
+00:05:49,000 --> 00:05:52,000
+You need to join or create a workspace.
+
+74
+00:05:52,000 --> 00:05:55,000
+What is a workspace in Slack?
+
+75
+00:05:55,000 --> 00:06:02,000
+A workspace refers to a virtual environment where team members collaborate, communicate, and share
+
+76
+00:06:02,000 --> 00:06:03,000
+information.
+
+77
+00:06:03,000 --> 00:06:10,000
+It acts as a central hub for a group of people such as a company, organization or project team, to
+
+78
+00:06:10,000 --> 00:06:13,000
+connect and work together within the Slack platform.
+
+79
+00:06:13,000 --> 00:06:20,000
+Once you are signed in, you will be prompted to join an existing workspace or create a new one.
+
+80
+00:06:20,000 --> 00:06:27,000
+If you are part of a team or organization that already uses Slack, enter the workspace URL or invite
+
+81
+00:06:27,000 --> 00:06:30,000
+link provided by your team admin.
+
+82
+00:06:30,000 --> 00:06:35,000
+If you are creating a new workspace, follow the prompts to set it up.
+
+83
+00:06:35,000 --> 00:06:42,000
+For training purposes, I recommend to create your own workspace because for different things we would
+
+84
+00:06:42,000 --> 00:06:45,000
+require admin access to the workspace.
+
+85
+00:06:45,000 --> 00:06:50,000
+At the beginning, you will be asked what is the name of your company or team?
+
+86
+00:06:50,000 --> 00:06:56,000
+In our specific case, I would write Learn by Tbs.com OpenAI.
+
+87
+00:06:57,000 --> 00:07:01,000
+You can come up with any other name if you wish.
+
+88
+00:07:01,000 --> 00:07:05,000
+That is the name that will be used for workspace identification.
+
+89
+00:07:06,000 --> 00:07:07,000
+Click next.
+
+90
+00:07:07,000 --> 00:07:11,000
+On the next page you need to specify your name.
+
+91
+00:07:11,000 --> 00:07:17,000
+Optionally, you can upload a photo, but we can upload a photo anytime later in the future.
+
+92
+00:07:17,000 --> 00:07:21,000
+There is no rush to upload it right now on this page.
+
+93
+00:07:21,000 --> 00:07:22,000
+Click next.
+
+94
+00:07:23,000 --> 00:07:29,000
+On the third step, you have opportunity to invite your team members using their email addresses.
+
+95
+00:07:29,000 --> 00:07:35,000
+You just paste the addresses here and invitation link will be sent to them.
+
+96
+00:07:35,000 --> 00:07:40,000
+Or you can copy invitation link and send them link directly.
+
+97
+00:07:40,000 --> 00:07:45,000
+I would like to skip this step because I have nobody to add at the moment.
+
+98
+00:07:45,000 --> 00:07:52,000
+And again, don't worry, you will have an opportunity to add all the team members on later stages.
+
+99
+00:07:52,000 --> 00:07:58,000
+For now, I click skip this step and confirm my decision in the pop up window.
+
+100
+00:07:59,000 --> 00:08:05,000
+And on the fourth step, Slack asks me, What is my team working on right now?
+
+101
+00:08:05,000 --> 00:08:09,000
+It asks me this question in order to create channel.
+
+102
+00:08:09,000 --> 00:08:12,000
+I just enter OpenAI and click next.
+
+103
+00:08:13,000 --> 00:08:15,000
+And here's my workspace.
+
+104
+00:08:15,000 --> 00:08:17,000
+Open a channel is created.
+
+105
+00:08:18,000 --> 00:08:20,000
+I also have general channel random.
+
+106
+00:08:21,000 --> 00:08:28,000
+I have possibility to add channels below channels you can find your own direct messages, but in general,
+
+107
+00:08:28,000 --> 00:08:29,000
+that's it.
+
+108
+00:08:29,000 --> 00:08:31,000
+Congratulations.
+
+109
+00:08:31,000 --> 00:08:33,000
+You created the space for a work.
+
+110
+00:08:34,000 --> 00:08:41,000
+You notice that we have a list of channels on the left pane, but what are channels in Slack?
+
+111
+00:08:41,000 --> 00:08:47,000
+Channels are shared spaces where team members can communicate, collaborate and discuss specific topics,
+
+112
+00:08:47,000 --> 00:08:50,000
+projects or areas of interest.
+
+113
+00:08:50,000 --> 00:08:56,000
+They serve as an organized and focused conversation threads within a workspace.
+
+114
+00:08:56,000 --> 00:09:00,000
+For the sake of example, let me create just one more channel.
+
+115
+00:09:01,000 --> 00:09:06,000
+I click on Add Channels button, then select Create a new channel.
+
+116
+00:09:06,000 --> 00:09:15,000
+We already have open a channel, so let's call the new channel GPT and click next configure visibility
+
+117
+00:09:15,000 --> 00:09:16,000
+of the channel.
+
+118
+00:09:16,000 --> 00:09:24,000
+Whether it is public or private, I configure it as public and click create on the last step.
+
+119
+00:09:24,000 --> 00:09:31,000
+You can invite people or you can select option to automatically add anyone who joins your team.
+
+120
+00:09:31,000 --> 00:09:35,000
+Let's select the two and click save.
+
+121
+00:09:35,000 --> 00:09:36,000
+Great.
+
+122
+00:09:36,000 --> 00:09:43,000
+So we installed Slack Registered account, created our workspace and created the channel Super.
+
+123
+00:09:44,000 --> 00:09:48,000
+Now we need to learn more about development in Slack.
+
+124
+00:09:48,000 --> 00:09:54,000
+As developers, we need to create an application in the slack and add it into our workspace.
+
+125
+00:09:55,000 --> 00:10:00,000
+After we would create the application, we can use Slack API to interact with our workspace.
+
+126
+00:10:00,000 --> 00:10:09,000
+Just navigate to the API Slack dotcom apps on the top, you can find green button with the label, create
+
+127
+00:10:09,000 --> 00:10:11,000
+new app, click on it.
+
+128
+00:10:11,000 --> 00:10:20,000
+When creating an app in the Slack, you have two options creating an app from scratch or creating an
+
+129
+00:10:20,000 --> 00:10:22,000
+app from an app manifest.
+
+130
+00:10:22,000 --> 00:10:23,000
+Let's learn.
+
+131
+00:10:23,000 --> 00:10:27,000
+What is the difference between these two and which one to choose?
+
+132
+00:10:27,000 --> 00:10:29,000
+Creating an app from scratch.
+
+133
+00:10:29,000 --> 00:10:35,000
+This option allows you to start building your Slack app from the ground up.
+
+134
+00:10:35,000 --> 00:10:42,000
+You have full control over the development process and can customize every aspect of your app's functionality,
+
+135
+00:10:42,000 --> 00:10:44,000
+User interface and features.
+
+136
+00:10:45,000 --> 00:10:52,000
+Creating an app from scratch gives you the flexibility to design and implement your app according to
+
+137
+00:10:52,000 --> 00:10:58,000
+your specific requirements using the Slack API documentation and resources as your guide.
+
+138
+00:10:59,000 --> 00:11:02,000
+Creating an app from an app manifest.
+
+139
+00:11:02,000 --> 00:11:10,000
+An app manifest is a configuration file that describes your app's properties, permissions, and features.
+
+140
+00:11:10,000 --> 00:11:16,000
+When creating an app from an app manifest, you provide this manifest file instead of starting from
+
+141
+00:11:16,000 --> 00:11:18,000
+a blank page.
+
+142
+00:11:18,000 --> 00:11:25,000
+The app manifest simplifies the app creation process by predefining certain settings and permissions,
+
+143
+00:11:25,000 --> 00:11:28,000
+making it quicker and easier to get started.
+
+144
+00:11:29,000 --> 00:11:34,000
+Creating an app from an app manifest is useful when you want to create an app with a predefined set
+
+145
+00:11:34,000 --> 00:11:41,000
+of features or when you are building an app that follows a certain template or pattern.
+
+146
+00:11:41,000 --> 00:11:48,000
+The app manifest provides a standardized structure for defining your app's properties, including its
+
+147
+00:11:48,000 --> 00:11:53,000
+name, icons, scopes and event subscriptions.
+
+148
+00:11:53,000 --> 00:12:00,000
+This approach can be particularly beneficial if you are creating multiple apps with similar configurations
+
+149
+00:12:00,000 --> 00:12:03,000
+or if you want to streamline the app creation process.
+
+150
+00:12:04,000 --> 00:12:12,000
+Both options offer flexibility, but creating an app from scratch provides more control and customization.
+
+151
+00:12:12,000 --> 00:12:19,000
+While creating an app from an app manifest offers a quicker way to get started by leveraging Pre-configured
+
+152
+00:12:19,000 --> 00:12:20,000
+settings and permissions.
+
+153
+00:12:20,000 --> 00:12:27,000
+The choice between the two options depends on your specific requirements, development preferences and
+
+154
+00:12:27,000 --> 00:12:29,000
+the complexity of your app.
+
+155
+00:12:29,000 --> 00:12:34,000
+But in scope of this lesson, we are going to select from scratch on this stage.
+
+156
+00:12:35,000 --> 00:12:37,000
+Now we need to give a name to our app.
+
+157
+00:12:37,000 --> 00:12:39,000
+Let's call it GPT.
+
+158
+00:12:40,000 --> 00:12:45,000
+And also we need to pick a workspace to develop our app in.
+
+159
+00:12:45,000 --> 00:12:49,000
+Let's select the workspace that we have just created.
+
+160
+00:12:49,000 --> 00:12:51,000
+Run by Tools.com.
+
+161
+00:12:51,000 --> 00:12:52,000
+OpenAI.
+
+162
+00:12:52,000 --> 00:12:56,000
+And now we can click Create App button.
+
+163
+00:12:57,000 --> 00:12:57,000
+Great.
+
+164
+00:12:57,000 --> 00:13:02,000
+We created an app and now we are on the page of our application.
+
+165
+00:13:02,000 --> 00:13:09,000
+The different menus over here, I believe it is no need to be going over each one here because it will
+
+166
+00:13:09,000 --> 00:13:12,000
+be hard for you to remember all of them at once.
+
+167
+00:13:12,000 --> 00:13:18,000
+Instead, we are going to learn gradually all the configurations that we need in each lesson.
+
+168
+00:13:19,000 --> 00:13:23,000
+But before we move further, let's understand what else do we need to configure?
+
+169
+00:13:24,000 --> 00:13:31,000
+We are going to deal with different third party tools and APIs in this course, and I want you to understand
+
+170
+00:13:31,000 --> 00:13:38,000
+the basic concept of incoming and outgoing webhooks, because this is a common terminology, particularly
+
+171
+00:13:38,000 --> 00:13:42,000
+in the context of integrating with communication platforms like Slack.
+
+172
+00:13:42,000 --> 00:13:49,000
+And no matter which tool or API you want to integrate with, you are going to start from searching in
+
+173
+00:13:49,000 --> 00:13:57,000
+the documentation about how incoming and outgoing webhooks work and how they can be configured in this
+
+174
+00:13:57,000 --> 00:13:57,000
+tool.
+
+175
+00:13:57,000 --> 00:14:03,000
+Let's understand first what are incoming webhooks in common?
+
+176
+00:14:03,000 --> 00:14:10,000
+Webhooks are a feature provided by platforms like Slack that allow external systems or applications
+
+177
+00:14:10,000 --> 00:14:13,000
+to send data or messages into a specific channel.
+
+178
+00:14:14,000 --> 00:14:21,000
+It provides a URL endpoint that can be used to programmatically post messages or updates into the platform.
+
+179
+00:14:21,000 --> 00:14:29,000
+This feature is commonly used to integrate external services, scripts or systems with messaging platforms,
+
+180
+00:14:29,000 --> 00:14:34,000
+enabling notifications, alerts or information sharing.
+
+181
+00:14:34,000 --> 00:14:39,000
+So we need to use incoming webhook in order to send the information to the slack.
+
+182
+00:14:39,000 --> 00:14:42,000
+And what is outgoing webhook?
+
+183
+00:14:42,000 --> 00:14:43,000
+Would go in.
+
+184
+00:14:43,000 --> 00:14:51,000
+Webhooks, on the other hand, are a way for platforms like Slack to send data or notifications to external
+
+185
+00:14:51,000 --> 00:14:53,000
+systems or applications.
+
+186
+00:14:53,000 --> 00:15:00,000
+They work by configuring a URL endpoint in the platform, which the platform will send Http requests
+
+187
+00:15:00,000 --> 00:15:04,000
+to when specific events or triggers occur.
+
+188
+00:15:04,000 --> 00:15:11,000
+This allows external systems to receive real time updates or data from the platform and take appropriate
+
+189
+00:15:11,000 --> 00:15:14,000
+actions or process the information accordingly.
+
+190
+00:15:14,000 --> 00:15:22,000
+So we need to configure outgoing webhook in order to receive updates each time when somebody posts something
+
+191
+00:15:22,000 --> 00:15:24,000
+and tags our application in the slack.
+
+192
+00:15:24,000 --> 00:15:30,000
+Just one of the examples because there are a lot of different events that we can track.
+
+193
+00:15:31,000 --> 00:15:35,000
+In this case, we can receive the event and process it accordingly.
+
+194
+00:15:36,000 --> 00:15:43,000
+I will go in webhooks in Slack enable you to configure specific triggers or events within Slack channels
+
+195
+00:15:43,000 --> 00:15:46,000
+when one of these triggers occurs.
+
+196
+00:15:46,000 --> 00:15:53,000
+Slack will send an Http post request to a designated URL or endpoint of your choice.
+
+197
+00:15:53,000 --> 00:15:59,000
+The payload of the request contains relevant information about the triggering event, such as the message
+
+198
+00:15:59,000 --> 00:16:02,000
+content, sender channel and more.
+
+199
+00:16:03,000 --> 00:16:10,000
+By setting up outgoing webhooks, you can integrate Slack with external systems, services or APIs to
+
+200
+00:16:10,000 --> 00:16:16,000
+trigger actions or send data to other applications based on events within Slack.
+
+201
+00:16:16,000 --> 00:16:23,000
+This allows for real time communication and automation between Slack and other platforms.
+
+202
+00:16:23,000 --> 00:16:30,000
+To configure an outgoing webhook integration in Slack, you typically specify the trigger conditions.
+
+203
+00:16:30,000 --> 00:16:37,000
+For example, keywords mentions channel events and provides a target URL or endpoint that will receive
+
+204
+00:16:37,000 --> 00:16:39,000
+the outgoing webhook requests.
+
+205
+00:16:40,000 --> 00:16:46,000
+The receiving endpoint can be implemented by your own application or service, allowing you to process
+
+206
+00:16:46,000 --> 00:16:52,000
+the incoming requests and perform the desired actions or data processing in the slack.
+
+207
+00:16:52,000 --> 00:16:56,000
+Outgoing webhook is implemented as a part of events API.
+
+208
+00:16:57,000 --> 00:17:02,000
+Let's learn more about events in order to understand what it actually is.
+
+209
+00:17:03,000 --> 00:17:10,000
+The Slack Events API allows you to build apps that listen to and respond to events happening within
+
+210
+00:17:10,000 --> 00:17:13,000
+a Slack workspace in real time.
+
+211
+00:17:13,000 --> 00:17:19,000
+It provides a way for your app to receive notifications about various activities, such as messages
+
+212
+00:17:19,000 --> 00:17:26,000
+being posted, channels being created, users joining or leaving a channel and more.
+
+213
+00:17:26,000 --> 00:17:32,000
+And to build great applications, it is integrated with Slack and ensures amazing user experience.
+
+214
+00:17:32,000 --> 00:17:36,000
+We need to be able to process these events.
+
+215
+00:17:36,000 --> 00:17:40,000
+Here are some key points about the Slack events API.
+
+216
+00:17:41,000 --> 00:17:43,000
+Real time event notifications.
+
+217
+00:17:43,000 --> 00:17:50,000
+The Events API provides real time notifications about events occurring within a Slack workspace.
+
+218
+00:17:50,000 --> 00:17:54,000
+When an event is that your app has subscribed to takes place.
+
+219
+00:17:54,000 --> 00:18:02,000
+Slack sends an Http post request to a designated URL known as the event endpoint.
+
+220
+00:18:02,000 --> 00:18:04,000
+Configure it for your app.
+
+221
+00:18:05,000 --> 00:18:06,000
+Event types.
+
+222
+00:18:06,000 --> 00:18:13,000
+The Slack Events API supports a wide range of event types that you can subscribe to, including message
+
+223
+00:18:13,000 --> 00:18:20,000
+related events, user related events, channel related events, app related events, and more.
+
+224
+00:18:20,000 --> 00:18:26,000
+This allows your app to be notified of specific events that are relevant to your app's functionality
+
+225
+00:18:26,000 --> 00:18:27,000
+and integration.
+
+226
+00:18:28,000 --> 00:18:35,000
+Authentication and Permission Scopes To receive event notifications, Your app needs to be installed
+
+227
+00:18:35,000 --> 00:18:39,000
+in a Slack workspace and authorized with the necessary scopes.
+
+228
+00:18:39,000 --> 00:18:46,000
+The Events API requires the appropriate permission scopes to access the data and perform actions related
+
+229
+00:18:46,000 --> 00:18:48,000
+to the subscribed events.
+
+230
+00:18:48,000 --> 00:18:53,000
+I'm going to show you in the following lessons how to configure these permissions.
+
+231
+00:18:54,000 --> 00:18:55,000
+Event payload.
+
+232
+00:18:55,000 --> 00:19:03,000
+When an event occurs, Slack sends Json payload containing information about the event to your app's
+
+233
+00:19:03,000 --> 00:19:05,000
+event endpoint.
+
+234
+00:19:05,000 --> 00:19:11,000
+Your app can process this payload to extract relevant data and take appropriate actions.
+
+235
+00:19:12,000 --> 00:19:15,000
+Event subscriptions and app configuration.
+
+236
+00:19:16,000 --> 00:19:21,000
+To use the events API, you need to configure event subscriptions for your app.
+
+237
+00:19:21,000 --> 00:19:28,000
+This involves specifying the event types you want to receive notifications for and providing the necessary
+
+238
+00:19:28,000 --> 00:19:30,000
+event handling logic in your app.
+
+239
+00:19:30,000 --> 00:19:37,000
+You can configure event subscriptions either programmatically or through the Slack app configuration
+
+240
+00:19:37,000 --> 00:19:38,000
+dashboard.
+
+241
+00:19:39,000 --> 00:19:41,000
+Response Acknowledgement.
+
+242
+00:19:41,000 --> 00:19:48,000
+Your app is expected to acknowledge the receipt of an event by sending a 200 okay response to Slack
+
+243
+00:19:48,000 --> 00:19:50,000
+within a certain time frame.
+
+244
+00:19:50,000 --> 00:19:58,000
+This acknowledgement indicates that your app has received the event notification successfully by leveraging
+
+245
+00:19:58,000 --> 00:19:59,000
+the Slack Events API.
+
+246
+00:19:59,000 --> 00:20:07,000
+You can build apps that respond to real time events, automate tasks, synchronize data between Slack
+
+247
+00:20:07,000 --> 00:20:12,000
+and other systems, and create interactive experiences within Slack channels.
+
+248
+00:20:13,000 --> 00:20:18,000
+Coming back to our Slack application, let's click on event subscriptions and configure it.
+
+249
+00:20:18,000 --> 00:20:25,000
+Here, you need to change the state of switch to enable events, and now we need to provide a URL.
+
+250
+00:20:26,000 --> 00:20:31,000
+This is the point where Slack will send post requests to in case of event.
+
+251
+00:20:32,000 --> 00:20:35,000
+You can see that I set IP address here.
+
+252
+00:20:35,000 --> 00:20:36,000
+What is it?
+
+253
+00:20:36,000 --> 00:20:41,000
+This is public API endpoint exposed to the world from my home.
+
+254
+00:20:41,000 --> 00:20:50,000
+Just paste your endpoint in request URL text field and post request will be sent to your application.
+
+255
+00:20:50,000 --> 00:20:57,000
+I published a separate lesson about how to expose your application endpoints from your home computer,
+
+256
+00:20:57,000 --> 00:21:02,000
+and also that lesson contains information about port forwarding configuration.
+
+257
+00:21:02,000 --> 00:21:10,000
+Make sure you watch that lesson because in that lesson I explained all the details How to configure
+
+258
+00:21:10,000 --> 00:21:11,000
+port forwarding in order.
+
+259
+00:21:11,000 --> 00:21:15,000
+You can use IP address of your computer in this lesson.
+
+260
+00:21:15,000 --> 00:21:18,000
+Please let me know in case there are any questions.
+
+261
+00:21:19,000 --> 00:21:24,000
+So when you configure it request URL, you are going to receive something like this.
+
+262
+00:21:25,000 --> 00:21:29,000
+Json was talking challenge and type attributes.
+
+263
+00:21:30,000 --> 00:21:36,000
+You can learn this by printing to console request body that you received in your endpoint and most likely
+
+264
+00:21:36,000 --> 00:21:43,000
+you will receive error from the slack side because in order to pass this simple validation, you need
+
+265
+00:21:43,000 --> 00:21:47,000
+to send back to slack the value of the challenge parameter.
+
+266
+00:21:47,000 --> 00:21:54,000
+That's why you need to write simple code in order to pass the challenge parameter and send it back in
+
+267
+00:21:54,000 --> 00:21:55,000
+response.
+
+268
+00:21:55,000 --> 00:21:59,000
+So you need to write similar message like you can see on the screen.
+
+269
+00:21:59,000 --> 00:22:05,000
+We just need to extract the value of the challenge attribute and send it back in response.
+
+270
+00:22:05,000 --> 00:22:07,000
+Don't worry.
+
+271
+00:22:07,000 --> 00:22:12,000
+In attachments for this lesson, I would attach the reference to the commit and source code and you
+
+272
+00:22:12,000 --> 00:22:18,000
+will be able to see exactly the source code that I used to pass this verification.
+
+273
+00:22:18,000 --> 00:22:25,000
+Once you wrote the method in the similar way, you need to click resend button in Slack, then Slack
+
+274
+00:22:25,000 --> 00:22:33,000
+will send one more message and in case you get everything correct, you are going to see the notification
+
+275
+00:22:33,000 --> 00:22:34,000
+that verification is passed.
+
+276
+00:22:35,000 --> 00:22:43,000
+In order to activate Save Changes button, let's just subscribe to one simple event and all other scopes
+
+277
+00:22:43,000 --> 00:22:49,000
+and details will clarify in the next lesson because we already learned a lot for this lesson.
+
+278
+00:22:49,000 --> 00:22:58,000
+In the subscribe to both Events section, I add app mentioned event and now Save Changes button Become
+
+279
+00:22:58,000 --> 00:23:05,000
+active and I can click it After making changes with permissions, you need to reinstall your application
+
+280
+00:23:05,000 --> 00:23:09,000
+taking into account we have just created this application.
+
+281
+00:23:09,000 --> 00:23:12,000
+We didn't install it yet to the workspace.
+
+282
+00:23:12,000 --> 00:23:20,000
+Let's click install app in the side pane and let's click here install to workspace, follow the hints
+
+283
+00:23:20,000 --> 00:23:23,000
+to complete the installation.
+
+284
+00:23:23,000 --> 00:23:24,000
+Congratulations.
+
+285
+00:23:24,000 --> 00:23:31,000
+From now on we can add new subscriptions to events, but we will add those in the next lessons.
+
+286
+00:23:31,000 --> 00:23:36,000
+And the last but not the least, things that we are going to do in this lesson in order to prepare our
+
+287
+00:23:36,000 --> 00:23:38,000
+environment for development.
+
+288
+00:23:38,000 --> 00:23:45,000
+In the next lesson, let's activate incoming webhook because we would need also to post messages into
+
+289
+00:23:45,000 --> 00:23:45,000
+the slack.
+
+290
+00:23:45,000 --> 00:23:46,000
+Correct?
+
+291
+00:23:46,000 --> 00:23:53,000
+So in the side pane you can find list of features select incoming webhooks.
+
+292
+00:23:53,000 --> 00:23:57,000
+Here you need to activate incoming webhooks.
+
+293
+00:23:57,000 --> 00:24:04,000
+Use this feature and once it is activated you need to add new webhook to workspace.
+
+294
+00:24:04,000 --> 00:24:10,000
+So just click this button On the next step you will need to select the channel.
+
+295
+00:24:10,000 --> 00:24:13,000
+Where should application post to?
+
+296
+00:24:14,000 --> 00:24:17,000
+Let's select GPT channel and click Allow.
+
+297
+00:24:18,000 --> 00:24:19,000
+Amazing.
+
+298
+00:24:19,000 --> 00:24:24,000
+So now you have webhook URL and you are completely ready for the next lesson.
+
+299
+00:24:25,000 --> 00:24:28,000
+That's all what I wanted to share with you in this lesson.
+
+300
+00:24:28,000 --> 00:24:33,000
+Let's recap what we have learned today in this lesson.
+
+301
+00:24:33,000 --> 00:24:34,000
+We learned what a slack is.
+
+302
+00:24:35,000 --> 00:24:39,000
+Together, we created an account, a workspace and a channel.
+
+303
+00:24:39,000 --> 00:24:39,000
+In Slack.
+
+304
+00:24:40,000 --> 00:24:42,000
+We created Application and Slack.
+
+305
+00:24:42,000 --> 00:24:46,000
+We configured outgoing and incoming web hooks in Slack.
+
+306
+00:24:46,000 --> 00:24:50,000
+Now you know the basics of events API in Slack.
+
+307
+00:24:51,000 --> 00:24:52,000
+That's it.
+
+308
+00:24:52,000 --> 00:24:54,000
+Thanks a lot for your attention.
+
+309
+00:24:54,000 --> 00:24:57,000
+Have a great day and see you in the next lesson.
+
diff --git a/98 - GPT + Slack Integration/001 Source-code-of-examples-from-the-lesson-commit-with-changes-.url b/98 - GPT + Slack Integration/001 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..d3e144f17650e52b5a427e68df896b7153f06ac1
--- /dev/null
+++ b/98 - GPT + Slack Integration/001 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/openai-learnit/commit/83729ecb93896662e0dce86e4e0ce7d18ca5e10b
\ No newline at end of file
diff --git a/98 - GPT + Slack Integration/002 Connect GPT to the Slack_en.srt b/98 - GPT + Slack Integration/002 Connect GPT to the Slack_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..0a1dc60577700f3b367938db45ec12d90c67aaff
--- /dev/null
+++ b/98 - GPT + Slack Integration/002 Connect GPT to the Slack_en.srt
@@ -0,0 +1,1460 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:13,000
+In the previous lesson we created an app in Slack and configure it incoming and outgoing webhooks and
+
+3
+00:00:13,000 --> 00:00:18,000
+we gradually move to our goal to create an application that would help us to automate project management
+
+4
+00:00:18,000 --> 00:00:19,000
+operations.
+
+5
+00:00:19,000 --> 00:00:25,000
+And the next step towards our goal is to make sure that we can interact with GPT from the Slack channel
+
+6
+00:00:25,000 --> 00:00:28,000
+that we also created in the previous lesson.
+
+7
+00:00:28,000 --> 00:00:33,000
+So today we are going to have a lot of practical examples and we will make sure that we can talk to
+
+8
+00:00:33,000 --> 00:00:37,000
+GPT and receive responses from it through the slack.
+
+9
+00:00:38,000 --> 00:00:42,000
+We are going to start the lesson from review of the application architecture.
+
+10
+00:00:42,000 --> 00:00:48,000
+I'm going to explain you how integration between our application Slack and GPT is going to look like
+
+11
+00:00:48,000 --> 00:00:50,000
+on the simple scheme.
+
+12
+00:00:50,000 --> 00:00:56,000
+Then I will show you how you can add the app to the channel and I will make a demo of what we are going
+
+13
+00:00:56,000 --> 00:00:58,000
+to implement during the lesson.
+
+14
+00:00:58,000 --> 00:01:04,000
+Especially for this lesson, I prepared real web applications that integrate Slack and GPT.
+
+15
+00:01:04,000 --> 00:01:10,000
+The biggest part of the lesson we are going to spend on review of code examples in order to understand
+
+16
+00:01:10,000 --> 00:01:17,000
+how all integrations work under the hood, we are going to learn the key attributes of Slack events
+
+17
+00:01:17,000 --> 00:01:18,000
+payload in order.
+
+18
+00:01:18,000 --> 00:01:23,000
+You can understand which attributes you can use in your application.
+
+19
+00:01:23,000 --> 00:01:26,000
+During the lesson, we are going to use Slack Java SDK.
+
+20
+00:01:26,000 --> 00:01:31,000
+So after this lesson you will know how to use Slack Java SDK.
+
+21
+00:01:32,000 --> 00:01:38,000
+Also, we will make a brief overview of Slack SDKs for other programming languages, and at the end
+
+22
+00:01:38,000 --> 00:01:44,000
+of the lesson we are going to learn what scopes in Slack are and configure all required scopes for our
+
+23
+00:01:44,000 --> 00:01:45,000
+application.
+
+24
+00:01:45,000 --> 00:01:50,000
+And also we are going to set up nice picture for our Slack application.
+
+25
+00:01:51,000 --> 00:01:52,000
+Let's start our lesson.
+
+26
+00:01:53,000 --> 00:01:57,000
+Let me start with a brief overview of what we are going to implement today.
+
+27
+00:01:57,000 --> 00:02:00,000
+Basically, we will implement simple flow.
+
+28
+00:02:00,000 --> 00:02:02,000
+We post a message inside the slack.
+
+29
+00:02:03,000 --> 00:02:09,000
+Our web application receives a payload with the details of events that happened in Slack.
+
+30
+00:02:09,000 --> 00:02:16,000
+We process the slag's payload to extract all information needed in order to prepare a request to the
+
+31
+00:02:16,000 --> 00:02:17,000
+GPT.
+
+32
+00:02:17,000 --> 00:02:19,000
+We send a request to GPT.
+
+33
+00:02:20,000 --> 00:02:27,000
+We receive a response from GPT and then we post response from GPT directly to the Slack channel.
+
+34
+00:02:28,000 --> 00:02:33,000
+That is a simple and basic flow that we are going to implement in this lesson.
+
+35
+00:02:33,000 --> 00:02:38,000
+And as I said at the beginning of the lesson, this is going to be the lesson full of practical examples
+
+36
+00:02:38,000 --> 00:02:40,000
+and exercises.
+
+37
+00:02:40,000 --> 00:02:44,000
+So let me jump directly to the screen sharing and code examples.
+
+38
+00:02:45,000 --> 00:02:51,000
+Let me start with the demo of the expected result that we are going to achieve in this lesson.
+
+39
+00:02:51,000 --> 00:02:57,000
+So by the end of this lesson, we will be able to communicate with ChatGPT through the Slack interface.
+
+40
+00:02:58,000 --> 00:03:07,000
+I can tag my application and send the message GPT Hey, that's what I wrote and I expect to receive
+
+41
+00:03:07,000 --> 00:03:08,000
+response.
+
+42
+00:03:08,000 --> 00:03:15,000
+And another important thing, I can chat with GPT from any channel where I added my app.
+
+43
+00:03:15,000 --> 00:03:20,000
+As you can see, I can also receive response from an OpenAI channel.
+
+44
+00:03:20,000 --> 00:03:23,000
+How to add app to the channel.
+
+45
+00:03:23,000 --> 00:03:24,000
+There are few ways to do this.
+
+46
+00:03:24,000 --> 00:03:27,000
+Let me show you on the example of general channel.
+
+47
+00:03:27,000 --> 00:03:34,000
+The first option is to click on the channel name in the header Select Integrations tab, click button,
+
+48
+00:03:34,000 --> 00:03:39,000
+add an app and find an app that you want to add to the channel.
+
+49
+00:03:39,000 --> 00:03:45,000
+You can see that there is already GPT app in my workspace, so I can easily add it if I wish.
+
+50
+00:03:46,000 --> 00:03:52,000
+The second option to add app integration to the channel in case it is already present in the workspace
+
+51
+00:03:52,000 --> 00:03:55,000
+is just tag it in the message.
+
+52
+00:03:55,000 --> 00:03:56,000
+Let me show you.
+
+53
+00:03:56,000 --> 00:03:59,000
+I write a message and I tag GPT.
+
+54
+00:04:00,000 --> 00:04:04,000
+As you can see, Slack offers me to add GPT to the channel.
+
+55
+00:04:04,000 --> 00:04:07,000
+Just invite GPT and that's it.
+
+56
+00:04:07,000 --> 00:04:12,000
+Integration is created and now you can use GPT from this channel too.
+
+57
+00:04:12,000 --> 00:04:18,000
+I wrote code in such a way that it will reply to the channel where question was asked.
+
+58
+00:04:18,000 --> 00:04:24,000
+As usual, you can find source code examples in attachments to this lesson, but in order to explain
+
+59
+00:04:24,000 --> 00:04:29,000
+you how everything works here, let me show you how the code works line by line.
+
+60
+00:04:29,000 --> 00:04:32,000
+So I started my spring boot app.
+
+61
+00:04:32,000 --> 00:04:34,000
+It is up and running.
+
+62
+00:04:34,000 --> 00:04:39,000
+Everything begins in the class that is called Slack Integration Controller.
+
+63
+00:04:39,000 --> 00:04:45,000
+In the previous lesson, we used this endpoint when we configured subscription to app mention an event.
+
+64
+00:04:45,000 --> 00:04:49,000
+That's why we receive payload from Slack in this method.
+
+65
+00:04:50,000 --> 00:04:54,000
+Pay attention how this method is written because I need to return 200.
+
+66
+00:04:54,000 --> 00:04:55,000
+Okay.
+
+67
+00:04:55,000 --> 00:05:02,000
+Status back to Slack confirming that I received an event in case Slack wouldn't receive confirmation
+
+68
+00:05:02,000 --> 00:05:03,000
+within three seconds or so.
+
+69
+00:05:03,000 --> 00:05:09,000
+It will make retry attempt and we don't want to receive the same events multiple times.
+
+70
+00:05:09,000 --> 00:05:12,000
+That's why I run event processing.
+
+71
+00:05:12,000 --> 00:05:18,000
+In the separate thread you can see that I used class completablefuture in order to kick off new thread.
+
+72
+00:05:19,000 --> 00:05:21,000
+If you want to learn more about Multi-threading in Java.
+
+73
+00:05:21,000 --> 00:05:28,000
+Just to remind you that of course Java from zero to first job where I publish separate and solid section
+
+74
+00:05:28,000 --> 00:05:30,000
+about Multi-threading in Java.
+
+75
+00:05:30,000 --> 00:05:33,000
+There was a separate lesson about Completablefuture too.
+
+76
+00:05:34,000 --> 00:05:39,000
+That's why wouldn't stop too much explaining the details about Multi-threading in Java.
+
+77
+00:05:40,000 --> 00:05:44,000
+You can also see here callback in when complete method.
+
+78
+00:05:44,000 --> 00:05:50,000
+It is here to notify us about exception in the thread, so in case some exception will be thrown in
+
+79
+00:05:50,000 --> 00:05:55,000
+the thread, we will print the details to the stack trace and of course team.
+
+80
+00:05:55,000 --> 00:06:02,000
+Like I teach my students in the lessons about best practices, it is recommended to use logger and log
+
+81
+00:06:02,000 --> 00:06:08,000
+all the exceptions in the configured logger, but taking into account we have learning sessions in the
+
+82
+00:06:08,000 --> 00:06:14,000
+style of active development, I believe that it would be easier for you to observe errors and details
+
+83
+00:06:14,000 --> 00:06:16,000
+directly in the console.
+
+84
+00:06:16,000 --> 00:06:22,000
+But of course when we will go to production, we need to clean this up and configure proper logging.
+
+85
+00:06:22,000 --> 00:06:24,000
+Okay, so we agreed on this.
+
+86
+00:06:25,000 --> 00:06:31,000
+I'll return from the method empty string because the main thing for Slack is to receive 200.
+
+87
+00:06:31,000 --> 00:06:32,000
+Okay.
+
+88
+00:06:32,000 --> 00:06:35,000
+Status and that is default response status.
+
+89
+00:06:35,000 --> 00:06:38,000
+That's why I don't specify anything special here.
+
+90
+00:06:38,000 --> 00:06:44,000
+We need to process payload that we received from Slack in order to process the payload.
+
+91
+00:06:45,000 --> 00:06:49,000
+Let's look at it in order to understand what information we can find there.
+
+92
+00:06:50,000 --> 00:06:54,000
+On this slide, you can see formatted view of the payload from Slack.
+
+93
+00:06:54,000 --> 00:07:00,000
+Let me make a brief overview of it and highlight the key points about its structure and main properties.
+
+94
+00:07:00,000 --> 00:07:07,000
+My goal is to help you to understand which properties might be useful for building your own application
+
+95
+00:07:07,000 --> 00:07:10,000
+and how potentially you can use them in your application.
+
+96
+00:07:11,000 --> 00:07:16,000
+As you can see, the payload is a Json object containing various properties.
+
+97
+00:07:16,000 --> 00:07:19,000
+It represents an event callback received from Slack.
+
+98
+00:07:19,000 --> 00:07:21,000
+When your app is mentioned.
+
+99
+00:07:21,000 --> 00:07:23,000
+Let's review important properties now.
+
+100
+00:07:24,000 --> 00:07:32,000
+Token A unique token representing the authentication of the Slack app id the ID of the Slack team.
+
+101
+00:07:32,000 --> 00:07:33,000
+Where.
+
+102
+00:07:33,000 --> 00:07:34,000
+The event occurred.
+
+103
+00:07:35,000 --> 00:07:39,000
+API app ID, the idea of the Slack app associated with the event.
+
+104
+00:07:40,000 --> 00:07:47,000
+That's the one that we created in the previous lesson because potentially you can have one web application
+
+105
+00:07:47,000 --> 00:07:53,000
+and build custom processing logic for events from different slack applications.
+
+106
+00:07:54,000 --> 00:08:00,000
+Event, an object containing details about the specific event that triggered the callback.
+
+107
+00:08:00,000 --> 00:08:06,000
+In our today's example, most of the required information will pass from this object type.
+
+108
+00:08:06,000 --> 00:08:10,000
+The type of event which in this case is app mansion.
+
+109
+00:08:10,000 --> 00:08:16,000
+You can use the value from this field to build different logic for processing of different types of
+
+110
+00:08:16,000 --> 00:08:17,000
+events.
+
+111
+00:08:17,000 --> 00:08:20,000
+So far in this stage we have only one type of event.
+
+112
+00:08:20,000 --> 00:08:28,000
+That's why it is obvious for me that all events that will receive are app mentions events, text the
+
+113
+00:08:28,000 --> 00:08:31,000
+text of the message that mentioned the app.
+
+114
+00:08:32,000 --> 00:08:34,000
+Pay attention here to the message.
+
+115
+00:08:34,000 --> 00:08:39,000
+You can see that in case there was a mention, it has specific format in text.
+
+116
+00:08:39,000 --> 00:08:42,000
+Namely user ID is used like this.
+
+117
+00:08:42,000 --> 00:08:51,000
+It is not clear who is mentioned here and whether it makes some sense for the context in general, because
+
+118
+00:08:51,000 --> 00:08:57,000
+imagine that in case you mentioned few team members in the same message and ask when they will finish
+
+119
+00:08:57,000 --> 00:09:00,000
+their tasks according to plan.
+
+120
+00:09:00,000 --> 00:09:04,000
+In this case, we would need to handle mapping between user IDs and names.
+
+121
+00:09:05,000 --> 00:09:11,000
+If we would consider that this is important for the context, you know, the GPT can recognize the mentioned
+
+122
+00:09:11,000 --> 00:09:12,000
+people.
+
+123
+00:09:13,000 --> 00:09:14,000
+Today in the lesson.
+
+124
+00:09:14,000 --> 00:09:16,000
+I'm going to handle this case.
+
+125
+00:09:16,000 --> 00:09:23,000
+Namely, I'm going to fetch from slack information about user by its ID that I can see here.
+
+126
+00:09:23,000 --> 00:09:30,000
+Take the real name of user associated with this ID and substitute it in the text before sending prompt
+
+127
+00:09:30,000 --> 00:09:30,000
+to the GPT.
+
+128
+00:09:30,000 --> 00:09:32,000
+Is it clear?
+
+129
+00:09:32,000 --> 00:09:36,000
+And remember team, in case you have any questions, don't wait.
+
+130
+00:09:36,000 --> 00:09:40,000
+Ask them instantly below this video and I will be happy to answer.
+
+131
+00:09:41,000 --> 00:09:42,000
+User attribute.
+
+132
+00:09:42,000 --> 00:09:46,000
+It contains the user who sends the message.
+
+133
+00:09:46,000 --> 00:09:51,000
+This is also important information for us when we will build history of messages.
+
+134
+00:09:51,000 --> 00:09:59,000
+It is nice to specify author of each message in order to give the GPT as much context as we can, but
+
+135
+00:09:59,000 --> 00:10:01,000
+pay attention that we have here again.
+
+136
+00:10:01,000 --> 00:10:05,000
+So we will need to resolve author name to.
+
+137
+00:10:06,000 --> 00:10:09,000
+Here's the timestamp of the message.
+
+138
+00:10:09,000 --> 00:10:14,000
+Might be a good idea to use timestamp in order to track the time of event and message.
+
+139
+00:10:15,000 --> 00:10:20,000
+Blocks, an array of blocks representing the messages, content and structure.
+
+140
+00:10:20,000 --> 00:10:24,000
+This is for more advanced message content analysis.
+
+141
+00:10:25,000 --> 00:10:25,000
+Team.
+
+142
+00:10:25,000 --> 00:10:29,000
+The idea of the team was the event occurred channel.
+
+143
+00:10:29,000 --> 00:10:32,000
+The idea of the channel was the message was posted.
+
+144
+00:10:33,000 --> 00:10:34,000
+Events.
+
+145
+00:10:35,000 --> 00:10:37,000
+The timestamp of the event.
+
+146
+00:10:37,000 --> 00:10:41,000
+And you remember that previously we had field that is called RTS.
+
+147
+00:10:41,000 --> 00:10:43,000
+So what is the difference?
+
+148
+00:10:43,000 --> 00:10:48,000
+Basically, RTS is associated with the message that triggered the event.
+
+149
+00:10:48,000 --> 00:10:55,000
+It helps to identify when message was posted, but when RTS refers to the timestamp of event, callback
+
+150
+00:10:55,000 --> 00:11:00,000
+itself represents the timestamp of the overall event that occurred within Slack.
+
+151
+00:11:01,000 --> 00:11:09,000
+Type indicates that this payload represents an event callback, but obviously different types can be
+
+152
+00:11:09,000 --> 00:11:09,000
+here.
+
+153
+00:11:10,000 --> 00:11:14,000
+Event id the ID of the specific event within the team.
+
+154
+00:11:14,000 --> 00:11:17,000
+Event time The timestamp of the event.
+
+155
+00:11:18,000 --> 00:11:22,000
+You can see that it is just a little bit different format.
+
+156
+00:11:22,000 --> 00:11:27,000
+In events we have better precision and this is regular Unix time format.
+
+157
+00:11:28,000 --> 00:11:34,000
+Authorizations, an array containing information about authorized users for the app.
+
+158
+00:11:34,000 --> 00:11:40,000
+Based on this content, you can see that we use of our boat associated with the application.
+
+159
+00:11:40,000 --> 00:11:43,000
+It was created automatically.
+
+160
+00:11:43,000 --> 00:11:46,000
+Is X shared channel.
+
+161
+00:11:46,000 --> 00:11:50,000
+Indicates whether the event occurred in the externally shared channel.
+
+162
+00:11:51,000 --> 00:11:56,000
+An externally shared channel in Slack refers to the channel that is shared between two separate Slack
+
+163
+00:11:56,000 --> 00:11:59,000
+workspaces or organizations.
+
+164
+00:11:59,000 --> 00:12:05,000
+It allows users from different workspaces to collaborate and communicate within the same channel, providing
+
+165
+00:12:06,000 --> 00:12:10,000
+a way to bridge communication between different teams or organizations.
+
+166
+00:12:11,000 --> 00:12:14,000
+So now you know the structure of Slack's payload.
+
+167
+00:12:15,000 --> 00:12:21,000
+The next thing that we are going to do is to pass relevant information that we need send request to
+
+168
+00:12:21,000 --> 00:12:26,000
+GPT, receive response from GPT and send response back to the slack.
+
+169
+00:12:26,000 --> 00:12:28,000
+Let's continue.
+
+170
+00:12:28,000 --> 00:12:31,000
+Let's get back to our example now.
+
+171
+00:12:31,000 --> 00:12:36,000
+I'm going to explain you what is happening inside process, unmentioned event method.
+
+172
+00:12:36,000 --> 00:12:43,000
+As you can see, this is the method of Slack service that are injected into the controller.
+
+173
+00:12:43,000 --> 00:12:48,000
+Slack service is just an interface that declares a contract for two methods.
+
+174
+00:12:48,000 --> 00:12:55,000
+So far they are process and mention event that we are going to review today and remove all messages
+
+175
+00:12:55,000 --> 00:12:56,000
+from channel.
+
+176
+00:12:57,000 --> 00:13:00,000
+The second method is for development purposes.
+
+177
+00:13:00,000 --> 00:13:06,000
+It helps me to keep history of the channel clean because there are a lot of iterations of debugging
+
+178
+00:13:06,000 --> 00:13:13,000
+and instead of removing channel and creating new, I created APIs that allows me to remove all messages
+
+179
+00:13:13,000 --> 00:13:14,000
+from the channel.
+
+180
+00:13:14,000 --> 00:13:20,000
+There is one implementation of this interface that is called default Slack service.
+
+181
+00:13:20,000 --> 00:13:23,000
+Let's understand what is going on there inside.
+
+182
+00:13:24,000 --> 00:13:27,000
+I call method extract slack request data.
+
+183
+00:13:28,000 --> 00:13:34,000
+According to the developed API here, I expect to receive Slack request data object that should contain
+
+184
+00:13:34,000 --> 00:13:40,000
+author name the message itself and the channel where this message came from.
+
+185
+00:13:41,000 --> 00:13:49,000
+Inside extract Slack request data method With the help of Json library, I convert request body string
+
+186
+00:13:49,000 --> 00:13:50,000
+into Json object.
+
+187
+00:13:51,000 --> 00:13:58,000
+We already learned the structure, so I bet you remember that in Slack payload we had event object and
+
+188
+00:13:58,000 --> 00:14:01,000
+inside that object we add text attribute.
+
+189
+00:14:01,000 --> 00:14:04,000
+So extract text value.
+
+190
+00:14:04,000 --> 00:14:06,000
+That is our message.
+
+191
+00:14:06,000 --> 00:14:10,000
+Separately, I extract a year of the author of the message.
+
+192
+00:14:10,000 --> 00:14:15,000
+Also, I need to extract channel ID in order to know where to reply.
+
+193
+00:14:16,000 --> 00:14:20,000
+In this line I extract user id to usernames map.
+
+194
+00:14:20,000 --> 00:14:22,000
+Why do I need this?
+
+195
+00:14:22,000 --> 00:14:29,000
+You remember that when we reviewed Slack payload, we noticed that Slack mentions are just user IDs
+
+196
+00:14:29,000 --> 00:14:31,000
+with specific markup around.
+
+197
+00:14:31,000 --> 00:14:36,000
+And also you don't have the name of the author of the message.
+
+198
+00:14:36,000 --> 00:14:37,000
+We just have the ID.
+
+199
+00:14:37,000 --> 00:14:44,000
+In order to get the name by ID, I need this map in the extract user id to name map method.
+
+200
+00:14:44,000 --> 00:14:47,000
+I use Slack SDK for Java.
+
+201
+00:14:47,000 --> 00:14:52,000
+So first of all, I need to add a dependency in the pom.xml.
+
+202
+00:14:52,000 --> 00:14:54,000
+Let me open pore maximum.
+
+203
+00:14:54,000 --> 00:14:58,000
+Here you will find new dependency that I added.
+
+204
+00:14:58,000 --> 00:15:00,000
+You can find it in maven wrapper.
+
+205
+00:15:01,000 --> 00:15:04,000
+This is official software development kit for Java by Slack.
+
+206
+00:15:04,000 --> 00:15:10,000
+But what to do in case you want to develop application using other programming language?
+
+207
+00:15:10,000 --> 00:15:11,000
+No worries.
+
+208
+00:15:11,000 --> 00:15:15,000
+Slack released SDK for different programming languages.
+
+209
+00:15:15,000 --> 00:15:28,000
+Slack provides SDK for Java, Python, JavaScript, Node.js, Ruby Go PHP, dot net C-sharp and remember
+
+210
+00:15:28,000 --> 00:15:35,000
+that you always have an option to interact with Slack using API and simple Http requests.
+
+211
+00:15:35,000 --> 00:15:41,000
+Do you remember in the previous lesson we configured in comment webhook and there was a URL that you
+
+212
+00:15:41,000 --> 00:15:43,000
+can use to send messages to the slack.
+
+213
+00:15:43,000 --> 00:15:50,000
+So no matter whether you will build your integration using incoming webhook URL or specially developed
+
+214
+00:15:50,000 --> 00:15:54,000
+SDK, you can do it in one of these ways.
+
+215
+00:15:54,000 --> 00:16:00,000
+But I recommend you to use developed SDK because it can optimize lines of codes.
+
+216
+00:16:00,000 --> 00:16:08,000
+It has built in authorization and authentication support and sometimes can even optimize amount of requests
+
+217
+00:16:08,000 --> 00:16:09,000
+that you do.
+
+218
+00:16:09,000 --> 00:16:15,000
+Also in comment webhook allows you to post messages to the configured channel, but with the Slack Java
+
+219
+00:16:15,000 --> 00:16:18,000
+SDK you can post to any channel.
+
+220
+00:16:19,000 --> 00:16:22,000
+This can be important for your business logic.
+
+221
+00:16:22,000 --> 00:16:29,000
+So after adding this dependency to the maximum, we need to configure message client bin.
+
+222
+00:16:30,000 --> 00:16:32,000
+I open beans configuration class.
+
+223
+00:16:32,000 --> 00:16:38,000
+Here you can see that I used slack API to configure beans of masses client.
+
+224
+00:16:38,000 --> 00:16:42,000
+I use security tokens that was generated in the slack in the previous lesson.
+
+225
+00:16:43,000 --> 00:16:48,000
+The tokens that you need to paste here you can find in the OAuth and Permissions menu.
+
+226
+00:16:48,000 --> 00:16:53,000
+It is generated right after you installed the app into the workspace.
+
+227
+00:16:53,000 --> 00:16:59,000
+You need to get both user OAuth token in case you can see user OAuth token.
+
+228
+00:16:59,000 --> 00:17:01,000
+Don't touch it so far.
+
+229
+00:17:01,000 --> 00:17:06,000
+In this lesson we need both user OAuth token only.
+
+230
+00:17:06,000 --> 00:17:09,000
+What is user OAuth token and when to use it?
+
+231
+00:17:09,000 --> 00:17:12,000
+We are going to learn in the next lessons.
+
+232
+00:17:13,000 --> 00:17:19,000
+You already know that all secret codes and secret tokens you need to store in secrets management tool.
+
+233
+00:17:19,000 --> 00:17:26,000
+So that's why you will not find my secret token in the repository and you would need to add your own
+
+234
+00:17:26,000 --> 00:17:32,000
+token manually here in case you would like to run my application and my source code.
+
+235
+00:17:32,000 --> 00:17:38,000
+We are going to use this bean each time we need to send requests to the slack.
+
+236
+00:17:38,000 --> 00:17:44,000
+And now I come back to the default slack service and you can see that I injected bin of the message
+
+237
+00:17:44,000 --> 00:17:45,000
+client here.
+
+238
+00:17:46,000 --> 00:17:52,000
+I also injected the bin of message client created based on the user OAuth token.
+
+239
+00:17:52,000 --> 00:17:57,000
+It is needed for implementation of another method that deletes all messages in channel.
+
+240
+00:17:57,000 --> 00:18:03,000
+We are going to review it in the next lesson, so don't pay attention to it now.
+
+241
+00:18:04,000 --> 00:18:09,000
+And coming back to the method where we stopped extract user id to name map.
+
+242
+00:18:09,000 --> 00:18:12,000
+Pay attention how I built request to slack.
+
+243
+00:18:12,000 --> 00:18:21,000
+I use clause user's list request call builder and call build method in the Slack API client library.
+
+244
+00:18:21,000 --> 00:18:24,000
+There are similar types for different slack entities.
+
+245
+00:18:25,000 --> 00:18:30,000
+We are going to learn them gradually because it would be hard for you to remember all of them.
+
+246
+00:18:30,000 --> 00:18:32,000
+In case I would start with you now.
+
+247
+00:18:32,000 --> 00:18:40,000
+Then I use message client and call message user list and pass my user's list request.
+
+248
+00:18:40,000 --> 00:18:48,000
+You can spend some more time exploring this API, for example exploring different types open builders
+
+249
+00:18:48,000 --> 00:18:54,000
+in order to understand better what properties you can set while building requests for different entities.
+
+250
+00:18:54,000 --> 00:18:59,000
+Learning programming is also about spending time reading the documentation and source code.
+
+251
+00:19:00,000 --> 00:19:06,000
+Then create map and iterate over all users that I received in response.
+
+252
+00:19:06,000 --> 00:19:13,000
+I populate map with entries where the key would be user ID and the value would be real name.
+
+253
+00:19:14,000 --> 00:19:20,000
+In case you have other business needs requirements you can store in memory the whole object of user
+
+254
+00:19:20,000 --> 00:19:21,000
+if you wish.
+
+255
+00:19:21,000 --> 00:19:27,000
+But for our requirements today it is enough to store just IDs and real names.
+
+256
+00:19:28,000 --> 00:19:29,000
+In case some error happens.
+
+257
+00:19:30,000 --> 00:19:31,000
+Return empty map.
+
+258
+00:19:32,000 --> 00:19:36,000
+So let's get back to the extract Slack request data method.
+
+259
+00:19:37,000 --> 00:19:41,000
+Now we have map with a user IDs to user names mapping.
+
+260
+00:19:42,000 --> 00:19:47,000
+Now we can easily extract name of the author of the message from the map.
+
+261
+00:19:47,000 --> 00:19:53,000
+And I wrote special method to substitute all IDs and mentions in the text of the message.
+
+262
+00:19:54,000 --> 00:19:57,000
+This will help GPT to understand context better.
+
+263
+00:19:58,000 --> 00:20:02,000
+Not sure whether you want me to go over each line of this algorithm.
+
+264
+00:20:02,000 --> 00:20:08,000
+Anyway, you would have the reference to the source code and you can explore the source code slowly.
+
+265
+00:20:08,000 --> 00:20:14,000
+In short, I just extract all user id mentions using the regular expression.
+
+266
+00:20:14,000 --> 00:20:22,000
+It is not hard thing to do because Slack uses special syntax for mentions and then iterate over each
+
+267
+00:20:22,000 --> 00:20:28,000
+user ID and extract the real name from the map and substitute it in the text.
+
+268
+00:20:28,000 --> 00:20:33,000
+As a result, it returns the same message but with a substituted user IDs.
+
+269
+00:20:33,000 --> 00:20:38,000
+Now I have only real names in text and no user IDs.
+
+270
+00:20:38,000 --> 00:20:44,000
+Now I have all necessary data in order to build Slack request data object.
+
+271
+00:20:44,000 --> 00:20:49,000
+Once I have Slack request data, I call method in GPT service.
+
+272
+00:20:49,000 --> 00:20:54,000
+I created one more message that overloads existing one with additional parameter.
+
+273
+00:20:54,000 --> 00:20:59,000
+Get answer to single query method now accepts the name of the user.
+
+274
+00:21:00,000 --> 00:21:05,000
+If you would explore the source code of default GPT service, you are going to find that I did small
+
+275
+00:21:05,000 --> 00:21:07,000
+refactoring here.
+
+276
+00:21:07,000 --> 00:21:14,000
+I moved the common code to the method prepare request because in these two cases the only difference
+
+277
+00:21:14,000 --> 00:21:15,000
+would be messages.
+
+278
+00:21:15,000 --> 00:21:16,000
+List preparation.
+
+279
+00:21:17,000 --> 00:21:19,000
+One more important thing here.
+
+280
+00:21:19,000 --> 00:21:26,000
+I bet you remember from the lesson when we learned OpenAI GPT API that there are some limitations on
+
+281
+00:21:26,000 --> 00:21:27,000
+the name value.
+
+282
+00:21:27,000 --> 00:21:30,000
+There is a strict pattern of values that can be used.
+
+283
+00:21:31,000 --> 00:21:40,000
+The name attribute may contain an as characters, both lowercase uppercase digits from 0 to 9 and underscores
+
+284
+00:21:40,000 --> 00:21:44,000
+with a maximum length of 64 characters.
+
+285
+00:21:44,000 --> 00:21:47,000
+Consider this while implementing your own app.
+
+286
+00:21:47,000 --> 00:21:54,000
+In my case, names are written in English, but still, sometimes I may have a space in the full real
+
+287
+00:21:54,000 --> 00:21:55,000
+name of the user.
+
+288
+00:21:55,000 --> 00:22:00,000
+That's why I substitute all spaces with underscores.
+
+289
+00:22:00,000 --> 00:22:04,000
+Everything else remains the same like we did in the previous lessons.
+
+290
+00:22:04,000 --> 00:22:07,000
+So request is sent to the GPT.
+
+291
+00:22:08,000 --> 00:22:15,000
+We received response from the GPT when we have response from the GPT and the default slack service.
+
+292
+00:22:15,000 --> 00:22:21,000
+The only thing that is left to do is to send a response back to the channel from where request came
+
+293
+00:22:21,000 --> 00:22:22,000
+from.
+
+294
+00:22:22,000 --> 00:22:25,000
+I call send message to Slack method.
+
+295
+00:22:26,000 --> 00:22:26,000
+I paused.
+
+296
+00:22:26,000 --> 00:22:32,000
+The response from the GPT and channel ID from which I received the request.
+
+297
+00:22:32,000 --> 00:22:37,000
+According to this implementation, I can reply in any channel where my bot is added.
+
+298
+00:22:37,000 --> 00:22:40,000
+And here again I use Slack SDK.
+
+299
+00:22:41,000 --> 00:22:45,000
+I create object of chat post message request using builder.
+
+300
+00:22:46,000 --> 00:22:50,000
+I set the channel ID and text that I want to post.
+
+301
+00:22:51,000 --> 00:22:53,000
+Taking into account our Slack message.
+
+302
+00:22:53,000 --> 00:22:55,000
+Client beam is already authenticated.
+
+303
+00:22:55,000 --> 00:23:02,000
+The only thing that I need to do is to invoke chat, post message and pass my request.
+
+304
+00:23:02,000 --> 00:23:05,000
+After this, we receive response in our slack.
+
+305
+00:23:05,000 --> 00:23:06,000
+Isn't this cool?
+
+306
+00:23:07,000 --> 00:23:13,000
+Basically, that all changes that I did in our web application, but in order everything would work
+
+307
+00:23:13,000 --> 00:23:16,000
+and you can reproduce the whole scenario end to end.
+
+308
+00:23:16,000 --> 00:23:20,000
+We need to do few more configurations in the slack.
+
+309
+00:23:20,000 --> 00:23:22,000
+We need to configure scopes in Slack.
+
+310
+00:23:22,000 --> 00:23:28,000
+But let's first understand what scopes are in the context of Slack.
+
+311
+00:23:28,000 --> 00:23:35,000
+Scopes are a way to define and control the permissions granted to apps when accessing various features
+
+312
+00:23:35,000 --> 00:23:37,000
+and data within a Slack workspace.
+
+313
+00:23:37,000 --> 00:23:44,000
+Scopes determine what an app can do and access on behalf of users or within a workspace.
+
+314
+00:23:44,000 --> 00:23:50,000
+Each scope represents a specific set of permissions that an app can request from Slack's API.
+
+315
+00:23:51,000 --> 00:23:58,000
+By specifying the required scopes when installing or authorizing an app, you define the level of access
+
+316
+00:23:58,000 --> 00:24:01,000
+The app will have to interact with the Slack platform.
+
+317
+00:24:01,000 --> 00:24:07,000
+When developing a Slack app, it is important to understand the available scopes and requests.
+
+318
+00:24:07,000 --> 00:24:12,000
+Only the scopes necessary for your app's functionality.
+
+319
+00:24:12,000 --> 00:24:19,000
+This helps ensure a clear and transparent user experience and maintains the security and privacy of
+
+320
+00:24:19,000 --> 00:24:20,000
+Slack workspaces.
+
+321
+00:24:20,000 --> 00:24:27,000
+Anyway, in case some scopes will be missing, you are going to see error message from the slack telling
+
+322
+00:24:27,000 --> 00:24:32,000
+you what exact scope is missing for this action and you would need to add it.
+
+323
+00:24:32,000 --> 00:24:40,000
+On this slide you can see example of the error message and full list of scopes that we need for this
+
+324
+00:24:40,000 --> 00:24:40,000
+lesson.
+
+325
+00:24:41,000 --> 00:24:43,000
+So we need to add such scopes.
+
+326
+00:24:44,000 --> 00:24:53,000
+Groups read, read im read users read app mentions, read.
+
+327
+00:24:53,000 --> 00:24:53,000
+Chat.
+
+328
+00:24:53,000 --> 00:24:54,000
+Write bot.
+
+329
+00:24:55,000 --> 00:24:58,000
+Let me show you where you need to add scopes.
+
+330
+00:24:59,000 --> 00:25:05,000
+Just open your app at Slate.com and select OAuth and permissions.
+
+331
+00:25:06,000 --> 00:25:12,000
+On this page, you can find your tokens that you have to use in order to authenticate via Slack SDK
+
+332
+00:25:12,000 --> 00:25:13,000
+API client.
+
+333
+00:25:13,000 --> 00:25:16,000
+But below it you can find scopes.
+
+334
+00:25:16,000 --> 00:25:17,000
+There are two sections.
+
+335
+00:25:18,000 --> 00:25:21,000
+There are both token scopes and user token scopes.
+
+336
+00:25:22,000 --> 00:25:28,000
+Both tokens are associated with Slack apps and represents the functionality and capabilities of the
+
+337
+00:25:28,000 --> 00:25:30,000
+app within a workspace.
+
+338
+00:25:30,000 --> 00:25:38,000
+Both token scopes define the permissions and access that the app has within a Slack workspace.
+
+339
+00:25:38,000 --> 00:25:45,000
+User tokens are associated with individual Slack users and represent their own access and permissions
+
+340
+00:25:45,000 --> 00:25:47,000
+within the workspace.
+
+341
+00:25:47,000 --> 00:25:54,000
+User token Scopes defines the permissions and access that the user has within their own workspace account.
+
+342
+00:25:55,000 --> 00:25:59,000
+These scopes determine what actions the user can perform.
+
+343
+00:25:59,000 --> 00:26:04,000
+So for our today's lesson, we need to add both token scopes.
+
+344
+00:26:04,000 --> 00:26:11,000
+Just use Add in-house scope button and add all required scopes that we have discussed and that you can
+
+345
+00:26:11,000 --> 00:26:12,000
+see on the screen.
+
+346
+00:26:13,000 --> 00:26:16,000
+Also added picture to our app.
+
+347
+00:26:16,000 --> 00:26:17,000
+It is super easy.
+
+348
+00:26:17,000 --> 00:26:20,000
+If you want, you can add picture too.
+
+349
+00:26:20,000 --> 00:26:23,000
+Just go to the basic information and scroll to the bottom.
+
+350
+00:26:23,000 --> 00:26:25,000
+You can add picture here.
+
+351
+00:26:26,000 --> 00:26:27,000
+Basically.
+
+352
+00:26:27,000 --> 00:26:28,000
+That's it.
+
+353
+00:26:28,000 --> 00:26:31,000
+That's all what I wanted to show you in this lesson.
+
+354
+00:26:31,000 --> 00:26:34,000
+Let's recap what we have learned today.
+
+355
+00:26:35,000 --> 00:26:40,000
+In this lesson, we learned example of web applications that integrates Slack and GPT.
+
+356
+00:26:40,000 --> 00:26:43,000
+Now you know how to add the app to the channel.
+
+357
+00:26:44,000 --> 00:26:49,000
+We learned how Slack event payload looks like and, you know, key attributes from the payload.
+
+358
+00:26:50,000 --> 00:26:55,000
+I explained you how to use Slack Java SDK also.
+
+359
+00:26:55,000 --> 00:27:03,000
+Now you know what scopes in Slack are and we configured all required scope of our Slack app and small
+
+360
+00:27:03,000 --> 00:27:05,000
+sink but also important one.
+
+361
+00:27:05,000 --> 00:27:07,000
+Reconfigure the picture for our app.
+
+362
+00:27:07,000 --> 00:27:12,000
+We should never forget about small things because small things matter a lot.
+
+363
+00:27:13,000 --> 00:27:14,000
+That's it.
+
+364
+00:27:14,000 --> 00:27:16,000
+Thanks a lot for your attention.
+
+365
+00:27:16,000 --> 00:27:19,000
+Have a great day and see you in the next lesson.
+
diff --git a/98 - GPT + Slack Integration/002 Source-code-of-examples-from-the-lesson-commit-with-changes-.url b/98 - GPT + Slack Integration/002 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..21ea6e428b189ceed656eed2c5545368059e3739
--- /dev/null
+++ b/98 - GPT + Slack Integration/002 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/openai-learnit/commit/bee57bc89cb40a50882550c05ca4ec005f8dba4c
\ No newline at end of file
diff --git a/98 - GPT + Slack Integration/003 Context Management in Web App to Integrate with GPT_en.srt b/98 - GPT + Slack Integration/003 Context Management in Web App to Integrate with GPT_en.srt
new file mode 100644
index 0000000000000000000000000000000000000000..60ef860ac96a8de8a006c00e3ca0d8b79cf8f998
--- /dev/null
+++ b/98 - GPT + Slack Integration/003 Context Management in Web App to Integrate with GPT_en.srt
@@ -0,0 +1,1136 @@
+1
+00:00:05,000 --> 00:00:06,000
+Hello team.
+
+2
+00:00:06,000 --> 00:00:11,000
+In this lesson we are going to learn how to manage context in GPT Chat API.
+
+3
+00:00:11,000 --> 00:00:17,000
+By the end of this lesson you are going to have clear understanding of how you can make sure that GPT
+
+4
+00:00:17,000 --> 00:00:21,000
+understands the context of the whole conversation.
+
+5
+00:00:21,000 --> 00:00:28,000
+On the example of Slack chat approaches and principles of context management that we are going to learn
+
+6
+00:00:28,000 --> 00:00:34,000
+today can be applied in different cases and with different platforms, not only with Slack.
+
+7
+00:00:34,000 --> 00:00:36,000
+Specially for this lesson.
+
+8
+00:00:36,000 --> 00:00:43,000
+I prepared a lot of code examples because live demo is the best approach to explain and understand this
+
+9
+00:00:43,000 --> 00:00:44,000
+topic.
+
+10
+00:00:44,000 --> 00:00:48,000
+We are going to review implementation of my application a line by line.
+
+11
+00:00:48,000 --> 00:00:52,000
+This will give you more useful insights and experience.
+
+12
+00:00:52,000 --> 00:00:57,000
+Separately, we are going to discuss such important topic as tokens limit in GPT.
+
+13
+00:00:57,000 --> 00:01:05,000
+We already discussed this topic before, but in this lesson we will discuss practical aspects of it,
+
+14
+00:01:05,000 --> 00:01:11,000
+namely how you can implement token limit management in your application.
+
+15
+00:01:11,000 --> 00:01:17,000
+Also, I'm going to share with you approach and explain how you can manage context of the Slack team.
+
+16
+00:01:18,000 --> 00:01:24,000
+And at the end of the lesson I'm going to show you the demo of utility endpoint that helps us to keep
+
+17
+00:01:24,000 --> 00:01:30,000
+the channel history clean during the development and remove all messages from channel at once.
+
+18
+00:01:30,000 --> 00:01:32,000
+Let's start our lesson.
+
+19
+00:01:33,000 --> 00:01:35,000
+I bet you watched previous lesson.
+
+20
+00:01:35,000 --> 00:01:38,000
+This is important in order you can understand the context.
+
+21
+00:01:38,000 --> 00:01:47,000
+In the previous lesson we implemented integration between our web app Slack and GPT, but GPT API doesn't
+
+22
+00:01:47,000 --> 00:01:55,000
+store the context automatically because each API request is treated like independent request and we
+
+23
+00:01:55,000 --> 00:02:01,000
+need to be in charge of state management and control the amount of context that we give to the GPT in
+
+24
+00:02:01,000 --> 00:02:03,000
+order to get relevant response.
+
+25
+00:02:03,000 --> 00:02:06,000
+Let me show you the problem statement on the example.
+
+26
+00:02:06,000 --> 00:02:14,000
+Imagine that some employee warned in chat that he is going to have a vacation no matter was mentioning
+
+27
+00:02:14,000 --> 00:02:17,000
+of GPT or without mentioning GPT.
+
+28
+00:02:17,000 --> 00:02:22,000
+Again, it is up to us how we would build the context for GPT.
+
+29
+00:02:22,000 --> 00:02:29,000
+For example, we can fetch all messages from the channel and send them to GPT as a context, but it
+
+30
+00:02:29,000 --> 00:02:32,000
+can be more messages than token limits.
+
+31
+00:02:32,000 --> 00:02:32,000
+Allow.
+
+32
+00:02:32,000 --> 00:02:35,000
+Then we would need to apply workaround.
+
+33
+00:02:35,000 --> 00:02:39,000
+I'm going to explain you this too late in the lesson.
+
+34
+00:02:39,000 --> 00:02:41,000
+Let's come back to our example.
+
+35
+00:02:41,000 --> 00:02:50,000
+So for the sake of the demo, let me even tag GPT telling GPT I'm going to be on vacation the last week
+
+36
+00:02:50,000 --> 00:02:51,000
+of July.
+
+37
+00:02:51,000 --> 00:02:59,000
+GPT will reply me Sampson, But the next time manager would ask GPT when Andre will be on vacation.
+
+38
+00:03:00,000 --> 00:03:07,000
+GPT will reply that it doesn't know, even in case when the answer is the previous message in chat.
+
+39
+00:03:08,000 --> 00:03:12,000
+That is because GPT doesn't store the context on its side.
+
+40
+00:03:12,000 --> 00:03:19,000
+It treats each request independently and we didn't gather enough context before sending requests to
+
+41
+00:03:19,000 --> 00:03:20,000
+the GPT.
+
+42
+00:03:20,000 --> 00:03:22,000
+We are going to fix this in the lesson.
+
+43
+00:03:23,000 --> 00:03:25,000
+Now you understand our goal.
+
+44
+00:03:25,000 --> 00:03:31,000
+For today's lesson, I want to make GPT three understand the context of the discussion in the channel,
+
+45
+00:03:31,000 --> 00:03:37,000
+and we are going to review improvements that I did in my web application in order to address the business
+
+46
+00:03:37,000 --> 00:03:38,000
+requirement.
+
+47
+00:03:39,000 --> 00:03:45,000
+So I showed you this slide with the problem statement because I already deployed the solution that doesn't
+
+48
+00:03:45,000 --> 00:03:48,000
+have any challenge with understanding the context.
+
+49
+00:03:48,000 --> 00:03:49,000
+Let's see.
+
+50
+00:03:49,000 --> 00:03:54,000
+End result and what we are supposed to get by the end of this lesson.
+
+51
+00:03:54,000 --> 00:03:56,000
+I would repeat the same scenario.
+
+52
+00:03:56,000 --> 00:04:04,000
+Imagine that I'm about to go on vacation and I would notify GPT and potentially the whole team that
+
+53
+00:04:04,000 --> 00:04:08,000
+I'm going to be on vacation during the last week of July.
+
+54
+00:04:08,000 --> 00:04:14,000
+And then I would ask the follow up question when Andre is going to be on vacation.
+
+55
+00:04:14,000 --> 00:04:22,000
+And as you can see, GPT understands the context and can confirm when Andre is going to be on vacation.
+
+56
+00:04:23,000 --> 00:04:30,000
+That's because GPT recognizes the context of the conversation and can analyze all the conversation.
+
+57
+00:04:30,000 --> 00:04:34,000
+So let's take a look at how this is implemented.
+
+58
+00:04:34,000 --> 00:04:37,000
+Let me walk you through the solution line by line.
+
+59
+00:04:37,000 --> 00:04:42,000
+As usual, you can find the reference to the source code in attachments to this lesson.
+
+60
+00:04:42,000 --> 00:04:46,000
+Feel free to explore the source code in order to understand the solution better.
+
+61
+00:04:46,000 --> 00:04:53,000
+And also feel free to ask me questions below the video and I will be happy to answer.
+
+62
+00:04:53,000 --> 00:05:00,000
+In the previous lesson you already learned that we receive notification about Slack event in Slack Integration
+
+63
+00:05:00,000 --> 00:05:01,000
+controller.
+
+64
+00:05:01,000 --> 00:05:03,000
+So nothing is changed here.
+
+65
+00:05:03,000 --> 00:05:08,000
+In the similar way I call process and mention event in Slack service.
+
+66
+00:05:08,000 --> 00:05:15,000
+So let's open default slack service and explore processing mention event method.
+
+67
+00:05:16,000 --> 00:05:19,000
+Here I introduced some changes.
+
+68
+00:05:19,000 --> 00:05:23,000
+I call extract context for slack request method.
+
+69
+00:05:23,000 --> 00:05:29,000
+This is the new method that I wrote in order to fetch the conversations history from Slack in order
+
+70
+00:05:29,000 --> 00:05:33,000
+to prepare the context before sending it to GPT.
+
+71
+00:05:33,000 --> 00:05:38,000
+Let me open this mindset and review with you how it is implemented.
+
+72
+00:05:39,000 --> 00:05:42,000
+I create a list parameterized by GPG messages.
+
+73
+00:05:43,000 --> 00:05:46,000
+I'm going to fill it out with GPG message objects.
+
+74
+00:05:46,000 --> 00:05:53,000
+Then I use Slack Java SDK in order to query the history of messages in the channel.
+
+75
+00:05:53,000 --> 00:06:01,000
+I need to pass an object of request configurator to the Conversations history method taking into account
+
+76
+00:06:01,000 --> 00:06:04,000
+that the request configurator is a functional interface.
+
+77
+00:06:04,000 --> 00:06:08,000
+I can describe this object using lambda function.
+
+78
+00:06:08,000 --> 00:06:15,000
+I configure channel from which to fetch the history and you can see that I use Slack request data to
+
+79
+00:06:15,000 --> 00:06:20,000
+get information about channel ID and I specified max limit of messages to fetch.
+
+80
+00:06:21,000 --> 00:06:23,000
+This is going to be configurable value.
+
+81
+00:06:24,000 --> 00:06:28,000
+As you can see, I injected it to the class from properties file.
+
+82
+00:06:29,000 --> 00:06:36,000
+Currently I set the limit to 1000 messages, but again it is up to business requirements.
+
+83
+00:06:36,000 --> 00:06:44,000
+What limit to set here and in our case we will be more concerned about tokens limit in GPT rather than
+
+84
+00:06:44,000 --> 00:06:51,000
+the amount of messages to fetch because there can be five messages in Slack that would have more tokens
+
+85
+00:06:51,000 --> 00:06:54,000
+than your GPT model allows.
+
+86
+00:06:54,000 --> 00:07:00,000
+We are going to handle this case a little bit later and I will show you how I handle it.
+
+87
+00:07:00,000 --> 00:07:05,000
+I encourage you to check the documentation and other properties that you can configure.
+
+88
+00:07:05,000 --> 00:07:08,000
+Just look through the source code, read the documentation.
+
+89
+00:07:08,000 --> 00:07:14,000
+Probably it will be helpful for you in the future when you would need to configure more granular filtering
+
+90
+00:07:14,000 --> 00:07:15,000
+rules.
+
+91
+00:07:16,000 --> 00:07:19,000
+So that's how I fetch messages.
+
+92
+00:07:19,000 --> 00:07:24,000
+Pay attention that in this list we have messages from Slack in the specific order.
+
+93
+00:07:24,000 --> 00:07:32,000
+The latest message I mean, the newest is the most recent message is at the beginning of the list and
+
+94
+00:07:32,000 --> 00:07:35,000
+the oldest message is at the end.
+
+95
+00:07:35,000 --> 00:07:43,000
+This might be not obvious at the beginning because I personally got used to another order, even in
+
+96
+00:07:43,000 --> 00:07:46,000
+chat interface that we can use in Slack.
+
+97
+00:07:46,000 --> 00:07:49,000
+The most recent messages are at the bottom.
+
+98
+00:07:49,000 --> 00:07:55,000
+That brings me to conclusion that the most recent message should be at the end of the list.
+
+99
+00:07:55,000 --> 00:08:02,000
+But probably it is just my perception and the current ordering looks logical for you.
+
+100
+00:08:02,000 --> 00:08:08,000
+Now we need to process the messages in the same way we did with one single message.
+
+101
+00:08:08,000 --> 00:08:12,000
+But for this we need user IDs to name SMAp.
+
+102
+00:08:12,000 --> 00:08:14,000
+This is slack specific.
+
+103
+00:08:14,000 --> 00:08:20,000
+They remember in the previous lesson I showed you that each time user is mentioned in the message,
+
+104
+00:08:20,000 --> 00:08:27,000
+Slack stores it as user ID and also author name is user ID too.
+
+105
+00:08:27,000 --> 00:08:34,000
+In order to keep the context and messages consistent and in order to give GPT as much details as we
+
+106
+00:08:34,000 --> 00:08:39,000
+can, it is better to substitute user IDs with readable names.
+
+107
+00:08:39,000 --> 00:08:42,000
+But for this I need user IDs to name SMAp.
+
+108
+00:08:43,000 --> 00:08:45,000
+Let's learn what improvements I did here.
+
+109
+00:08:46,000 --> 00:08:51,000
+First of all, I created class is this called Slack team context?
+
+110
+00:08:51,000 --> 00:08:59,000
+For now I have only map of user id used real names of users here, but in the future we can use objects
+
+111
+00:08:59,000 --> 00:09:05,000
+of this type in order to store all the context related to specific slack team.
+
+112
+00:09:05,000 --> 00:09:07,000
+Why do I need this?
+
+113
+00:09:08,000 --> 00:09:10,000
+This mechanism as session mechanism.
+
+114
+00:09:10,000 --> 00:09:15,000
+But I can't use regular session because client doesn't store session.
+
+115
+00:09:15,000 --> 00:09:17,000
+ID like browser usually does.
+
+116
+00:09:18,000 --> 00:09:24,000
+That's why I need to come up with alternative session mechanism and I decided that this will be map
+
+117
+00:09:24,000 --> 00:09:28,000
+of team ID to the Slack team context object.
+
+118
+00:09:28,000 --> 00:09:33,000
+Like this I can extract context in any part of my program using the team ID.
+
+119
+00:09:34,000 --> 00:09:36,000
+Let me open beans configuration class.
+
+120
+00:09:36,000 --> 00:09:37,000
+Now.
+
+121
+00:09:37,000 --> 00:09:45,000
+In this class I declared new bean map that would store the Slack team context associated with a specific
+
+122
+00:09:45,000 --> 00:09:45,000
+team ID.
+
+123
+00:09:46,000 --> 00:09:53,000
+Now, in any part of my program, I can use the singleton bean in order to get Slack team context.
+
+124
+00:09:53,000 --> 00:09:57,000
+Thus get user id used to user map when it will be needed.
+
+125
+00:09:57,000 --> 00:10:04,000
+Coming back to the default slack service, I bet you remember that we create user id used to name map
+
+126
+00:10:04,000 --> 00:10:11,000
+when we process a regional slack request right in the method extract user id to name map.
+
+127
+00:10:11,000 --> 00:10:14,000
+Here I added few lines of code.
+
+128
+00:10:14,000 --> 00:10:18,000
+I extract slack team context using the team id.
+
+129
+00:10:18,000 --> 00:10:26,000
+Then in case there is no slack team context associated with this team id, I create a new one and put
+
+130
+00:10:26,000 --> 00:10:31,000
+it together with the team ID in case there is some context on place.
+
+131
+00:10:31,000 --> 00:10:37,000
+I just use it to substitute the map with the most recent user ID use and real names map.
+
+132
+00:10:38,000 --> 00:10:45,000
+This code should address the challenge when you just added new user and he or she wrote his first message
+
+133
+00:10:45,000 --> 00:10:50,000
+or somebody tagged the new user and we need to pass new user ID.
+
+134
+00:10:50,000 --> 00:10:55,000
+That's why updating this map on regular basis might be a good idea.
+
+135
+00:10:56,000 --> 00:11:02,000
+Another important point if you already played the beat with the Slack API, then you are already faced
+
+136
+00:11:02,000 --> 00:11:05,000
+with the rate limits that exist in Slack.
+
+137
+00:11:05,000 --> 00:11:12,000
+There are limits for sending subsequent API calls, including call to fetch users from the channel.
+
+138
+00:11:12,000 --> 00:11:18,000
+That's why, in case this request would be executed multiple times in a row with a short interval,
+
+139
+00:11:18,000 --> 00:11:24,000
+you can imagine the case when two users from your team simultaneously decided to send requests to our
+
+140
+00:11:24,000 --> 00:11:25,000
+app.
+
+141
+00:11:25,000 --> 00:11:28,000
+In such case, there can be Slack API exception.
+
+142
+00:11:28,000 --> 00:11:31,000
+Let me explain you the business logic here.
+
+143
+00:11:31,000 --> 00:11:35,000
+And again that assumption what you can implement in different way.
+
+144
+00:11:36,000 --> 00:11:38,000
+I just give you food for thoughts in order.
+
+145
+00:11:39,000 --> 00:11:43,000
+You don't forget about this when you implement your own application.
+
+146
+00:11:43,000 --> 00:11:52,000
+In my implementation I catch Slack API exception and in case Slack team context is not null and contains
+
+147
+00:11:52,000 --> 00:11:53,000
+required map.
+
+148
+00:11:53,000 --> 00:11:56,000
+I just return the latest version of this map.
+
+149
+00:11:56,000 --> 00:12:03,000
+I just make an assumption that in case I faced with rate limit, this means that the map was updated
+
+150
+00:12:03,000 --> 00:12:10,000
+recently and the really low risks that during these moments new user was added to the channel.
+
+151
+00:12:10,000 --> 00:12:15,000
+But if this is not the case, I throw an exception.
+
+152
+00:12:15,000 --> 00:12:15,000
+What?
+
+153
+00:12:15,000 --> 00:12:16,000
+Happens next.
+
+154
+00:12:17,000 --> 00:12:25,000
+Outside of this method in the extract slack request data I implemented retry attempts amount of retry
+
+155
+00:12:25,000 --> 00:12:30,000
+attempts and seconds to sleep between attempts is also configurable in properties.
+
+156
+00:12:30,000 --> 00:12:34,000
+That's how rate limit is handled for this specific case.
+
+157
+00:12:34,000 --> 00:12:40,000
+Now we can get back to review of the extract context for Slack request method.
+
+158
+00:12:40,000 --> 00:12:47,000
+So now you know and understand from where and how I extracted user used the real names map.
+
+159
+00:12:48,000 --> 00:12:52,000
+As you already know, each GPT model has context limit.
+
+160
+00:12:52,000 --> 00:12:55,000
+Currently I use model with 4000 tokens.
+
+161
+00:12:55,000 --> 00:13:00,000
+Limit and calculation of the tokens is not an easy task.
+
+162
+00:13:01,000 --> 00:13:06,000
+Take into account token is not always equal neither to word nor to character.
+
+163
+00:13:07,000 --> 00:13:15,000
+All calculations you can do only approximately The worst case that can happen is that GPT will reply
+
+164
+00:13:15,000 --> 00:13:23,000
+with error message telling that you exceed the tokens limit, taking into account that there is no single
+
+165
+00:13:23,000 --> 00:13:28,000
+answer or formula to define the size of one token in amount of characters.
+
+166
+00:13:28,000 --> 00:13:33,000
+I'm going to do all calculations approximately, but of course with some buffer.
+
+167
+00:13:34,000 --> 00:13:39,000
+Let's assume that in average one token is equal to four characters.
+
+168
+00:13:39,000 --> 00:13:45,000
+That gives us a limit of 16,000 characters to have some buffer.
+
+169
+00:13:45,000 --> 00:13:50,000
+I configure it limit to 15,000 characters in my app properties.
+
+170
+00:13:50,000 --> 00:13:56,000
+You can find the separate properties that stores this threshold value and inject this property in the
+
+171
+00:13:56,000 --> 00:13:59,000
+field of the default slack service class.
+
+172
+00:13:59,000 --> 00:14:02,000
+In the method I declare a counter.
+
+173
+00:14:02,000 --> 00:14:11,000
+I will add length of each message to this counter, but I will make a pre check in case value of current
+
+174
+00:14:11,000 --> 00:14:18,000
+counter with addition of the message length will be more than threshold then I break the loop and don't
+
+175
+00:14:18,000 --> 00:14:22,000
+add any messages to the list in case this check is passed.
+
+176
+00:14:22,000 --> 00:14:25,000
+I just increase the value of the counter.
+
+177
+00:14:25,000 --> 00:14:28,000
+Then I add GPT message to the list.
+
+178
+00:14:29,000 --> 00:14:33,000
+Here I need to understand with what role to add the message.
+
+179
+00:14:33,000 --> 00:14:39,000
+I did simple validation in case the real name of the author of the message is GPT.
+
+180
+00:14:39,000 --> 00:14:43,000
+Then I add GPT message with assistant role.
+
+181
+00:14:43,000 --> 00:14:46,000
+Otherwise I add message with user role.
+
+182
+00:14:47,000 --> 00:14:54,000
+Also, I added condition in this if statement that I will process only messages with type message and
+
+183
+00:14:54,000 --> 00:14:57,000
+that doesn't have channel join subtype.
+
+184
+00:14:57,000 --> 00:15:05,000
+So basically with this statement I filter all messages to skip all system generated messages and keep
+
+185
+00:15:05,000 --> 00:15:09,000
+only messages created by users in the channel and our bot.
+
+186
+00:15:10,000 --> 00:15:15,000
+Taking into account we are iterating over message object from Slack SDK.
+
+187
+00:15:15,000 --> 00:15:22,000
+I encourage you to look through the source code or explore examples of messages in order to learn what
+
+188
+00:15:22,000 --> 00:15:26,000
+other properties are present in this type that you can use.
+
+189
+00:15:26,000 --> 00:15:31,000
+Probably it would be useful for you in case you want to build your custom business logic.
+
+190
+00:15:32,000 --> 00:15:40,000
+Also, pay attention that I substitute all spaces in full names of the author here, so I added All
+
+191
+00:15:40,000 --> 00:15:44,000
+required GPT message objects to the list and now attention.
+
+192
+00:15:44,000 --> 00:15:46,000
+Important point.
+
+193
+00:15:46,000 --> 00:15:52,000
+As you remember from previous lessons when we just started learning GPT API, I said that the order
+
+194
+00:15:52,000 --> 00:15:57,000
+of messages in the context when we submit request to GPT is important.
+
+195
+00:15:57,000 --> 00:16:05,000
+So I reverse order of elements in my list because the most recent message should be the last element
+
+196
+00:16:05,000 --> 00:16:07,000
+when we submit request for GPT.
+
+197
+00:16:07,000 --> 00:16:13,000
+Now we have list of GPT messages created and we can return it from the message.
+
+198
+00:16:14,000 --> 00:16:19,000
+In my GP service, I overloaded the method with a new version of input parameter.
+
+199
+00:16:19,000 --> 00:16:26,000
+I created method get answer to single query that takes list of GPG messages and variable argument of
+
+200
+00:16:26,000 --> 00:16:28,000
+GPG functions.
+
+201
+00:16:28,000 --> 00:16:31,000
+Let me open default GPG service class.
+
+202
+00:16:31,000 --> 00:16:35,000
+I use prepare request methods that we created during the previous lesson.
+
+203
+00:16:35,000 --> 00:16:41,000
+After refactoring I just pause the list with messages and functions and that's it.
+
+204
+00:16:42,000 --> 00:16:49,000
+Then I send request to the GPG, receive response and after receiving response I send it back to Slack
+
+205
+00:16:49,000 --> 00:16:50,000
+like we did.
+
+206
+00:16:50,000 --> 00:16:55,000
+Nothing is changed here but this response that we received from GPG.
+
+207
+00:16:56,000 --> 00:16:59,000
+It is based on the context provided.
+
+208
+00:16:59,000 --> 00:17:08,000
+So GPG analyzes the history of messages, the whole conversation that we gave to it and gives us response
+
+209
+00:17:08,000 --> 00:17:09,000
+based on the context.
+
+210
+00:17:09,000 --> 00:17:16,000
+That's why in the demo, at the beginning of the lesson, GPG was able to provide me with correct answer
+
+211
+00:17:16,000 --> 00:17:23,000
+about vacation of team member from the Slack Channel, basically about my planned vacation since I'm
+
+212
+00:17:23,000 --> 00:17:25,000
+the only one in the test channel so far.
+
+213
+00:17:26,000 --> 00:17:27,000
+That's it.
+
+214
+00:17:27,000 --> 00:17:28,000
+Regarding context management.
+
+215
+00:17:29,000 --> 00:17:35,000
+And remember, there may be more challenging cases and some of them were already reviewed in the lesson
+
+216
+00:17:35,000 --> 00:17:42,000
+that is called GPG best practices, where I shared how you can make a summary of the context and apply
+
+217
+00:17:42,000 --> 00:17:46,000
+all the techniques to reduce the amount of tokens.
+
+218
+00:17:46,000 --> 00:17:53,000
+Anyway, team, I'm just two clicks away from you in case you have any questions, just post them below
+
+219
+00:17:53,000 --> 00:17:55,000
+the video and I will be happy to answer.
+
+220
+00:17:56,000 --> 00:18:02,000
+The only thing that we didn't review yet is the endpoint that I created to remove messages automatically.
+
+221
+00:18:02,000 --> 00:18:07,000
+I mentioned it in the previous lesson and promised you to review it.
+
+222
+00:18:07,000 --> 00:18:12,000
+So let me remind you the problem statement during the development.
+
+223
+00:18:12,000 --> 00:18:19,000
+I bet you post a lot of messages and you want to keep the context clean and keep the history of messages
+
+224
+00:18:19,000 --> 00:18:20,000
+clean too.
+
+225
+00:18:20,000 --> 00:18:23,000
+So what options do you have?
+
+226
+00:18:23,000 --> 00:18:25,000
+You can remove text messages manually.
+
+227
+00:18:25,000 --> 00:18:30,000
+This can be also an option in case there are not so much messages.
+
+228
+00:18:30,000 --> 00:18:34,000
+You can remove channel and create the new one from scratch.
+
+229
+00:18:34,000 --> 00:18:38,000
+You can use this option to or to create.
+
+230
+00:18:38,000 --> 00:18:41,000
+End point is itrillionemoves all messages in the chat.
+
+231
+00:18:41,000 --> 00:18:43,000
+That's what I did.
+
+232
+00:18:43,000 --> 00:18:49,000
+I just want to send one simple query and not be bothered with creation of the new channel.
+
+233
+00:18:50,000 --> 00:18:57,000
+So in the Slack integration controller I created separate endpoint that takes channel ID as request
+
+234
+00:18:57,000 --> 00:18:58,000
+parameter.
+
+235
+00:18:58,000 --> 00:19:02,000
+You can get channel ID from each request event from Slack.
+
+236
+00:19:02,000 --> 00:19:07,000
+That's easy and then you can use it as request parameter for this query.
+
+237
+00:19:08,000 --> 00:19:11,000
+The call is delegated to the slack service.
+
+238
+00:19:11,000 --> 00:19:19,000
+Let me open default slack service again and at the bottom you can find the implementation of this method.
+
+239
+00:19:19,000 --> 00:19:22,000
+I use Slack SDK to extract message.
+
+240
+00:19:22,000 --> 00:19:28,000
+I get the conversation object first, then I get messages from that conversation.
+
+241
+00:19:28,000 --> 00:19:35,000
+Here you can find also another configurable property max amount of messages that I can remove at once.
+
+242
+00:19:35,000 --> 00:19:41,000
+And then I iterate over each message and call Chad delete message.
+
+243
+00:19:41,000 --> 00:19:47,000
+I also implemented retry attempts here because in case you are going to remove a lot of messages at
+
+244
+00:19:47,000 --> 00:19:54,000
+once, you're going to see Slack API exception because of violation of rate limit.
+
+245
+00:19:54,000 --> 00:20:02,000
+Another interesting thing is that for this case I use message client that was generated using user OAuth
+
+246
+00:20:02,000 --> 00:20:06,000
+token that is needed for remove operations.
+
+247
+00:20:06,000 --> 00:20:12,000
+I can'trillionemove messages with the message client generated based on the bot user OAuth token.
+
+248
+00:20:13,000 --> 00:20:17,000
+That's why I added all required scopes for user token.
+
+249
+00:20:17,000 --> 00:20:19,000
+Pay attention on the screen.
+
+250
+00:20:19,000 --> 00:20:23,000
+You would need to add the similar scopes in order to make this solution work.
+
+251
+00:20:24,000 --> 00:20:26,000
+I copied user OAuth token.
+
+252
+00:20:27,000 --> 00:20:33,000
+And in the Bins configuration class I created one more bin using user OAuth token.
+
+253
+00:20:33,000 --> 00:20:34,000
+Here it is.
+
+254
+00:20:34,000 --> 00:20:41,000
+So now we have been with Name, Slack Bot client and bin with name Slack user client.
+
+255
+00:20:42,000 --> 00:20:45,000
+Both of them are of message client type.
+
+256
+00:20:45,000 --> 00:20:51,000
+And in the default slack service, I injected both of them using qualifier.
+
+257
+00:20:51,000 --> 00:20:54,000
+And I use these beans in the class.
+
+258
+00:20:54,000 --> 00:20:57,000
+In most cases I use slack bot client.
+
+259
+00:20:57,000 --> 00:21:02,000
+So far I use slack user client only for messages removal operations.
+
+260
+00:21:02,000 --> 00:21:03,000
+That's it.
+
+261
+00:21:03,000 --> 00:21:04,000
+And that is all.
+
+262
+00:21:04,000 --> 00:21:06,000
+Regarding the remove endpoint.
+
+263
+00:21:06,000 --> 00:21:11,000
+Let me send the request via browser and it would take some time.
+
+264
+00:21:11,000 --> 00:21:16,000
+And when I open slack I see that there are no messages in the channel.
+
+265
+00:21:16,000 --> 00:21:18,000
+That's how it works.
+
+266
+00:21:18,000 --> 00:21:19,000
+Kim.
+
+267
+00:21:19,000 --> 00:21:21,000
+We learned a lot for today.
+
+268
+00:21:21,000 --> 00:21:24,000
+Let's recap what we have learned in this lesson.
+
+269
+00:21:25,000 --> 00:21:30,000
+In this lesson, we learned how to manage context when we integrate with GPT API.
+
+270
+00:21:31,000 --> 00:21:34,000
+You saw a demo of real life scenario with Slack.
+
+271
+00:21:34,000 --> 00:21:36,000
+Our web application and GPT.
+
+272
+00:21:37,000 --> 00:21:43,000
+I also showed you code examples and explained how to achieve the expected result with context management.
+
+273
+00:21:44,000 --> 00:21:51,000
+I explained the approach of controlling context length because it is important to respect tokens limit
+
+274
+00:21:51,000 --> 00:21:53,000
+of the model that we work with.
+
+275
+00:21:53,000 --> 00:22:00,000
+I also suggested approach for Slack team context management inside our web application.
+
+276
+00:22:00,000 --> 00:22:02,000
+This is more architectural decision.
+
+277
+00:22:02,000 --> 00:22:07,000
+While there can be different ways to address the same challenge.
+
+278
+00:22:07,000 --> 00:22:11,000
+Now you know how I address this challenge in my application.
+
+279
+00:22:11,000 --> 00:22:15,000
+And also we reviewed endpoint that was created in order.
+
+280
+00:22:15,000 --> 00:22:18,000
+We can easily remove all messages from the Slack channel.
+
+281
+00:22:19,000 --> 00:22:24,000
+Hopefully it will be also useful for you during the development.
+
+282
+00:22:24,000 --> 00:22:26,000
+That's all for this lesson.
+
+283
+00:22:26,000 --> 00:22:28,000
+Thanks a lot for your attention.
+
+284
+00:22:28,000 --> 00:22:31,000
+Have a great day and see you in the next lesson.
+
diff --git a/98 - GPT + Slack Integration/003 Source-code-of-examples-from-the-lesson-commit-with-changes-.url b/98 - GPT + Slack Integration/003 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
new file mode 100644
index 0000000000000000000000000000000000000000..86e050aef7e9691de3d12d23273ed5967e063080
--- /dev/null
+++ b/98 - GPT + Slack Integration/003 Source-code-of-examples-from-the-lesson-commit-with-changes-.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://github.com/AndriiPiatakha/openai-learnit/commit/1e7ec07bfa4ea33ecdbd282a29e9ce90a93077e4
\ No newline at end of file
diff --git a/98 - GPT + Slack Integration/external-links.txt b/98 - GPT + Slack Integration/external-links.txt
new file mode 100644
index 0000000000000000000000000000000000000000..bcceb9735eaf096f145ca220fad1f76283173a8a
--- /dev/null
+++ b/98 - GPT + Slack Integration/external-links.txt
@@ -0,0 +1,9 @@
+
+001 Source-code-of-examples-from-the-lesson-commit-with-changes-
+https://github.com/AndriiPiatakha/openai-learnit/commit/83729ecb93896662e0dce86e4e0ce7d18ca5e10b
+
+002 Source-code-of-examples-from-the-lesson-commit-with-changes-
+https://github.com/AndriiPiatakha/openai-learnit/commit/bee57bc89cb40a50882550c05ca4ec005f8dba4c
+
+003 Source-code-of-examples-from-the-lesson-commit-with-changes-
+https://github.com/AndriiPiatakha/openai-learnit/commit/1e7ec07bfa4ea33ecdbd282a29e9ce90a93077e4
diff --git a/99 - Jira/001 The Role of Jira in our Web Application Why this section is needed.html b/99 - Jira/001 The Role of Jira in our Web Application Why this section is needed.html
new file mode 100644
index 0000000000000000000000000000000000000000..877999801fcf4e8528f802a63c58a1b0fa640fa7
--- /dev/null
+++ b/99 - Jira/001 The Role of Jira in our Web Application Why this section is needed.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ The Role of Jira in our Web Application Why this section is needed
+
+
+
+
+
+
+
The Role of Jira in our Web Application Why this section is needed
+
During the course, we create a Web application for Project Management operations automation.
To implement this application we are going to use the following stack:
Spring Boot Web App
Slack
GPT
Jira
That's why we need to learn Jira and the basics of Jira API in order to build all the required integrations. And that is why this section is needed :)
Hope you would enjoy this section.
Kind regards,
Andrey
+
+
+
+