···11+22+## git repo contents
33+44+Commands (run with, eg, `go run ./cmd/bigsky`):
55+66+- `cmd/bigsky`: BGS+indexer daemon
77+- `cmd/gosky`: client CLI for talking to a PDS
88+- `cmd/lexgen`: codegen tool for lexicons (Lexicon JSON to golang package)
99+- `cmd/pds`: PDS daemon
1010+- `cmd/stress`: connects to local/default PDS and creates a ton of random posts
1111+- `gen`: dev tool to run CBOR type codegen
1212+1313+Packages:
1414+1515+- `api`: mostly output of lexgen (codegen) for lexicons: structs, CBOR marshaling. some higher-level code, and a PLC client (may rename)
1616+- `bgs`: server implementation for crawling, etc
1717+- `carstore`: library for storing repo data in CAR files on disk, plus a metadata SQL db
1818+- `events`: types, codegen CBOR helpers, and persistence for event feeds
1919+- `indexer`: aggregator, handling like counts etc in SQL database
2020+- `key`: did:key crypto helpers (serialization, signing) (may rename or spin out)
2121+- `lex`: implements codegen for Lexicons (!)
2222+- `mst`: merkle search tree implementation
2323+- `notifs`: helpers for notification objects (hydration, etc)
2424+- `plc`: implementation of a *fake* PLC server (not persisted), and a PLC client
2525+- `repo`: implements atproto repo on top of a blockstore. CBOR types
2626+- `repomgr`: wraps many repos with a single carstore backend. handles events, locking
2727+- `pds`: PDS server implementation
2828+- `testing`: integration tests; testing helpers
2929+- `models`: database types/models/schemas; shared in several places
3030+- `util`: a few common definitions (may rename)
3131+- `xrpc`: XRPC client (not server) helpers
3232+3333+Other:
3434+3535+- `testscripts`: shell scripts that run gosky (CLI client) against local PDS
3636+3737+3838+## jargon
3939+4040+- BGS: Big Graph Service (or Server), which centrals crawls/consumes content from "all" PDSs and re-broadcasts as a firehose
4141+- PDS: Personal Data Server (or Service), which stores user atproto repositories and acts as a user agent in the network
4242+- CLI: Command Line Tool
4343+- CBOR: a binary serialization format, smilar to JSON
4444+- PLC: "placeholder" DID provider
4545+- DID: Decentralized IDentifier, a flexible W3C specification for persistent identifiers in URI form (eg, "did:plc:abcd1234")
4646+- XRPC: atproto convention for HTTP GET and POST endpoints specified by namespaced Lexicon schemas
4747+- CAR: simple file format for storing binary content-addressed blocks/blobs, sort of like .tar files
4848+- CID: content identifier for binary blobs, basically a flexible encoding of hash values
4949+- MST: Merkle Search Tree, a key/value map data structure using content addressed nodes
5050+5151+5252+## lexicon and CBOR marshaling code generation
5353+5454+`gen/main.go` has a list of types internal to packages in this repo which need CBOR helper codegen. If you edit those types, or update the listed types/packages, re-run codegen like:
5555+5656+ # make sure everything can build cleanly first
5757+ make build
5858+5959+ # then generate
6060+ go run ./gen
6161+6262+To run codegen for new or updated Lexicons, using lexgen, first place (or git
6363+checout) the JSON lexicon files `$SOMEWHERE`. Also, install the `goimports`
6464+tool. Then, in *this* repository (indigo), run commands like:
6565+6666+ go run ./cmd/lexgen/ --package bsky --prefix app.bsky --outdir api/bsky $SOMEWHERE/lexicons/app/bsky/
6767+ go run ./cmd/lexgen/ --package atproto --prefix com.atproto --outdir api/bsky $SOMEWHERE/lexicons/com/atproto/
6868+6969+You may want to delete all the codegen files before re-generating, to detect deleted files.
7070+7171+It can require some manual munging between the lexgen step and a later `go run ./gen` to make sure things compile at least temporarily; otherwise the `gen` will not run.
7272+7373+To generate server stubs and handlers, push them in a temporary directory
7474+first, then merge changes in to the actual PDS code:
7575+7676+ go run ./cmd/lexgen/ --package pds --gen-server --types-import com.atproto:github.com/bluesky-social/indigo/api/atproto --types-import app.bsky:github.com/bluesky-social/indigo/api/bsky --outdir pds $SOMEWHERE/lexicons
7777+7878+ mkdir tmppds
7979+ go run ./cmd/lexgen/ --package pds --gen-server --types-import com.atproto:github.com/bluesky-social/indigo/api/atproto --types-import app.bsky:github.com/bluesky-social/indigo/api/bsky --outdir tmppds --gen-handlers $SOMEWHERE/lexicons
8080+8181+8282+## tips and tricks
8383+8484+When debugging websocat streams, the `websocat` tool (rust) can be helpful. CBOR binary is sort of mangled in to text by default. Eg:
8585+8686+ # consume repo events from PDS
8787+ websocat ws://localhost:4989/events
8888+8989+ # consume repo events from BGS
9090+ websocat ws://localhost:2470/events
9191+9292+Send the BGS a ding-dong:
9393+9494+ # tell BGS to consume from PDS
9595+ http --json post localhost:2470/add-target host="localhost:4989"
9696+9797+Set the log level to be more verbose, using an env variable:
9898+9999+ GOLOG_LOG_LEVEL=info go run ./cmd/pds