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
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.
Functions
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)
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)
Association name on the child side (singular, derived).
belongs_to_name(:authors) #=> :author
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_file_path(MyApp.Domains.Library)
#=> "lib/my_app/library.ex"
context_file_path(%Domain{... version: "v1" ...})
#=> "lib/my_app/library/v1.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.
context_module(MyApp.Domains.Library) #=> MyApp.Library
context_module(%Domain{... version: "v1" ...}) #=> MyApp.Library.V1
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"
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"
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
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
Foreign-key column name ("<singular>_id").
foreign_key(:authors) #=> :author_id
Association name on the parent side (plural, matches DSL entity name).
has_many_name(:books) #=> :books
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)
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)
Plural string form of an entity name.
plural_string(:books) #=> "books"
Repo module derived by convention from the app root. MyApp.Library
becomes MyApp.Repo.
repo_module(MyApp.Domains.Library) #=> MyApp.Repo
Plural route segment for an entity.
route_path(:books) #=> "/books"
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"
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.
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)
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)
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.
svelte_component_name(:books, :index) #=> "BookIndex"
svelte_component_name(:books, :form) #=> "BookForm"
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)
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)
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)
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"
Web module name derived from the app/context root. MyApp.Library
becomes MyAppWeb.
web_module(MyApp.Domains.Library) #=> MyAppWeb