quark is a single-binary URL shortener. Backend is Rust (axum + tokio); the
admin panel is a React + TypeScript + Vite SPA under web/. Storage, cache,
analytics, and rate-limiting are pluggable: embedded defaults (LMDB, in-memory)
with opt-in production backends (Postgres, Valkey/Redis, ClickHouse).
- HTTP handlers and the router live in
src/api/, a directory module split by area.mod.rsholdsAppState, the shared imports, and re-exports; handlers are grouped intolinks.rsandlinks_admin.rs(the/,/:code, and admin link CRUD),guard.rs(admin auth),oidc_login.rs,tenants.rs,domains.rs,sso_domains.rs,invites.rs,sheets.rs,webhooks_api.rs, androuter.rs(router()/router_with_cors()). Submodules useuse super::*;over a flat glob re-export inmod.rs, so the internal namespace stays flat and the public surface (AppState,router, ...) is reachable atquark::api::. - Request/response types are serde structs defined inline in the relevant
src/api/*.rssubmodule (e.g.CreateReq,CreateRespinlinks.rs). Persisted domain types (Record,Rule,Variant, ...) live insrc/store/mod.rs. - Storage:
src/store/— theStoretrait inmod.rs, backendslmdb.rs(default, embedded) andpostgres.rs(shared). - Cache:
src/cache/—mod.rs(L1 moka + optional L2 tier),valkey.rs. - Analytics:
src/analytics/—mod.rs(ClickEvent,Aggregates, the channel worker, theAnalyticsSinktrait),clickhouse.rs. - Webhooks:
src/webhooks/—mod.rs(types, Standard Webhooks signing),delivery.rs(dispatcher + delivery worker). - Abuse / cross-cutting guards (the closest thing to middleware):
src/abuse/—ratelimit.rsandmod.rs(SSRFis_internal_host,extract_host). Admin auth is insrc/api/guard.rs(admin_guard,require_admin_for_create); API tokens and scopes are insrc/auth.rs. - Other modules:
src/pixel.rs(conversion forwarding),src/import.rs, thearxidcrate reexported asquark::{permute, codec}insrc/lib.rs(keyed Feistel code generation + base62; extracted from this repo),src/invalidate.rs(cross-node pub/sub invalidation),src/main.rs,src/lib.rs. - Tests: integration tests are
tests/*_it.rs(e.g.api_it.rs,webhooks_api_it.rs,tokens_api_it.rs); unit tests are inline#[cfg(test)]modules. Postgres / Valkey / ClickHouse integration tests are gated behind env vars (QUARK_TEST_DATABASE_URL,QUARK_TEST_VALKEY_URL, ...). Integration tests build theirAppStatethrough the sharedtests/common/mod.rsTestStatebuilder (defaults to the OSS single-tenant shape, fluent setters per field) rather than a hand-rolled struct literal. Frontend tests areweb/src/**/*.test.tsx(Vitest).
- Everything is AGPL-3.0-only EXCEPT
src/ee/andweb/src/ee/, which are under the quark Enterprise Edition License (src/ee/LICENSE). Deleting both directories must leave a buildable, passing core; CI enforces it in thecommunity-onlyjob. Never make core code depend onsrc/ee/. - The server side lives behind the non-default cargo feature
ee(cargo build --features ee); the panel behind the@eealias, whichvite.config.tspoints atweb/src/ee/whenVITE_QUARK_EE=1and at the inertweb/src/lib/ee-stub.tsxotherwise. The stub is the type contract the real barrel must satisfy. - What belongs in
ee: administering OTHER people's accounts (workspaces, invites, per-tenant IdP, Keycloak realm provisioning, multiple verified domains, billing). What stays core: anything one organization uses for itself, anything on the redirect hot path, and every type named by theStoretrait. The full rule and the file-by-file inventory are indocs/specs/2026-08-03-luc19-open-core-design.mdanddocs/research/2026-08-03-luc19-inventario-oss-ee.md. - Modules in
src/ee/api/reach the core namespace withuse crate::api::*(the reexports insrc/api/mod.rsarepub(crate)), thenuse super::*for their siblings. EE routes are mounted at ONE injection point,crate::ee::api::mount, called fromrouter_with_cors; never scatter#[cfg(feature = "ee")]across individual routes. The EE boot is likewise one call,crate::ee::boot, frommain.rs. - Gated test binaries that only exercise EE routes carry
#![cfg(feature = "ee")]; panel tests for EE screens live inweb/src/ee/and run vianpm run test:ee.
- Project docs live in
docs/as Markdown files. - Each user-facing feature has an English doc plus a
.PT_BR.mdtwin (e.g.docs/WEBHOOKS.mdanddocs/WEBHOOKS.PT_BR.md). Both start with the language-switch header line:**English** · [Português](X.PT_BR.md)(and the mirror on the PT_BR file). - Design specs go in
docs/specs/, implementation plans indocs/plans/, research and audits indocs/research/. - Prose follows the avoid-ai-writing rules: no em-dashes, plain direct technical English (and natural pt-BR on the PT_BR twin).