A PLC Mirror written in Rust
1# Parakeet PLC Mirror
2
3A little Rust mirror of Bluesky Social PBC's [plc.directory](https://web.plc.directory/)
4for use with the [Parakeet AppView](https://gitlab.com/parakeet-social/parakeet) project.
5
6All endpoints bar `/export` and `/{did}/data` are implemented and should be functionally identical.
7
8## Running
9
10### Prerequisites
11
12- Either Docker, or a binary from [Compiling](#compiling)
13- Postgres (tested with 16, but any recent version should work)
14
15### Running PLC Mirror
16
17A docker image is provided as `registry.gitlab.com/parakeet-social/plc-mirror`, or you can [compile](#compiling) a binary.
18
19Complete the below environment variables:
20
21| Variable | Description | Default |
22|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
23| `PLC_DB_URI` | (required) Postgres DB URI in format `postgres://{user}:{pass}@{addr}/{db}` | |
24| `PLC_UPSTREAM` | (optional) Upstream PLC directory to import from | `https://plc.directory` |
25| `PLC_BIND_ADDR` | (optional) The address and port to bind to, in format `{IP}:{port}` | `127.0.0.1:8080` |
26| `PLC_USER_AGENT` | (recommended) The User-Agent header to set on export requests from upstream. Setting this is highly advised | `parakeet-plc` |
27| `PLC_START_AFTER` | (optional) Where in time to start importing from PLC. Leaving blank will trigger an import from the beginning of the directory or from the last seen TS if applicable. In format `2018-01-26T18:30:09.453Z`. | |
28
29Then, run the binary. Imports from the upstream directory will begin immediately alongside the API server.
30
31## Compiling
32
33You'll need [Rust](https://www.rust-lang.org/), Cargo, and openssl-dev (aka libssl-dev) to build.
34Builds are tested on Rust 1.85.
35
36A simple `cargo b` or `cargo r` should work just fine, likewise for release options.
37
38## License & Contributing
39
40This project is licensed under Apache-2. Contributions are welcome, but please discuss first.