1.6 KiB
1.6 KiB
System Overview
Runtime components
apps/web: public site, user dashboard, admin UI, HTTP API handlersapps/worker: background jobs for generation execution, reconciliation, cleanup, and health checksapps/bot: Telegram admin bot runtimeapps/cli: operator commands executed on the server
Shared packages
packages/config: environment parsing and config contractspackages/db: Prisma schema, migrations, data access helperspackages/domain: business rules and state machinespackages/providers: external adapters for model APIs, payment processor, storage, email, and Telegram
Core request flow
- User submits a generation request from the chat UI.
- The web app validates auth, subscription, quota, and request shape.
- The app stores a
GenerationRequestand enqueues work. - The worker runs provider routing through the key pool.
- The worker persists
GenerationAttemptrows for each key-level attempt. - On the first success, the worker stores assets, marks the request succeeded, and consumes quota.
- The web app exposes polling endpoints until the result is ready.
Data boundaries
- User-visible request lifecycle lives in
GenerationRequest. - Key-level retries live in
GenerationAttempt. - Quota accounting lives in
UsageLedgerEntry. - Provider key health lives in
ProviderKeyplus status-event history.
Failure handling
- Retryable provider failures are hidden from the user while eligible keys remain.
- User-caused provider failures are terminal for that request.
- Balance or quota exhaustion removes a key from active rotation.
- Provider-key state transitions must be audited.