Chad Miller 0:00 Is it— hello? 0:01 OK. 0:02 My name's Chad Miller. 0:04 You can find me on Bluesky, chadcmiller.com. 0:08 I've been doing a lot of different experimentation with app views. 0:12 So a lot of experiments with apps that aren't Bluesky clients or anything related to Bluesky at all. 0:20 Just kind of like, you have some custom lexicons and you want to build an app. 0:25 So I've been doing a lot of experiments with that. 0:29 What is an app view? 0:32 If you don't know, it kind of sits in between the Relay and the sort of client that you're using. 0:39 So you have all this information flowing from the, all of your records flowing from the PDS through the Relay. 0:47 The app view sort of is a place that stores all of your records and brings them all together from all the different PDSs across the network. 0:59 And then sort of hydrate— brings all that data together, hydrates it, so your like counts and your comment counts and all that stuff, and provides it to, you know, your web app or your mobile application to render it on the screen. 1:19 If we look closer at the app view itself, there's a bunch of things going on. 1:24 So we have a Firehose connection. 1:28 But we also need to take into account pretty much all the data that we care about. 1:33 So the backfill, that's the backfill portion. 1:37 So we have some kind of indexer that's going to take in all of these events from the network You have, like, commits. 1:45 They're called commit events. 1:47 So you have creates, updates, deletes. 1:51 Those then, you know, you filter those down to what you care about. 1:54 So you might only care about a— what is the— a connection lexicon from the connection app that everybody's been using. 2:08 You might only care about that. 2:09 So that filters through the database. 2:11 And then you sort of have a hydration layer. 2:14 That's going to request all those and return them via what in, at Protoland is called xRPC endpoints. 2:23 Really it's just an HTTP endpoint that's typed against your lexicons. 2:27 So you can define what the responses are in your lexicon definitions. 2:33 And then if we look a little bit closer at the sort of request pipeline, You'll, if you look closer at the appproto repo, you'll sort of see this pattern a lot. 2:44 And you sort of fetch all of the, you know, you batch fetch all these records from the database. 2:51 Apply some rules to them. 2:52 This might be some labels that you have. 2:56 Some app, for moderation. 3:00 And, you know, bringing all that together, all of the, the like counts and the comment counts together. 3:05 To return the JSON response. 3:11 So where can you get started if you want to build your own App View? 3:16 You know, the main reference repo is the appproto repo that is essentially the backend for Bluesky. 3:24 How many people have spent a lot of time digging through that code? 3:29 Yeah. 3:31 There's Stratosphere, but it's pretty basic. 3:34 It just has, like, a single CRUD— it's just, like, a create operation. 3:38 So it's not really, like, that much going on. 3:41 And obviously, you want your app to be a lot more, you know, a lot richer than Stratosphere. 3:49 And then we have all the community app views. 3:51 So we have, like, Leaflet, Tangled. 3:54 What else is there? 3:58 Margin. 3:59 There's Offprint. 4:01 There's all these app views out there now. 4:04 So there's a lot of good reference places, like, depending on which programming language you're into. 4:11 And right now it's kind of like, you know, an art project. 4:13 So everybody has their own implementation of what, you know, it says on appproto.com and the specs and what they've sort of gathered from the appproto repo. 4:25 I have spent some time sort of putting patterns together into a service that you can just deploy called Quick Slice, and it sort of maps your lexicons to a GraphQL API that you can just query without having to do a whole lot. 4:44 And then there's also Constellation. 4:46 There's— sometimes you might not need an app view. 4:49 Fig's APIs provide a way to just get like— for example, npmx just wants to show the like count on their packages, so they can just use Constellation for that. 5:02 So they don't even need NetView. 5:05 So what are all the things that you need? 5:06 You need a way to backfill all of the data on the network. 5:12 So that is going to be— you've probably heard a lot about Tap. 5:17 TAP provides a way to filter those collections that you want. 5:23 There's also other ways. 5:24 You can parse the CAR files manually and have your own process for backfilling. 5:30 Indexing. 5:31 So you need some sort of layer to translate the lexicon records into your database. 5:42 And then there's some kind of code gen aspect which works with the lexicon definitions, again, with the XRPC endpoints. 5:51 So usually when you're working with lexicons, you want a way to have, you know, type-safe endpoints against those. 6:00 OAuth, generally it'd be nice to have this all figured out for you and you don't have to worry about it. 6:08 And not really necessary for every application, but there is this concept of the feed generator in Bluesky, which is a separate server that you can run that pretty much just returns the URIs of records that can be picked up by Bluesky to render a feed. 6:29 That same pattern can be used in any App Proto application. 6:34 And I'm actually going to show you really in a second what that looks like. 6:40 Labels. 6:41 Obviously, if you want to do some kind of moderation, you're going to need to have some sort of support for labeling. 6:47 This can be a simple— just a simple table in your database to make it quick. 6:54 And then preferences. 6:58 Sometimes you want to have data that's stored privately to the app view. 7:03 And you can sort of just have a preferences table for that. 7:08 And then Open Graph. 7:10 So generally you want to have a way to share images— image previews back to Bluesky for rendering a social post. 7:23 So I've been sort of playing around with the newer ideas. 7:26 In this framework I call Hack. 7:28 It's sort of like a conventional— like a convention over configuration, although there's still some configuration framework for building an app view. 7:40 You can sort of attach this app view server to a Svelte app. 7:47 You can check it out at hack.dev. 7:48 It's pretty early alpha. 7:50 Just sort of playing around with some ideas. 7:53 I just recently rewrote Grain Social to use— this is the— rewrote Grain Social to use all these patterns. 8:03 It's all open source on Tangled. 8:05 There's a bunch of feeds here. 8:06 So, like, you can— people upload photos and it shows the EXIF data as a feed and locations as a feed. 8:17 And then There's actually one thing I wanted to point out is there's a great pattern for running your app view locally. 8:24 A lot of times it's hard to reproduce stuff because there's a lot, you know, there's a lot of stuff that you have to do to bring an app view together. 8:31 But there's a pattern in there for running your app locally and having reproducible data that you can use to help build your app. 8:40 And, yeah. 8:42 That's all I got.