Different types of architecture || API
Client - server architecture
database
TCP – transmission control protocol
Client1 requests
Server(applicatio
Internet
n runs)
Client2 requests
process the
request and
send
response back
Advantages Disadvantages
Management is easy Network congestion
Security is good costly
Easily accessible
Spring Architectures
Spring framework architecture
1. Spring MVC
2. Spring Boot/layered/monolithic architecture
3. Microservices
Spring framework is container which contains all the things
Spring Architecture :-which contains all things , we can easily use this
1) Spring MVC – model view and controller -> UI code and backend code
are pres
https://www.javatpoint.com/spring-mvc-tutorial
Mvc not supported in ReactJs
Spring MVC Framework ka workflow ko samajhne ke liye simple example lete hain. Jab user
koi request bhejta hai, toh yeh request sabse pehle Dispatcher Servlet ke paas jata hai.
Wahan se Handler Mapping ka kaam hota hai, jo yeh decide karta hai ki yeh request kis
Controller ko bhejni hai. Phir Controller request ko process karta hai aur jo data prepare
hota hai, uske sath saath kis view (UI) ko dikhana hai, iska jawab ModelAndView ke through
deta hai. Iske baad, Dispatcher Servlet ko view ka naam milta hai, aur yeh kaam
ViewResolver karta hai jo correct view (jaise HTML ya JSP) dhoondta hai. Aakhir mein, user
ko final view ke form mein output dikhaya jata hai. Pura process smooth aur organized hota
hai, jo Spring MVC Framework ko asaan banata hai.
Model – data of application (product, customer, order…)
View – displaying the data in web page using html, css jsp
Controller – business logic which contains API to run main code and it
also connectes to database.
Dispatcher servlet – in built(which calls the corresponding controller
class)
2) Spring boot/layered/monolithic architecture –only contains backend
code
Whole application is one project and it contains multiple layers
https://www.javatpoint.com/spring-boot-architecture
Customer, Product, Order, payment….
Presentation
Business layer Data persistence
layer
layer
taking http requests Controller API, business logic performs database
performing authentication validations operations
database
PRESENTATION LAYER:-It handles the Http requests,translate JSON parameter
to object.-->and Authenticate the request and transfer it to the business layer.--
>it is fronted part
BUSINESS LAYER :-This layer handles all the business logic.it consists of service
classes and uses service provided by data access layer . It also performs
authorization and validation.
PERSISTENCE LAYER:- This layer contains all the storage logic and translates
business objects from and to database rows.
DATABASE LAYER:- In the database layer , CRUD operations are performed.
Spring Boot ka layered monolithic architecture ek structured approach hai jisme application ko alag-
alag layers mein divide kiya jata hai, aur har layer apna specific kaam karti hai. Sabse upar
Presentation Layer hoti hai, jo user ke sath interact karti hai aur authentication aur JSON translation
jese tasks handle karti hai. Iske neeche Business Layer hoti hai, jo application ka main logic,
validation, aur authorization ke rules ko manage karti hai. Phir aata hai Persistence Layer, jo data ko
database se retrieve karne, store karne aur manage karne ka kaam karti hai. Sabse neeche actual
Database hota hai, jahan data physically store hota hai. Ye architecture simplicity aur maintainability
ke liye famous hai, lekin kyunki ye monolithic hai, sari functionality ek hi codebase mein hoti hai, jo
deployment aur scaling ke liye kabhi-kabhi challenging ho sakti hai.Customer, product was in
single layer but in microservice, we divided into parts
3) Microservices – small+applications(projects)
https://www.javatpoint.com/microservices
Breaking whole one bigger application into smaller applications(services)
product
Micorservice1
Database1
customer
UI or frontend Microservice2
(react js) Dataabse2
resttemplate
order
Microservice3
Dataabase3
API – application programming interface https://www.geeksforgeeks.org/what-is-an-api/
communication between request and response
req req
Customer request
API
custid
savCustomer Process the request
Name
findCustoner performs database
Email activity and send back
updateCustomer the response
Mobile
deleteCustomer
……
resp resp
user url/endpoints
customer/save
customer/find
customer/update
customer/delete
Mainly 2 types :-
Stateless API Stateful API
Stateless APIs do not store the client Stateful APIs store the client state on
state on the server between requests. the server between requests like history
REST APIs – POST, GET, DELETE, PUT of the client who is updating it, when
created when updated.
Access token API
More scalable Less scalable
Spring