This document orients AI co-workers to the Quark codebase so you can make confident, repo-aware edits without guesswork.
- Stack: Java 21 (Maven multi-module backend) + SvelteKit/Vite management UI.
- Monorepo layout: Backend has nested modules like
core,http,protocol/*; the UI lives inmanagement-ui/. - Primary domain: Real-time streaming orchestration (ingress, session control, multi-egress).
- Key docs:
doc/ARCHITECTURE.md,doc/CONFIGURING.md,doc/WEBHOOKS.md.
| Path | Purpose |
|---|---|
bootstrap |
Entry point that discovers protocol daemons via custom annotations. |
core |
Session lifecycle logic, webhook dispatch, extensibility contracts. |
http |
REST/HTTP playback server. |
protocol/rtmp |
RTMP ingress + egress. |
protocol/webrtc |
WHIP/WebRTC ingress. |
protocol/hls |
HLS egress playlist/segment generation. |
protocol/pipeline |
Internal media pipeline helpers. |
management-ui |
Svelte management console (Vite build, Tailwind-like styles in app.css). |
doc |
Human/agent-facing docs (this file included). |
Tip: Many submodules already have compiled
target/artifacts—editsrc/main/javaand rely on Maven to rebuild.
Bootstrapscans the classpath for Quark annotations:@QuarkEntrypoint→ daemon classes withstart().@QuarkEgressConfiguration→ register egress config factories.@QuarkHttpEndpoint→ bind REST handlers.@QuarkStaticSessionListener→ observe session events.
- A session begins when an ingress (RTMP/WHIP/etc.) connects.
- Webhooks gate and configure the session (see next section).
- Media flows through configured egresses (RTMP restream, HLS, pipeline, etc.).
- Shutdown triggers ending webhooks and cleans resources.
When editing, keep the annotation discovery and plugin boundaries intact—new functionality usually fits as a new annotated component inside the relevant module.
All webhooks are POST JSON with shape { "type": "...", "data": { ... } }.
| Event | Direction | Notes for agents |
|---|---|---|
SESSION_STARTING |
Sync | Provide/validate stream ID. Reject by omitting id. Use fields: protocol, ip, url, app, key, metadata. |
SESSION_STARTED |
Async | Supply egress configs (rtmp, pipeline, others) or set shouldTerminate. |
SESSION_ENDING |
Sync | Can jam session via { source, loop }. wasGraceful indicates error vs normal exit. |
SESSION_ENDED |
Async | Notification only; response ignored. |
Any new feature that changes session timing or metadata must stay compatible with this contract.
- Core:
QUARK_DEBUG,QUARK_AUTH_SECRET,QUARK_ANON_PREGEX,QUARK_WEBHOOK_URL,QUARK_THUMB_IT,QUARK_EXP_VIRTUAL_THREAD_HEAVY_IO. - HTTP:
HTTP_PORT(set-1to disable API/UI controls). - RTMP:
RTMP_PORT(set-1to disable ingress). - WebRTC:
QUARK_EXP_WHIP,QUARK_EXP_WHIP_AVC_AUTO_RECONFIG,QUARK_WHIP_OVERRIDE_ADDRESS. - HLS:
QUARK_EXP_HLS.
If you introduce new configuration, document it in doc/CONFIGURING.md and propagate defaults through the appropriate module.
- Backend: Use Maven (e.g.,
mvn clean install). Each module has its ownpom.xml, but the parent handles dependency alignment. - UI: From
management-ui/, runnpm installonce, thennpm run devornpm run build(SvelteKit 5 & Vite). TypeScript config lives intsconfig.json. - Docker:
compose.yamlwires services; update any new ports or env vars there.
Always run targeted tests (or at least the module build) after touching backend code, and run npm run check/test for UI changes.
- Respect module boundaries: Place protocol-specific code under
protocol/<name>/src/main/javaand keep shared abstractions incore. - Keep docs in sync: Architecture/config/webhooks docs should evolve with code changes; update this
AGENTS.mdif behavior shifts. - Mind generated assets: Ignore
target/outputs andlanguageServers-log/when editing. - UI ↔ API alignment: Any API shape changes in
httpmust be reflected in Svelte stores/routes (management-ui/src/lib&routes). - Testing priority: For new session behaviors, add/adjust unit or integration tests in the relevant module and exercise webhook scenarios if applicable.
- Security: If touching auth (
QUARK_AUTH_SECRET), ensure JWT/HMAC usage remains opt-in and defaults to open access only when explicitly desired.
- Architecture deep dive:
doc/ARCHITECTURE.md. - Env configuration table:
doc/CONFIGURING.md. - Webhook payloads & sequencing:
doc/WEBHOOKS.md. - UI entry layout:
management-ui/src/routes/+layout.svelteand+page.sveltefor dashboard screens.
Keep this file updated whenever you add protocols, env vars, or workflows so future agents can onboard instantly.