# Architecture Nuxt 3 app, Nitro `node-server`, Vue 3. Production image is `node:22.23.4-alpine` with ffmpeg added in the runner stage. The container listens on port 3000 and reads the library from `LIBRARY_DIR` (default `/data/library`). ## Library `server/utils/library.ts` stores one catalog per owner under `users//`. The owner key is a hash of the session identity, or a single private-instance id when password auth is on. Catalog writes are serialized per owner and written to a temp file, then renamed. `deleteStill`, `deleteStillFamily`, and `wipeFolderContents` update the catalog even if `rmSync` fails. A folder wipe removes every still, clip, and track for that folder, checks the folder is empty, and drops that owner's in-memory catalog cache. The next read loads the file that was just written. It does not treat an unchanged mtime as proof the cache is current. `pruneMissingStillMasters` only drops stills whose master file is missing. `publicLibrary` and `publicLibraryPage` run that prune before they return rows or folder counts. The wipe route returns that read after the cache drop. Studio 2 reads a paged `/api/library` list. After a delete or wipe it replaces local library state from the server response, refetches that list, and clears the stage still and form slots that pointed at a removed id. A folder `imageCount` of 0 is an empty folder. ## Auth `server/middleware/auth.ts` allows a fixed set of paths with case-sensitive prefixes (`/api/auth/login`, `/api/health`, `/login`, and the other listed public paths). Every other `/api/` path without a session returns 401. Other pages redirect to login. Cache headers for `/api/generate/` and `/api/prompt/` are set in `server/middleware/cache-headers.ts`, not Nitro `routeRules`. ## LoRAs Comfy returns relative paths under `models/loras/`. `server/utils/loras.ts` caches that list and `?fresh=1` forces a live object-info scan so new files appear without a restart. Matching lives in `utils/loras.ts`. A path segment `xaigen` or `xiagen` is xAIGen-only. A path segment `aigen` is visible on AIGen. The directory immediately under that segment is the engine (`flux`, `krea`, `moss`, and `minimax`, `ltx`, or `qwen` when present). Filename tokens such as `krea-something.safetensors` still match when the file has not been moved. The value stored on a stack is the Comfy-relative path. ## Generation Studio 2 jobs are built in `server/utils/studio2/` and sent to the configured Comfy host. Klein, Krea, MOSS, MiniMax, and LTX graph construction is separate from library delete and from LoRA folder matching.