# ch-rds
`ch-rds` resolves runtime resources and starts conventional local services when
an application uses loopback endpoints.
More information is available in the [API documentation](https://docs.rs/ch-rds).
## High-level features
- Typed loaders for web listeners, MariaDB, and SpacetimeDB
- Explicit production behavior with no local fallback
- Conventional `.env`, `.env.local`, and `services.env` discovery
- Protocol-verified local Docker Compose startup for loopback resources
- Optional frontend/backend development process orchestration
## Usage
```rust,no_run
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let runtime = ch_rds::Runtime::bootstrap()?;
let bind_addr = runtime
.load(ch_rds::WebBind::builder().addr("127.0.0.1:8080"))
.await?;
println!("{bind_addr}");
Ok(())
}
```
`Runtime` resolves configured remote endpoints directly. Production mode
rejects local fallbacks. `ENV_FILE` selects one explicit dotenv file, while
`PORT` overrides only the port of the fallback listener address.
For conventional layouts, MariaDB discovers `services.env` in the project root
and derives the Compose project name from `app/Cargo.toml`. A SpacetimeDB module
under `crates/database/spacetimedb` is detected from its Cargo package name.
Builders remain available for nonstandard names, paths, ports, and local stacks.
Local MariaDB readiness uses a real authenticated query, while SpacetimeDB uses
its documented `/v1/ping` endpoint. A broken local service is restarted at most
once under the shared lifecycle lock. SpacetimeDB source changes are published
into the existing database so its data and server-issued owner identity remain
durable across editor rebuilds.
## Development runner
The `dev` feature provides `ProjectProfile` and `run_project`. Vite owns frontend
hot-module replacement; Watchexec restarts the backend when Rust sources,
manifests, lockfiles, Cargo configuration, or SQL migrations change.
```console
cargo install watchexec-cli --version 2.5.1 --locked
```
## Feature flags
| `dev` | Frontend/backend process orchestration and project profiles |
| `btcpay` | Local BTCPay setup in addition to `dev` |
## Minimum supported Rust version
`ch-rds` requires Rust 1.96 or newer.
## License
Licensed under the Sustainable Use License 1.0. See
[`LICENSE.md`](LICENSE.md).