Development Guide
This page explains how to work on RS-IBED locally, including the backend, frontend, OpenAPI workflow, and docs site.
Repository structure
Section titled “Repository structure”This project is a monorepo with the following main directories:
.├── docs├── frontend├── migrations├── src├── Cargo.toml├── config.toml└── openapi.jsonsrc/: Rust backend source codefrontend/: SvelteKit admin frontenddocs/: Astro Starlight documentation sitemigrations/: database migration filesopenapi.json: exported OpenAPI specification
Prerequisites
Section titled “Prerequisites”You should have the following tools installed:
- Rust and Cargo
pnpm- SQLite or PostgreSQL, depending on your database choice
You also need runtime environment variables:
export IMG_AUTH_TOKEN="dev-token"export IMG_JWT_SECRET="dev-secret"export IMG_DATABASE_URL="sqlite://data.db"Backend development
Section titled “Backend development”Common commands
Section titled “Common commands”cargo buildcargo testcargo runTo start with a specific config file:
cargo run -- --config ./config.tomlExport OpenAPI
Section titled “Export OpenAPI”You can export the OpenAPI schema without starting the server:
cargo run -- export-openapicargo run -- export-openapi frontend/openapi.jsonBy default, the schema is written to openapi.json in the repository root.
Additional binaries
Section titled “Additional binaries”You can add independent binaries under src/bin/. For example:
src/bin/upload.rs: CLI uploader for the upload API
After building or packaging, this produces a standalone upload executable that can be run directly:
./upload --helpFrontend development
Section titled “Frontend development”The frontend lives in frontend/ and uses SvelteKit.
Common commands
Section titled “Common commands”Run these inside frontend/:
pnpm installpnpm gen:apipnpm checkpnpm buildpnpm devRecommended integration order
Section titled “Recommended integration order”- Export OpenAPI from the backend:
cargo run -- export-openapi frontend/openapi.json- Generate the frontend SDK:
cd frontendpnpm gen:api- Start the backend:
cargo run- Start the frontend dev server:
cd frontendpnpm devAuthentication flow
Section titled “Authentication flow”The project includes a CLI-to-browser login flow:
- When you run
cargo run, the server prints a CLI login URL - That link targets
/login?token=... - Opening it in the browser makes the frontend call
/api/auth/cli - The backend then sets the
ibed_tokencookie to establish a browser session
Protected endpoints also support direct Bearer token access, for example:
Authorization: Bearer <AUTH_TOKEN>Documentation development
Section titled “Documentation development”The docs site is located in docs/ and uses Astro Starlight.
Common commands
Section titled “Common commands”Run these inside docs/:
pnpm installpnpm devpnpm buildpnpm previewLocalized documentation
Section titled “Localized documentation”docs/src/content/docs/zh/: Chinese documentationdocs/src/content/docs/en/: English documentation
If you add a new Chinese page, you should usually add the matching English page too so navigation stays aligned across locales.
API documentation source
Section titled “API documentation source”The docs site uses starlight-openapi and reads the repository root openapi.json.
So after backend API changes, the usual flow is:
- Re-export
openapi.json - Sync
frontend/openapi.jsonif needed - Then start or rebuild the docs site and frontend
Debugging tips
Section titled “Debugging tips”Upload API debugging
Section titled “Upload API debugging”You can debug uploads with:
curlcargo run --bin upload -- ...- The browser network panel
Useful files to inspect
Section titled “Useful files to inspect”When working on upload, resizing, or image delivery, these files are usually the most relevant:
src/handlers/upload.rssrc/handlers/view.rssrc/router.rssrc/config.rssrc/auth.rs
Common things to verify
Section titled “Common things to verify”If an API request fails, check:
- whether
IMG_AUTH_TOKENis correct - whether
IMG_DATABASE_URLis reachable - whether
url_patterninconfig.tomlmatches the paths you are testing - whether
image.allow_show_originaffects original file access - whether OpenAPI has been re-exported after backend changes
Before submitting changes
Section titled “Before submitting changes”Before submitting changes, it is a good idea to run at least:
cargo testcargo buildIf you changed the frontend:
cd frontendpnpm checkpnpm buildIf you changed the documentation:
cd docspnpm build