+13
-23
CLAUDE.md
+13
-23
CLAUDE.md
···
31
31
## Architecture
32
32
33
33
- **Web app**: SvelteKit with adapter-node, deployed to Fly.io
34
-
- **Ingester**: Separate process on Fly.io (LiteFS primary)
35
-
- **Database**: Split SQLite architecture with LiteFS:
36
-
- **Content DB** (`content.db`): Posts, comments, accounts - written by ingester, replicated to webapp via LiteFS
34
+
- **Ingester**: Runs alongside webapp via supervisord on same machine
35
+
- **Database**: SQLite with two databases on shared volume:
36
+
- **Content DB** (`content.db`): Posts, comments, accounts - written by ingester
37
37
- **Local DB** (`local.db`): Auth state, sessions, votes - webapp only
38
38
39
39
### Data Flow
40
40
41
-
1. User submits post/comment → Webapp writes to ATProto (PDS)
42
-
2. Jetstream ingester picks up event → Writes to content DB (LiteFS primary)
43
-
3. LiteFS replicates to webapp machines → Content visible to users
44
-
4. Votes stored locally in webapp's local DB (not replicated)
41
+
1. User submits post/comment -> Webapp writes to ATProto (PDS)
42
+
2. Jetstream ingester picks up event -> Writes to content DB
43
+
3. Content visible to users immediately (same machine)
44
+
4. Votes stored in local DB
45
45
46
46
## Local Development
47
47
···
116
116
117
117
### Deployment
118
118
119
-
- `fly.toml` - Webapp Fly.io config
120
-
- `fly.ingester.toml` - Ingester Fly.io config
121
-
- `litefs.yml` - LiteFS config for webapp (replica)
122
-
- `litefs.ingester.yml` - LiteFS config for ingester (primary)
119
+
- `fly.toml` - Fly.io config
120
+
- `supervisord.conf` - Multi-process configuration
123
121
- `.tangled/workflows/ci.yaml` - CI pipeline (lint, type check, tests)
124
122
125
123
### Documentation
···
157
155
## Deployment
158
156
159
157
```bash
160
-
# Deploy webapp (LiteFS replica)
158
+
# Deploy (single app runs both webapp and ingester)
161
159
fly deploy
162
160
163
-
# Deploy ingester (LiteFS primary) - separate app
164
-
fly deploy -c fly.ingester.toml
165
-
166
161
# First time setup:
167
-
# 1. Create persistent volume for local DB
168
-
fly volumes create papili_data --size 1
169
-
170
-
# 2. Enable LiteFS (Consul lease)
171
-
fly consul attach
162
+
# 1. Create persistent volume for databases
163
+
fly volumes create papili_data --size 1 --region sjc
172
164
```
173
165
174
166
## Environment Variables
···
222
214
command: pnpm install --frozen-lockfile
223
215
- name: Build
224
216
command: pnpm build
225
-
- name: Deploy webapp
217
+
- name: Deploy
226
218
command: fly deploy --remote-only
227
-
- name: Deploy ingester
228
-
command: fly deploy -c fly.ingester.toml --remote-only
229
219
```
230
220
231
221
Required secrets: