You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.9 KiB
1.9 KiB
quotesdb — Architecture
Component Overview
| Component | Path | Description |
|---|---|---|
| API binary | src/bin/api/main.rs |
Rust/Axum backend on Cloudflare Workers. Handles all data operations via SQLx and Cloudflare D1. |
| UI binary | src/bin/ui/main.rs |
Yew (Rust/Wasm) frontend on Cloudflare Pages. Communicates with the API over HTTP. |
| Shared library | src/lib.rs |
Types and utilities shared between api and ui binaries. Must compile for both host and wasm32. |
| Integration tests | tests/ |
Standard Cargo integration tests. Spin up the API against in-memory SQLite and make real HTTP requests. |
| Infra | infra/ |
OpenTofu configuration for Cloudflare Worker, D1 database, and Pages project. |
Component Interactions
Browser
└──> Cloudflare Pages (ui binary compiled to Wasm)
└──> Cloudflare Workers (api binary)
└──> Cloudflare D1 (SQLite)
The UI is a static Wasm bundle served from Cloudflare Pages. It makes fetch requests to the Worker API, which reads and writes to a D1 database bound to the Worker.
Integration tests bypass the UI and talk directly to the API over HTTP, using a local in-memory SQLite database.
Build Targets
| Artifact | Command | Compile target |
|---|---|---|
| API server | cargo run or cargo build |
host (native) |
| UI Wasm bundle | trunk serve or trunk build |
wasm32-unknown-unknown |
| Tests | cargo test |
host (native) |
Shared Code Constraints
src/lib.rs must compile for both wasm32-unknown-unknown (ui) and the host target (api). Avoid:
- Threading primitives (
std::thread,std::sync::Mutex) - Filesystem access (
std::fs) - Any API that is not available in a Wasm environment
Use #[cfg(not(target_arch = "wasm32"))] and #[cfg(target_arch = "wasm32")] guards where needed.