🗃️ Data Model
Prompt Wizard replaces the archive’s WebSim collections with seven local SQLite tables. The archive declared an ideas collection, but the live archive had no reads or writes for it; the local port does not create it.
Database invariants
- engine:
- SQLite through Bun
- database:
data/pwiz.db - journal mode: WAL
- every table:
id TEXT PRIMARY KEYcreated_at TEXT NOT NULL- server-assigned values for both fields
- JSON fields:
- stored as
TEXT - parsed and serialized at API boundaries
- never treated as queryable nested columns
- stored as
- identity:
- user-scoped tables are stamped from request identity
- client-supplied
user_id,id, andcreated_atare ignored where the server owns them
Tables
wizards:iduser_idnamepromptsrcprevious_urlsoffset_x INTEGERoffset_y INTEGERsize INTEGERis_custom INTEGERcreated_at
blueprints:idtitledescriptionproject_typestepsauthor_idauthor_usernameis_public INTEGERcover_image_urlmetadatatagslikes_count INTEGER DEFAULT 0remixes_count INTEGER DEFAULT 0created_atupdated_at- index:
is_public
prompt_history:iduser_idideaproject_typecomplexitystylefocussteps INTEGERinclude_settings INTEGERresultcreated_at
saved_prompts:iduser_idtitledescriptionproject_typestepsmetadatacreated_at
likes:iduser_idblueprint_idcreated_at- unique:
user_id,blueprint_id - index:
user_id
admin_prompts:idkey UNIQUEtextdescriptionupdated_atcreated_at
llm_logs:idkindtemplate_keysystem_promptuser_messageresponse_jsoncreated_at
Mutation rules
POST /api/collections/:name:- creates row
- stamps
idandcreated_at - uses authenticated identity where applicable
PATCH /api/collections/:name/:id:- updates allowed row fields
- does not let callers rewrite ownership columns
DELETE /api/collections/:name/:id:- removes the row by id
POST /api/likes/toggle:- transactionally inserts or deletes one
likesrow - increments or decrements
blueprints.likes_countin the same transaction - returns the authoritative
likedstate and count
- transactionally inserts or deletes one
Reconciled archive drift
- wizard
size:- archive UI read and wrote
size - archive schema omitted
size - local schema includes
size INTEGER
- archive UI read and wrote
- wizard ordering:
- archive logic sorted by
created_at - archive wizard creation did not always stamp
created_at - local server always stamps
created_at
- archive logic sorted by
- prompt history project type:
- archive wrote camelCase options such as
projectTypeandincludeSettings - archive readers expected snake_case fields such as
project_type - local API stores snake_case only
- archive wrote camelCase options such as
- user ownership:
- archive declared
user_idbut did not consistently write it on history and saved prompts - local server stamps it from authenticated identity
- archive declared
ideascollection:- archive config declared it
- verified app code had no live dependency on it
- local data model omits it
See api for route shapes and verification for contract checks.