···308308 record,
309309 })
310310 } catch (err) {
311311- ctx.logger.warn({ err }, 'failed to write record')
311311+ logger.warn({ err }, 'failed to write record')
312312 return res.status(500).json({ error: 'Failed to write record' })
313313 }
314314···624624 })
625625 uri = res.uri
626626 } catch (err) {
627627- ctx.logger.warn({ err }, 'failed to write record')
627627+ logger.warn({ err }, 'failed to write record')
628628 return res.status(500).json({ error: 'Failed to write record' })
629629 }
630630631631 try {
632632 // Optimistically update our SQLite <-- HERE!
633633- await ctx.db
633633+ await db
634634 .insertInto('status')
635635 .values({
636636 uri,
···641641 })
642642 .execute()
643643 } catch (err) {
644644- ctx.logger.warn(
644644+ logger.warn(
645645 { err },
646646 'failed to update computed view; ignoring as it should be caught by the firehose'
647647 )
···653653```
654654655655You'll notice this code looks almost exactly like what we're doing in `firehose.ts`.
656656+657657+## Thinking in AT Proto
658658+659659+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.
660660+661661+When building your app, think in these four key steps:
662662+663663+- Design the [Lexicon](#) schemas for the records you'll publish into the Atmosphere.
664664+- Create a database for aggregating the records into useful views.
665665+- Build your application to write the records on your users' repos.
666666+- Listen to the firehose to hydrate your aggregated database.
667667+668668+Remember this flow of information throughout:
669669+670670+```
671671+ ┌─────Repo put─────┐
672672+ │ ▼
673673+┌──────┴─────┐ ┌───────────┐
674674+│ App server │ │ User repo │
675675+└────────────┘ └─────┬─────┘
676676+ ▲ │
677677+ └────Event log─────┘
678678+```
679679+680680+This is how every app in the Atmosphere works, including the [Bluesky social app](https://bsky.app).
656681657682## Next steps
658683