dev talk: anatomy of a modern web application
[00:14 - 00:37]Lecture on web engineering with guest lecture from Christian Sito
[00:38 - 00:44]Discussion on topics not covered in class such as scaling applications and dealing with databases
[01:14 - 01:24]Q&A session for feedback on current semester and plans for next year's class
[01:26 - 01:33]Christian Sito's background in web development and projects he has worked on
[03:09 - 03:19]Examples of Christian's projects, including a film festival verification app, a web app for a popular streamer, and a political questionnaire app
[04:52 - 05:01]Details on the political questionnaire app, including the inspiration from a similar project and the technology used (TypeScript, React, Next.js, MySQL, Prisma, Tailwind CSS)
[08:07 - 08:21]Discussion on the data model and querying data from MySQL using SQL
[08:49 - 09:08]Explanation of Prisma and its use for interacting with databases in JavaScript/TypeScript, defining database schema, handling migrations, and maintaining type safety
[00:00 - 09:15]Lecture on web engineering with guest lecture from Christian Sito, who discusses his background and various projects he has worked on, including a political questionnaire app using TypeScript, React, Next.js, MySQL, Prisma, and Tailwind CSS. The app received significant usage and media coverage.
[09:15 - 09:25] Every column in a table has a data type, such as string, integer, or date, which can catch 25-30% of bugs.
[11:48 - 11:55]Querying data with Prisma is simple and readable.
[14:11 - 14:21]Invalid data types will result in a types of error.
[14:58 - 15:12]Prisma will compile a statement down to SQL.
[14:58 - 15:12]Rendering is executing the view code with data to create the user interface.
[16:07 - 16:14]Prisma does internal optimization to make the experience faster for the database.
[16:16 - 16:29]Routing and rendering are core parts of the web experience.
[16:16 - 16:29]Routing is the URL which defines what data to fetch and what view code to render.
[17:08 - 17:24]Dynamic servers allowed for dynamic generation of HTML based on routes and data sources.
[17:08 - 17:24]Server-side rendering serves a complete HTML page to the client, which then executes a JavaScript bundle for rendering and interactions.
[17:45 - 17:58]Routing and rendering can happen on the server or client.
[17:45 - 17:58]There are several paradigms for web rendering.
[17:45 - 17:58]Client-side rendering became popular to improve speed and user experience.
[17:45 - 17:58]The latest iteration is server-side rendering with partial hydration, where only necessary components are sent to the client for rendering.
[17:45 - 17:58]The pros of client-side rendering include not needing a server for rendering and the server acting as a lightweight file CDN.
[17:59 - 18:04]In the beginning, there were just static files.
[09:15 - 18:13]The overall evolution of web rendering has been from static files to dynamic servers to client-side rendering to server-side rendering with partial hydration.
[18:26 - 18:43]CDN is responsible for hosting files and serving them quickly
[22:16 - 22:25]CDN locations can be all over the world for faster response times
[25:31 - 25:37]Data fetching can take time, resulting in a slow first page load
[27:28 - 27:35]Server-side rendering splits responsibility between browser and server
[27:28 - 27:35]Server will match route, fetch data, and use React to render and send to client
[27:28 - 27:35]Cons: more complex mental model, need for servers and potential cost
[27:36 - 27:51]Not optimized for search engines, as Google expects valid HTML within first two seconds
[27:36 - 27:51]Client downloads HTML with valid data, executes JavaScript for further interactions
[27:36 - 27:51]Pros: fast initial response of actual data, optimized for search engines
[27:51 - 28:02]Browser requests index page, server returns HTML, CSS, and JavaScript
[27:51 - 28:02]Browser downloads empty HTML and renders it, React takes over and fetches data
[27:51 - 28:02]This switch from dynamic servers is cost-effective and has a simple mental model
[27:51 - 28:02]React component is returned and rendered on the server, with HTML and JavaScript response
[28:03 - 28:19]Cannot access private data directly, must leave API keys and credentials in server rendering
[28:03 - 28:19]Next.js is a progressive and cutting edge framework for routing and rendering
[28:03 - 28:19]Routes are defined in the file system, with parameters specified in the function
[28:03 - 28:19]Data is fetched from the database using Prisma
[28:03 - 28:19]If candidate not found, routing stops and shows a 404 page
[28:03 - 28:19]First request is full URL, subsequent requests are a special HTTP GET route from Next.js
[18:14 - 28:19]CDN hosts files for fast response times, browser requests index page and server returns HTML, CSS, and JS. React takes over and fetches data for rendering. Server-side rendering splits responsibility, routes defined in file system, data fetched from database, and React component returned for rendering. First request is full URL, subsequent requests are a special route.
[28:19 - 28:26] After second request, all on client in service rendering
[28:34 - 28:40]Components mostly rendered on server and never sent to client
[28:41 - 28:53]Components can fetch data directly from database because code never sent to client
[28:54 - 29:06]React Server Components allow defining of async functions to run on server and not sent to client
[29:17 - 29:34]Questionnaire component rendered on client and gets data from React Server component for server-side rendering
[29:52 - 30:00]Caching is important for scaling applications to hundreds of thousands of users
[30:02 - 30:16]Caching means saving expensive data into a place for quick and cheap access
[30:18 - 30:25]Next.js allows for defining caching strategies for pages and fetches
[30:35 - 30:41]Strategies include static, dynamic, and revalidate
[30:42 - 30:52]Static means data fetched once on deployment and never refetched
[31:00 - 31:08]Dynamic means fresh data fetched for every request
[31:20 - 31:31]Revalidate sets interval for data to be cached and updated in the background
[35:24 - 35:32]Serverless functions abstract away the idea of servers and spin up new instances for each request
[36:14 - 36:24]Pro of serverless functions is only using necessary compute for each request
[36:14 - 36:24]Serverless functions have more control than platform as a service
[36:32 - 36:37]Useful for applications with few users
[36:47 - 36:58]Platform as a service allows for more freedom in organizing files and code
[36:47 - 36:58]Platform as a service may also have a run time for applications
[28:19 - 37:45]After second request, all on client in service rendering. Components mostly rendered on server and can fetch data from database. Caching is important for scaling and Next.js allows for defining strategies. Serverless functions abstract away servers and only use necessary compute. Platform as a service provides more freedom for code and file organization.
[37:45 - 37:52] Temporary compute environments used to be more restricted
[44:34 - 44:46]Caching may not be possible with serverless functions
[46:28 - 46:37]Caching may be done by a CDN
[46:38 - 46:48]Vercel used for serverless functions and CDN
[46:49 - 46:57]Technology has progressed, allowing for easier use of temporary compute environments
[46:49 - 46:57]Platform as a service (PaaS) provides a runtime that automatically scales
[46:49 - 46:57]Cold starts are a common issue with serverless functions
[46:49 - 46:57]Land of functions have a warm phase to improve response time
[46:49 - 46:57]Database scaling using a platform called planet scale
[46:58 - 47:10]Two types of serverless functions: Lambda functions and edge functions
[47:30 - 47:39]Hosting costs estimated at around 210,000 page views and 500,000 requests in a month
[37:45 - 47:49]Temporary compute environments have become more accessible and advanced, with PaaS providing automatic scaling and options for caching through CDNs. Serverless functions have two types, Lambda and edge, with the former having a warm phase to improve response time but the latter being quicker and cheaper. Database scaling is done through planet scale, while hosting is managed through Vercel.
[47:50 - 47:56] Person talks about getting 100 euros and asking for other questions or ideas
[48:06 - 48:12]Mention of 20 euros, 150 euros, and zero cost for plans
[48:13 - 48:19]Person discusses using Vercel plan and running multiple projects on it
[48:13 - 48:19]Project discussed was around 2% usage of Vercel plan or possibly free
[48:20 - 48:25]Plant scale was more expensive but still had a lot of room to grow
[48:32 - 48:39]Possibility of reaching a million page views without leaving the free plan
[48:42 - 48:50]Person hosted their website on a service for free and didn't have any servers
[48:58 - 49:04]Only pay $20 a month for Vercel plan
[49:04 - 49:11]Pro plan needed for selling a service
[49:11 - 49:18]Can run a free project on the free plan
[50:04 - 50:12]Can do this too, it's not hard and mostly free
[50:12 - 50:18]Building things is fun and a great way to learn
[50:54 - 50:59]Recommended tools: Next.js, Remix, Nux, Russell, Netlify, Cloudflare, Plan-scale, Super-base, Neon, Railway, Sadie, Postgres
[52:31 - 52:40]Data and request can stay in EU by setting functions to run in specific locations
[52:49 - 52:55]Different approaches to developing using services
[54:59 - 55:06]Services all interconnected and accessible by URL
[55:18 - 55:25]Can run all of this on your own
[55:33 - 55:39]Database can be Postgres, Plan-scale, or SQLite
[56:07 - 56:21]Latency for database is usually very quick
[56:07 - 56:21]Data centers are in the same place and networking inside is very fast
[56:38 - 56:49]Takes about 10 to 30 milliseconds for service function to get data from database
[56:55 - 57:03]Can use different hosting services
[47:50 - 57:22]Person discusses using free hosting services, recommended tools, and various options for databases and data privacy, emphasizing the ease and affordability of building and developing projects on these platforms.
[57:24 - 57:29]Experience with performance hits from cloud database
[57:30 - 57:38]Importance of proper caching for database
[57:47 - 57:53]List of 300+ developers to follow for resources
[58:07 - 58:13]Personal recommendations for YouTubers and Twitch streamers
[58:33 - 58:45]Benefits of attending local meetups for networking and job opportunities
[59:30 - 59:38]Other considerations for choosing a serverless platform
[59:30 - 59:38]Example of deploying a project using serverless
[1.00:04 - 1.00:12]Serverless is ideal for simple applications with all necessary data within the code
[1.00:28 - 1.00:36]Serverless becomes more complicated when integrating external data sources or needing asynchronous processing
[1.01:32 - 1.01:38]Personal preference for serverless due to ease of use and cost-effectiveness
[1.06:01 - 1.06:06]Personal experience with learning JavaScript and TypeScript
[1.06:20 - 1.06:35]Flexibility in switching between providers without needing to change code
[57:24 - 1.07:36]Speaker's experience, recommendations, and personal preference for serverless technology.
[1.07:48 - 1.07:58] The speaker talks about not wanting to rely on a single company for data and how Prisma makes it easy to switch databases.
[1.07:58 - 1.08:06]Prisma can generate a schema for different databases and handle queries and insertions automatically.
[1.10:27 - 1.10:33]The speaker mentions some common performance issues, such as not having foreign key functionality and not having the server and database in the same data center.
[1.11:34 - 1.11:42]The speaker emphasizes the importance of caching and optimizing images and scripts.
[1.12:01 - 1.12:08]The speaker shows a demo of building a full-stack Next.js app with Vercel and explains the importance of optimization for performance.
[1.12:44 - 1.12:50]The speaker explains how serverless functions work and how Vercel abstracts away the hosting process.
[1.12:44 - 1.12:50]The speaker shows an example of mapping endpoints to URLs for serverless functions.
[1.14:31 - 1.14:40]The speaker mentions the future of database offerings and how platforms will handle the storage of data.
[1.15:56 - 1.16:02]The speaker concludes the talk and thanks the audience for their questions.
[1.07:36 - 1.16:13]The speaker summarizes the main points of the talk and thanks the audience for their attention.