···11-atcute-statusphere-app is a repository reimplementing atproto's Statusphere demo with atcute and SvelteKit.
11+atcute-statusphere-app is a repository reimplementing atproto's Statusphere demo with atcute and
22+SvelteKit (with Svelte 5).
2334## development notes
45
···11-# sv
11+# statusphere
22+33+a reimplementation of Bluesky's
44+[Statusphere example app](https://github.com/bluesky-social/statusphere-example-app), using
55+[atcute](https://github.com/mary-ext/atcute) and [SvelteKit](https://svelte.dev).
66+77+
88+99+## setup
21033-Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
1111+1. install dependencies:
1212+1313+ ```sh
1414+ pnpm install
1515+ ```
1616+1717+2. set up the environment variables:
1818+1919+ ```sh
2020+ pnpm env:setup
2121+ ```
42255-## Creating a project
2323+ this copies the `.env.example` file to `.env` with the following values filled in:
2424+ - `COOKIE_SECRET` - random secret for signing cookies
2525+ - `OAUTH_PRIVATE_KEY_JWK` - ES256 keypair for OAuth
62677-If you're seeing this, you've probably already done this step. Congrats!
2727+3. start a [Tap](https://github.com/bluesky-social/indigo/tree/main/cmd/tap) instance:
82899-```sh
1010-# create a new project in the current directory
1111-npx sv create
2929+ ```sh
3030+ docker run -p 2480:2480 \
3131+ -e TAP_SIGNAL_COLLECTION=xyz.statusphere.status \
3232+ -e TAP_COLLECTION_FILTERS=xyz.statusphere.status,app.bsky.actor.profile \
3333+ ghcr.io/bluesky-social/indigo/tap:latest
3434+ ```
12351313-# create a new project in my-app
1414-npx sv create my-app
1515-```
3636+ Tap handles subscribing to the atproto firehose, backfilling repos, and filtering events. we set
3737+ it up such that it'd backfill all repos that have posted a status, and only emits events for
3838+ status and profile records.
16391717-## Developing
4040+ then configure the Tap connection:
18411919-Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or
2020-`yarn`), start a development server:
4242+ ```sh
4343+ TAP_URL=http://localhost:2480
21442222-```sh
2323-npm run dev
4545+ # if configured with a password
4646+ TAP_ADMIN_PASSWORD=
4747+ ```
24482525-# or start the server and open the app in a new browser tab
2626-npm run dev -- --open
2727-```
4949+4. configure the public-facing URL:
28502929-## Building
5151+ ```sh
5252+ OAUTH_PUBLIC_URL=https://insulation-famous-bluetooth-secret.trycloudflare.com
5353+ ```
30543131-To create a production version of your app:
5555+5. migrate the database:
32563333-```sh
3434-npm run build
3535-```
5757+ ```sh
5858+ pnpm db:migrate
5959+ ```
36603737-You can preview the production build with `npm run preview`.
6161+6. run it!
38623939-> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for
4040-> your target environment.
6363+ ```sh
6464+ pnpm dev
6565+ ```
···11+CREATE TABLE `app_session` (
22+ `id` text PRIMARY KEY NOT NULL,
33+ `did` text NOT NULL,
44+ `created_at` integer NOT NULL,
55+ `last_seen_at` integer NOT NULL
66+);
77+--> statement-breakpoint
88+CREATE INDEX `app_session_did_idx` ON `app_session` (`did`);--> statement-breakpoint
99+CREATE TABLE `identity` (
1010+ `did` text PRIMARY KEY NOT NULL,
1111+ `handle` text NOT NULL,
1212+ `is_active` integer NOT NULL,
1313+ `status` text NOT NULL,
1414+ `updated_at` integer NOT NULL
1515+);
1616+--> statement-breakpoint
1717+CREATE TABLE `oauth_session` (
1818+ `did` text PRIMARY KEY NOT NULL,
1919+ `session_json` text NOT NULL,
2020+ `updated_at` integer NOT NULL
2121+);
2222+--> statement-breakpoint
2323+CREATE INDEX `oauth_session_updated_at_idx` ON `oauth_session` (`updated_at`);--> statement-breakpoint
2424+CREATE TABLE `oauth_state` (
2525+ `key` text PRIMARY KEY NOT NULL,
2626+ `state_json` text NOT NULL,
2727+ `expires_at` integer NOT NULL
2828+);
2929+--> statement-breakpoint
3030+CREATE INDEX `oauth_state_expires_at_idx` ON `oauth_state` (`expires_at`);--> statement-breakpoint
3131+CREATE TABLE `profile` (
3232+ `did` text PRIMARY KEY NOT NULL,
3333+ `display_name` text,
3434+ `record_json` text NOT NULL,
3535+ `indexed_at` integer NOT NULL
3636+);
3737+--> statement-breakpoint
3838+CREATE TABLE `status` (
3939+ `uri` text PRIMARY KEY NOT NULL,
4040+ `author_did` text NOT NULL,
4141+ `rkey` text NOT NULL,
4242+ `status` text NOT NULL,
4343+ `created_at` text NOT NULL,
4444+ `indexed_at` integer NOT NULL
4545+);
4646+--> statement-breakpoint
4747+CREATE INDEX `status_indexed_at_idx` ON `status` (`indexed_at`);
···77 // for more information about preprocessors
88 preprocess: vitePreprocess(),
991010+ compilerOptions: {
1111+ experimental: {
1212+ async: true,
1313+ },
1414+ },
1515+1016 kit: {
1117 // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
1218 // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
1319 // See https://svelte.dev/docs/kit/adapters for more information about adapters.
1420 adapter: adapter(),
2121+ experimental: {
2222+ remoteFunctions: true,
2323+ },
1524 },
1625};
1726