Diagrams
Diagrams
Source-grounded visual maps of what the software is doing. Each diagram explains what you are seeing, how it was verified, and what remains uncertain — and links back to the functionality and warnings it relates to.
Diagrams never claim behaviour that has not been traced to source. Inferred or unverified paths are labelled in the diagram itself.
Understand the whole app
The fastest visual entry points before reading records.
AI Saga Arcana application overview
How visitors become signed-in generators, how jobs move through the queue and worker into the gallery, and how Stripe credits and B2 storage fit the picture.
Parts — what each one is
Each part explains why it appears, where it lives in the repository, and which files to read.
Visitor
Verified from sourceA person in a browser opening Arcana's public and signed-in pages.
Related functionality: Public landing page
Landing
Verified from sourceThe marketing home page presents the product, sample imagery, and CTAs to register or log in.
Related functionality: Public landing page
index.php
- Entry point
index.phpCanonical desktop landing; may redirect mobile UAs to index.mobile.php.
Canonical purpose: Public marketing landing with mobile redirect.
Auth gate
Verified from sourceInvite-gated registration, email verification, and session login before protected features.
Related functionality: Account registration Login and logout Email verification
auth_lib.phparcana.register.phparcana.login.php
- Primary implementation
auth_lib.phpSession, PDO users table, CSRF, login/register helpers.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
- Entry point
arcana.register.phpInvite + Turnstile registration page.
- Entry point
arcana.login.phpCanonical login page.
Generator
Verified from sourceSigned-in form that collects band/song/lyrics/style/portraits and enqueues a render job.
Related functionality: Image-generation form Queue submission
arcana.image.generator.php
- Primary implementation
arcana.image.generator.phpMain UI and AJAX enqueue into arcana_queue.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Queue
Verified from sourcePending/processing/completed job rows that workers claim.
Related functionality: Queue submission Background render processing
MySQL/
arcana.image.generator.php
- Storage
arcana.image.generator.phpInserts pending rows with style, aspect, portraits, watermark.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Uncertain: CREATE TABLE for arcana_queue is not in-repo.
Cron worker
Inferred from sourceBackground PHP script that analyzes lyrics, builds prompts, calls Gemini image models, and persists results.
Related functionality: Background render processing Song and lyric analysis Gemini image generation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.php
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpBest-evidence production worker with parallel Gemini, styles, retries, credits, B2.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Uncertain: Which worker is scheduled on the host is not confirmed in-repo.
Gallery
Verified from sourcePer-user browse/search/delete/share UI over completed renders.
Related functionality: User render gallery
arcana.image.gallery.php
- Primary implementation
arcana.image.gallery.phpLists arcana_renders for the signed-in user.
Canonical purpose: User gallery browse/search/sort/paginate/email/delete.
Stripe
Verified from sourceCheckout sessions and webhooks that sell credit packs and subscriptions.
Related functionality: Stripe checkout Stripe webhook processing
stripe_lib.phparcana.stripe.endpoint.php
- Primary implementation
stripe_lib.phpCheckout creation and webhook handlers.
Canonical purpose: Stripe SDK helpers for products, checkout, webhooks, credit grants.
- Entry point
arcana.stripe.endpoint.phpModern Stripe webhook endpoint.
Credits
Verified from sourceImage credit balances on users that gate enqueue and are consumed after successful renders.
Related functionality: Credit balances
MySQL users/
auth_lib.php
- Primary implementation
auth_lib.phpauth_user_has_credits / consume / add_credits with row locks.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Backblaze B2
Verified from sourceObject storage for full images and thumbnails, with optional local backup under uploads/dble.
Related functionality: Local and Backblaze B2 storage
includes/
- includes/
b2_helpers.php
- Integration adapter
includes/b2_helpers.phpUpload, delete, and public URL helpers for B2.
Canonical purpose: Backblaze B2 upload/delete/public URL helpers.
Connections — why they connect
Each connection names the concrete mechanism linking its two parts. The mechanism is the proof the relationship passed the explainability gate.
The visitor's browser requests the site document root, which serves index.php as the marketing landing.
Related functionality: Public landing page
- Entry point
index.phpDefault landing entry.
Canonical purpose: Public marketing landing with mobile redirect.
Landing CTAs link to arcana.register.php and arcana.login.php for account creation and sign-in.
Related functionality: Public landing page Account registration Login and logout
- Caller
index.phpLinks to register and login pages.
Canonical purpose: Public marketing landing with mobile redirect.
Protected pages include auth_check.php, which requires a logged-in session before the generator runs.
Related functionality: Login and logout Image-generation form
- Validation
auth_check.phpLogin + maintenance gate used by the generator.
Canonical purpose: Require login and honor maintenance mode.
On generate, the form inserts a pending row into arcana_queue with inputs and flags.
Related functionality: Queue submission
- Primary implementation
arcana.image.generator.phpPerforms the INSERT into arcana_queue.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Queue retrieves from Cron worker
Inferred from source Dashed lineThe worker SELECTs pending rows FOR UPDATE, marks them processing, then runs the Gemini pipeline.
Basis for the inference: Claim/lock pattern is present in the v3 worker source; which script cron invokes is unconfirmed.
Related functionality: Background render processing
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpClaims and processes queue rows.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Uncertain: Host crontab not in repo.
Cron worker creates Gallery
Inferred from source Dashed lineAfter a successful image save, the worker inserts an arcana_renders row that the gallery lists.
Basis for the inference: v3 worker contains the INSERT and gallery reads the same table; end-to-end runtime not executed.
Related functionality: Gemini image generation User render gallery
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpINSERT into arcana_renders after save.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Cron worker stores in Backblaze B2
Verified from source Solid lineThe worker encodes WebP/thumb and uploads them through b2_helpers.
Related functionality: Local and Backblaze B2 storage
- Integration adapter
includes/b2_helpers.phpb2_upload_file used by workers.
Canonical purpose: Backblaze B2 upload/delete/public URL helpers.
Stripe checkout/invoice handlers call stripe_grant_credits / auth_user_add_credits to increase image_credits.
Related functionality: Stripe webhook processing Credit balances
- Primary implementation
stripe_lib.phpWebhook handlers grant credits.
Canonical purpose: Stripe SDK helpers for products, checkout, webhooks, credit grants.
Before enqueue, the generator checks auth_user_has_credits for at least one image credit.
Related functionality: Credit balances Queue submission
- Validation
auth_lib.phpCredit balance helpers.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Gallery retrieves from Backblaze B2
Verified from source Solid lineGallery helpers prefer B2 public URLs (or the viewimage proxy) when presenting thumbnails and full images.
Related functionality: User render gallery Local and Backblaze B2 storage
- Primary implementation
arcana.image.gallery.phpBuilds image/thumbnail src from B2 helpers.
Canonical purpose: User gallery browse/search/sort/paginate/email/delete.
Understand the main product flow
How generation jobs move from the form through the queue to the gallery.
Generation pipeline from form to gallery
Credit-checked enqueue, worker claim, Gemini analysis and image generation, B2 persistence, and post-success credit consumption.
Parts — what each one is
Each part explains why it appears, where it lives in the repository, and which files to read.
Generator form
Verified from sourceCollects band, song, lyrics, style, aspect, and portraits then POSTs action=generate.
Related functionality: Image-generation form
arcana.image.generator.php
- Entry point
arcana.image.generator.phpUser-facing generation UI and AJAX handler.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Credit check
Verified from sourceEnsures the user has at least one image credit before a job is accepted.
Related functionality: Credit balances Queue submission
auth_lib.php
- Validation
auth_lib.phpauth_user_has_credits gates enqueue.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Queue row
Verified from sourceA pending arcana_queue record holding all generation inputs and flags.
Related functionality: Queue submission
MySQL/
arcana.image.generator.php
- Primary implementation
arcana.image.generator.phpINSERT pending queue row.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Uncertain: Table DDL not in repository.
Claim job
Verified from sourceWorker transactionally selects pending rows and marks them processing.
Related functionality: Background render processing Parallel worker execution
arcana.queue.processor.cron.parallel.v3.dynamicstyle.php
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpSELECT ... FOR UPDATE then status=processing.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Song DNA
Verified from sourceGemini text model returns structured mood/theme/visual DNA for the song.
Related functionality: Song and lyric analysis
arcana.queue.processor.cron.parallel.v3.dynamicstyle.php
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpParallel Gemini text analysis phase.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Cinematic prompt
Verified from sourceAssembles the image prompt from DNA, optional style directive, portraits, and watermark branding.
Related functionality: Cinematic prompt creation Static visual styles Dynamic band-style analysis Watermark application
arcana.queue.processor.cron.parallel.v3.dynamicstyle.php
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpPrompt construction and style branching.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Image gen
Verified from sourceGemini image model produces the cinematic still, with multi-attempt fallbacks on safety failures.
Related functionality: Gemini image generation Retry and fallback behavior
arcana.queue.processor.cron.parallel.v3.dynamicstyle.php
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpImage generation and retry loop.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Persist
Inferred from sourceWrites WebP + thumb to B2 (and local backup) and inserts arcana_renders metadata.
Related functionality: Local and Backblaze B2 storage User render gallery
- includes/
b2_helpers.php
arcana.queue.processor.cron.parallel.v3.dynamicstyle.php
- Integration adapter
includes/b2_helpers.phpObject upload helpers.
Canonical purpose: Backblaze B2 upload/delete/public URL helpers.
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpSave + INSERT arcana_renders.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Uncertain: End-to-end save not executed in this environment.
Consume credit
Verified from sourceAfter success, deducts one image credit and marks the queue row completed.
Related functionality: Credit balances Background render processing
auth_lib.php
- Primary implementation
auth_lib.phpauth_user_consume_credit.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Connections — why they connect
Each connection names the concrete mechanism linking its two parts. The mechanism is the proof the relationship passed the explainability gate.
Generator form validates Credit check
Verified from source Solid lineThe generate action calls auth_user_has_credits before writing a queue row.
Related functionality: Credit balances Queue submission
- Validation
auth_lib.phpBalance check API.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Credit check writes Queue row
Verified from source Solid lineWhen credits pass, the generator inserts a pending arcana_queue row with the request payload.
Related functionality: Queue submission
- Primary implementation
arcana.image.generator.phpQueue INSERT.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
The cron worker retrieves pending rows under a transaction lock and marks them processing.
Related functionality: Background render processing
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpClaim loop.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
After claim, the worker calls Gemini text models to produce Song DNA JSON from band/song/lyrics.
Related functionality: Song and lyric analysis
- Caller
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpText analysis phase.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Song DNA returns to Cinematic prompt
Verified from source Solid lineAnalysis JSON is folded into the cinematic prompt builder along with style and watermark rules.
Related functionality: Cinematic prompt creation
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpPrompt assembly uses analysis output.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Cinematic prompt sends to Image gen
Verified from source Solid lineThe finished prompt (and optional portraits) are sent to the Gemini image model.
Related functionality: Gemini image generation
- Caller
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpImage generation request.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
Successful image bytes are encoded to WebP, uploaded to B2, and recorded in arcana_renders.
Basis for the inference: Save/upload/insert code paths exist in the worker; runtime upload not executed here.
Related functionality: Local and Backblaze B2 storage
- Integration adapter
includes/b2_helpers.phpUpload path.
Canonical purpose: Backblaze B2 upload/delete/public URL helpers.
Persist updates Consume credit
Verified from source Solid lineAfter a successful persist, the worker consumes one image credit and marks the queue job completed.
Related functionality: Credit balances
- Callee
auth_lib.phpCredit consumption helper.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Authentication and access flow
Invite registration, email verification, session login, protected-page gating, and password reset against the users table.
Parts — what each one is
Each part explains why it appears, where it lives in the repository, and which files to read.
Invite code
Verified from sourceRegistration requires a valid row in access_codes that is deleted after use.
Related functionality: Account registration
MySQL/
arcana.register.php
- Validation
arcana.register.phpLooks up and consumes invite codes.
Uncertain: access_codes DDL not in-repo.
Register
Verified from sourceCreates the account after Turnstile, CSRF, and invite checks.
Related functionality: Account registration
arcana.register.phparcana.turnstile.php
- Entry point
arcana.register.phpRegistration page.
- Validation
arcana.turnstile.phpBot challenge.
Email verify
Verified from sourceToken link marks email_verified and clears the verification token.
Related functionality: Email verification
arcana.verify.phparcana.auth_email_verification.php
- Entry point
arcana.verify.phpToken consumer.
- Primary implementation
arcana.auth_email_verification.phpToken generation and email send.
Login
Verified from sourceValidates credentials, blocks unverified emails, and starts a session.
Related functionality: Login and logout
arcana.login.phpauth_lib.php
- Entry point
arcana.login.phpCanonical login UI.
- Primary implementation
auth_lib.phpauth_attempt_login / auth_login.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Protected page
Verified from sourceauth_check.php enforces login (and maintenance) before generator/gallery flows.
Related functionality: Login and logout Maintenance mode
auth_check.php
- Validation
auth_check.phpShared protected-page gate.
Canonical purpose: Require login and honor maintenance mode.
Password reset
Verified from sourceForgot-password email issues a time-limited token; reset page sets a new hash.
Related functionality: Password reset
arcana.password.forgot.phparcana.password.reset.phparcana.password.auth_reset.php
- Entry point
arcana.password.forgot.phpRequest reset.
- Entry point
arcana.password.reset.phpConsume token.
- Primary implementation
arcana.password.auth_reset.phpToken + SMTP helpers.
users table
Verified from sourceAuthoritative account, verification, password, plan, and credit columns.
Related functionality: Account registration Login and logout Credit balances
MySQL/
auth_lib.php
- Data model
auth_lib.phpauth_ensure_schema and user queries.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Connections — why they connect
Each connection names the concrete mechanism linking its two parts. The mechanism is the proof the relationship passed the explainability gate.
Invite code validates Register
Verified from source Solid lineRegistration looks up the invite code and refuses signup without a valid unused code.
Related functionality: Account registration
- Validation
arcana.register.phpInvite SELECT/DELETE.
Register creates users table
Verified from source Solid lineauth_register_user inserts the new users row after validation.
Related functionality: Account registration
- Primary implementation
auth_lib.phpUser insert helper.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Register sends to Email verify
Verified from source Solid lineAfter insert, registration generates a verification token and emails the verify link.
Related functionality: Email verification
- Primary implementation
arcana.auth_email_verification.phpToken + mail.
Email verify validates Login
Verified from source Solid lineLogin refuses sessions for users with email_verified=0 until the verify link succeeds.
Related functionality: Email verification Login and logout
- Validation
arcana.login.phpVerified-email gate before session.
Login routes to Protected page
Verified from source Solid lineA successful login sets session user_id; auth_check requires that session on protected pages.
Related functionality: Login and logout
- Validation
auth_check.phpauth_require_login.
Canonical purpose: Require login and honor maintenance mode.
Login reads users table
Verified from source Solid lineLogin SELECTs the user by username/email and verifies the password hash.
Related functionality: Login and logout
- Primary implementation
auth_lib.phpauth_attempt_login.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Password reset updates users table
Verified from source Solid linePassword reset writes password_hash and clears reset tokens on the users row.
Related functionality: Password reset
- Primary implementation
arcana.password.reset.phpApplies new hash.
Understand the technical system
Where data lives and which external services are involved.
Data and storage map
Dual PDO/mysqli MySQL access, local uploads/dble backups, Backblaze B2 objects, and PHP sessions.
Parts — what each one is
Each part explains why it appears, where it lives in the repository, and which files to read.
PHP pages
Verified from sourceServer-rendered entrypoints and workers that perform reads/writes.
Related functionality: Login and logout Queue submission Stripe checkout
repo root/
auth_lib.php
- Dependency
auth_lib.phpShared PDO/session helpers included widely.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
PDO path
Verified from sourcePrimary database access for auth, credits, queue pages using auth_pdo().
Related functionality: Login and logout Credit balances
auth_lib.php
- Primary implementation
auth_lib.phpauth_pdo and schema helpers.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
mysqli path
Verified from sourceStripe library uses mysqli for product/checkout/subscription tables.
Related functionality: Stripe checkout Stripe webhook processing
stripe_lib.php
- Primary implementation
stripe_lib.phpmysqli-based Stripe persistence.
Canonical purpose: Stripe SDK helpers for products, checkout, webhooks, credit grants.
MySQL / MariaDB
Inferred from sourceRelational store for users, queue, renders, styles, settings, and Stripe tables.
Related functionality: Credit balances Queue submission User render gallery
host DB/
auth_lib.php
- Data model
auth_lib.phpCreates users/credit_transactions; other tables assumed external.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Uncertain: Several tables lack in-repo CREATE statements.
Local uploads
Verified from sourceFilesystem backup and staging under uploads/dble including refs and thumbs.
Related functionality: Portrait reference uploads Local and Backblaze B2 storage
uploads/dble/
arcana.image.generator.php
- Storage
arcana.image.generator.phpWrites portrait refs under uploads/dble/refs.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Backblaze B2
Verified from sourceDurable public object storage for generated images and thumbnails.
Related functionality: Local and Backblaze B2 storage
includes/
- includes/
b2_helpers.php
- config/
backblaze.example.php
- Integration adapter
includes/b2_helpers.phpB2 API helpers.
Canonical purpose: Backblaze B2 upload/delete/public URL helpers.
- Configuration
config/backblaze.example.phpDocuments B2 config variable names (not values).
PHP session
Verified from sourceCookie aisaga_sid holds the logged-in user_id and CSRF state.
Related functionality: Login and logout
auth_lib.php
- Primary implementation
auth_lib.phpSession bootstrap and cookie settings.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Connections — why they connect
Each connection names the concrete mechanism linking its two parts. The mechanism is the proof the relationship passed the explainability gate.
Most auth and generator pages include auth_lib and call auth_pdo() for SQL.
Related functionality: Login and logout
- Callee
auth_lib.phpPDO factory.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
PHP pages calls mysqli path
Verified from source Solid linePricing and webhook pages use stripe_lib's mysqli connection for commerce tables.
Related functionality: Stripe checkout
- Callee
stripe_lib.phpmysqli commerce path.
Canonical purpose: Stripe SDK helpers for products, checkout, webhooks, credit grants.
PDO path reads MySQL / MariaDB
Verified from source Solid linePDO statements read and write the shared MySQL database.
Related functionality: Credit balances
- Primary implementation
auth_lib.phpPrepared statements against MySQL.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
mysqli path writes MySQL / MariaDB
Verified from source Solid linestripe_lib writes checkout sessions, subscriptions, and related commerce rows through mysqli.
Related functionality: Stripe webhook processing
- Primary implementation
stripe_lib.phpCommerce persistence.
Canonical purpose: Stripe SDK helpers for products, checkout, webhooks, credit grants.
PHP pages stores in Local uploads
Verified from source Solid lineGenerator and workers write portraits and WebP backups under uploads/dble.
Related functionality: Portrait reference uploads Local and Backblaze B2 storage
- Primary implementation
arcana.image.generator.phpPortrait upload path.
Canonical purpose: Primary user-facing generation UI and queue enqueue.
Local uploads sends to Backblaze B2
Verified from source Solid lineAfter local encode, workers upload full image and thumbnail objects to B2.
Related functionality: Local and Backblaze B2 storage
- Integration adapter
includes/b2_helpers.phpb2_upload_file.
Canonical purpose: Backblaze B2 upload/delete/public URL helpers.
PHP pages stores in PHP session
Verified from source Solid lineAuth pages store user_id and CSRF tokens in the PHP session backed by cookie aisaga_sid.
Related functionality: Login and logout
- Primary implementation
auth_lib.phpSession bootstrap.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Understand uncertainty
Where to be careful and what is not yet verified.
Risk and uncertainty map
Dual Stripe receivers and double-grant risk, missing DDL, exposed debug endpoints, duplicate login pages, and unknown production cron selection.
Parts — what each one is
Each part explains why it appears, where it lives in the repository, and which files to read.
Dual webhooks
Verified from sourceTwo Stripe receiver scripts exist with different grant/schema assumptions.
Related functionality: Stripe webhook processing
arcana.stripe.endpoint.phpwebhook.php
- Entry point
arcana.stripe.endpoint.phpModern SDK-verified webhook.
- Entry point
webhook.phpLegacy HMAC webhook path.
Canonical purpose: Lightweight Stripe webhook for checkout session credit grants.
⚠ Warnings: Dual Stripe webhook implementations
Uncertain: Which URL Stripe calls in production is unknown.
Double grant risk
Verified from sourceCheckout success page can grant packs if the session row is not yet marked completed, overlapping the webhook grant.
Related functionality: Credit-pack purchases Stripe webhook processing
arcana.purchase.success.phpstripe_lib.php
- Primary implementation
arcana.purchase.success.phpClient-side grant path.
- Primary implementation
stripe_lib.phpWebhook grant path.
Canonical purpose: Stripe SDK helpers for products, checkout, webhooks, credit grants.
⚠ Warnings: Possible double credit grant paths
Credit balances
Verified from sourceusers.image_credits is the spend currency; incorrect grants permanently change balances.
Related functionality: Credit balances
MySQL/
auth_lib.php
- Primary implementation
auth_lib.phpCredit mutate helpers.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Missing DDL
Verified from sourceCritical tables are queried without in-repo CREATE statements.
Related functionality: Queue submission Stripe checkout Account registration In-app notifications
auth_lib.php
- Data model
auth_lib.phpOnly users/credit_transactions ensured in-repo.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
⚠ Warnings: arcana_queue schema missing in-repo Stripe commerce tables missing CREATE access_codes schema missing in-repo user_notifications schema missing
Uncertain: Production may have migrated tables out of band.
Debug endpoints
Verified from sourceUnauthenticated or weakly gated debug scripts can leak configuration fingerprints.
Related functionality: Local and Backblaze B2 storage
arcana.debug_b2.phppath.php
- Test / verification evidence
arcana.debug_b2.phpPrints B2 key id / key prefix without login.
- Test / verification evidence
path.phpPrints filesystem paths for cron setup.
⚠ Warnings: Debug/test utilities present in tree
Dual login pages
Verified from sourcelogin.php and arcana.login.php both exist; default redirects still mention login.php.
Related functionality: Login and logout
login.phparcana.login.php
- Entry point
login.phpLegacy login page.
Canonical purpose: Alternate/duplicate login entry point used by auth_check default redirect.
- Entry point
arcana.login.phpCanonical login page.
⚠ Warnings: Duplicate login pages
Cron unknown
Inferred from sourceMultiple processor variants coexist; host crontab is not in the repository.
Related functionality: Background render processing Parallel worker execution
hosting/
path.php
- Supporting utility
path.phpOperator helper to discover cron paths.
Uncertain: Actual scheduled script unknown.
Worker variants
Verified from sourcev3 dynamicstyle, gpt-named, nowatermark, and sequential processors implement different watermark/parallel behaviour.
Related functionality: Background render processing Watermark application
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phparcana.queue.processor.cron.nowatermark.php
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpBest-evidence current worker.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
- Supporting utility
arcana.queue.processor.cron.nowatermark.phpMisnamed; still applies Imagick logos.
Connections — why they connect
Each connection names the concrete mechanism linking its two parts. The mechanism is the proof the relationship passed the explainability gate.
Dual webhooks depends on Double grant risk
Verified from source Solid lineHaving two receivers plus a success-page grant multiplies opportunities for the same checkout to be credited more than once.
Related functionality: Stripe webhook processing
- Entry point
webhook.phpLegacy path still present.
Canonical purpose: Lightweight Stripe webhook for checkout session credit grants.
⚠ Warnings: Dual Stripe webhook implementations Possible double credit grant paths
Double grant risk updates Credit balances
Verified from source Solid lineEach grant path increments users.image_credits, so overlapping grants permanently inflate balances.
Related functionality: Credit balances Credit-pack purchases
- Callee
auth_lib.phpauth_user_add_credits / stripe_grant_credits.
Canonical purpose: Core auth, PDO, schema helpers, credits, settings, CSRF/session utilities.
Missing DDL depends on Worker variants
Inferred from source Dashed lineWorkers and enqueue code assume arcana_queue exists with expected columns even though CREATE DDL is absent from the repo.
Basis for the inference: Code queries the table; only ALTERs found in-repo, no CREATE.
Related functionality: Queue submission Background render processing
- Primary implementation
arcana.queue.processor.cron.parallel.v3.dynamicstyle.phpQueries arcana_queue.
Canonical purpose: Best-evidence current worker: parallel Gemini, styles, retries, credits, notifications.
⚠ Warnings: arcana_queue schema missing in-repo
Cron unknown configures Worker variants
Inferred from source Dashed lineThe host crontab (not in repo) selects which worker variant actually runs in production.
Basis for the inference: Multiple processors exist; no crontab committed.
Related functionality: Background render processing
- Supporting utility
path.phpHelps operators discover paths for cron.
Uncertain: Exact schedule unknown.
Debug endpoints depends on Missing DDL
Inferred from source Dashed lineDebug utilities exist partly because operators must inspect external storage/schema state that is not fully bootstrapped by the repo.
Basis for the inference: Debug scripts reference external config and storage assumptions.
Related functionality: Local and Backblaze B2 storage
- Test / verification evidence
arcana.debug_b2.phpB2 connectivity debug.
⚠ Warnings: Debug/test utilities present in tree