-
Notifications
You must be signed in to change notification settings - Fork 1
Data Model
Cristiano Carvalho edited this page Apr 2, 2026
·
11 revisions
Aludel stores prompts, executions, evaluations, and provider configuration in PostgreSQL. The schema stays structured where clarity matters and turns to JSONB where the work demands a more flexible vessel.
erDiagram
projects ||--o{ prompts : contains
prompts ||--o{ prompt_versions : snapshots
prompts ||--o{ runs : executes
prompts ||--o{ suites : validates
runs ||--o{ run_results : produces
providers ||--o{ run_results : powers
providers ||--o{ suite_runs : evaluates_with
suites ||--o{ test_cases : includes
suites ||--o{ suite_runs : records
test_cases ||--o{ test_case_documents : attaches
projects {
id id
string name
string description
}
prompts {
id id
id project_id
string name
string template
string tags
integer current_version
}
prompt_versions {
id id
id prompt_id
integer version_number
string template
datetime inserted_at
}
runs {
id id
id prompt_id
id prompt_version_id
json variable_values
string status
datetime executed_at
}
run_results {
id id
id run_id
id provider_id
string response
integer latency_ms
integer tokens_input
integer tokens_output
decimal cost_usd
string error
}
providers {
id id
string name
string provider_type
string model
string api_endpoint
json config
boolean enabled
}
suites {
id id
id prompt_id
string name
string description
}
test_cases {
id id
id suite_id
string name
json variable_values
json assertions
}
test_case_documents {
id id
id test_case_id
string filename
string content_type
string file_path
integer file_size
}
suite_runs {
id id
id suite_id
id provider_id
string status
integer passed_count
integer failed_count
integer total_latency_ms
decimal total_cost_usd
datetime executed_at
}
field :provider_type, :string # "openai", "anthropic", "ollama"
field :model, :string
field :config, :map # JSONB
field :enabled, :booleanProvider-specific settings are stored in JSONB, for example %{temperature: 0.7, max_tokens: 1000}.
field :template, :string # "Summarize {{article}}"
field :tags, {:array, :string} # ["summarization"]
belongs_to :projectImmutable snapshots. Each update_prompt/2 creates a new version record, preserving the lineage of the prompt instead of overwriting its past.
field :version_number, :integer
field :template, :string
belongs_to :promptfield :variable_values, :map # JSONB: {"article": "..."}
field :status, :string # "pending", "running", "completed"
belongs_to :prompt
belongs_to :prompt_versionfield :response, :string
field :latency_ms, :integer
field :tokens_input, :integer
field :tokens_output, :integer
field :cost_usd, :decimal
belongs_to :run
belongs_to :providerEstimated cost formula:
(tokens_input / 1000 * input_price) + (tokens_output / 1000 * output_price)
field :variable_values, :map # JSONB
field :assertions, {:array, :map} # JSONB array
belongs_to :suiteAssertion types: contains, regex, exact_match, json_field
Supported attachments include PDFs, images (.jpg, .png), and text-like files (.txt, .csv, .json).
field :passed_count, :integer
field :failed_count, :integer
field :total_latency_ms, :integer
field :total_cost_usd, :decimal
belongs_to :suite
belongs_to :provider- JSONB fields keep provider config, variable payloads, and assertions flexible
- Composite indexes support prompt history and provider-result lookups
- Window functions power percentile metrics such as P50 and P95 latency
- Cascading deletes keep prompt-related data consistent across versions, runs, and suites
# Prompt with latest version
Prompt
|> Repo.get!(id)
|> Repo.preload(versions: from(v in PromptVersion,
order_by: [desc: v.version_number], limit: 1))
# Run with results
Run |> Repo.get!(id) |> Repo.preload([results: :provider])
# Evolution metrics
Aludel.Prompts.Evolution.get_evolution(prompt_id)- Prompts
- Providers
- Runs and Execution
- Evaluation Suites
- Regex Assertions
- Metric Context
- Evaluator Execution Details
- Rubric Judges
- Judge Catalog
- Repeated Sampling
- Quality Policies
- ExUnit Evaluations
- File-Based Suites
- Evaluation Reporters
- Datasets
- Red-Team Datasets
- Generated Red-Team Cases
- Analytics and Prompt Evolution
- Exports and CI
- Documents and Storage
- Embedding and Access