Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Fixius50/WorlBuilding-Writting-App/llms.txt

Use this file to discover all available pages before exploring further.

The Archetype Manager is Chronos Atlas’s system for extending the default entity structure with the custom fields your world requires. Because every world is different — a hard-magic fantasy needs spell-power ratings, a sci-fi setting needs starship classifications, a historical project needs dates of coronation — the Archetype Manager lets you define exactly which extra attributes appear on entities, what data type each holds, and whether they are required or optional.

What is an Archetype?

An Archetype (internally a Plantilla) is a named field definition associated with one or more entity types within a project. When you create an archetype, Chronos Atlas registers it in the plantillas table and automatically renders a corresponding input field in the entity editor sidebar for every entity of the targeted type. This follows the EAV (Entity–Attribute–Value) pattern: the schema lives in Plantilla records, and the actual data lives in Valor records linked to individual entities.

Project-scoped

Each archetype belongs to a specific project_id. Changing a field definition in one project does not affect any other project.

Global or Specific

An archetype can apply to all entity types in the project (aplica_a_todo = 1) or only to a specific type (tipo_objetivo, e.g., PERSONAJE, LUGAR).

Creating a Template Field

1

Navigate to Archetype Manager

Open Settings (gear icon in the left sidebar footer), then click Archetype Manager in the navigation. The page loads all existing archetypes for the current project via TemplateUseCase.getTemplates(projectId).
2

Click '+ Nuevo Atributo'

Click the primary button in the top-right of the page header. The creation form expands inline within a highlighted panel.
3

Fill in the field name

Enter a descriptive name in the Nombre del Atributo field. Examples: “Nivel de Magia”, “Raza”, “Fecha de Coronación”, “Clase de Nave”.
4

Choose the data type

Select one of the six supported field types from the Tipo de Dato dropdown:
TypeLabel in UIDescription
textTexto CortoShort single-line text
long_textTexto LargoMulti-line textarea
numberNúmeroNumeric value
dateFechaDate picker
booleanInterruptor (Sí/No)Yes/No toggle
selectLista DesplegableDropdown list
5

Assign a category

Enter a Categoría label (e.g., “Apariencia”, “Estadísticas”, “Biografía”). Category names group related fields into sections in the entity editor sidebar.
6

Set the scope

Choose Global (aplica_a_todo = 1) to apply the field to all entity types in the project, or Específico (aplica_a_todo = 0) to restrict it to one type. If Específico is selected, choose the target type from the dropdown: PERSONAJE, LUGAR, ORGANIZACION, OBJETO, or EVENTO.
7

Toggle required

Check Es obligatorio if the field must be filled. This sets es_obligatorio = 1 on the Plantilla record.
8

Save

Click Establecer Ley to save the new archetype via TemplateUseCase.createTemplate(). It immediately appears in the archetype list and will render as a field in all relevant entity editors.

TemplateUseCase Methods

The TemplateUseCase class (src/features/Settings/application/TemplateUseCase.ts) is the application-layer interface for all archetype and attribute-value operations:
// ── Archetype (Plantilla) CRUD ──────────────────────────────────────────

/** Fetch all archetypes for a project (global + project-specific) */
static async getTemplates(projectId: number): Promise<Plantilla[]>

/** Create a new archetype field definition */
static async createTemplate(
  data: Omit<Plantilla, 'id' | 'created_at'>
): Promise<Plantilla>

/** Update an existing archetype */
static async updateTemplate(
  templateId: number,
  data: Partial<Omit<Plantilla, 'id' | 'project_id'>>
): Promise<void>

/** Delete an archetype (cascades to Valor records per DB rules) */
static async deleteTemplate(templateId: number): Promise<void>

/** Get project folders (for category filtering) */
static async getProjectFolders(projectId: number): Promise<Carpeta[]>

// ── Entity Attribute Values (EAV) ───────────────────────────────────────

/** Get all attribute values assigned to a specific entity */
static async getEntityValues(entityId: number): Promise<Valor[]>

/** Add a new attribute value for an entity */
static async addEntityValue(
  entityId: number,
  templateId: number,
  value: string
): Promise<void>

/** Update an existing attribute value */
static async updateEntityValue(valueId: number, newValue: string): Promise<void>

/** Remove an attribute value from an entity */
static async deleteEntityValue(valueId: number): Promise<void>

The Plantilla Interface

Every archetype is stored as a Plantilla record. The full TypeScript interface from database.ts is:
export interface Plantilla {
  id: number;
  nombre: string;                   // Field label shown in the UI
  tipo: string;                     // "text" | "long_text" | "number" | "date" | "boolean" | "select"
  valor_defecto: string | null;     // Default value pre-filled in new entities
  metadata: string | null;          // JSON string (e.g., options list for "select" type)
  es_obligatorio: boolean | number; // Whether the field is required (1 = required)
  project_id: number;               // Owning project
  aplica_a_todo: boolean | number;  // 1 = all entity types, 0 = tipo_objetivo only
  tipo_objetivo: string | null;     // "PERSONAJE" | "LUGAR" | "ORGANIZACION" | "OBJETO" | "EVENTO"
  categoria: string | null;         // Grouping label for the entity editor sidebar
  orden: number;                    // Display order within the category
  created_at: string;
}
And the Valor record that stores the actual data per entity:
export interface Valor {
  id: number;
  entidad_id: number;    // The entity this value belongs to
  plantilla_id: number;  // The Plantilla (field definition) this value fulfills
  valor: string | null;  // The stored value as a string
  updated_at: string;
  plantilla?: Plantilla; // Optionally joined for display
}

Editing Existing Archetypes

The archetype list on the Archetype Manager page displays every Plantilla for the current project. Each row shows:
  • Field name (tpl.nombre) in bold uppercase
  • Type badge (tpl.tipo) as a small colored chip
  • Category and Scope (Global or Solo ${tipo_objetivo}) as metadata labels
  • Edit and Delete action buttons that appear on hover
Click Edit (pencil icon) on a row to load its data back into the form. The submit button changes to Actualizar Regla. Saving writes the changes via TemplateUseCase.updateTemplate(). Click Delete (trash icon) to remove the archetype via TemplateUseCase.deleteTemplate(). This also removes all Valor records associated with that Plantilla across all entities in the project (cascade behavior enforced at the database level).
Use the Categoría field to group related attributes. For example, group "Altura", "Color de Ojos", and "Color de Pelo" under "Apariencia", and "Fuerza", "Agilidad", and "Nivel de Magia" under "Estadísticas". The entity editor sidebar renders each category as a section header, keeping the attribute list navigable even for entities with dozens of custom fields.

Build docs developers (and LLMs) love