TheDocumentation Index
Fetch the complete documentation index at: https://docs.veloiq.dev/llms.txt
Use this file to discover all available pages before exploring further.
veloiq_framework package exposes every symbol you need to build a full-stack VeloIQ application: the app factory, SQLModel base classes, a relationship wrapper with cardinality metadata, automatic CRUD router generation, role-based and row-level access control decorators, and FastAPI dependencies for auth and database sessions.
Installation
App factory
create_veloiq_app
config is omitted, VeloIQConfig is constructed from environment variables and any **kwargs you pass. The returned app is a standard FastAPI instance — you can add routes, middleware, or dependencies on top.
A
VeloIQConfig instance. If None, one is built from environment variables. See Configuration.Forwarded to
VeloIQConfig when config is not provided. Accepts the same fields as VeloIQConfig.create_veloiq_app raises ValueError if no DATABASE_URL can be determined from the config or the environment.Base models
All base classes extendSQLModel. Declare your tables by inheriting from one of these classes with table=True.
FrameworkModel
Minimal base model providing a standard auto-increment integer primary key named id. Use this when you do not need timestamp columns.
| Field | Type | Description |
|---|---|---|
id | Optional[int] | Auto-increment primary key. |
TimestampedModel
Extends FrameworkModel with automatic created_at and updated_at columns. The schema generator appends these two fields after all fields you declare, so they appear last in every list, form, and detail view.
| Field | Type | Description |
|---|---|---|
id | Optional[int] | Inherited from FrameworkModel. Auto-increment PK. |
created_at | Optional[datetime] | Set on insert. Never overwritten by CRUD updates. |
updated_at | Optional[datetime] | Updated automatically on every write. |
StandardModel
CubicWeb-compatible base model for applications that require eid as the primary key and cw_ column naming conventions. The eid Python attribute maps to the cw_eid physical column. Use this only when migrating from CubicWeb or maintaining an existing CubicWeb schema; new applications should use FrameworkModel or TimestampedModel.
| Field | Type | Description |
|---|---|---|
eid | Optional[int] | Maps to cw_eid column. Auto-increment PK. |
creation_date | Optional[datetime] | Set on insert. |
modification_date | Optional[datetime] | Updated automatically on every write. |
Relationships
jm_relationship
Relationship wrapper that attaches cardinality metadata. The DynamicResource UI component reads this metadata to render required/optional indicators and pagination hints. All **kwargs are passed through to SQLModel’s Relationship.
Minimum number of related items (used for UI validation hints).
Maximum number of related items.
None means unbounded.Whether the relation is required.
Passed directly to SQLModel’s
Relationship (e.g. back_populates, link_model).RelationCardinality
Dataclass stored in the SQLAlchemy relationship info dict by jm_relationship. You do not normally construct this directly.
| Field | Type | Default | Description |
|---|---|---|---|
min_items | int | 0 | Minimum cardinality. |
max_items | int | None | None | Maximum cardinality (None = unbounded). |
required | bool | False | Whether at least one item is required. |
get_pk_field_name
"id" if inspection fails.
CRUD router
create_crud_router
APIRouter with standard list, get, create, update, and delete endpoints for model_class. See CRUD Router for the full endpoint reference.
A SQLModel table class.
URL prefix for all routes. Defaults to
/<tablename>.OpenAPI tags. Defaults to
[<tablename>].Python type of the primary key.
Access control
VeloIQ provides three layers of declarative access control. All are opt-in and can be combined freely.Method set constants
| Constant | Value | Description |
|---|---|---|
ALL_METHODS | {"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"} | All HTTP methods. |
WRITE_METHODS | {"GET", "POST", "PUT", "PATCH", "OPTIONS", "HEAD"} | All methods except DELETE. |
READ_METHODS | {"GET", "OPTIONS", "HEAD"} | Read-only methods. |
RoleDef
RoleDef objects to VeloIQConfig.roles; they are upserted to the database on startup.
DEFAULT_ROLES
Built-in role definitions used when VeloIQConfig.roles is not overridden.
| Name | Methods | Description |
|---|---|---|
Admin | ALL_METHODS | Full administrative access. |
Manager | WRITE_METHODS | Create, edit, and view — no delete. |
Viewer | READ_METHODS | Read-only access. |
model_access
veloiq_field
pydantic.Field and stores role metadata in json_schema_extra so the schema generator emits readRoles/writeRoles into TypeScript schemas. The CRUD router enforces these restrictions at runtime.
Roles allowed to read this field. Absent means all roles can read it.
Roles allowed to write this field. Absent means all roles can write it.
Passed through to
pydantic.Field (e.g. default, description).rebac
filter, owner_field, or tenant_field must be supplied. Multiple options are OR-combined — a row is visible if any rule allows it.
A lambda
(user, cls, session) -> SQLAlchemy clause | True | False | None. Return a WHERE clause for permitted rows, True for no restriction, or False to deny all rows.Name of a column pointing to
veloiq_user.id. Shorthand for a filter that matches cls.<field> == user["eid"].Name of a column pointing to
veloiq_tenant.id. Grants access when the tenant is one the authenticated user belongs to.@rebac applies to all roles, including Admin. To exempt Admins, return True from the filter when the user has the Admin role. Inaccessible rows return 404, not 403, to avoid leaking which IDs exist.rebac_subquery
model_class rows that user may access. Designed to be called inside a @rebac(filter=…) lambda to express relationship-based access. The target model_class must itself carry a @rebac decorator. Raises ValueError on circular dependencies.
Auth utilities
get_current_user
FastAPI dependency that returns the authenticated user payload decoded from the JWT Bearer token. The payload is a dict containing at minimum sub (user ID as string) and roles (list of role names).
require_role
FastAPI dependency that raises HTTP 403 if the authenticated user does not hold at least one of the specified roles.
get_session
FastAPI dependency that yields a sqlmodel.Session bound to the configured database engine. Use it in custom endpoints that need direct database access.
Configuration
Full VeloIQConfig field reference and environment variables.
CRUD Router
Auto-generated endpoint reference and query parameter details.