Naming conventions translating domain declarations into Elixir module names, file paths, and Postgres table names.
The DSL uses plural entity names (entity :books). The generator
translates them into singular module names (Book), plural table names
(library_books), and the matching file paths under lib/.
The domain module's .Domains. segment (if present) is stripped to
obtain the "context module": MyApp.Domains.Library → MyApp.Library.
When a domain declares version "v1", entity and context modules are
further namespaced under a camelized version segment
(MyApp.Library.V1.Book), and matching directories appear under
lib/<app>/<context>/v1/....
Most helpers accept either a domain module (atom) or a compiled
Caravela.Schema.Domain struct. Passing the struct is required to
pick up version-aware behaviour.
Summary
Types
Either a compiled Caravela.Schema.Domain struct or a raw domain module atom.
An entity's DSL name (plural atom — e.g. :books).
A LiveView / Svelte component kind.
Functions
Filesystem path for a generated auth LiveView module.
Module name for an auth LiveView page. name is a string like
"Login", "Register", "TokenManager".
Association name on the child side (singular, derived).
CamelCase an atom or string.
File path for the generated context module, relative to the project
root. When the domain declares a version, the context file lives under
the context directory as v<n>.ex.
Context module derived from the domain module by stripping a .Domains.
segment if present. When given a Domain struct with a declared
version, appends the version segment.
Short context name (lowercased, underscored). Used as the table-name prefix and directory name. Version-agnostic: always derived from the raw context module so table names remain stable across versions.
Controller file path relative to the project root. Version-aware when
given a Domain struct.
Controller module for an entity. Version-aware when given a Domain
struct — inserts a version segment between the web module and the
controller name.
Full module name for an entity under its context. Version-aware when
given a Domain struct.
Foreign-key column name ("<singular>_id").
Association name on the parent side (plural, matches DSL entity name).
File path for a generated LiveView module.
LiveView module name for an entity view. kind is :index, :show,
or :form.
Plural string form of an entity name.
Repo module derived by convention from the app root. MyApp.Library
becomes MyApp.Repo.
Plural route segment for an entity.
File path for the generated schema module, relative to the project root.
Version-aware when given a Domain struct.
Singular string form for a plural entity name. Used by the context and controller generators to derive function / route names.
Simple singularization. Handles -ies → -y, -sses → -ss, trailing s
(unless preceded by another s). Falls back to the input unchanged.
LiveSvelte component reference for an auth component (the string passed
to <LiveSvelte.svelte name="..." />).
Filesystem path for a generated auth Svelte component.
Import path used inside a generated auth Svelte component to reach the
domain's TypeScript interfaces file. Both sit under the same
v<N>/ (or root) scope so the relative path is always ../types/<ctx>.
Svelte component name (CamelCase). kind is :index, :show, or
:form.
LiveSvelte component reference — the path string passed to
<LiveSvelte.svelte name="..." />. Matches the Svelte-file path
relative to assets/svelte/, without the .svelte extension.
Filesystem path for the generated Svelte component.
Filesystem path for the generated TypeScript interfaces file.
Postgres table name for an entity: "<context>_<entity>". Tables are
version-independent — different versions of a domain share a table.
Web module name derived from the app/context root. MyApp.Library
becomes MyAppWeb.
Types
@type domain_or_module() :: Caravela.Schema.Domain.t() | module()
Either a compiled Caravela.Schema.Domain struct or a raw domain module atom.
@type entity_name() :: atom()
An entity's DSL name (plural atom — e.g. :books).
@type kind() :: :index | :show | :form
A LiveView / Svelte component kind.
Functions
@spec auth_live_file_path(Caravela.Schema.Domain.t(), String.t()) :: String.t()
Filesystem path for a generated auth LiveView module.
auth_live_file_path(domain, "Login")
#=> "lib/my_app_web/live/auth_live/login.ex"
#=> "lib/my_app_web/live/v1/auth_live/login.ex" (when versioned)
@spec auth_live_module(Caravela.Schema.Domain.t(), String.t()) :: module()
Module name for an auth LiveView page. name is a string like
"Login", "Register", "TokenManager".
auth_live_module(domain, "Login")
#=> MyAppWeb.AuthLive.Login
#=> MyAppWeb.V1.AuthLive.Login (when versioned)
@spec belongs_to_name(entity_name()) :: atom()
Association name on the child side (singular, derived).
belongs_to_name(:authors) #=> :author
CamelCase an atom or string.
@spec context_file_path(domain_or_module()) :: String.t()
File path for the generated context module, relative to the project
root. When the domain declares a version, the context file lives under
the context directory as v<n>.ex.
context_file_path(MyApp.Domains.Library)
#=> "lib/my_app/library.ex"
context_file_path(%Domain{... version: "v1" ...})
#=> "lib/my_app/library/v1.ex"
@spec context_module(domain_or_module()) :: module()
Context module derived from the domain module by stripping a .Domains.
segment if present. When given a Domain struct with a declared
version, appends the version segment.
context_module(MyApp.Domains.Library) #=> MyApp.Library
context_module(%Domain{... version: "v1" ...}) #=> MyApp.Library.V1
@spec context_short(domain_or_module()) :: String.t()
Short context name (lowercased, underscored). Used as the table-name prefix and directory name. Version-agnostic: always derived from the raw context module so table names remain stable across versions.
context_short(MyApp.Domains.Library) #=> "library"
@spec controller_file_path(domain_or_module(), entity_name()) :: String.t()
Controller file path relative to the project root. Version-aware when
given a Domain struct.
controller_file_path(MyApp.Domains.Library, :books)
#=> "lib/my_app_web/controllers/book_controller.ex"
controller_file_path(%Domain{... version: "v1" ...}, :books)
#=> "lib/my_app_web/controllers/v1/book_controller.ex"
@spec controller_module(domain_or_module(), entity_name()) :: module()
Controller module for an entity. Version-aware when given a Domain
struct — inserts a version segment between the web module and the
controller name.
controller_module(MyApp.Domains.Library, :books)
#=> MyAppWeb.BookController
controller_module(%Domain{... version: "v1" ...}, :books)
#=> MyAppWeb.V1.BookController
@spec entity_module(domain_or_module(), entity_name()) :: module()
Full module name for an entity under its context. Version-aware when
given a Domain struct.
entity_module(MyApp.Domains.Library, :books) #=> MyApp.Library.Book
entity_module(%Domain{... version: "v1" ...}, :books) #=> MyApp.Library.V1.Book
@spec foreign_key(entity_name()) :: atom()
Foreign-key column name ("<singular>_id").
foreign_key(:authors) #=> :author_id
@spec has_many_name(entity_name()) :: entity_name()
Association name on the parent side (plural, matches DSL entity name).
has_many_name(:books) #=> :books
@spec live_file_path(Caravela.Schema.Domain.t(), entity_name(), kind()) :: String.t()
File path for a generated LiveView module.
live_file_path(domain, :books, :index)
#=> "lib/my_app_web/live/library/book_live/index.ex"
#=> "lib/my_app_web/live/v1/library/book_live/index.ex" (when versioned)
@spec live_module(Caravela.Schema.Domain.t(), entity_name(), kind()) :: module()
LiveView module name for an entity view. kind is :index, :show,
or :form.
live_module(domain, :books, :index)
#=> MyAppWeb.Library.BookLive.Index
#=> MyAppWeb.V1.Library.BookLive.Index (when version set)
@spec plural_string(entity_name()) :: String.t()
Plural string form of an entity name.
plural_string(:books) #=> "books"
@spec repo_module(domain_or_module()) :: module()
Repo module derived by convention from the app root. MyApp.Library
becomes MyApp.Repo.
repo_module(MyApp.Domains.Library) #=> MyApp.Repo
@spec route_path(entity_name()) :: String.t()
Plural route segment for an entity.
route_path(:books) #=> "/books"
@spec schema_file_path(domain_or_module(), entity_name()) :: String.t()
File path for the generated schema module, relative to the project root.
Version-aware when given a Domain struct.
schema_file_path(MyApp.Domains.Library, :books)
#=> "lib/my_app/library/book.ex"
schema_file_path(%Domain{... version: "v1" ...}, :books)
#=> "lib/my_app/library/v1/book.ex"
@spec singular_string(entity_name()) :: String.t()
Singular string form for a plural entity name. Used by the context and controller generators to derive function / route names.
singular_string(:books) #=> "book"
Simple singularization. Handles -ies → -y, -sses → -ss, trailing s
(unless preceded by another s). Falls back to the input unchanged.
@spec svelte_auth_component_ref(Caravela.Schema.Domain.t(), String.t()) :: String.t()
LiveSvelte component reference for an auth component (the string passed
to <LiveSvelte.svelte name="..." />).
svelte_auth_component_ref(domain, "LoginForm") #=> "auth/LoginForm"
#=> "v1/auth/LoginForm" (when versioned)
@spec svelte_auth_file_path(Caravela.Schema.Domain.t(), String.t()) :: String.t()
Filesystem path for a generated auth Svelte component.
svelte_auth_file_path(domain, "LoginForm")
#=> "assets/svelte/auth/LoginForm.svelte"
#=> "assets/svelte/v1/auth/LoginForm.svelte" (when versioned)
@spec svelte_auth_types_import(Caravela.Schema.Domain.t()) :: String.t()
Import path used inside a generated auth Svelte component to reach the
domain's TypeScript interfaces file. Both sit under the same
v<N>/ (or root) scope so the relative path is always ../types/<ctx>.
@spec svelte_component_name(entity_name(), kind()) :: String.t()
Svelte component name (CamelCase). kind is :index, :show, or
:form.
svelte_component_name(:books, :index) #=> "BookIndex"
svelte_component_name(:books, :form) #=> "BookForm"
@spec svelte_component_ref(Caravela.Schema.Domain.t(), entity_name(), kind()) :: String.t()
LiveSvelte component reference — the path string passed to
<LiveSvelte.svelte name="..." />. Matches the Svelte-file path
relative to assets/svelte/, without the .svelte extension.
svelte_component_ref(domain, :books, :index) #=> "library/BookIndex"
#=> "v1/library/BookIndex" (when versioned)
@spec svelte_file_path(Caravela.Schema.Domain.t(), entity_name(), kind()) :: String.t()
Filesystem path for the generated Svelte component.
svelte_file_path(domain, :books, :index)
#=> "assets/svelte/library/BookIndex.svelte"
#=> "assets/svelte/v1/library/BookIndex.svelte" (when versioned)
@spec svelte_types_file_path(Caravela.Schema.Domain.t()) :: String.t()
Filesystem path for the generated TypeScript interfaces file.
svelte_types_file_path(domain)
#=> "assets/svelte/types/library.ts"
#=> "assets/svelte/v1/types/library.ts" (when versioned)
@spec table_name(domain_or_module(), entity_name()) :: String.t()
Postgres table name for an entity: "<context>_<entity>". Tables are
version-independent — different versions of a domain share a table.
table_name(MyApp.Domains.Library, :books) #=> "library_books"
@spec web_module(domain_or_module()) :: module()
Web module name derived from the app/context root. MyApp.Library
becomes MyAppWeb.
web_module(MyApp.Domains.Library) #=> MyAppWeb