TRANSCRIPTEnglish

Frontend Architecture Patterns You Need to Know in 2025

46m 16s7,564 words1,208 segmentsEnglish

FULL TRANSCRIPT

0:00

Hey folks, my name is Dimma. I'm a

0:02

senior web developer based in Berlin.

0:04

I've got more than eight years of

0:06

experience across different companies.

0:09

I've been through many interviews myself

0:11

and conducted plenty as an interviewer,

0:14

too. On this channel, we talk about

0:16

passing front-end interviews and

0:18

advanced front-end topics in general. If

0:20

you are preparing for an interview or

0:23

working on your career as a web

0:25

developer, you will find some really

0:27

good stuff here. Today I want to discuss

0:30

front- end architecture. Front end

0:32

architecture I believe a very overlooked

0:35

topic. Not many of us take it seriously

0:38

when we are working on projects. But

0:40

here's the thing. Front end apps have

0:42

become complex enough that we really

0:44

need to consider their architecture as a

0:47

crucial part of the development process.

0:49

In this video, we will look at some

0:51

popular front-end patterns, discuss

0:54

their advantages, and talk about when we

0:56

should use them and when we shouldn't.

0:59

Let's dive in.

1:02

Now, when developers hear the word

1:04

architecture, a lot of them immediately

1:06

think about files and directories. And

1:08

while that's part of it, it's not the

1:10

main idea. Architecture isn't just about

1:13

how your files is structured. It's about

1:15

how different layers of your app

1:17

interact with each other. You might have

1:19

heard of MVC or model view controller

1:22

which was a pretty common pattern back

1:24

in the day. Even though it's not as

1:26

widely used now, especially in modern

1:27

fronted apps, the concept still helps us

1:30

understand how different parts of an

1:31

application communicate. And here's the

1:33

thing, your architecture can dictate how

1:36

your files are structured, but it

1:38

doesn't have to. For example, if you put

1:40

every single file into one folder, which

1:42

of course nobody in your team will like,

1:44

you'll still have an architecture as

1:46

long as your components interact in a

1:48

structured way. So why do we need

1:50

architecture? First, flexibility. It

1:53

allows different part of the app to be

1:56

modified or replaced without affecting

1:58

everything else. Realistically, how

2:00

often do you replace React with Vue or

2:03

View as well? Probably not too often.

2:05

But flexibility isn't just about

2:07

swapping frameworks. It's about having

2:10

clear boundaries between components to

2:12

make maintenance application easier.

2:14

Testability. Individual layers are

2:16

easier to test and scalability. As an

2:19

app grows, clear separation of concerns

2:21

helps manage complexity. The importance

2:24

of architecture depends on three key

2:26

factors. Project size. Bigger apps

2:29

require more structure to stay

2:31

maintainable. Team size. The more people

2:33

working on the project, the more

2:35

critical architecture becomes. Even if

2:37

you're just a two, three person team,

2:40

having some architecture is still

2:42

beneficial. But in team of 10 to 15

2:44

developers, good architecture is a must.

2:47

Project lifetime. For short life MVP, we

2:50

can prioritize speed over structure, but

2:53

long-term projects need solid

2:54

architecture to prevent technical depth.

2:57

One thing to note, architecture often

2:59

slows down initial development, but in

3:01

the long run, it makes scaling and

3:03

feature development much faster. Okay,

3:06

now let's get into MVC or model view

3:09

controller. The first pattern that we

3:11

will look at.

3:15

Hey again, sorry for the quick

3:17

interruption. We will continue in just a

3:19

minute. I've noticed that almost half of

3:22

you aren't subscribed to the channel

3:24

yet. I would really appreciate if you

3:27

could hit that subscribe button. And

3:29

here are three good reasons why. I make

3:32

videos rarely but consistently. So, if

3:34

you subscribe, you won't miss any new

3:37

content. There are no shorts or daily

3:40

uploads here, so you definitely won't

3:42

get spammed. Based on what I see in the

3:45

comments, this is one of the best

3:47

channels on YouTube for advanced

3:49

front-end developers. That's not my

3:51

opinion. That's what I see in the

3:53

comments. So subscribing would be a

3:56

pretty smart move. And finally, as you

3:58

can see, there is no advertising, no

4:01

paid content, nothing like that. I don't

4:03

earn anything from this. So subscriber

4:06

count is honestly one of the main ways I

4:09

can tell if I should keep making these

4:11

videos. That's it. Thank you for

4:13

listening and let's get back to the

4:15

video.

4:17

Most of you have probably heard of it.

4:19

It's been around for over 36 years. And

4:22

while it's not commonly used in modern

4:25

front ended applications, it still

4:27

contains some fundamental concepts and

4:29

can be useful in its own right and can

4:31

help us to understand more complex

4:33

patterns. MVC breaks an app into three

4:36

main layers. Model represents the

4:38

application data and business logic.

4:41

This layer usually represented by back

4:43

end, database and sometimes API. View

4:46

responsible for displaying data. This is

4:48

the UI what the user actually sees on

4:51

the screen. Also, it can include UI

4:53

logic like opening a model window and

4:56

controller acts as a bridge between

4:58

model and view. It handles user input,

5:01

updates the model and tells the view

5:03

what to display. Let's walk through an

5:06

example of MVC workflow. Step one, user

5:09

input. This is where everything starts.

5:11

User clicks a button, types something,

5:14

scroll, swipe, basically any kind of

5:16

interaction. Step two, view captures the

5:19

input and passes it to the controller.

5:21

At this stage, the view itself doesn't

5:23

process the event. It just forwards it

5:26

to the controller. Step three,

5:28

controller processes the input and

5:30

interact with the model. The controller

5:32

takes the input and decided what to do

5:35

with it. If the action requires updating

5:37

the database, the controller sends a

5:39

request to the model. For example, if

5:41

the user clicks delete item, the

5:44

controller tells the model to remove it

5:46

from the database. Step four, model

5:49

updates the data. The model, which is

5:51

usually the back end or a state

5:53

management system, processes the request

5:55

and modifies the data accordingly. In

5:57

our delete example, it removes the

5:59

entity from the database. Step five,

6:02

here's where things get interesting.

6:04

Both the controller and model can update

6:06

the view. The question is how does the

6:08

model communicate changes to the view?

6:10

There are two common approaches. The

6:12

first one is observer pattern. The view

6:14

subscribes to updates from the model and

6:17

reacts automatically and flow

6:19

synchronization. The view explicitly ask

6:21

the model for updates when needed. And

6:24

finally, user sees the updated UI.

6:26

Finally, the changes are reflected in

6:28

the UI and the user sees the updated

6:30

state of the app. That's the core idea

6:32

behind MVC. In the real world, it could

6:35

look like this. A user clicks like on a

6:38

post. The view captures the event and

6:40

sends it to the controller. The

6:42

controller updates the model, increments

6:45

the like count in the database. The

6:47

model sends the updated like count back

6:49

to the view. The view updates the UI to

6:52

show the new like count. Now, here's

6:54

something interesting. MVC doesn't have

6:57

to involve a backend server. You can

6:59

have a pure front-end MVC structure

7:01

where model is your state management

7:03

system like Redux, Ves or Pina. Vue is

7:07

your React, View or SWEL components and

7:09

controller. Well, this part is a bit

7:12

tricky. Some say we don't have a

7:14

controller in modern front end apps

7:17

because the view directly updates the

7:19

model. Others argue that hooks,

7:21

composables, or middleware act as a

7:23

controller like layer. So depending on

7:26

how you structure your app, you might

7:28

have a clear controller layer or none at

7:31

all. Now let's take MSE to the full

7:33

stack. Here's how it works. View the

7:36

front end UI built with React, View,

7:38

Angular or any other web framework.

7:41

Controller, the API layer handling

7:43

client ser communication and model the

7:46

back end containing business logic and

7:48

the database. So in this structure, the

7:50

front end only handles UI logic and no

7:53

any business logic. The API or

7:55

controller handles communication and

7:57

requests. The backend model processes

8:00

and stores data. Now, what happens when

8:03

you're working on a huge app? Well,

8:06

instead of having one massive MVC

8:08

structure, we break it down into smaller

8:11

independent embassy units. This is

8:13

called hierarchical MVC where each

8:15

feature, model or page has its own MVC

8:18

structure. For example, in a Redux

8:20

store, we can split the store into

8:22

multiple slices, each handling a

8:24

different feature. In React or View,

8:26

each page can have its own state, logic,

8:29

and controller like utilities, hooks,

8:31

and composables. So, instead of one big

8:34

MVC, we have multiple smaller MVCs all

8:37

working together. Let's talk about the

8:39

difference between thin and thick

8:41

clients. This distinction defines how

8:44

much processing happens on the client

8:46

side versus the server side. So what is

8:48

the theme client? A theme client keeps

8:51

most of the processing on the server

8:52

while the client web app only handles

8:55

the UI and user interactions. This is a

8:57

common approach in traditional

8:59

multi-page applications and static

9:01

websites. You can think of a simple HTML

9:04

website or a traditional web app that

9:06

reloads every time you click a button.

9:08

Every interaction goes to the server

9:10

which does all the processing and sends

9:12

back an updated page. On the other hand,

9:15

we have a thick client, also called fat

9:17

clients. A thick clients performs a lot

9:19

of logic on the client side, reducing

9:21

the server workload. Most interactions

9:24

don't require a full page reload.

9:26

Instead, there are handled instantly on

9:28

the client side, sometimes even offline.

9:30

So, the biggest difference between these

9:32

two, a thin client is heavily dependent

9:35

on the server, whereas a thick client

9:37

can work more independently with less

9:40

reliance on the back end. Now let's see

9:42

how MSC architecture changes depending

9:44

on whether we're using a thin or thick

9:47

client. In a classic MSC we have a thin

9:50

client and back end. The client just

9:52

renders data and sends user actions to

9:54

the controller. The controller API acts

9:57

as a bridge between the client and back

9:59

end and the model back end handles all

10:02

business logic and data processing. It's

10:04

simpler and lightweight front end. Bad

10:06

thing every interaction depends on the

10:08

server which means slower response time.

10:11

The other option is thick client and

10:14

back end. This combination is most often

10:16

found in modern web applications. The

10:18

client view does more than just displays

10:21

data. It manage state, handles logic,

10:23

and can even store data offline. The

10:26

controller API still acts as a bridge.

10:28

The back end model is lighter because

10:31

the front end takes over more

10:32

responsibilities. Good part, it's faster

10:35

on powerful devices. Betix can works

10:37

offline. Bad thing, heavier on the

10:40

client side. This is why SPA,

10:42

progressive F apps and local first

10:44

applications rely on thick clients. It

10:46

improves user experience, but it shifts

10:48

more complexity to the front end. With

10:51

thick clients, we can implement MVC

10:53

entirely on the client side. In

10:54

traditional MSE, the server is the

10:57

model. In modern frontend MSE, the model

10:59

is a state management system like Redux,

11:02

VUK or PA. So now instead of the server

11:04

handling all business logic we have

11:06

model is a state manager and controller

11:09

includes composables hooks middleares or

11:12

API calls. For example in the react app

11:14

with redux when a user clicks delete

11:16

item the view captures the event the

11:18

controller updates the model redux store

11:21

and the view renders automatically based

11:24

on store changes. Is MVC still useful

11:27

today? Yes, but it has some limitations.

11:31

Good things about MVC. It's easy to

11:33

understand. This pattern is clear and

11:35

logical and it's easy to develop and

11:38

maintain. However, we can face with a

11:40

fat controller problem. This problem

11:42

occurs because views don't handle events

11:46

and push them to the controller. This

11:48

creates bloated controllers that do too

11:51

much. The next problem is blurry

11:53

boundaries between model and controller.

11:55

Sometimes it's unclear what should be in

11:58

the model versus what should be in the

12:00

controller. View is also responsible for

12:02

receiving updates from model which makes

12:04

it not just a pure UI layer. Views are

12:08

only supposed to display UI but in

12:10

modern applications they also handle

12:12

events and observe for state changes.

12:14

This complicates testing and

12:16

maintenance. And the last problem, MSE

12:18

was introduced in 1979 and is mainly

12:21

suitable for classic web applications

12:23

with just a presentation layer on the

12:25

client side, not for modern complex web

12:28

applications with client side logic and

12:30

client side data stoages. Let's look at

12:32

the fat controller problem. Controller

12:35

supposed to be a bridge between the view

12:37

and the model. This definition sounds

12:39

too abstract and actually includes

12:41

things like a sending request to the

12:43

server, a handling API responses,

12:46

synchronization with the back end. For

12:47

example, if we use websocket for

12:49

realtime updates, controller also manage

12:52

client side caching and a bunch of other

12:54

things. And that's the problem. The

12:56

controller ends up doing way more than

12:59

it should becoming a massive bloated

13:01

layer. I think it's happening because

13:03

MVC was introduced in 1979. It never

13:06

supposed to be used for complex web

13:08

applications. Back then, client side

13:10

state management didn't exist. SPA

13:12

weren't a thing and a first application

13:15

didn't exist. When we try to follow MVC

13:18

strictly, we're most likely forcing

13:20

modern web apps into a structure that

13:22

wasn't built for them. When is MVC still

13:25

be a good choice? MVC can still work for

13:28

small to medium-sized web applications.

13:30

Also, MVC can be a good starting point

13:33

if scalability isn't a big concern. But

13:35

MVC is not a good fit for SPA with

13:38

complex state management apps with heavy

13:41

client side logic and the FL first or

13:44

local first applications because these

13:46

habs requires stronger separation of

13:48

concerns and better handling of local

13:51

state. The next pattern is called MVP or

13:54

model view presenter. MVP evolved from

13:57

MVC to better fit modern web

13:59

application. In MVP, the view doesn't

14:01

communicate with the model directly.

14:03

Instead, everything goes through the

14:04

presenter. Remember how in MVC, we had

14:07

to put observer logic into the view that

14:10

made it too complex. MVP solved that by

14:13

moving this logic into the presenter. So

14:15

now the view is just a pure UI layer,

14:18

nothing more. This makes the system more

14:20

predictable because we have no weird

14:22

circle dependencies, easier to test

14:24

because the view doesn't contain any

14:27

logic and more structured. Each layer

14:29

has a clear role. Let's take a look at

14:32

the difference between these two in the

14:34

picture. In MVC, the view always

14:37

observes the data update. We have to add

14:39

observer logic to the view layer, which

14:41

makes it more complex and hard to test.

14:44

In MVP, the view layer receives data

14:46

updates from the presenter and remains a

14:49

pure UI layer. There are actually two

14:51

types of MVP. supervising controller

14:54

which is more likely like MVC and

14:57

supervising controller the view still

14:59

handles some simple updates on its own

15:01

only complex logic goes through the

15:03

presenter that's what I meant when I

15:05

said that the view could contain some

15:07

logic and a passive view MVP in that

15:10

case the view is completely passive all

15:13

logic is handled by the presenter good

15:15

things about passive view are less

15:18

boilerplate less delegation code since

15:20

the view handles some task directly and

15:22

faster faster development because it

15:23

reduces unnecessary directions. However,

15:26

view becomes harder to test and maintain

15:28

since the view contains more logic. Unit

15:31

testing and development become harder.

15:33

This approach is suitable for cases of

15:35

simple UI where view logic is minimal.

15:37

And another option is passive view. Good

15:39

thing about it, we have more clear

15:41

boundaries between view, presenter, and

15:43

model. The view is purely passive and

15:46

the presenter contains all the logic

15:48

making all parts easier to test.

15:51

Downsides requires more code to handle

15:53

basic UI tasks and can lead to overhead

15:56

in cases where a simple view model

15:59

interaction would be enough. This

16:01

pattern is suitable for applications

16:03

with complex UI logic or when

16:04

testability and long-term scalability

16:07

are key concerns. Next, let's talk about

16:10

pros and cons of MVP itself. The first

16:13

benefit is better separation of

16:14

concerns. View is purely UI. Presenter

16:17

handles logic. Also, it is usually more

16:19

testable because view doesn't need to

16:21

observe data updates. However, we still

16:24

can face with a fat presenter problem.

16:26

Just like the fat controller in MVC, the

16:29

presenter can become a god layer if not

16:31

organized properly. MVP is also not a

16:34

very expressive pattern. It doesn't

16:36

define where to handle backend sync,

16:38

client side caching, and other things

16:40

that are not rare in modern web

16:42

applications. Use cases for MVP are the

16:44

same as for MVC, but MVP also is

16:47

suitable for applications with more

16:48

complex client side logic because it

16:50

provides better layer separation and

16:52

testability. The next pattern is called

16:55

MVVM or model view view model. The main

16:58

idea of MVVM is to separate view logic

17:02

from business logic. And I know we have

17:04

mentioned these terms before, but let's

17:07

make sure we actually get what they

17:09

mean. Business logic is when we actually

17:11

modify data in some way. For example, if

17:13

we change a username, that's type of

17:16

business logic. Make a payment, that's

17:18

business logic. If we remove an item

17:20

from a card, that's business logic.

17:22

Basically, if it affects the

17:23

application's real data, it's business

17:25

logic. Now, compare that to view logic.

17:28

View logic is purely UI related stuff.

17:30

It's just about what the user sees, but

17:33

it doesn't modify real data. For

17:35

example, opening or closing a model

17:37

window, disabling a button when

17:39

something's loading, updating a progress

17:42

bar while downloading a file. It's all

17:44

about what happens visually, but it

17:46

doesn't change the core data. But why

17:48

does these matter? Well, when MVC and

17:51

MVP were created, websites were simple

17:54

HTML, CSS, and a little of JavaScript.

17:56

But now, modern web applications are

17:58

insanely complex. Think about something

18:00

like Figma or Google Calendar. There are

18:03

super interactive, tons of UI updates

18:05

happening constantly. And if we just

18:07

throw all this UI logic into the view

18:09

layer like in a things get messy fast.

18:12

We need a better way to handle view

18:14

logic. That's where MVVM comes in. Let's

18:17

look at how it works. MVVM has three

18:20

parts. View the UI same as always. View

18:23

model handles all UI related logic. And

18:26

model handles business logic and actual

18:28

data. The new part is the view model.

18:30

The view model takes care of all the UI

18:33

logic. It updates the view and interact

18:35

with the model. It makes sure that the

18:37

UI stays in sync with the data. That's

18:40

the key difference between MVVM and

18:42

older patterns. MVVM introduces another

18:45

new concept called two-way bending. You

18:47

can see in the picture that view depends

18:50

on view model. But the opposite is also

18:52

true. This means that when we change

18:54

something in view model, the changes

18:56

happen in view accordingly. And when we

18:58

change the view, we automatically update

19:00

the model. This is how two-way binding

19:03

works. Let's look at the example how

19:05

view web framework implements this

19:07

concept. Let's say we have an input

19:09

field where the user types their name.

19:12

Normally, we would have to manually

19:13

track changes like this. The user type

19:16

the name, we update the state, the UI

19:18

update to reflect the new name. But with

19:21

MVVM, this happens automatically using

19:24

two-way data bindings. So when the user

19:26

types their name, the UI updates

19:29

instantly and the data model updates

19:31

automatically. If you have ever worked

19:33

with Vue, you have already seen this in

19:35

action. Let's look again at the key

19:38

differences between MVVM and previous

19:40

patterns. View model is designed to

19:42

store user interface data. The problem

19:45

with MVC and MVP is that they don't

19:48

distinguish between business and UI

19:50

data. The view is isolated from the

19:52

model. Many views can share a single

19:54

view model. A single view cannot have

19:56

more than one view model. The view model

19:59

contains all the data and behavior of

20:01

the user's interface window but without

20:03

any of the controls used to display that

20:06

user interface on the screen. When the

20:08

view model detects changes to the view,

20:10

it updates its own state with two-way

20:12

data bindings. If the model needs to be

20:14

updated, view model modifies the model

20:17

directly. Now, let's look at the

20:19

tradeoffs of this pattern. The good

20:22

parts, clear layer separation between UI

20:25

logic and business logic and

20:26

scalability, easier to test, maintain

20:29

and scale. The downsides, it has a

20:31

stepper learning curve. If you have

20:33

never used Vue or KnockoutJS, this

20:35

pattern might seem confusing at first

20:37

and again an expressiveness. MVVM

20:40

doesn't tell you where to handle things

20:42

like API requests or error handling. You

20:45

will still need to incorporate other

20:47

patterns for that. When should you use

20:49

MVVM? This pattern works best for

20:52

applications with complex UI logic that

20:54

needs to be tested. If you are building

20:56

an app with lots of user interactions,

20:58

forms with live validation or dynamic UI

21:01

updates, MVM is a solid choice. But you

21:04

probably don't need it for a simple

21:06

static websites. The next pattern is

21:08

hierarchical MVC. So we already

21:11

discussed MVC and one of its problem is

21:14

scalability. It works great for small

21:16

applications, but once your app grows,

21:19

MVC starts to fall apart. What usually

21:22

happens is that one controller starts

21:24

handling too many things. Instead of

21:26

just dealing with one model, it starts

21:29

interacting with multiple models.

21:31

Instead of handling a simple UI update,

21:33

it's now processing data from multiple

21:35

APIs, services, and backend sources. And

21:38

as a result, CO gets messy. Testing

21:40

become nightmare and making changes

21:42

takes forever. This is where HMV comes

21:45

in. Hierarchical model view controller

21:48

is just an extension of MVC that tries

21:50

to fix its scalability issues. Instead

21:52

of one big MVC structure controlling

21:55

everything, we break it down into

21:57

smaller independent MVC blocks. Each

21:59

block handles a specific feature and

22:01

interacts with other blocks only through

22:04

controllers. So now instead of one

22:06

controller talking to three models

22:08

directly, each feature or model has its

22:11

own self-contained MVC structure. You

22:13

can think of it like this. You have a

22:15

user feature. It gets its own MVC model.

22:18

You have a dashboard feature. It also

22:20

gets its own MVC model. And then if they

22:23

need to communicate, they only interact

22:25

via their controllers. This decoupling

22:27

makes architecture modeler reusable and

22:30

scalable. If you have worked with

22:31

Angular, this concept should sound

22:33

familiar. Angular has feature moders

22:35

which are pretty much an implementation

22:38

of HMSC in the front end. In a large

22:40

Angular app, you don't have one global

22:42

MVC controlling everything. Instead,

22:44

each feature users, orders, dashboard

22:47

get its own separate modus with its own

22:50

components, services, and state

22:51

management. This model approach makes

22:53

the codebase easier to maintain, test,

22:55

and scale. Good things about HMBC are

22:59

middlearity. An application can be

23:01

broken down into smaller modus which

23:03

encourage independent development,

23:05

facilitate maintenance, improve

23:07

testability and send error boundaries.

23:10

The model nature promotes code reuse.

23:13

Bad things are stepper learning curve.

23:16

It's harder to understand and develop

23:18

and possible inconsistent across models.

23:20

Each model can feel like its own mini

23:22

application and different developers or

23:24

teams may adopt slightly different

23:26

coding standards, patterns, tools or

23:29

naming conventions. When should you use

23:31

HMV? If you're building a large scale

23:34

application with multiple independent

23:36

features, a system where different teams

23:39

own different parts of the project, a

23:41

front-end app that fetches data from

23:44

multiple APIs and services, then HMC is

23:47

a great choice. If you're working on a

23:49

small or mediumsiz tab, probably you

23:51

don't need it. To sum it up, HMVC takes

23:54

the traditional MVC structure and makes

23:56

it scalable by splitting it into

23:58

independent MVC blocks. It's a great for

24:01

large applications but overkill for

24:03

small ones. The next pattern is MVVMC or

24:06

model view view model coordinator. I

24:09

know that the name is too long probably,

24:11

but stick with me. It's actually not

24:14

that complicated. If you have already

24:16

learned about MVVM, then you already

24:19

know most of it. The only thing new here

24:22

is the coordinator and its job is to

24:24

manage navigation and screen

24:26

transitions. Why do we need a

24:28

coordinator? Well, if you have worked

24:30

with MVVM, you probably run into this

24:33

issue. There is no clear place to handle

24:36

navigation. Think about it. The view is

24:38

just UI. It shouldn't be responsible for

24:41

handling coring. The model is just row

24:43

data. It doesn't even know the UI

24:45

exists. The view model could do it, but

24:47

then it gets bloated with navigation

24:49

logic. And that's exactly why MVVMC was

24:53

created. Instead of stuffing all the

24:54

navigation logic into the view model, we

24:56

move it into a separate entity, the

24:58

coordinator. Now, whenever you need to

25:01

navigate between screens, your view

25:02

model doesn't handle it anymore. Good

25:05

things about it, separation of concerns.

25:07

Navigation logic is completely separate

25:09

from UI and business logic and better

25:11

testability. You can unit test

25:13

navigation logic independently. The bad

25:16

thing is increased complexity. You are

25:18

adding another layer to your

25:20

architecture. MVM is suitable for

25:22

applications with complex navigation

25:23

scenarios like multi-step workflows. For

25:26

example, e-commerce checkout flow. The

25:29

next button offers even more structure.

25:31

It is called view interactor presenter

25:33

entity router. The view is a passive

25:35

view. It doesn't handle any logic. Just

25:37

displays UI and forwards user actions.

25:40

The presenter prepares data for the view

25:42

and makes sure everything is in the

25:44

right format. The interacctor handles

25:46

business logic. It is responsible for

25:48

fetching and modifying data. The entity

25:51

is just row data. No logic, just

25:53

structured information. And the router,

25:55

it manages screen transitions and

25:57

navigation. So the view only

25:59

communicates with the presenter. The

26:01

presenter talks to the interactor. The

26:03

interactor handles data from the entity

26:06

and the router takes care of moving

26:08

between screens. In Viper, we split the

26:11

logic into even more layers to keep

26:14

things modular and scalable. Viper is

26:16

used mostly in mobile development, but

26:18

it can be applied to front- end web

26:21

apps, too. It adds more structure than

26:23

classic MV patterns. It makes unit

26:26

testing easier because each part is more

26:28

independent, and it's better for large

26:30

scale applications where different teams

26:32

work on different moders. Let's also

26:34

take a look at how dependencies work in

26:36

Viper. View is the part of the UI that

26:39

changes most often. So we don't want

26:41

other parts to be responsible for view.

26:43

View itself is dependent on presenter.

26:46

Presenter depends on interractor and

26:48

rotor which acts as a highlevel layer

26:51

here. And interractor depends on entity

26:54

and as usual model but this time with a

26:56

different name entity doesn't depend on

26:58

anything. Another good thing about viper

27:01

which I like is that we can separate

27:03

interacctor into services and entity

27:05

into model entities. if it's needed. Key

27:08

features of wiper are designing

27:10

application based on use case. We can

27:13

build an application around use cases or

27:15

services that define the app course

27:17

feature. We have a place for API. In the

27:20

Viper architecture, the interacctor is

27:22

responsible for fetching data. The wiper

27:24

architecture has a place for handling

27:26

navigation. It's a router. Wiper offers

27:29

better separation of concerns. Each

27:31

component has a clear responsibility. It

27:34

scales well. It is better suited for

27:36

large applications or when multiple

27:38

projects are working on different

27:40

features. However, we usually need to

27:42

write more boilerplate. We have to write

27:45

a vast amount of interfaces for classes

27:48

sometimes with minimal responsibilities.

27:50

Wiper is better suited for complex

27:52

long-term applications. For small

27:54

applications, MV patterns are more

27:56

suitable. Clean architecture. Some of

27:59

you might already know this from the

28:02

Uncle Bob book. It's a well-known

28:04

approach, but let's break it down and

28:06

see how it works in front end and full

28:08

stack applications. If you look at the

28:10

diagram, you will notice it has four

28:12

main layers. Entities, the core business

28:15

logic, use cases, the application logic,

28:18

interface adapters, a bridge between use

28:20

cases and external systems, and

28:22

frameworks and drivers. Things like

28:24

databases, UI frameworks, APIs, and

28:27

external services. Dependencies always

28:30

point inward. The inner layers don't

28:32

know about the outer layers, but the

28:34

outer layers depend on the inner layers.

28:37

Entities are pure business logic. They

28:40

don't care about UI. They don't care

28:42

about databases and they don't care

28:44

about the frameworks. For example, think

28:46

of a banking app. Entity doesn't care if

28:48

the data is stored in MongoDB, poss.

28:52

It only cares about the business rules

28:55

like how transactions works or how

28:57

overdrafts are handled. They orchestrate

28:59

business logic but don't handle UI or

29:02

external services. For example, if we

29:04

have a list of bank transactions,

29:06

entities might store all of them. A use

29:08

case could be get the last 100

29:11

transactions. It processes the data but

29:14

doesn't store it. This keeps business

29:15

logic separate from how data is stored

29:18

or how it's presented to users.

29:20

Interface adopters layer is all about

29:23

adapting data between use cases and

29:25

frameworks. It ensures data is formatted

29:27

correctly before it reach the UI or

29:30

database. It acts as a translator

29:32

between different parts of the system.

29:34

The interface adapter makes sure that

29:36

data is converted properly before it

29:38

reached the UI. Framework and drivers is

29:41

the outer layer includes things like UI

29:43

frameworks, react view or angular

29:46

databases, posgrql, or firebase

29:49

and other external APIs. This layer is

29:51

not essential to the core business

29:53

logic. If you swap U for React, the

29:56

inner layers don't care. If you move

29:58

from MongoDB to posgress SQL, the core

30:00

logic stays the same. This is why clean

30:02

architecture is so modular and scalable.

30:05

Two principles of clean architecture.

30:08

Separation by dividing the software into

30:10

layers. The entity and external

30:12

interface layers are mandatory. Other

30:15

layers can be discarded if they are not

30:17

needed. Additional layers can also be

30:19

added. And the dependency rule. The rule

30:21

says that outer layers depend on inner

30:24

layers but inner layers cannot depend on

30:27

outer layers. Nothing inner circle can

30:29

know anything at all about something in

30:31

an outer circle. Let's imagine we have

30:34

no back end or don't need to think about

30:36

it. For example, if you're building an

30:38

offline first app that stores data in

30:41

index DB, the structure remains the

30:43

same. entities, local data models, use

30:46

cases, data manipulation logic,

30:47

adapters, bridge between UI and index DB

30:50

and frameworks, UI, React, and index DB

30:53

API. So instead of calling a database

30:56

API, the use cases interact with index

30:59

DB instead. And the last example is a

31:01

pure UI web app with just a view logic

31:04

on the client side. In that scenario,

31:06

the core logic is all UI based. Instead

31:08

of database models, we have view logic

31:11

at the center. The back end becomes just

31:13

a framework. It doesn't define core

31:14

logic. So clean architecture can even

31:17

apply to UI heavy apps where the all

31:20

business logic leaves on the back end.

31:22

Good things about clean architecture.

31:23

It's highly testable. Clean architecture

31:26

allows for testing each layer

31:27

individually making it easy to identify

31:30

and address errors and database

31:33

independent. The application is

31:34

decoupled from the database making it

31:37

easier to make changes at the database

31:39

level. UI dependent. The UI framework is

31:42

isolated. So making changes at the view

31:44

level is easier and the bad things

31:47

higher barrier to entry depends on

31:49

experienced and disciplined team to use

31:51

it well and increased complexity.

31:54

Implementing clean architecture can

31:55

introduce significant complexity

31:57

especially for smaller projects due to

31:59

managing multiple layers and ensuring

32:01

proper separation of concerns. The next

32:04

pattern is called hexagonal

32:06

architecture. Like other patterns that

32:08

clearly separate layers, hexagonal

32:10

architecture makes distributed

32:12

development easier. Chims in different

32:14

locations can work in different parts of

32:16

the same application independently using

32:18

integration test and mocks so that

32:20

components can be tested in standalone

32:23

mod. Another name for hexagonal

32:25

architecture is ports and adapters. If

32:27

we look at the diagram, we will see how

32:30

hexagonal architecture works. We have

32:32

business logic at the center. Then we

32:34

have input and output ports. Input ports

32:37

are for the driving side. Output ports

32:40

are for the dreaming side. On the image

32:43

you see a scenario how two teams front

32:45

end and backend teams are working on the

32:48

app. Team B is responsible for business

32:50

logic and ports. We can think of this

32:52

team as a backend team. They build the

32:55

logic without worrying about the UI.

32:57

They just define ports, entry points

32:58

where other parts of the system can

33:00

connect, retrieve data or modify data.

33:03

Team A is the UI team. They work on the

33:06

adapters and the UI itself. They don't

33:08

need to know how the back end works

33:10

internally. They just know that input

33:12

ports exist and use them to send and

33:15

receive data. Of course, it might be one

33:17

team or full stack developers team. This

33:20

architecture can be applied to the web

33:22

applications. On the driving side, left

33:24

side, we have user events, web sockets

33:26

and server events. On the driven side,

33:29

right side, we have the user interface,

33:32

client storage and local storage. So the

33:34

driving side controls the application

33:36

whereas the driven side is controlled by

33:39

the application logic. Like other

33:41

patterns with a clear separation between

33:43

layers, the hexagonal architecture

33:44

facilitates distributed development.

33:47

Hims in different locations can build a

33:49

single application using integration

33:51

tests and mocks so that components can

33:53

be tested in standalone mode. Now let's

33:56

talk about contracts. This is something

33:58

we can add to make development even more

34:00

stable and predictable. Contracts define

34:03

clear separation for interactions

34:05

between ports in the adapters. To

34:07

enforce contracts, we can use response

34:09

validators like Zot, Joy or Yube and

34:13

integration tests. So between the

34:15

adapters and the ports, we place these

34:18

contracts. They can be types, graphical

34:21

schemas, open API specifications or

34:24

others. How they work? For example,

34:26

client sends a request to the input

34:28

port. The back end validates the request

34:31

body, query params, and body structure.

34:34

On the client side, we also have a

34:35

contract to ensure the UI always gets

34:37

what it expects. This prevents

34:39

unexpected API changes and ensures front

34:42

end and back end remains in sync. Using

34:45

contracts helps our team work

34:46

independently and then synchronize their

34:49

work and multiple interfaces. If your

34:52

app interacts with REST API, GraphQL,

34:54

SLI or multiple UI and rich web

34:56

applications. If your front end has

34:58

business logic or it is a local first

35:00

app, hexing architecture can be a great

35:03

fit. It's not recommended for simple

35:05

apps. Overhead is unnecessary if the

35:08

project is small and small teams and

35:10

projects. If your team is small or the

35:13

scope is limited, hexagonal architecture

35:14

might be too much complex without clear

35:17

benefits. Now if we compare clean

35:19

architecture and hexagonal architecture,

35:22

we see some key differences. Clean

35:24

architecture is newer and evolved from

35:26

hexagonal architecture. It focuses on

35:28

layer separation within a single

35:30

application. Separates concerns into

35:33

entities, use cases, controllers and

35:35

infrastructure. Hexagonal architecture

35:37

older but in my opinion still very

35:40

effective. Best suited when your system

35:42

involves multiple distributed parts. It

35:45

focuses on interactions between services

35:47

and external interfaces. So if you have

35:49

multiple interfaces, hexagonal

35:51

architecture makes more sense. I

35:53

personally like it. I think it's easier

35:55

to understand and it gives clear

35:56

separation of concerns without being

35:58

overly rigged. The next concept I want

36:01

to describe is crimite.

36:03

This concept is not about how models

36:05

interact with each other. Instead, it's

36:07

about how we should structure our code

36:10

and how we should name our entities.

36:13

Screaming architecture was introduced by

36:15

Robert Martin. The idea behind it is

36:17

that the architecture of a software

36:19

system should be immediately

36:20

recognizable just by looking at its top

36:23

level structure. Things like packages

36:25

name, model names, and directories in

36:28

the codebase. In other words, the

36:29

architecture should scream the intent

36:31

and purpose of the application. It

36:32

should be obvious what the system does

36:34

without needing to dig into the details.

36:37

I added this concept here because I

36:39

think screaming architecture is useful

36:41

for understanding another concept we

36:43

will discuss later. Screaming

36:45

architecture is all about emphasizing

36:47

entities in our code. If you are

36:49

familiar with DDD or domain driven

36:51

design, you will see some parallels.

36:53

Both approaches focus on describing

36:55

architecture in terms of the business

36:57

model. For example, we shouldn't

36:58

structure our application around

37:00

technical details like React or Vue,

37:02

MongoDB or posgressql. Instead, we

37:05

should focus on what our application

37:07

actually does. So, if we are building a

37:09

to-do list, for example, our features

37:11

should be named accordingly, like tasks

37:13

or to-dos. If you have a user management

37:16

system, let's call it users, not

37:18

controllers or handlers. That's the main

37:20

idea of screaming architecture. Imagine

37:23

this case. You open a project, you take

37:25

a quick glance at the directory

37:27

structure, immediately you should know

37:29

what the application does. That's what

37:31

scream architecture is about. It ensures

37:33

that by just looking at the structure,

37:35

you can tell what this project is for,

37:37

what the main entities are, and how the

37:40

business logic is organized. A good

37:42

tople design should tell the reader

37:44

about the business, not technical

37:46

details. Focus on the business domain.

37:48

Structure the codebase around core

37:50

business concepts and use domain

37:52

specific names for models and features.

37:54

Organized by features, not layers. Each

37:56

feature should contain everything it

37:58

needs. logic, data handling and UI

38:01

components and hide technical details.

38:03

Things like frameworks, databases or

38:05

APIs should be abstracted away. Keep

38:07

them in lower level models, not on the

38:10

top level. In a system design interview,

38:12

we should primarily focus on the

38:14

architecture rather than the

38:15

organizations. The final organization

38:18

can be changed easily at any stage of

38:20

the project by changing the

38:21

architecture. Once a project has grown,

38:24

it's difficult if not impossible. That's

38:26

what I call tough decision. something

38:28

that we cannot easily revert. We should

38:30

avoid this decision if we have no enough

38:32

information to make it. Of course,

38:34

sometimes it's not possible. For

38:36

example, architecture is a tough hard to

38:38

reverse decision. It's not just because

38:40

our team is used to working with a

38:42

particular architecture. It's because as

38:44

the application grows, the codebase

38:45

becomes massive and that's completely

38:48

normal for enterprise projects.

38:49

Rewriting an entire architecture, it's

38:51

not just difficult, it's time consuming

38:54

and often not feasible. In most cases,

38:56

the only realistic way to migrate to new

38:58

architecture is to completely rebuild

39:00

the application from scratch. And if you

39:02

have worked on real world projects, you

39:04

probably know how rarely companies have

39:07

the budget for such a massive rewrite.

39:09

This is why when you start working at a

39:11

company, you might realize that

39:12

architecture is outdated and ask

39:14

yourself, why does this huge company

39:17

still use such an old abandoned

39:19

architecture? And the answer is usually

39:21

simple. It's just too hard to rewrite

39:23

everything from scratch. At the same

39:25

time, choosing the perfect architecture

39:27

at the start of the project is nearly

39:29

impossible because in the beginning, you

39:31

don't know what the application will

39:33

evolve into over time. It starts in one

39:36

form and a few years later, it might

39:39

look completely different and at the

39:41

start it's almost impossible to predict

39:43

how exactly the application will

39:44

transform as it grows. However, that

39:46

doesn't mean we shouldn't try and

39:48

eventually, I believe, choose at least a

39:51

good enough architecture. The file

39:53

structures and naming conventions are

39:54

the opposite of architecture decisions.

39:57

They are easily changeable. If you want

39:59

to rename a file or refactor the

40:01

structure, it's not a big deal. We just

40:03

rename files, update imports, and we're

40:06

done. That's why we don't focus too much

40:08

on discussing file structure because

40:10

file naming and file organizations are

40:12

easy to reverse. Let's move to the next

40:16

and last architecture pattern in our

40:18

list. Vertical slices. I would say that

40:20

vertical slices are probably the most

40:23

modern architectural style on this list.

40:25

And at the same time, I would also say

40:27

that it's one of the most widely used

40:30

today. To understand what vertical

40:32

slices are, let's go back to clean

40:34

architecture in our minds. Remember that

40:36

clean architecture follows a layered

40:38

approach where each layer is a technical

40:40

entity. But here's the issue. Clean

40:42

architecture tell us how to separate

40:45

layers, but it doesn't tell us how to

40:47

organize features within those layers.

40:50

This lack of internal structure can

40:51

sometimes be confusing. Vertical slices

40:54

solve this problem by promoting a

40:56

feature-based approach where each

40:58

feature is a business case. Think of

41:00

vertical slices as an internal structure

41:02

for your architecture layers. For

41:04

example, in clean architecture, we have

41:06

entities, use cases, controllers, and

41:09

external interfaces. Now, instead of

41:11

treating each of them as a separate

41:13

layer covering the entire app, we slice

41:15

the application vertically into

41:17

self-contained features. Each slice

41:19

contains its own entity, its own use

41:22

case, its own controller, and its own

41:24

external interface. Every feature is

41:27

self-contained inside a slice. This make

41:29

the architecture more modeler, easier to

41:32

scale, and more maintainable. We can

41:34

also combine vertical slices with other

41:36

architecture patterns. For example, in

41:38

an MVP application, we usually have

41:40

three layers, but we don't know how to

41:43

internally structure them. With vertical

41:45

slices, we create one slice per feature.

41:47

For example, create to-do slice, delete

41:50

to-do slice, and update to-do slice.

41:52

Each slice internally follows MVP

41:54

architecture, but each of them remains

41:56

independent. Vertical slices can give us

41:59

better code organization. Each feature

42:01

is self-contained, making the codebased

42:04

modeler and easy to manage. It's easier

42:06

to work on by multiple teams. Each slice

42:08

is independent, so multiple teams can

42:11

work on different slices simultaneously.

42:13

However, there is a potential for over

42:15

engineering. If developers try to

42:17

strictly follow vertical slices

42:19

everywhere, even for simple features, it

42:21

can lead to unnecessary complexity and

42:23

extra boilerplate code and inconsistency

42:26

between teams. Because teams work

42:28

independently on slices, different teams

42:30

might structure things differently. This

42:32

can lead to inconsistencies across the

42:34

codebase. Possible solutions are use

42:37

common design guides, enforce linting

42:39

and formatting rules and rotate

42:41

developers across teams. When to use

42:43

vertical slices? Large scale

42:45

applications. Vertical slices

42:47

architecture is particularly beneficial

42:49

in a large scale applications with many

42:51

distinct features. It helps keep the

42:53

codebase organized by feature making it

42:56

easier for teams to work in different

42:57

parts of the application independently.

42:59

and crossunctional teams. In

43:01

organizations where teams are

43:03

crossunctional, vertical slices allow

43:05

team to take ownership of specific

43:07

features from end to end. This promotes

43:10

better collaboration and quicker

43:12

delivery of complete features. We

43:14

probably should use something else for

43:16

simple applications. Overhead is

43:18

unnecessary for simple fullstack

43:21

applications or thin web clients and

43:23

small teams and projects. The

43:25

application architectural complexity

43:26

might not pay off if your team is small

43:29

or the project scope is limited. The

43:32

future slice pattern was defined. I

43:34

would like to share a final thoughts on

43:36

front- end architecture. First of all,

43:38

while we are explored several patterns,

43:41

we certainly didn't cover all of them.

43:43

My goal was to focus on the most widely

43:45

used ones such as MVC, MVP, clean

43:48

architecture. However, it is impossible

43:50

to cover every pattern. There are likely

43:53

hundreds of them or even thousand and

43:55

covering them all was never my

43:57

intention. I also wanted to introduce

43:59

you to some less common front-end

44:02

patterns. For instance, we discussed

44:03

wiper which is traditionally used in

44:05

mobile development. But as I mentioned

44:08

earlier, just because a pattern is

44:10

primarily designed for mobile

44:11

application doesn't mean we can't

44:13

extract valable ideas for front-end

44:15

development. In fact, front-end

44:17

developers regularly borrow useful

44:19

concepts and patterns from back-end

44:21

development. It is completely normal for

44:23

ideas to migrate across different areas

44:25

of software development. The topic of

44:28

front architecture has been overshadowed

44:30

for a long time. And I think that's

44:32

wrong. Even though front end usually

44:34

doesn't have complex business logic,

44:36

modern front end applications have

44:37

become extremely complex. Think about

44:39

it. local first application, a flying

44:41

first applications, highly interactive

44:43

UI, state heavy applications like Figma,

44:46

notion or Google Docs. The front end is

44:49

no longer just rendering views. The

44:51

front end is no longer just rendering

44:53

views. It often has managed state,

44:55

caching, data persistence and even

44:58

synchronization with backend services.

45:00

That's why I think front end

45:01

architecture should be more widely

45:02

discussed than it's now. Another

45:04

important thing, patterns are not meant

45:06

to be followed rigidly. Well, each

45:08

pattern has its own core concepts.

45:10

Doesn't mean we can't or shouldn't

45:12

adjust them to fit our specific needs.

45:15

In fact, I would argue that we must

45:17

adopt them. For example, we can add more

45:20

layers if necessary. We can remove

45:22

unnecessary layers if they don't add

45:24

value. No two web applications are

45:27

completely identical. Every project

45:29

differs in terms of challenges that we

45:31

need to solve. That's why there is no

45:33

single perfect pattern that works for

45:35

every situation. Each application is

45:37

unique. So we must tailor our

45:39

architectural approach accordingly.

45:41

Another reason why using patterns is

45:43

important because they provide a common

45:45

language for developers. For instance,

45:47

if I describe a system using terms like

45:50

model, controller, and view, most

45:52

developers will immediately understand

45:54

what I mean. Even if there are small

45:56

differences in interpretation, that's

45:58

one of the biggest advantages of using

46:01

established patterns.

46:03

That's all for today. I hope you found

46:05

this video useful. If you did, please

46:07

don't forget to hit the like button and

46:09

subscribe to the channel. See you in the

46:11

next one. Bye.

UNLOCK MORE

Sign up free to access premium features

INTERACTIVE VIEWER

Watch the video with synced subtitles, adjustable overlay, and full playback control.

SIGN UP FREE TO UNLOCK

AI SUMMARY

Get an instant AI-generated summary of the video content, key points, and takeaways.

SIGN UP FREE TO UNLOCK

TRANSLATE

Translate the transcript to 100+ languages with one click. Download in any format.

SIGN UP FREE TO UNLOCK

MIND MAP

Visualize the transcript as an interactive mind map. Understand structure at a glance.

SIGN UP FREE TO UNLOCK

CHAT WITH TRANSCRIPT

Ask questions about the video content. Get answers powered by AI directly from the transcript.

SIGN UP FREE TO UNLOCK

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.