Skip to content

Intermediate Representations

Each generator in the pipeline returns a plain Rust struct. These intermediate representations (IRs) carry typed metadata from one stage to the next. There’s no magic here — just data that downstream generators use to make smarter decisions.

Returned by parse_schema(). The starting point for everything.

FieldTypeDescription
entitiesVec<EntityDef>All parsed entity definitions from your schema directory.

EntityDef and its subtypes (FieldDef, FieldType, FieldRole, RelationInfo, RelationKind) are covered in the Field Types reference.


Returned by gen_seaorm(). Describes what was generated for the persistence layer.

FieldTypeDescription
entity_tablesVec<EntityTableMeta>Table metadata for each generated entity.
junction_tablesVec<JunctionMeta>Junction table metadata for many-to-many relations.
conversion_fnsVec<ConversionMeta>Which from_model/to_active_model conversions were generated.
FieldTypeDescription
entity_nameStringRust struct name (e.g., "Workout").
table_nameStringSQL table name (e.g., "workouts").
module_pathStringRust module path for the generated SeaORM entity (e.g., "crate::persistence::db::entities::workout").
columnsVec<ColumnMeta>Column definitions for this table.
FieldTypeDescription
nameStringColumn name (e.g., "workout_id").
column_typeStringSeaORM column type as a string (e.g., "String", "Option<i32>").
is_primary_keyboolWhether this column is the primary key.
FieldTypeDescription
table_nameStringJunction table name (e.g., "workout_tags").
source_entityStringSource entity name (e.g., "Workout").
target_entityStringTarget entity name (e.g., "Tag").
source_fkStringFK column pointing to the source (e.g., "workout_id").
target_fkStringFK column pointing to the target (e.g., "tag_id").
FieldTypeDescription
entity_nameStringEntity name this conversion is for.
module_pathStringModule path where the conversion code lives.

When you pass Some(&seaorm) to gen_store, it uses the structured metadata for exact table names, column names, and junction table references instead of guessing from naming conventions. For example:

  • JunctionMeta.table_name tells it the exact junction table to sync for many-to-many updates.
  • JunctionMeta.source_fk and target_fk give exact column names for the sync_junction() calls.
  • EntityTableMeta.module_path drives the correct use statements in generated store code.

When you pass None, the store generator derives all of this from snake_case transformations of entity and field names. This works if your naming is conventional, but the structured metadata is more reliable.


Returned by gen_store(). Describes the generated CRUD layer.

FieldTypeDescription
methodsVec<StoreMethodMeta>All generated and scanned store methods.
scaffolded_hooksVec<ScaffoldMeta>Hook files that were scaffolded during this build.
change_channelsVec<ChannelMeta>Per-entity broadcast channels (when change events are enabled).
FieldTypeDescription
entity_nameStringWhich entity this method belongs to (e.g., "Workout").
nameStringMethod name (e.g., "create_workout", "list_workouts").
kindStoreMethodKindWhether it’s a standard CRUD operation or a custom method.
paramsVec<ParamMeta>Method parameters.
return_typeStringReturn type as a string (e.g., "Vec<Workout>", "Workout").
sourceSourceWhere this method came from (generated or scanned).
pub enum StoreMethodKind {
Crud(CrudOp),
Custom,
}
pub enum CrudOp {
List,
Get,
Create,
Update,
Delete,
}
FieldTypeDescription
entity_nameStringEntity this hook file belongs to.
file_pathPathBufAbsolute path to the scaffolded hook file.
functionsVec<String>Function names in the hook file (e.g., ["before_create", "after_create", ...]).
FieldTypeDescription
entity_nameStringEntity this channel is for.
subscribe_methodStringMethod name to subscribe (e.g., "subscribe_workout_changes").
event_typeStringEvent type name (e.g., "WorkoutChangeEvent").

Returned by gen_api(). The unified view of all API endpoints — both generated CRUD and hand-written custom endpoints.

FieldTypeDescription
modulesVec<ApiModule>All API modules, organized by entity/domain.
FieldTypeDescription
nameStringModule name (e.g., "workout", "reports").
fnsVec<ApiFnMeta>All functions in this module.
state_typeStateKindWhether functions in this module use AppState or Store.
FieldTypeDescription
nameStringFunction name (e.g., "create", "get_by_id", "archive").
docStringDoc comment text. Used as the MCP tool description and in future OpenAPI docs.
paramsVec<ParamMeta>Function parameters (excluding the first state/store parameter).
return_typeStringReturn type as a string (e.g., "Vec<Workout>").
sourceSourceGenerated or scanned.
classified_opOpKindOperation classification that drives HTTP verb and route structure.
pub enum StateKind {
AppState, // Function takes &AppState as first param
Store, // Function takes &Store as first param
}

Store-scoped functions get project-scoped routes when route_prefix is configured. AppState-scoped functions get unscoped routes.


Returned by gen_servers(). Describes all transport endpoints that were generated.

FieldTypeDescription
http_routesVec<HttpRouteMeta>Generated HTTP route handlers.
ipc_commandsVec<IpcCommandMeta>Generated Tauri IPC commands.
mcp_toolsVec<McpToolMeta>Generated MCP tool definitions.
FieldTypeDescription
methodStringHTTP method (e.g., "GET", "POST", "PUT", "DELETE").
pathStringRoute path (e.g., "/api/workouts", "/api/workouts/:id").
handler_nameStringHandler function name in the generated Rust code.
module_nameStringAPI module this route belongs to.
FieldTypeDescription
command_nameStringTauri command name (e.g., "get_workouts", "create_workout").
paramsVec<ParamMeta>Command parameters.
return_typeStringReturn type.
FieldTypeDescription
tool_nameStringMCP tool name (e.g., "list_workouts").
descriptionStringTool description from the API function’s doc comment.
paramsVec<ParamMeta>Parameters the tool accepts. The MCP transport generator turns these into a JSON Schema at codegen time.

Every method and function in the IR carries a Source discriminator that records whether it was generated from an EntityDef or scanned from a hand-written source file.

pub enum Source {
Generated { module_path: String },
Scanned { module_path: String, file_path: PathBuf },
}
VariantFieldsDescription
Generatedmodule_pathProduced by a codegen layer from an EntityDef. The module_path is the Rust path to the generated module (e.g., "crate::api::v1::generated::workout").
Scannedmodule_path, file_pathParsed from a hand-written source file. file_path points to the original .rs file on disk.

Downstream generators use Source to emit correct use statements. A Generated function is imported from the generated module path. A Scanned function is imported from its original location.

Classifies what kind of operation an API function represents. This drives HTTP verb selection, route structure, and parameter handling in transport generators. Defined in ontogen_core::ir::OpKind and re-exported as ontogen::OpKind.

pub enum OpKind {
List,
GetById,
Create,
Update,
Delete,
JunctionList { child_segment: String },
JunctionAdd { child_segment: String },
JunctionRemove { child_segment: String },
CustomGet,
CustomPost,
EventStream,
}
VariantHTTP MethodRoute PatternDescription
ListGET/entitiesReturns all entities.
GetByIdGET/entities/:idReturns one entity by ID.
CreatePOST/entitiesCreates a new entity.
UpdatePUT/entities/:idUpdates an existing entity.
DeleteDELETE/entities/:idDeletes an entity.
JunctionList { child_segment }GET/parents/:parent_id/{child_segment}List child entities of a parent through a junction.
JunctionAdd { child_segment }POST/parents/:parent_id/{child_segment}Add a child to a parent through a junction.
JunctionRemove { child_segment }DELETE/parents/:parent_id/{child_segment}/:child_idRemove a child from a parent through a junction.
CustomGetGET/entities/:actionCustom read operation with non-standard parameters.
CustomPostPOST/entities/:actionCustom write operation with non-standard parameters.
EventStreamGET (SSE)/events/:nameServer-Sent Events stream.

OpKind is assigned automatically during API scanning based on function name patterns and parameter shapes. For generated CRUD functions, the mapping is direct. Junction operations are recognized by name prefixes like list_*/add_*/remove_* paired with parent+child id parameters. For other scanned custom functions, the classifier looks at the function name prefix (get_* becomes CustomGet, others become CustomPost) and whether the return type looks like a stream.

A function or method parameter, shared across store, API, and server IRs.

FieldTypeDescription
nameStringParameter name (e.g., "id", "input").
param_typeStringRust type as a string (e.g., "&str", "CreateWorkoutInput").