Let’s see if we can tackle a relatively complex architectural pattern, with a relatively straightforward stack: Let’s do do Event Sourcing with SQLite!
We attempted to do Event Sourcing on the last stream, but couldn’t quite get PocketBase to align with what we wanted! Fair enough, PocketBase is supposed to simpler solution with its own opinions on how to store and represent your data, so for this stream, we’re going SQLite directly!
In most streams, we perform CRUD: Create Read Update Delete operations by manipulating the database directly. When a user wants to update their handle… we literally update their handle in the database! Straightforward, BUT: it does mean that we can never find what their old handle was ever again! We cannot retroactively gather stats on how many times they’ve updated their handle either. We need to add separate logic to track that, and it will only be tracking occurrences from the moment that logic made it to production.
Event Sourcing doesn’t do direct mutations! You keeps track of all the events that have happened, and you determine the current state of the data by replaying them. A user was created, with a randomised handle based on their email. Then they updated their handle. Then they undid that update! Then they updated again. All those events themselves are stored in the database, and are used to derive what their current handle is, but also how many times they’ve changed it, and to what values.
Why would we go through all that trouble? What are the drawbacks? Let’s discuss in today’s LIVE Coding & Chill, because we’ll be building a new app, where I think Event Sourcing will greatly benefit one of its key selling points 🙂
🚀 Click around the app yourself: https://chronokit.vercel.app/
💻 See the code (private repo 😱): https://github.com/johnnify & https://github.com/johnnify/chrono
If you’re a beginner, you may want to start with our Portfolio "Paulina Puppers" series, and end up with the same or an equivalent project: • Brand new Fullstack App with Svelte 5...
No need to watch the previous episode, but this series playlist is: • 4+1 ways to fetch data with SvelteKit...
Check around the channel for more playlists and increasingly complicated tech stack choices 🙌
— JOHNNIFY PREMIUM —
Get this repository AND MORE with Johnnify Premium: https://johnnify.com/premium
— 🙌🙌🙌 —
— COMMUNITY —
Our DISCORD SERVER 👾: / discord
— 🥳🥳🥳 —
— Agenda —
[ ] What are we doing today? A YouTube helper app?
[ ] New SvelteKit route to create a livestream! `/livestream/new`
[ ] Create Livestream form with Superforms & Zod: https://superforms.rocks/get-started & https://zod.dev/
[ ] Drizzle schema and migrations!
[ ] “Detail” route to see a livestream! `livestream/[id]`
[ ] Event Sourcing overview!
[ ] Schema for an `agenda_events` db table!
[ ] Creating agenda items!
[ ] Toggling agenda items!
[ ] Removing agenda items!
[ ] Converting an agenda into YouTube Timestamps!
— BONUS —
[ ] Copy button! https://developer.mozilla.org/en-US/d...
[ ] Get an LLM to suggest a description based on the agenda! Using Vercel’s AI SDK https://sdk.vercel.ai/docs/introduction
[ ] Final 🥳 DEMO + LIKE 💜 SUBSCRIBE
— HAVE FUN —
No affiliations whatsoever: if I show something, you know you're hearing my unfiltered thoughts 😄
— Highlighted software —
SvelteKit: https://kit.svelte.dev/
Turso: https://docs.turso.tech/introduction
Playwright: https://playwright.dev/
Tailwind: https://tailwindcss.com/
shadcn-svelte: https://shadcn-svelte.com/
Vercel: https://vercel.com/johnnify
Turbo: https://turbo.build/
My own website: https://magrippis.com/
Search for `@jmagrippis` to find me on socials like Instagram & Twitter! And remember our DISCORD SERVER 😉: / discord
Between the comment section and the socials, let me know *somewhere* what you’d like me to cover next 🙌
Stream number 119!
Смотрите видео Event Sourcing with SQLite, Turso, Drizzle & SvelteKit! ⏱️ Chrono App 🔴 LIVE Coding & Chill онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Johnny Magrippis 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 310 раз и оно понравилось 10 людям.