the statusphere demo reworked into a vite/react app in a monorepo

Add a 'thinking in atproto' section

+29 -4
+29 -4
TUTORIAL.md
··· 308 308 record, 309 309 }) 310 310 } catch (err) { 311 - ctx.logger.warn({ err }, 'failed to write record') 311 + logger.warn({ err }, 'failed to write record') 312 312 return res.status(500).json({ error: 'Failed to write record' }) 313 313 } 314 314 ··· 624 624 }) 625 625 uri = res.uri 626 626 } catch (err) { 627 - ctx.logger.warn({ err }, 'failed to write record') 627 + logger.warn({ err }, 'failed to write record') 628 628 return res.status(500).json({ error: 'Failed to write record' }) 629 629 } 630 630 631 631 try { 632 632 // Optimistically update our SQLite <-- HERE! 633 - await ctx.db 633 + await db 634 634 .insertInto('status') 635 635 .values({ 636 636 uri, ··· 641 641 }) 642 642 .execute() 643 643 } catch (err) { 644 - ctx.logger.warn( 644 + logger.warn( 645 645 { err }, 646 646 'failed to update computed view; ignoring as it should be caught by the firehose' 647 647 ) ··· 653 653 ``` 654 654 655 655 You'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). 656 681 657 682 ## Next steps 658 683