hey there this is akan and welcome back to a new video and this video is going to be important and interesting I would say right because nowadays you know that things are changing very fastly in the fields of AI right every day new things are coming and every startup every company wants to adopt AI in like in some form in their products so that's why in normal interviews also for software engineering and software development AI is getting asked right that's why I want you to understand the whole architecture of an AI application right so in this video we are not going to talk about that go ahead and use open a apis or go ahead and use gini apis I already know that you can do that right but in this video we are going to understand how companies actually use uh AI in their applications how they communicate how they build such an architecture which can communicate between your AI model then your server then your front end textt right that we are going to understand in this video right plus I'm also going to give you all the text tacks that you should learn to build standard AI applications using this architecture right I have already built videos on various ways through which you can build AI applications plus I also cre a video on what are the advanced AI projects that you can build when you're in college or when you are even a fresher right so let's go ahead so first of all AI applications are not very different than normal applications uh that you make right using front end and back end so in AI applications also you have one front end layer and you have one backend layer right but what happens is in these AI applications or even you take blockchain applications or you take arvr application one third component also comes into picture that third component in case of AI application is your Model Management and deployment right this is the third thing that comes into picture in case of blockchain application you have to think about the smart contract in case of the arvr application you have to think about your you know rendering of your 3D models where should be rendering Unity 3D and all that right so that's why when you build these uh complex application which needs like Ai blockchain and you know arvr there one third component also get added on top of front end and pack end I hope this is clear okay so in this video we are going to see the two main architectures that are being followed nowadays to build AI application right so let me put the topic AI application ARS that is architectures right so there are two ways and before that you also need to understand the components of front and back and and models right so in every mobile application or in every web application desktop application like Smartwatch application there are going to be three things right one is your front end let's say this is a mobile app then it will be your uh server that is your backend and one third thing also is there that is your AI model right so this is your app or your front end right it can be mobile let's assume it's a mobile app right then your next component is your server that is your backend and last is your AI model okay these three things are there right now the two ways which I was talking about the first way is if you have your AI model embedded in your front end itself right and before before before before I start teaching you this stuff you have to understand the client server architecture you should be clear with what is back end what is front end so just you know you can skip this part but just don't skip it right so let me show you so in every software you have one client and you have one server right you have client you have your server so a client makes a request to the server and a server returns a response to the client and at the back end this server can be you know communicating with uh database right it can be communicating with the database it can be communicating with a let's say AI model right anything it can do it can be communicating with a model it can be communicating with a smart contract in case of blockchain application anything so server can do anything smart contract right so these are just the external components which can be attached to a server but at the end this is the client server architecture this is your front end this is your back end front can be mobile app web app desktop app Smartwatch app right server can be a normal it's just a normal computer which has certain code written on it and it just uh run those functions it just performs those functions right just an example just let's say I'm building one e-commerce application so let's say Amazon so the client is your mobile app the Amazon app which user can use to communicate right user can use to do something place a order or see the products right that is your client that is your front end server is the thing that scales up right or that takes the orders and puts those those orders in the database or server is responsible for making the secure transaction payment transactions right so that's all is being done by the server so server is like your brain the major brain and client is like your you know skin that users can touch and feel okay and most of the complex logic is written on the server itself so this is how this client server architecture Works hey guys don't forget to check out my my own app resume pal it is the best app for last minute interview preparation and placement practice so on our mobile app you're going to get a lot of features like resume building rume analysis thousands of flash cards but on our website also if you click on the placement prep tab you can actually practice by skills or by the companies so if I click on any company let's say at lashen I can actually see how they hire what are the interview processes then I can see the interview experiences like what was the round how long it was what was the difficulty what were the problems that were asked right then you can also check out the salaries which this company pays and the benefits so this is an amazing application and an amazing website so do check it out it will be really helpful for you now let's get back to the main topic so front end is your mobile app let's assume and this is your server the brain the AI model which is a add-on that we have to attach to either the front end or to the server right so what happens is in the two architect that I told you in the first architecture this AI model gets embedded in the uh front end itself okay it is embedded in the front end itself uh so something like this right what do I mean by a building how to do it I'll come to that but in the first architecture you have your AI model in the front end itself right so this will become my first architecture in my second architecture what you have is you have your server connected to your AI model so this is your second architecture okay now here I told you that AI model is embedded in the front end in some form that means model file is in the front end code itself in the project folder itself but here the AI model is not inside the server it is a stand alone server it is it is a standalone service and our main app server communicates with the with the AI model server like this where it is hosted where it is deployed everything we'll talk about slowly slowly okay so these are the two architectures in the first architecture AI model is in the front end and in the second architecture your AI model is attached to a server now the question is why are we even doing this what is the need right so there are certain points that you have to answer if the interviewer ask you like why are you explaining me these two architecture so these are the points why do we have to you know bifurcate these two architectures and when to use what I'll give you the answer so the answer is just remember these uh Five Points one is latency by latency I mean that if you if your app or if your user expects the results very quickly right then you need lower latency in your application right then you cannot afford the time that is spent here right you know you know the communication between client to server then server to AI model then AI model to server then server to client you cannot afford that right let's let's let's take an example let's say you are building an application where you have to in real time you have to detect whether this is a cat or a dog right using the camera so there when we are talking about real time that means camera is on and you want to see the results right so there you cannot have like loader loader loader and you can expect the results right user will be irritated so there we want lower latency right there we want lower latency so in that case it will be very much better if you just put the AI model in the front end itself in the mobile app itself or in the web app itself right latency second thing is so in this case if latency is expected to be lower use this architecture if latency is expected to be uh like it is okay if it is higher just go through uh just use this second architecture okay your next thing is complexity if your AI model is too complex right let's say it is a gan generative adversarial Network right there you have to generate the images you will be needing some GPU power right so that time your model can be too big also and it it will be very complex also right so there you cannot put that in the mobile app right because in mobile app you don't have like a dedicated GPU right for that you need a dedic dedicated GPU and that you can find it in the server in the back end itself right so if your model complexity is higher then use the second architecture if your complex complexity is too lower right like in the cat dog detection that's just like 01 prediction right there you can just go with the first architecture okay let's take the second third Point model size if due to some reason the model size is too big let's say your model is like 1 GB that time you cannot put put your model in the front end right because if you are putting your model in the front end in the mobile app or in the web app then these app sizes will also very big nobody will download the 1 GB or 2GB app from Play store or app store right so that time you cannot do that or if you if you put your model of 1GB size in a web app then it will may take like 10 minutes to load the website right there you cannot do that that time also if a model sty is too big then go ahead and put it in the server itself okay next point is sensitivity of data sensitivity of data now this is quite controversial if your users you know the data that is being generated in in the app is too sensitive then you have to you know it will be it will be much it will be recommended that you just put the data in the mobile app itself you don't send the data to the server because in this communication because at the end what is happening over here this is a front end this is a a model and at the end you have a server here right you have a server here and over here what is happening you have a mobile app here or you have a client side here right and at the end there is a request response apis rest apis that are there in over here right so what is happening your data is going to go from the front end to the server right there you cannot do it because your data is too sensitive privacy concerns are there right so it will be recommended that you put the data in the mobile app itself and you don't transfer the data right because hacking can happen like anything can happen and but there is another Point let's say mobile only got stolen right and because of like you and you not encrypt the data uh somehow and your mobile only got stolen then the data is also gone okay so that's that also but in in the case where you are just you know generating the data and just deleting it that time it is okay because you are not storing any data that is totally fine but in that case also there is one point right so here you have to think what is happening in your application if it makes more sense to just store the data in the server securely using encryption algorithms use the second architecture but if you are just using the real time generation and you you have privacy concern your data sensitive just go ahead with the front uh first architecture your last Point here is Model Management let's say you are building such an application where or you are building such an AI model where continuously in months you are updating the AI model uh weights right or you are putting more and more data into the AI model for training right so there what is happening your AI model is continuously getting managed or maintained right so that time you cannot put your AI model in the front end because every time you update the model you have to bring an update to the Play Store and app store right so that time you cannot put your model in the front end that time you have to put or you have to connect your a model with the server itself so that you can directly update in the back end and your users don't face any issues or you know a blocker right so this is also one important point that should be kept in mind so these are the five point that actually decide whether you should go with first architecture or you should go with the second architecture right both the architectures have their own pros and cons and they are used a at a lot of rate it's not like that this architecture is used the most or this architecture is used used getting used the most right both of them are getting used this is mainly used when you want to deploy your AI model in the edge device like in the washing machine or in the uh you know like directly in the mobile device or Smartwatch that time this makes more sense and here this one you use when you you you you know you your models are too big like chat GPD like open AI right or like gemini or llama everything Lama is a model but open API and jini apis they they are doing what they they doing this exact same thing there this is only this architecture is getting used because you are the client you don't know which AI model is used you don't know which where the model is located where the model is deployed which model linear regression logis whatever it is used you don't know right so there the server that is open AI server has the AI model deployed somewhere which I will be talking soon deployed somewhere and they just give you the apis right they just give you the Endo that hey this is the uh endpoint for chat this is the end point for Generation this is the end point for whisper right they just give you the end points and you directly communicate with these end points so there this architect second architecture is getting used okay okay nice now let's go ahead and understand how can you actually embed the AI model in the front end or where to have where to deploy your AI model how to deploy your AI model right so over here in the first architecture what is happening let me just copy this whole thing this we don't need this you already know so what is happening in the first architecture you have your mobile app or you have your web app so let me also write down the textt so that you have like proper road map which which text track you have to learn right so for the mobile app what you're going to do is you have flutter for mobile app react for web app react native for again mobile app you have ionic for uh crossplatform you have zamarin for CLA platform you have Cordo you have uh I think this much angular you have right many front end uh libraries are there or packages are there or sdks are there that you can use you have Swift for iOS right that you can use to build your front end applications so this front end will be built using uh these uh Frameworks okay then AI model for building the AI model traditional libraries python libraries you have your uh pytorch you have your tensor flow inser flow then you have your pyit learn numpy pandas all the python libraries hugging pH you can use you know to get the models I'm not talking about building the model I'm just talking about uh getting the model Transformers you know when you just plug in some components so a lot of libraries are there mostly python written in Python you can use these libraries and packages to build your AI model right so we can say that this AI model component will be made using these libraries now it is the point where you have to embed your AI model in the front end that how will you do right so for that even you build a model that will be at least in like MBS right 100 MB 200 MB right for normal prediction model also there how to put that model in the front end because even 200 MB is bad so what happens is there is a library called tensorflow light right let me write it down tensor flow light TF light is called it is available in flutter it is available in most of the famous front end Frameworks right so what happens is this Library when you are making the model itself you actually take your model and pass this AI model to this TF light library and this TF light actually gives you the lighter version of your AI model AI model light this gives you the lighter version of your AI model so what happens is now this model light is in like KBS or like 1 m 2 m 10 m Max Max right how does it do it that's actually mathematical it uses quantization or something like that where it actually reduces the dimensionality of your weights right let's say your one weight if I'm boring you you can skip that but let's say your weight uh number is 0.2 1 3 4 6 7 8 9 10 something like this very long number then this you know fine tuning and all of these techniques they reduce the dimensionality right they reduce the size of that number they will just make it 0.213 that's it so yes prediction is affected a bit but it it is you know nobody will actually notice it right so you have to do these kind of trade-offs so these libraries will actually give you a lighter version now you can use this lighter version uh in your mobile app over here right over here you can use this lighter version this is just like a normal file right your flutter code or your react code will give a input to this file and it will just give you the output back prediction back right like a like your mobile will give give it an image and prediction will come back that hey zero that means dog one that means cat something like this right so this is your architecture and this is how you build it right in the next case where is a server what is happening over here is uh let's just copy this also so in case of this architecture again your server can be like in nodejs it can be in um spring boot it can be in Rust it can me in go it can be in python python has many Frameworks like flask uh it is Jango then you have fast API right many backend Frameworks are also there so your app server can be build in any of these um you know architectures or any of these libraries or packages right but most of the cases in case of AI application fast API flask and Jang are preferred because they are also in Python and your AI models are also written in py so most of the companies don't prefer you know hiring two different types of developers they will just hire one python proficient developer and who will build the a model also who will just build the server also right so that's why most of the startups are startups are preferring these three uh text tacks for building their app servers right now it is the chance when you have to deploy your AI model so AI model you have like various Cloud platforms so AI model is usually deployed on cloud platforms so it is your Azure m ml right it is your uh Google Cloud Azure ml it is your gcp uh it is your AWS Sage maker which is a it is a service from AWS right these are the three main major cloud services uh Cloud platforms which provide various services for AI model deployment management and hosting right so these AI models will be deployed they will be built in the same text tack these these liaries only right but they will be deployed on these three Cloud platforms so what happens when the client comes up with a request or a dog image gives to the server server performs some computation gives the model gives the image numeric matrices to the model that is deployed on a cloud service model predicts gives it back to the server server again does something it stores it in the database gives the data back to the client and hey client is Happy got the prediction right so this is how the architectures are uh there for AI models right so these are the two ways through which you can actually create your AI apps standard AI apps as the AI companies are using and they are building so if any interview ask you like hey how how are you going to contribute to our um AI model app right AI application you can tell that hey I have worked with these two architectures I have buil some projects in this so yes projects are very important build some projects using this also build some projects using this architecture also right put them in your resume and you're good to go so this is it guys I hope you enjoyed this video this lecture and don't forget to check out resum palal it's an amazing app amazing app for placement preparation last minute interview practice uh resume building resume analysis plus we also collaborate with colleges so if your college is interested to collaborate with us go ahead and refer us right so till the next video keep coding keep inating and thanks a lot