YouTube2Text

Frontend System Design Explained w/ Senior Engineer (Microfrontends, Monorepo, MCP UI, Reactjs) — Transcript

by theSeniorDev · 7,923 words · 1,160 segments · language en · Watch on YouTube

Full transcript

  1. 0:00As AI is getting better at writing
  2. 0:02front-end code, your only choice to stay
  3. 0:04relevant and competitive as a front-end
  4. 0:06engineer is to level up your system
  5. 0:07design and architecture skills. The
  6. 0:09problem is that most system design
  7. 0:11content is way too focused on the
  8. 0:13back-end while completely ignoring the
  9. 0:15front-end. So today I'm going to break
  10. 0:17down every front-end system design
  11. 0:18concept you need to know from
  12. 0:19micro-front-ends architectures to system
  13. 0:22design patterns like back-end for
  14. 0:23front-end and then go into mono-repos
  15. 0:26and rendering strategies like
  16. 0:27server-side rendering. I'll also show
  17. 0:29you what is the best way to use AI and
  18. 0:31agentic coding to deploy these systems
  19. 0:33to production. Now let's start with our
  20. 0:35first front-end system design concept,
  21. 0:37micro-front-ends. Now the traditional
  22. 0:38front-end application will start as a
  23. 0:40front-end monolith. That means pretty
  24. 0:42much everything is in the same place.
  25. 0:44And when it comes to micro-front-ends,
  26. 0:46it basically means that we will split
  27. 0:48this application into independent
  28. 0:50front-end applications and then put them
  29. 0:52all together. But before we even talk
  30. 0:54about micro-front-ends, we need to
  31. 0:56understand microservices and that is a
  32. 0:58back-end architecture style. And so
  33. 1:00looking at our client-server model, both
  34. 1:02the server and the client will be
  35. 1:04monoliths. That is single applications.
  36. 1:06And at that point we keep adding
  37. 1:08features to it because you're in the
  38. 1:09initial phase of the project. But as you
  39. 1:12scale, more and more people will have to
  40. 1:14work on the same code base and your
  41. 1:16development team becomes huge. And I've
  42. 1:18worked with developers that told me
  43. 1:20their development team was 40 people and
  44. 1:23their daily stand-up took 1 hour and a
  45. 1:25half just for everybody to speak for 1
  46. 1:27minute and a half. And that's just not
  47. 1:29sustainable. So that's where
  48. 1:31microservices and micro-front-ends come
  49. 1:33into place because this kind of
  50. 1:34architecture doesn't scale from a
  51. 1:36development point of view. Now you've
  52. 1:37probably heard about the term two pizzas
  53. 1:40team where Jeff Bezos said that team
  54. 1:42shouldn't be bigger than five to nine
  55. 1:44people, which is as many as you can feed
  56. 1:46with one pizza. Now the two pizzas team
  57. 1:49becomes a one pizza team with AI.
  58. 1:52Because nowadays you can do the same
  59. 1:53work with a lot less people using
  60. 1:56agentic coding. And so, the ideal size
  61. 1:58of the team becomes smaller and smaller.
  62. 2:00Now, do remember that even if coding
  63. 2:02agents like Cloud Code drive
  64. 2:04implementation time to zero, they do
  65. 2:06increase the verification time. So,
  66. 2:08being an AI savvy front-end engineers it
  67. 2:10means you design system that decrease
  68. 2:12the verification time and minimize
  69. 2:14architectural drift while they maximize
  70. 2:15velocity. And so, it's not anymore about
  71. 2:18implementing fast, but rather building a
  72. 2:20system that is extremely easy to verify.
  73. 2:23And we'll see how that changes
  74. 2:24architecture later on. But, keep this
  75. 2:26principle in mind. And so, in the ideal
  76. 2:27case we are able to split our monolithic
  77. 2:29team into feature teams that own a
  78. 2:32specific feature. And those teams are
  79. 2:35full stack and they work with coding
  80. 2:37agents, but they can deliver
  81. 2:38independently and that's how we can keep
  82. 2:40our product moving forward. And so,
  83. 2:42we'll have these different feature
  84. 2:43teams, but it's also shared
  85. 2:45infrastructure and that's owned by the
  86. 2:46platform team. You might have front-end
  87. 2:49tooling or pure infrastructures like the
  88. 2:51servers. So, you might have a team for
  89. 2:53example that is building a design system
  90. 2:55that the feature teams are using. And
  91. 2:57all those teams are smaller and they all
  92. 2:59work with coding agents. That is the new
  93. 3:01norm in development teams. Now,
  94. 3:03according to Conway's law, the software
  95. 3:05architecture of a system will look like
  96. 3:06the organization of the people. So, if
  97. 3:08what we want is smaller independent
  98. 3:10teams, then we need to somehow break our
  99. 3:13system into small independent vertical
  100. 3:17slices. And this truly starts in the
  101. 3:19back-end where we take our monolith and
  102. 3:21we split out the independent modules to
  103. 3:24build microservices. Those are
  104. 3:26independent small back-ends, micro
  105. 3:28back-ends that expose their own API and
  106. 3:31can be deployed independently. The code
  107. 3:33base is independent and you have
  108. 3:34independent teams that don't need to
  109. 3:35talk to each other extending those and
  110. 3:37they only communicate between each other
  111. 3:39through APIs. And so, a typical
  112. 3:41microservice blueprint will look like
  113. 3:43something like this. We have an API,
  114. 3:44there's a business logic layer, then
  115. 3:46there's a persistence layer and usually
  116. 3:47a database. In this case I added a
  117. 3:49Postgres DB, but it could be a no sequel
  118. 3:51DB. And so, this is the building unit of
  119. 3:53your application, and big applications
  120. 3:55will have thousands of those in
  121. 3:57productions. A couple of years ago, I
  122. 3:59used to work for this financial company,
  123. 4:00and we had around 1,000 microservices in
  124. 4:03production, and you had different teams
  125. 4:04only different microservices. My team
  126. 4:06owned 13 of them. And by the way, if you
  127. 4:08want to see where do you stand across
  128. 4:10the full stack, there's a free
  129. 4:11assessment that you can take in the link
  130. 4:12below, and you basically understand how
  131. 4:15much of this full stack knowledge you
  132. 4:17actually have, where is the gap, and we
  133. 4:19added a new AI section because a lot of
  134. 4:21companies are starting to ask AI
  135. 4:22questions in front-end engineering
  136. 4:25interviews, also. So, take the
  137. 4:26assessment and you can see more or less
  138. 4:28where do you stand in the market and
  139. 4:29what gaps you need to close. Link it's
  140. 4:31in the comments. Now, moving on, we
  141. 4:33split our back end into microservices,
  142. 4:35but our front end is still a monolith.
  143. 4:37So, even if our back end teams now could
  144. 4:40ship independently and be much smaller
  145. 4:42and go much faster, the front end is
  146. 4:43pretty much the same. And the problem
  147. 4:45with the front end is that you have so
  148. 4:47many people pushing code to the same
  149. 4:49client that it's so easy for someone to
  150. 4:51make a mistake or bring the whole system
  151. 4:53down or change a global CSS rule that
  152. 4:57then affects everybody. So, as of now,
  153. 4:59our front end team is still very, very
  154. 5:00big and totally not sustainable. It gets
  155. 5:03to a point where we just cannot scale
  156. 5:05because there's just too much
  157. 5:06communication overhead between all those
  158. 5:07people needing to coordinate as they
  159. 5:09work on the same code base. And that's
  160. 5:11why we go back to micro front ends,
  161. 5:12where we have a front end monolith and
  162. 5:14we split it in different independent
  163. 5:16front end applications. Now, how do we
  164. 5:18put all those together? Well, basically,
  165. 5:20we'll have a shell. And the micro front
  166. 5:22end shell is the one that takes care of
  167. 5:24the global functionality, things like
  168. 5:27auth, routing, language, global state,
  169. 5:30you know, are the users logged in or
  170. 5:31not, it's all handled by that. And all
  171. 5:34the others model applications, they live
  172. 5:36inside this one. They're basically
  173. 5:37loaded by this micro front end shell.
  174. 5:40And this micro front end shell, it's
  175. 5:41also on passing this global state inside
  176. 5:44those micro front ends. But remember,
  177. 5:46those applications are now deployable
  178. 5:48independently. That means you might have
  179. 5:49a domain that it's
  180. 5:51header.theseniordev.com,
  181. 5:52where, for example, we would host only
  182. 5:54our header application, and you could
  183. 5:56load that independently. And then you
  184. 5:57have the product page and the cart page,
  185. 5:59but then you have the shell that puts
  186. 6:00them all together. So, if you look at a
  187. 6:02big software company like amazon.com,
  188. 6:04you could basically split the header,
  189. 6:06and then maybe take out the product page
  190. 6:09and the payment into two different micro
  191. 6:11front-ends. But, to be honest, I feel
  192. 6:13like they have even more granularity
  193. 6:15there, and they probably split their
  194. 6:16front-ends into even smaller and more
  195. 6:19focused micro front-ends. So, once you
  196. 6:21apply micro front-ends and microservices
  197. 6:23together, you end up with a micro
  198. 6:24front-end that will speak to one or
  199. 6:26several microservices in the same
  200. 6:28domain. And this is what we call a
  201. 6:30vertical slice. And this system can now
  202. 6:33be extended by an independent team. So,
  203. 6:35we can start releasing changes
  204. 6:36independently. Our releases are not a
  205. 6:39bottleneck for another team, and we can
  206. 6:41work against the APIs of other teams.
  207. 6:44This is how pretty much every big
  208. 6:46software company operates. And this is
  209. 6:48what in software architecture they call
  210. 6:50vertical slicing, where your features
  211. 6:52are vertically owned by one team. And
  212. 6:55I'm going to go even farther and tell
  213. 6:57you that if you are an engineer, and
  214. 7:00you're doing only front-end or back-end,
  215. 7:02you have to move as fast as you can
  216. 7:03towards becoming a vertically integrated
  217. 7:06engineer, basically a team of one that
  218. 7:08can work with a coding agent across the
  219. 7:10full stack. And we'll see in a second
  220. 7:12why that happens. But, that's the
  221. 7:13transition you're going to need to go
  222. 7:15through to survive in today's market.
  223. 7:17So, when it comes to traditional
  224. 7:18front-end engineering and front-end
  225. 7:19development, we see that moving towards
  226. 7:20two extremes, where you're either more
  227. 7:22of a full-stack person that works in a
  228. 7:24feature team, so they work across these
  229. 7:26vertical slices, and that's why you need
  230. 7:27to know a bit more about full-stack. By
  231. 7:29the way, we do have full-stack videos on
  232. 7:31this channel. If you want to know, as a
  233. 7:33front-end engineer, transition slowly
  234. 7:34towards a full-stack. Or, you're going
  235. 7:36to be really good at the front-end, and
  236. 7:38then you're going to the infra team, and
  237. 7:39you start building it at the shell, or
  238. 7:41you build a design system, and that's
  239. 7:42where you do spend a lot of time, you
  240. 7:44know, doing traditional front-end work
  241. 7:46with just CSS, and building the building
  242. 7:48blocks that the feature teams will
  243. 7:49implement. And pretty much both of those
  244. 7:52people will work with coding agents.
  245. 7:54Now, a quick tip about AI and AI coding,
  246. 7:57micro front-ends and microservices
  247. 7:58decrease the blast radius of a
  248. 8:00production bug, and they could use the
  249. 8:02cognitive load of code changes because
  250. 8:04you have smaller and localized PRs. You
  251. 8:07also get less context, which means your
  252. 8:09AI coding tool would be much more
  253. 8:11efficient because you work on smaller
  254. 8:13pieces and the risk is less. So, it's a
  255. 8:15really good strategy when you have a lot
  256. 8:16of people pushing a lot of code very
  257. 8:18frequently as we do with AI to move
  258. 8:21towards micro front-ends and
  259. 8:22microservices because the risk is lower
  260. 8:25and it decrease what we call the
  261. 8:27verification time. It's just easier to
  262. 8:29go on the quality when the surface area
  263. 8:31of the changes you are making is
  264. 8:32smaller. So, micro front-ends and
  265. 8:34microservices are usually the way to go
  266. 8:36if you're building fast with AI. Now,
  267. 8:37let's move to our next concept, which is
  268. 8:39only API gateway. Now, whenever we have
  269. 8:41a micro front-end and a back-end
  270. 8:43service, we need to end up making a lot
  271. 8:45of requests. And those requests have
  272. 8:47what we call edge functions. They need
  273. 8:49caching, HTTPS, authentication, content
  274. 8:52negotiation, rate limiting for security,
  275. 8:54and so all this functionality at the API
  276. 8:56level it's pretty repetitive. So, having
  277. 8:59to implement this both on the front-end
  278. 9:00side and on the back-end side every time
  279. 9:03we plug in a new microservice to the
  280. 9:05micro front-end ends up adding a lot of
  281. 9:08overhead. And it becomes a lot harder to
  282. 9:10do this if you have a lot of back-end
  283. 9:11services. So, a typical solution is to
  284. 9:14add what we call an API gateway, and
  285. 9:16that would be your gate into the
  286. 9:18back-end systems. And the advantage of
  287. 9:20an API gateway is that the client would
  288. 9:22only implement the edge functions once.
  289. 9:25So, they basically only implement the
  290. 9:26HTTPS handshake once, or caching, or
  291. 9:29rate limiting, and then once the request
  292. 9:31goes to the API gateway, it gets
  293. 9:33forwarded to the back-end services,
  294. 9:34which don't have to care about all this
  295. 9:36functionality. They can just care about
  296. 9:38their own logic. And all this usually
  297. 9:40lives in a virtual private cloud, which
  298. 9:42means it's totally secure because the
  299. 9:44only way to go into it is through the
  300. 9:46API gateway. The other cool feature when
  301. 9:48you have an API gateway is that you can
  302. 9:49make the communication between the
  303. 9:51client and API gateway HTTPS, but the
  304. 9:53communication between the microservices
  305. 9:55and the API gateway HTTP because you
  306. 9:57don't need that security anymore cuz
  307. 9:59you're in a closed environment. And the
  308. 10:01advantage here is performance because
  309. 10:03HTTPS it's likely less performant than
  310. 10:06the HTTP because you need more round
  311. 10:08trips to do the HTTPS handshake. So, in
  312. 10:10general, once you have a couple of
  313. 10:12microservices in production, it's a good
  314. 10:13idea to add an API gateway both for
  315. 10:15security and performance and also less
  316. 10:17complexity in the front end. Now, let's
  317. 10:19move on to our next pattern, very
  318. 10:20similar to the API gateway, we have the
  319. 10:22backend for frontend. Now, let's
  320. 10:23remember our setup from before where we
  321. 10:25have our client and our API gateway and
  322. 10:27all our microservices. The problem here
  323. 10:30is that the client has to make a call to
  324. 10:32all these different microservices that
  325. 10:34might have a different API and there's
  326. 10:36so many fetch calls. And if you're in
  327. 10:37the frontend team, whenever you need a
  328. 10:39new feature that needs even the
  329. 10:40slightest backend change, you need to go
  330. 10:42and talk to that backend team and figure
  331. 10:44out if that will be a priority for them,
  332. 10:46add it to their backlog, and maybe
  333. 10:48something gets done. So, it ends up
  334. 10:49being very, very slow. And one of the
  335. 10:51biggest challenge that some of the
  336. 10:52engineers we work with at the senior dev
  337. 10:55that work in bigger companies is that
  338. 10:56it's so hard for them to get things done
  339. 10:58because they have to talk to key
  340. 11:00different backend teams that have their
  341. 11:01own backlog and their own priority. So,
  342. 11:03they just don't want to implement that
  343. 11:04small API field that they need. So,
  344. 11:06better solution is to somehow own your
  345. 11:08backend as a frontend team, as a client
  346. 11:11team. There's also a lot of complexity
  347. 11:13when you have to implement all these
  348. 11:15different APIs because they all look
  349. 11:17different, you need a different client
  350. 11:18and SDK for all these different APIs.
  351. 11:20And so, that's more frontend complexity.
  352. 11:22So, the solution for that is to add what
  353. 11:23we call a backend for frontend. This is
  354. 11:26a backend that will take the frontend
  355. 11:28request and then just forward it to the
  356. 11:30microservices. But the advantage here is
  357. 11:32that whenever you have to implement a
  358. 11:34feature, you can act as a full-stack
  359. 11:37developer when you're in the front-end
  360. 11:38team. So, basically, you have all those
  361. 11:40microservices, you integrate, like to
  362. 11:43change the way you equals them from the
  363. 11:44back-end for front-end, and then you
  364. 11:45implement your feature, and you kind of
  365. 11:47own end-to-end the client-side feature.
  366. 11:50And the back-end teams, they can just
  367. 11:51work in isolation on the different
  368. 11:53microservices. So, the front-end team
  369. 11:55ends up owning both the client and the
  370. 11:57back-end for front-end, and back-end
  371. 11:59teams they develop pure back-end
  372. 12:01services. And this is very important for
  373. 12:02you as a front-end engineer because it
  374. 12:04means that you do need to know, at least
  375. 12:06at the high level, how to extend a
  376. 12:08microservice, how to build a back-end
  377. 12:09for front-end. You need to know API
  378. 12:11design, and you need to know a little
  379. 12:13bit about GraphQL, for example, which is
  380. 12:15a great technology to build back-end for
  381. 12:17front-ends. This is a requirement for
  382. 12:19all the front-end engineers that you see
  383. 12:21working at bigger companies, which are
  384. 12:23usually the ones that also have the best
  385. 12:25conditions and the most exciting work.
  386. 12:27So, even if you're in the front-end,
  387. 12:28make sure that you can also get things
  388. 12:30done in the back-end. Now, the advantage
  389. 12:33with BFFs is that you can adapt them to
  390. 12:35a specific client. So, if in the future
  391. 12:37we end up building a mobile app that has
  392. 12:39totally different requirements to our
  393. 12:41desktop app, we don't need to duplicate
  394. 12:43API endpoints. So, with back-end for
  395. 12:45front-ends, every client will have its
  396. 12:47own dedicated back-end, which means
  397. 12:49every client team can work independently
  398. 12:51and is completely decoupled from the
  399. 12:53back-end services that can just focus on
  400. 12:55their own service. And so, basically,
  401. 12:57whenever the desktop client, for
  402. 12:59example, goes to gateway, they get
  403. 13:01redirected to the desktop back-end for
  404. 13:03front-end. And for mobile, we have a
  405. 13:05completely different API, a completely
  406. 13:07different mobile back-end for front-end.
  407. 13:08It uses the same back-end services, but
  408. 13:10it might expose a total different API to
  409. 13:13consume them, just because the data
  410. 13:15needs in mobile are usually different
  411. 13:16from desktop. Where in desktop, you want
  412. 13:18to fetch a lot of information at once,
  413. 13:20but in mobiles, we have smaller screens,
  414. 13:21so you need different records. And if
  415. 13:23you try to put all those things together
  416. 13:25in a single API, it will become bloated,
  417. 13:27or it will end up not satisfying one of
  418. 13:29the requests. For example, you'll have a
  419. 13:31great API for desktop, but when it comes
  420. 13:33to mobile, you'll fetch too much data, a
  421. 13:35lot of data you don't really need
  422. 13:36because the interface is a bit
  423. 13:37different. Or if you make the smaller
  424. 13:39endpoints, when it comes to desktop,
  425. 13:40you'll have to make many requests to get
  426. 13:42the same data. So, you'll have
  427. 13:44over-fetching or under-fetching, and
  428. 13:46it's a lot better if you split those
  429. 13:47things. On to the next concept, which is
  430. 13:50load balancing. Now, going back to our
  431. 13:52client-server model, we had a server and
  432. 13:54we end up having clients. But, the
  433. 13:55problem is we might get a lot of users.
  434. 13:58And so, you have all those clients
  435. 13:59making requests to a single server. Now,
  436. 14:02a typical Node.js server is pretty
  437. 14:04powerful. It can usually satisfy up to
  438. 14:062,000 to 10,000 concurrent requests with
  439. 14:10a well-optimized Node.js server. But,
  440. 14:12when you go beyond that, you might need
  441. 14:13different ways to scale it because a
  442. 14:15single server has its own limits. And
  443. 14:18the easiest way to scale it is by load
  444. 14:20balancing. And that means you basically
  445. 14:23will create identical instances of your
  446. 14:26servers and then have this component
  447. 14:27that's an application load balancer
  448. 14:29splitting traffic between them. Now,
  449. 14:31load balancing is a topic by itself.
  450. 14:33There's different ways to split traffic
  451. 14:35and different criterias. And as a
  452. 14:37front-end engineer, you don't need to go
  453. 14:38so deep into it. But, do make sure that
  454. 14:40you know about it. Ideally, you're even
  455. 14:42capable of setting up a small load
  456. 14:44balancer using traditional web servers
  457. 14:46like Nginx and Docker Compose, you can
  458. 14:48have this set up on your local machine.
  459. 14:51Anyhow, the important thing is that you
  460. 14:52can reason your way through it. Most
  461. 14:54cloud providers like AWS or Google
  462. 14:56Cloud, they allow you to provision a
  463. 14:58load balancer in seconds. So, don't
  464. 15:00worry about it. It's very uncommon that
  465. 15:02you need to manually set up one, but
  466. 15:04it's important that you know about it.
  467. 15:06Now, congrats on making it this far.
  468. 15:07Make sure you subscribe so you don't
  469. 15:08lose any updates in the future, and
  470. 15:11let's move on to our next concept, which
  471. 15:13is container systems. So, we basically
  472. 15:15distributed our architecture into micro
  473. 15:17front-ends and different microservices,
  474. 15:20but the problem is that deploying all
  475. 15:22this would be a headache. Now we need to
  476. 15:25build up and provision infrastructure
  477. 15:27and pipelines, and they all might use
  478. 15:29different technologies. You might have a
  479. 15:31Python microservice and then a Node.js
  480. 15:33one. You might have a Vue.js application
  481. 15:36or a Next.js application. And this is
  482. 15:37all very complicated to get to
  483. 15:39production. So, in order to standardize
  484. 15:41the deployment, we can actually use
  485. 15:44Docker. And Docker is technology that
  486. 15:46allows you to package your application
  487. 15:48to Docker image. And the way you do that
  488. 15:50is that you take your code, and then you
  489. 15:53have a Dockerfile where you kind of
  490. 15:54declare your recipe of how we should
  491. 15:56package that code. And basically, based
  492. 15:59on that, you'll create a Docker image.
  493. 16:00The Docker image will contain all the
  494. 16:01application code and then the runtime.
  495. 16:04Let's imagine you're using Next.js, then
  496. 16:06it will contain Next.js, will have the
  497. 16:08runtime, which is Node, and then the
  498. 16:09operating system, which is usually
  499. 16:12Linux. And that is a full Docker image,
  500. 16:14and the advantage there is that whenever
  501. 16:16you find a host that runs Docker, you
  502. 16:18can run that image. You don't need to
  503. 16:20worry about the Node.js version or if
  504. 16:22they need to install PHP and all the
  505. 16:24dependencies that your application has.
  506. 16:25It really comes packaged all together.
  507. 16:28This is Docker image. You run it, open
  508. 16:30this port, you have a front end running.
  509. 16:31You don't need to know about what's
  510. 16:33inside. And this is wonderful for DevOps
  511. 16:36teams because all of the sudden they can
  512. 16:37take all those images and push them into
  513. 16:40a container orchestration system. A
  514. 16:42container orchestration system usually
  515. 16:44has a container deployment pipeline,
  516. 16:46which will run these containers. And so,
  517. 16:48running a container is not as easy as it
  518. 16:50sounds. You might need load balancing.
  519. 16:52Uh you might want to run several
  520. 16:54instances in parallel and be able to,
  521. 16:57you know, if a container fails, spin up
  522. 16:59another one really fast. So, all this
  523. 17:01kind of hard work it's built into
  524. 17:03systems like Kubernetes. You probably
  525. 17:05saw it in job office. Now, do you need
  526. 17:06to know Kubernetes as a front end
  527. 17:08engineer? No. But you do need to
  528. 17:10explain, you do need to know about it,
  529. 17:13and you will see a lot of front end
  530. 17:14positions that mention either Kubernetes
  531. 17:17or container systems or a ECS, which is
  532. 17:20the AWS alternative to Kubernetes, in
  533. 17:22the job description. Don't be scared.
  534. 17:24You don't need to become a DevOps
  535. 17:25engineer by tomorrow, but you should be
  536. 17:27able to, at a high level, understand
  537. 17:29where it fits in your architecture.
  538. 17:31Finally, a more front-end concept, a
  539. 17:33CDN, a content delivery network. So,
  540. 17:36what is a CDN? So, going back to a
  541. 17:37client-server model, imagine you are a
  542. 17:39client, you want to go on a website, you
  543. 17:42usually go to the server and get some
  544. 17:44static files. Static JavaScript and CSS,
  545. 17:47and you download that and you run that
  546. 17:49on your web browser. Let's imagine in a
  547. 17:51more hypothetical case that you are a
  548. 17:53user from the US and you want to visit
  549. 17:55the application that is based in Europe.
  550. 17:57For you to get the JavaScript and CSS
  551. 17:59and all the HTML, you have to go all the
  552. 18:01way to the Atlantic Ocean and come back.
  553. 18:03And that young trip adds latency, and
  554. 18:05there's no physical way you can work
  555. 18:07around it. No matter how performant your
  556. 18:10application is, there is the limit of
  557. 18:12the speed of light, because data only
  558. 18:14travels as fast as the speed of light,
  559. 18:16and over long distances, light is very
  560. 18:18fast, but it still will add around,
  561. 18:20let's say, 200 ms to 250 ms on every
  562. 18:23request of latency. So, a solution to
  563. 18:26that is to your client decrease the
  564. 18:27distance between you and where those
  565. 18:29files are hosted. And the easiest way is
  566. 18:31to use a content delivery network. And
  567. 18:33so, basically, a CDN will be a network
  568. 18:35of these edge locations that are placed
  569. 18:37all over the world, and what happens is
  570. 18:39that the server will push the static
  571. 18:41assets there, and whenever you make a
  572. 18:43request, you'll be redirected to the
  573. 18:45edge location that is closest to you.
  574. 18:46Now, this mechanism on how exactly are
  575. 18:49you getting redirected to that edge
  576. 18:51location that is closest to you, it's
  577. 18:52very interesting, and I do want to make
  578. 18:54a video about it, but I'm not sure if
  579. 18:56it's something you're interested in. If
  580. 18:58you want a video about it, let me know
  581. 18:59in the comments. It's a bit more
  582. 19:01technical, and it's not something you'll
  583. 19:02get in interviews. But, to be honest,
  584. 19:04it's really interesting. So, if you want
  585. 19:06me to make a video about it, just give
  586. 19:07me an excuse by letting me know in the
  587. 19:08comments, and I'll go ahead and do that.
  588. 19:10Now, a CDN is a distributed cache. So,
  589. 19:13the technical term for whenever you get
  590. 19:15the asset from the CDN, it's a cache
  591. 19:16hit. And whenever the server pushes a
  592. 19:19new version, that's called cache
  593. 19:21invalidation. And this concept is very
  594. 19:23closely related to what we call cache
  595. 19:25busting, which is a mechanism that
  596. 19:27module bundles use to invalidate your
  597. 19:30assets. So, we make sure that when you
  598. 19:31deploy a new version, users really get
  599. 19:34the latest one, not a previous version
  600. 19:35that is probably still sitting somewhere
  601. 19:37in the CDN. I do have other videos in
  602. 19:40the channel talking about it, so I'm not
  603. 19:41going to go deep into it. But make sure
  604. 19:43you're able to relate those things
  605. 19:44across the stack. Now, keep in mind that
  606. 19:46a CDN is the fastest and most
  607. 19:48cost-effective to increase web
  608. 19:49performance by serving optimized assets
  609. 19:52with the right cache policy out of the
  610. 19:53box. Because nowadays, CDNs do a lot
  611. 19:56more than just placing the asset close
  612. 19:58to the client. They also compress it,
  613. 19:59and they also take care of the caching
  614. 20:01policy. So, it's a really cheap way for
  615. 20:04you to fix most performance problems.
  616. 20:07Now, let's talk about design systems.
  617. 20:08And going back to our micro front-end
  618. 20:10discussions, we have a feature team,
  619. 20:12that's a product feature team, and then
  620. 20:14we might have the payments feature team,
  621. 20:15and they work separately and release
  622. 20:18independently. Those are completely
  623. 20:20separate product teams. And the problem
  624. 20:22there is that you might get code
  625. 20:23repetition or what we call visual
  626. 20:26divergence. You can have this silos
  627. 20:28mentality. And so, basically, a button
  628. 20:30in the product page will look
  629. 20:32differently than a button on the payment
  630. 20:34page. And so, you will lose what we call
  631. 20:35visual coherence, and people will start
  632. 20:37to notice that those are actually
  633. 20:39separate front-ends because they look
  634. 20:40differently. And that's not good from a
  635. 20:43product perspective, but it's also not
  636. 20:45good from a technical perspective
  637. 20:46because you have too much repeated code.
  638. 20:48And so, the solution is to have a design
  639. 20:49system. And in a design system, the
  640. 20:51first thing you do is to define your
  641. 20:52design tokens. That's basically your
  642. 20:55team information. What's your primary
  643. 20:57color, what is your border definition,
  644. 20:59your fonts families, and so on and so
  645. 21:02forth. And the modern way to do that is
  646. 21:04you add them as CSS custom properties,
  647. 21:07basically variables, at the global level
  648. 21:09in your CSS, probably in the shell micro
  649. 21:11front end, and then it gets fed into all
  650. 21:13the other micro front ends. But, you can
  651. 21:15go a bit farther and build reusable
  652. 21:16components that then the feature teams
  653. 21:18can use to assemble their features. So,
  654. 21:21you could build inputs and buttons, and
  655. 21:23basically they would consume that UI
  656. 21:25package and use it in all these
  657. 21:26different micro front ends. So,
  658. 21:28basically what you achieve is that the
  659. 21:29UI looks consistent, but also you don't
  660. 21:32repeat your code. The cool thing about
  661. 21:33the design system is you can take care
  662. 21:35of accessibility, you can have all those
  663. 21:37components unit tested, and basically
  664. 21:39you are applying at an architectural
  665. 21:41level the do not repeat yourself dry
  666. 21:44principle. And going back to AI coding,
  667. 21:46a solid design system really makes the
  668. 21:48difference between generating some
  669. 21:50component slob and having inconsistent
  670. 21:52styles and bugs that need a lot of
  671. 21:54rework, and really having a consistent,
  672. 21:56reliable coding agent output. Trust me,
  673. 21:59I've been building a lot of AI in the
  674. 22:01last couple of months, and the first
  675. 22:02thing I do when I make a new project is
  676. 22:04to tell to extract from whatever the
  677. 22:06design is the design system, because
  678. 22:08then you feed that into your coding
  679. 22:11agent through different sessions, and
  680. 22:13you still get consistent output. If you
  681. 22:14don't do that, the agent will make
  682. 22:16things up, and your UI would just look
  683. 22:18different, and it'll be obvious that it
  684. 22:20was live coded. Now, our next concept is
  685. 22:22a design to code MCP, that's a model
  686. 22:24context protocol server. And so,
  687. 22:26basically, you remember we have our
  688. 22:28design system, and normally you would
  689. 22:29import that to start building with it.
  690. 22:31But, nowadays, let's imagine that your
  691. 22:33designers built your design system
  692. 22:34initially in Figma, and then you
  693. 22:37implement it in your library. You can
  694. 22:38use the Figma MCP server with a coding
  695. 22:41agent to very quickly assemble features
  696. 22:45into the feature teams, into the
  697. 22:46vertical slices of your product. And
  698. 22:48this is the kind of workflow that most
  699. 22:49companies are moving towards. So, if you
  700. 22:51are a front end engineer, you got to
  701. 22:53make sure that you know how to use an
  702. 22:55MCP server, you know what an MCP server
  703. 22:57is, and ideally, whatever design tool
  704. 23:00your team is using, you can plug an MCP
  705. 23:02into that or you might have to even
  706. 23:03build that connection yourself. And then
  707. 23:06plug that into your AI coding agent like
  708. 23:08Cloud Code, which is the most used in
  709. 23:10enterprise or Codex. Now, a quick note
  710. 23:13on CSS architecture and design tokens.
  711. 23:15What you can do to take things even
  712. 23:17further is to apply the Atomic CSS
  713. 23:19methodology and with your design tokens,
  714. 23:21create atomic classes that you can use
  715. 23:23in your code base. So, basically, you
  716. 23:25define what the border would be, but
  717. 23:26then you create a dot border class that
  718. 23:28has that property. And then the only
  719. 23:30thing that other developers have to do
  720. 23:32is to use that class. And this is how
  721. 23:34Tailwind CSS works. So, keep this in
  722. 23:37mind. Tailwind CSS is an implementation
  723. 23:40of the Atomic CSS architecture style for
  724. 23:43CSS. And there's three more
  725. 23:45architectural styles, which I won't get
  726. 23:46into right now, but who knows, maybe
  727. 23:49I'll make a video about it later on.
  728. 23:51Next front end system design concept,
  729. 23:53the monorepo. So, basically, our
  730. 23:55applications right now are sitting in
  731. 23:56all these different repos where you have
  732. 23:58a GitHub repo for the shell, one for the
  733. 24:00payment micro front end, inventory micro
  734. 24:01front end, and it's all spread out into
  735. 24:04thousands of repos. And the problem
  736. 24:06there is that you end up with different
  737. 24:07code styles, different dependencies, and
  738. 24:09different quality standards. Some people
  739. 24:10might be using TypeScript, they might be
  740. 24:12using different linter configurations,
  741. 24:14and it's so easy to have what we call
  742. 24:16architectural drift or code style drift
  743. 24:19where two projects diverge too much.
  744. 24:21What's the problem with that? If you're
  745. 24:22a developer and you change teams, you
  746. 24:24have to relearn everything. So, you
  747. 24:27don't really leverage standardization.
  748. 24:29And the way to is to put everything into
  749. 24:31a single repository. So, basically, you
  750. 24:33have a big repository that contains all
  751. 24:35the other small applications, and you
  752. 24:37have tooling that works with both of
  753. 24:39them. So, for example, when you run NPM
  754. 24:40run build in a monorepo, all your
  755. 24:43applications will build individually.
  756. 24:45Now, when it comes to AI coding, a
  757. 24:47monorepo gives coding agents the context
  758. 24:49they need to make changes across service
  759. 24:51boundaries. So, for example, if you're
  760. 24:53building a micro front and you realize
  761. 24:56that you run into a reusable use case.
  762. 24:58You can easily extract that and propose
  763. 25:01it as a component into your design
  764. 25:02system. That might be a different repo.
  765. 25:04And you can do that with the coding
  766. 25:05agent in a single session if you have
  767. 25:08everything in a mono repo. If not, you
  768. 25:10have to somehow feed those two different
  769. 25:11repositories to your coding agent and
  770. 25:13everything becomes harder. So, combining
  771. 25:16micro frontends and microservices with a
  772. 25:18mono repo, it's usually the most
  773. 25:20efficient way to work with AI. Now, one
  774. 25:22thing I'm really excited about is also
  775. 25:24MC PUI. So, MC PUI is basically
  776. 25:27combining the traditional website with
  777. 25:29an LLM-powered app, and that's basically
  778. 25:30the glue in between them, the duct tape,
  779. 25:33let's say that. And so, basically, in a
  780. 25:35chat application, you usually send a
  781. 25:37chat query, and then that goes to the
  782. 25:39LLM, and the LLM will answer back, but
  783. 25:41in this case, it can actually answer
  784. 25:42with UI components. It can actually
  785. 25:44render products, for example, in the
  786. 25:46answer, not only text. But to do that,
  787. 25:49it has to somehow talk to the backend,
  788. 25:51and then we need to render some
  789. 25:53components. And that is what MC PUI
  790. 25:55solves. And this is an example I found
  791. 25:57in a recent website where I was looking
  792. 25:58for venues for events because we are
  793. 26:00organizing our annual in-person meetups
  794. 26:02at the Senior Dev, so we're going to
  795. 26:03meet all the engineers we work with
  796. 26:04around Europe or in the US, and I was
  797. 26:06looking for different cool venues where
  798. 26:08we could actually meet up. And so, I was
  799. 26:10talking to this chat UI, and all of a
  800. 26:11sudden, after a couple of questions, it
  801. 26:13started rendering those venues, and it's
  802. 26:15asking me for input, and then it would
  803. 26:17go into a deep search and give me even
  804. 26:19more venues. And as you see there, it
  805. 26:21can even render a map. And all this
  806. 26:23happens in a chat application. And I
  807. 26:25think this is the direction front end
  808. 26:26will go with LLMs, where we will
  809. 26:28integrate LLMs in web applications would
  810. 26:30be. A lot of people were saying that
  811. 26:32there's no more need for UI now that we
  812. 26:35have a chat. I disagree. I think the UI
  813. 26:37is a very useful way to communicate
  814. 26:39things, and I think you need front end
  815. 26:41developers, but we'll be able to combine
  816. 26:43the LLM approach with the traditional
  817. 26:45web approach. So, this component was
  818. 26:47rendered because the front end parsed it
  819. 26:50from the answers of the LLM. At a high
  820. 26:53level, the way this works is that the
  821. 26:55model harness will provide in the
  822. 26:57context the tool registries and all the
  823. 26:59MCP servers and then as a user prompt,
  824. 27:01and the LLM will send an answer back to
  825. 27:03the tool UI with the text answer, but
  826. 27:06also with an instruction to render a
  827. 27:07certain div, and then the tool, the web
  828. 27:10application has to follow that and
  829. 27:12render it.
  830. 27:13And just to really bring this to the
  831. 27:14code, the way we declare a resource or
  832. 27:17an MCP UI is we basically tell the LLM,
  833. 27:19"Hey, there's this resource, and you can
  834. 27:21use it in this case scenario, and this
  835. 27:24is the answer you can give." And then
  836. 27:25our front end has to take that and parse
  837. 27:27that and then render it. If you want me
  838. 27:29to make an in-depth video on how exactly
  839. 27:31MCP UI works, let me know, but this is
  840. 27:34one of those patterns that if you know
  841. 27:36really well, you'll really stand out
  842. 27:37because I believe it goes way beyond the
  843. 27:39current AI hype and it's actually
  844. 27:41something very useful for specific edge
  845. 27:44cases, and you'll see a lot of
  846. 27:45applications actually implementing this
  847. 27:47hybrid solutions. Now, to wrap up this
  848. 27:50talk a bit about performance, and the
  849. 27:52most important pattern that you'll ever
  850. 27:54see out mentioned in job descriptions
  851. 27:56for front end engineers, it's the Core
  852. 27:58Web Vitals. And so basically the Core
  853. 27:59Web Vitals are three metrics that
  854. 28:02quantify the three dimensions in which
  855. 28:04we measure the performance of a website,
  856. 28:07and those are the loading speed, the
  857. 28:09interactivity speed, and the visual
  858. 28:11stability. And the three Core Web Vitals
  859. 28:13that measure this are the Largest
  860. 28:14Contentful Paint, the Interaction to
  861. 28:15Next Paint, and the Cumulative Layout
  862. 28:17Shift. Basically, those are measured by
  863. 28:19Google, and they tell us what a good
  864. 28:21number would be. So, when you look at
  865. 28:23the Largest Contentful Paint, it would
  866. 28:24be the time it takes from when you hit
  867. 28:27enter to when the largest element in the
  868. 28:29web page is rendered. The Interaction to
  869. 28:31Next Paint, it's slightly different, and
  870. 28:32it has to do to when you interact. So,
  871. 28:34you do something, and then when do we
  872. 28:36repaint the UI? And the CLS is basically
  873. 28:38how much the UI changes when it loads.
  874. 28:41And so, the LCP and CLS have to do with
  875. 28:43the initial render, and the INP has to
  876. 28:45do with the re-renderings, which is very
  877. 28:47important when you talk about component
  878. 28:49frameworks. Now, to understand those,
  879. 28:50you need to understand the critical
  880. 28:52rendering path, which is all the steps
  881. 28:54you go from downloading some HTML to
  882. 28:56actually showing something on the
  883. 28:58screen. And that involves building the
  884. 29:00DOM, and then building the CSSOM, then
  885. 29:02building a render tree, then computing
  886. 29:04the layout tree, which is basically a
  887. 29:06tree of where all your nodes are and the
  888. 29:09positions and the width, and then
  889. 29:11transforming that into what we call
  890. 29:13paint operations that goes through to
  891. 29:15the GPU, then going to the composite
  892. 29:17phase, which has its own complexity, and
  893. 29:19I'm not going to talk about it, but just
  894. 29:21to summarize this, all those steps will
  895. 29:23happen, and then you have some
  896. 29:25re-renders because we use component
  897. 29:26frameworks, you get data, you start
  898. 29:28re-rendering, you finally finish, and
  899. 29:29then that's when you paint the LCP. So,
  900. 29:31all that time is measured in the LCP,
  901. 29:33and the bottom line here is, if you're
  902. 29:35shipping a lot of JavaScript, if you're
  903. 29:37shipping a lot of CSS, if you have to
  904. 29:39fetch a lot of data, and your server is
  905. 29:41slow, your application will be slow, and
  906. 29:43you'll get a very poor score in the LCP.
  907. 29:45The other thing that will happen if your
  908. 29:46application is poorly optimized is that
  909. 29:48you'll have layout switching all the
  910. 29:50time as you start loading things because
  911. 29:52CSS comes too late, and then fonts come
  912. 29:54in, and then some data comes in, and the
  913. 29:56browser will take screenshots of that
  914. 29:57and try to figure out if you are moving
  915. 29:59things too much. That would be the
  916. 30:00cumulative layout shift. And finally,
  917. 30:02the interaction to next paint is
  918. 30:04basically whenever you have a user
  919. 30:05event, and you have to go to the
  920. 30:07reconciliation and re-render after state
  921. 30:09update in your framework, and then you
  922. 30:11start again, you modify the DOM, and
  923. 30:14that triggers a re-paint. So, all that
  924. 30:16time it's quantified as the interaction
  925. 30:19to next paint. So, basically, if you
  926. 30:21have very slow re-renders or you're
  927. 30:23re-rendering too many components when
  928. 30:25users do something, then you have a very
  929. 30:27slow IMP. You can measure those metrics
  930. 30:30like house, and they go a lot deeper
  931. 30:31into this video on this channel about
  932. 30:33it, so make sure you check out that one.
  933. 30:35Our next concept also has to do with
  934. 30:36performance, and it's called splitting.
  935. 30:38Now, traditionally, a module bundler
  936. 30:40will take all our JavaScript and put it
  937. 30:42together in a single big file. But
  938. 30:44loading that single file will totally
  939. 30:47mess our core web vitals because we load
  940. 30:50too much JavaScript. So code splitting
  941. 30:53allows us to split our JavaScript to
  942. 30:55where it's being needed so we can really
  943. 30:57ship only the JavaScript that's needed
  944. 30:59to a specific page. And the easiest way
  945. 31:01to code split is by out. So basically,
  946. 31:03you would only ship to the slash login
  947. 31:05page the components that are
  948. 31:06specifically needed for the login. And
  949. 31:08if you have a dashboard that's very
  950. 31:10heavy with a lot of graphs, for example,
  951. 31:12you don't ship all that. So you
  952. 31:14selectively ship your JavaScript to
  953. 31:15where it's being needed instead of
  954. 31:16putting it together all in a single
  955. 31:18file. And all this is achieved with a
  956. 31:20module bundler like Webpack or Vit,
  957. 31:23which understands your bundle, splits
  958. 31:25it, and then dynamically loads it based
  959. 31:28on the path you're on, working together
  960. 31:30with your application router. And the
  961. 31:31higher overarching mental model here is
  962. 31:33lazy loading, which is the opposite of
  963. 31:35eager loading. Eager loading means you
  964. 31:37are really loading everything when a
  965. 31:39user lands on the page. And lazy loading
  966. 31:42means you load things as they needed. So
  967. 31:44for example, you might load certain
  968. 31:45things on scroll, or you might load
  969. 31:48certain things when they visit a certain
  970. 31:49page, or you might load certain things
  971. 31:51when they click on something. So you
  972. 31:52kind of wait for that user interaction,
  973. 31:54and when they land on the page, you
  974. 31:56really only ship the things they need.
  975. 31:58And all this is done in order to make
  976. 32:00this core web vitals better and working
  977. 32:02across the critical learning path. And
  978. 32:04finally, let's talk about rendering
  979. 32:05strategies. And nowadays, we usually
  980. 32:07work with modern component frameworks
  981. 32:09like React, Vue, and Angular. And the
  982. 32:11problem with those is that when you land
  983. 32:12on the page, you see a white screen. And
  984. 32:14the reason for that is because, you
  985. 32:15know, you load that empty HTML, and
  986. 32:17until you don't really run whatever
  987. 32:19render function they have, you don't
  988. 32:21really see much on the screen. That's
  989. 32:23what they call client-side rendering. So
  990. 32:26in an SPA architecture, in a single-page
  991. 32:28application with client-side rendering,
  992. 32:30you'd go, get your static file, and then
  993. 32:32you need to go get some dynamic data,
  994. 32:34and then finally render. And all that
  995. 32:36takes a lot of time. So, if you want to
  996. 32:38have a very performant website or a
  997. 32:40website that's ready to be crawled by a
  998. 32:42search engine, then client-side
  999. 32:44rendering is not the best choice for
  1000. 32:46you. An alternative to this, if you have
  1001. 32:47a static website where there's not a lot
  1002. 32:49of interactivity, is to pre-render it on
  1003. 32:51the server and ship it already rendered.
  1004. 32:53So, when your client goes to get the
  1005. 32:55static files, they already get HTML CSS
  1006. 32:57and they don't need to run so much
  1007. 32:59JavaScript. Now, again, this only works
  1008. 33:01with static sites. If your static site
  1009. 33:04will change often, let's say you have a
  1010. 33:06blog and you want to publish new
  1011. 33:07articles, then what you can do is
  1012. 33:09incremental static generation. That
  1013. 33:11means you only regenerate the pages that
  1014. 33:14have changed. So, basically, your CMS
  1015. 33:16will trigger a rebuild when you add a
  1016. 33:18new blog post and that will get the
  1017. 33:20dynamic data and go to a build pipeline
  1018. 33:22and regenerate the only portion of the
  1019. 33:24static files that change. So, it's a bit
  1020. 33:26of a partial rebuilding of the website.
  1021. 33:29The advantage here is not only that
  1022. 33:30makes the build faster, but if I'm a
  1023. 33:32client and I already downloaded part of
  1024. 33:34your CSS and JavaScript, but I don't
  1025. 33:35need to download re-download only the
  1026. 33:37parts that change. Now, in most cases,
  1027. 33:40this is built into a framework like
  1028. 33:42Next.js, so you never have to worry
  1029. 33:44about this yourself. And finally, we
  1030. 33:46have server-side rendering. And in
  1031. 33:48server-side rendering, the client will
  1032. 33:49make a request to the front-end server,
  1033. 33:51but then the front-end server will
  1034. 33:52request the back-end server and get some
  1035. 33:55data and then render the application on
  1036. 33:57the server and then send it back
  1037. 34:00pre-rendered. So, the client receives a
  1038. 34:03full HTML page. So, you don't have this
  1039. 34:05problem of the white screen. The problem
  1040. 34:07you still have is that this page is not
  1041. 34:10interactive yet because you haven't went
  1042. 34:12through building the virtual DOM and
  1043. 34:14attaching, for example, in the case of
  1044. 34:15React, your virtual DOM to the actual
  1045. 34:17DOM pre-built. And that's why you need
  1046. 34:18to hydrate. And so, basically, you
  1047. 34:20render that HTML page and then you have
  1048. 34:23to execute your JavaScript, create
  1049. 34:25internally the virtual DOM and then that
  1050. 34:27virtual DOM is attached to the existing
  1051. 34:29HTML markdown. That's what we call
  1052. 34:30hydration. And finally, when you're
  1053. 34:32hydrated, you might have to do some
  1054. 34:34extra data fetching, so you might still
  1055. 34:36need to go to the back. And again, this
  1056. 34:38is one of the most complex approaches,
  1057. 34:40so be careful with it. It's only useful
  1058. 34:43whenever you need very, very fast
  1059. 34:45performance or you need SEO. And a lot
  1060. 34:48of people and a lot of companies jumped
  1061. 34:50into this and they're doing server-side
  1062. 34:51rendering, but that's like building an
  1063. 34:53F1 car to go to the groceries. It's
  1064. 34:56over-engineering and it creates a lot of
  1065. 34:58problems and then everything gets
  1066. 34:59slower. There's so many issues that will
  1067. 35:01appear when you have this kind of setup.
  1068. 35:03Technology to make it work is very
  1069. 35:04complex. Bugs are harder to solve, so
  1070. 35:07you want to stay away from it. And I
  1071. 35:08really prefer simple solutions unless
  1072. 35:11your use case really needs the highest
  1073. 35:13performance. Oh, finally, let's talk
  1074. 35:15about data fetching and I know we are
  1075. 35:16front-end engineers, but it's very
  1076. 35:18important that you also can work at a
  1077. 35:19data layer. As I said before, we are
  1078. 35:21moving towards front-end engineers being
  1079. 35:22more full stack. And that is server-sent
  1080. 35:24events. And all this has to do with
  1081. 35:27real-time communication. When it comes
  1082. 35:28to real-time communication that is not
  1083. 35:31following the request-response cycle
  1084. 35:33that I showed until now, you basically
  1085. 35:35have to give it to it. You can do
  1086. 35:37polling, you can do web sockets or
  1087. 35:38server-sent events. And so polling would
  1088. 35:40mean that you keep calling a specific
  1089. 35:42endpoint until something happens. So,
  1090. 35:44let's say we have a transaction that's
  1091. 35:46processing, I can keep calling the
  1092. 35:48status endpoint until it becomes
  1093. 35:51completed. That's very easy to do with
  1094. 35:53plain JavaScript and set timeout.
  1095. 35:54There's nothing complex about it. The
  1096. 35:56problem is you're calling your server
  1097. 35:57way too much. And so it doesn't scale
  1098. 35:59really well. You can have race
  1099. 36:01conditions. So, it's a very simple
  1100. 36:03solution, but not the most performant
  1101. 36:05one. The next alternative would be web
  1102. 36:06sockets, where you open a channel
  1103. 36:09between the server and the browser and
  1104. 36:10you can send updates and they can send
  1105. 36:12you updates back. The problem here is
  1106. 36:14that again, it's a lot of overhead and
  1107. 36:16it's extremely good whenever you have
  1108. 36:18bi-directional communication. Like
  1109. 36:19you're working for a chat application,
  1110. 36:20for example, where both the client and
  1111. 36:22the server would keep sending chunks of
  1112. 36:24messages. Now, for most use cases, this
  1113. 36:27is not really needed and again, it's
  1114. 36:29complex and it's very intense on the
  1115. 36:31server. It needs a lot of resources.
  1116. 36:33Now, with AI, we do need real-time
  1117. 36:36communication, but it's only one
  1118. 36:37direction. Because usually when you send
  1119. 36:39a query to a chat application, you then
  1120. 36:41just wait and they start sending you
  1121. 36:43tokens back. So, it's the server sending
  1122. 36:45a lot of messages, but you usually only
  1123. 36:47send one. So, there's a lot of asymmetry
  1124. 36:48between the client and the server. And
  1125. 36:50the way to make this happen is with
  1126. 36:52server-sent events, where you send a
  1127. 36:53text message and that will create a
  1128. 36:55conversation and on that endpoint,
  1129. 36:58you're able to receive updates from the
  1130. 36:59server. So, you receive all these
  1131. 37:01tokens, but you don't send so many. And
  1132. 37:03this approach is the one used by most
  1133. 37:05LLM applications. If you've ever used
  1134. 37:07the OpenAI NPM package in a React
  1135. 37:09application to build a chat app with an
  1136. 37:11LLM, that's exactly what they use under
  1137. 37:13the hood. And you can actually figure
  1138. 37:14this out if you go to your network when
  1139. 37:16you use ChatGPT or Claude and find that
  1140. 37:19conversation request and you'll see that
  1141. 37:20the answer to that it's all these event
  1142. 37:23streams. So, you're getting chunks of
  1143. 37:25the answer. And that's how you build
  1144. 37:26these cool UIs for LLMs. It's not
  1145. 37:29WebSockets and it's not pulling, it's
  1146. 37:32the server-sent event API. Make sure you
  1147. 37:34look it up because it is something that
  1148. 37:36will help you build product software
  1149. 37:38products, software applications with AI
  1150. 37:40embedded. Thanks so much, folks. If you
  1151. 37:42want to go even deeper, make sure you
  1152. 37:43check out these two videos on our
  1153. 37:45channel. One of them is about all the
  1154. 37:47front-end architectures that you need to
  1155. 37:48know as a front-end engineer and the
  1156. 37:49other one is about in-depth concepts
  1157. 37:52about web performance, CSS, component
  1158. 37:55frameworks that you really need and that
  1159. 37:57show up in interviews at the senior
  1160. 37:59level. And I'll see you in the next one.

About this transcript

This page contains the full transcript of Frontend System Design Explained w/ Senior Engineer (Microfrontends, Monorepo, MCP UI, Reactjs) by theSeniorDev, generated from the public captions YouTube serves with the video. The transcript has 7,923 words across 1,160 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.