···308 record,
309 })
310 } catch (err) {
311- ctx.logger.warn({ err }, 'failed to write record')
312 return res.status(500).json({ error: 'Failed to write record' })
313 }
314···624 })
625 uri = res.uri
626 } catch (err) {
627- ctx.logger.warn({ err }, 'failed to write record')
628 return res.status(500).json({ error: 'Failed to write record' })
629 }
630631 try {
632 // Optimistically update our SQLite <-- HERE!
633- await ctx.db
634 .insertInto('status')
635 .values({
636 uri,
···641 })
642 .execute()
643 } catch (err) {
644- ctx.logger.warn(
645 { err },
646 'failed to update computed view; ignoring as it should be caught by the firehose'
647 )
···653```
654655You'll notice this code looks almost exactly like what we're doing in `firehose.ts`.
0000000000000000000000000656657## Next steps
658
···308 record,
309 })
310 } catch (err) {
311+ logger.warn({ err }, 'failed to write record')
312 return res.status(500).json({ error: 'Failed to write record' })
313 }
314···624 })
625 uri = res.uri
626 } catch (err) {
627+ logger.warn({ err }, 'failed to write record')
628 return res.status(500).json({ error: 'Failed to write record' })
629 }
630631 try {
632 // Optimistically update our SQLite <-- HERE!
633+ await db
634 .insertInto('status')
635 .values({
636 uri,
···641 })
642 .execute()
643 } catch (err) {
644+ logger.warn(
645 { err },
646 'failed to update computed view; ignoring as it should be caught by the firehose'
647 )
···653```
654655You'll notice this code looks almost exactly like what we're doing in `firehose.ts`.
656+657+## Thinking in AT Proto
658+659+In this tutorial we've covered the key steps to building an atproto app. Data is published in its canonical form on users' `at://` repos and then aggregated into apps' databases to produce views of the network.
660+661+When building your app, think in these four key steps:
662+663+- Design the [Lexicon](#) schemas for the records you'll publish into the Atmosphere.
664+- Create a database for aggregating the records into useful views.
665+- Build your application to write the records on your users' repos.
666+- Listen to the firehose to hydrate your aggregated database.
667+668+Remember this flow of information throughout:
669+670+```
671+ ┌─────Repo put─────┐
672+ │ ▼
673+┌──────┴─────┐ ┌───────────┐
674+│ App server │ │ User repo │
675+└────────────┘ └─────┬─────┘
676+ ▲ │
677+ └────Event log─────┘
678+```
679+680+This is how every app in the Atmosphere works, including the [Bluesky social app](https://bsky.app).
681682## Next steps
683