A locally focused bluesky appview
1# Konbini - A Cozy Bluesky AppView
2
3Konbini is a partially indexed bluesky appview. It's aim is to provide a "Friends of Friends" experience to the bluesky network.
4
5It is currently _very_ jank and I really just hacked this together in a day. More work to come when I get time.
6
7## Prerequisites
8
9- Go 1.25.1 or later
10- PostgreSQL database
11- Node.js and npm (for frontend)
12- Docker (optional, for easy PostgreSQL setup)
13- Bluesky account credentials
14
15## Quick Start with Docker Compose
16
17The easiest way to run Konbini is with Docker Compose, which will start PostgreSQL, the backend, and frontend all together.
18
19### Prerequisites
20
21- Docker and Docker Compose installed
22- Creating an app password (via: https://bsky.app/settings/app-passwords)
23
24### Setup
25
261. Create a `.env` file with your credentials:
27
28```bash
29cp .env.example .env
30# Edit .env and add:
31# - BSKY_HANDLE=your-handle.bsky.social
32# - BSKY_PASSWORD=your-app-password
33```
34
352. Start all services:
36
37```bash
38docker-compose up -d
39```
40
413. Wait for the backend to index posts from the firehose (this may take a few minutes for initial indexing)
42
434. Open your browser to http://localhost:3000
44
45### Stopping the services
46
47```bash
48docker-compose down
49```
50
51To also remove the database volume:
52
53```bash
54docker-compose down -v
55```
56
57## Manual Setup
58
59### 1. PostgreSQL Database Setup
60
61#### Using Docker (Recommended)
62
63```bash
64# Start PostgreSQL container
65docker run --name konbini-postgres \
66 -e POSTGRES_DB=konbini \
67 -e POSTGRES_USER=konbini \
68 -e POSTGRES_PASSWORD=your_password \
69 -p 5432:5432 \
70 -d postgres:15
71
72# The database will be available at: postgresql://konbini:your_password@localhost:5432/konbini
73```
74
75### 2. Environment Configuration
76
77Set the following environment variables:
78
79```bash
80# Database connection
81export DATABASE_URL="postgresql://konbini:your_password@localhost:5432/konbini"
82
83# Bluesky credentials
84export BSKY_HANDLE="your-handle.bsky.social"
85export BSKY_PASSWORD="your-app-password"
86```
87
88### 3. Build and Run the Go Application
89
90```bash
91go build
92
93# Run with environment variables
94./konbini
95```
96
97### 4. Frontend Setup
98
99```bash
100# Navigate to frontend directory
101cd frontend
102
103# Install dependencies
104npm install
105
106# Start the development server
107npm start
108```
109
110The frontend will be available at http://localhost:3000 and will connect to the API at http://localhost:4444.
111
112## Running the Bluesky App against Konbini
113
114Konbini implements a large portion of the app.bsky.\* appview endpoints that
115are required for pointing the main app to it and having it work reasonably
116well.
117
118To accomplish this you will need a few things:
119
120### Service DID
121
122You will need a DID, preferably a did:web for your appview that points at a
123public endpoint where your appview is accessible via https.
124I'll get into the https proxy next, but for the did, I've just pointed a domain
125I own (in my case appview1.bluesky.day) to a VPS, and used caddy to host a file
126at `/.well-known/did.json`.
127That file should look like this:
128
129```json
130{
131 "@context": [
132 "https://www.w3.org/ns/did/v1",
133 "https://w3id.org/security/multikey/v1"
134 ],
135 "id": "did:web:appview1.bluesky.day",
136 "verificationMethod": [
137 {
138 "id": "did:web:api.bsky.app#atproto",
139 "type": "Multikey",
140 "controller": "did:web:api.bsky.app",
141 "publicKeyMultibase": "zQ3shpRzb2NDriwCSSsce6EqGxG23kVktHZc57C3NEcuNy1jg"
142 }
143 ],
144 "service": [
145 {
146 "id": "#bsky_notif",
147 "type": "BskyNotificationService",
148 "serviceEndpoint": "YOUR APPVIEW HTTPS URL"
149 },
150 {
151 "id": "#bsky_appview",
152 "type": "BskyAppView",
153 "serviceEndpoint": "YOUR APPVIEW HTTPS URL"
154 }
155 ]
156}
157```
158
159The verificationMethod isn't used but i'm not sure if _something_ is required
160there or not, so i'm just leaving that there, it works on my machine.
161
162### HTTPS Endpoint
163
164I've been using ngrok to proxy traffic from a publicly accessible https url to my appview.
165You can simply run `ngrok http 4446` and it will give you an https url that you
166can then put in your DID doc above.
167
168### The Social App
169
170Now, clone and build the social app:
171
172```
173git clone https://github.com/bluesky-social/social-app
174cd social-app
175yarn
176```
177
178And then set this environment variable that tells it to use your appview:
179
180```
181export EXPO_PUBLIC_BLUESKY_PROXY_DID=did:web:YOURDIDWEB
182```
183
184And finally run the app:
185
186```
187yarn web
188```
189
190This takes a while on first load since its building everything.
191After that, load the localhost url it gives you and it _should_ work.
192
193## Selective Backfill
194
195If you'd like to backfill a particular repo, just hit the following endpoint:
196
197```
198curl http://localhost:4444/rescan/<DID OR HANDLE>
199
200```
201
202It will take a minute but it should pull all records from that user.
203
204## Upstream Firehose Configuration
205
206Konbini supports both standard firehose endpoints as well as jetstream. If
207bandwidth and CPU usage is a concern, and you trust the jetstream endpoint,
208then it may be worth trying that out.
209
210The configuration file is formatted as follows:
211
212```json
213{
214 "backends": [
215 {
216 "type": "jetstream",
217 "host": "jetstream1.us-west.bsky.network"
218 }
219 ]
220}
221```
222
223The default (implicit) configuration file looks like this:
224
225```json
226{
227 "backends": [
228 {
229 "type": "firehose",
230 "host": "bsky.network"
231 }
232 ]
233}
234```
235
236Note that this is an array of backends, you can specify multiple upstreams, and
237konbini will read from all of them. The main intended purpose of this is to be
238able to subscribe directly to PDSs. PDSs currently only support the full
239firehose endpoint, not jetstream, so be sure to specify a type of "firehose"
240for individual PDS endpoints.
241
242## License
243
244MIT (whyrusleeping)
245
246```
247
248```