Documentation of the FireBIM system architecture, backend capabilities, rule and graph execution model, lexicon layer, IFC/IDS workflows, authentication model, and operational API surface.
Architecture documentation. This document describes the open source FireBIM reference platform also known as the "backend system": the technical layers, runtime services, rule graph and check execution model, lexicon architecture, IFC and IDS workflows, and the authentication, admin, user, and security model. The chapters are organized for developers first, while still giving product, audit, and domain readers a coherent view of how FireBIM turns building data, rules, ontologies, and checks into explainable API capabilities.
Chapter 01
Backend Architecture Overview
# FireBIM Backend Architecture Overview
Source scope: firebim-api-server architecture view documents. Purpose: provide the executive and technical entry point for the static HTML architecture document.
Scope And System Boundary
The FireBIM backend is a graph-oriented API platform for BIM compliance workflows. It accepts source artifacts, stores graph-compatible domain data, exposes ontology-aware interpretation services, and executes traceable rule checks over building graph data.
The backend boundary includes:
API services exposed through FastAPI routers
authentication and user ownership through Authentik-backed JWT validation
file and metadata workflows for IFC and IDS artifacts
graph publication and schema extraction
stable rule artifacts and rule element composition
check execution with explicit true, false, and unknown paths
ontology-aware Lexicon services for catalogs, mappings, profiles, handshakes, reconstruction, and conformity
storage through PostgreSQL, S3/MinIO, and graph-store datasets
asynchronous worker execution through Celery and RabbitMQ
The backend boundary does not include the future firebim-webapp architecture. Frontend behavior is referenced only where it consumes or enforces backend capabilities.
Architecture Principles
The backend is organized around explicit boundaries and clear trade-offs:
The API layer exposes resource-oriented endpoints and typed contracts.
Domain modules own business behavior rather than pushing domain logic into routers.
Durable artifacts are separated by storage type: relational metadata, object storage, graph datasets, and user-scoped JSON documents.
Long-running or file-heavy work is moved to workers.
Rule execution prioritizes explainability over raw speed.
Unknown outcomes are modeled explicitly by rule authors instead of being treated as accidental engine failures.
Ontology drift is handled through Lexicon mapping and transformation capabilities rather than by rewriting stable rule artifacts.
Security is layered through external identity, token validation, local user projection, ownership checks, and future explicit admin policy.
flowchart TB
clients["Clients and API consumers"] --> api["FastAPI backend"]
api --> auth["Authentication and users"]
api --> ifcids["IFC and IDS artifacts"]
api --> graphs["Building graphs"]
api --> rules["Rules and rule elements"]
api --> checks["Checks runtime"]
api --> lexicon["Lexicon and ontology adaptation"]
ifcids --> worker["Celery worker"]
worker --> objectStorage[("S3 / MinIO")]
api --> objectStorage
api --> postgres[("PostgreSQL")]
graphs --> graphStore[("Graph datasets")]
rules --> graphStore
checks --> graphStore
lexicon --> objectStorage
This static architecture document also points to the API architecture view document firebim-api-staging-architecture view.html.
Reading Guide
This HTML document is composed from the source Markdown files in this architecture documentation set:
1. architecture-architecture view.md describes the assembled technical shape of the backend. 2. rules-graphs-checks-synergies.md explains the core rule/graph/check execution model. 3. lexicon-architecture.md explains ontology-aware adaptation and reconstruction. 4. ifc-ids-architecture.md explains file-based BIM interoperability and worker processing. 5. authentication-admin-users-security.md explains identity, users, admin posture, and security.
The sections are intentionally layered from high-level context to component details. This mirrors the backend architecture itself: system boundary first, then services, persistence, execution flows, and security posture.
Chapter 02
Backend Technical Architecture
FireBIM API Server Architecture
assembled: 2026-05-20T09:40:45+00:00 Source: C:\Users\krnj\OneDrive - Danmarks Tekniske Universitet\Dokumenter\Software\FireBIM\firebim-api-server
This architecture view describes the current technical shape of firebim-api-server. It is assembled from the codebase and is intended as a repeatable architecture baseline: high-level first, then runtime containers, API surface, internal modules, data flow, and assembled evidence.
The document is declarative. It states what the current system structure is, based on the scanned repository. Curated architecture analysis can build on top of this architecture view, but the architecture view itself remains grounded in source files, Docker Compose, Kubernetes manifests, FastAPI routers, Python imports, and project metadata.
1. Architectural Role
firebim-api-server is the backend boundary for FireBIM. It exposes HTTP APIs, authenticates users through OIDC/JWT integration, stores and retrieves graph-oriented artifacts, compiles and executes rule checks, and coordinates local runtime dependencies such as PostgreSQL, MinIO/S3, RabbitMQ, and Authentik.
The API server is not only a CRUD service. It is a graph-oriented application layer for rules, building graphs, ontology/lexicon resources, and check execution.
flowchart LR
user["FireBIM user / client"]
api["FireBIM API server"]
auth["Authentik OIDC"]
db[("PostgreSQL")]
s3[("MinIO / S3 object storage")]
mq[("RabbitMQ broker")]
user --> api
api --> auth
api --> db
api --> s3
api --> mq
2. Technical Layers
The backend is organized around clear technical layers. Requests enter through FastAPI routers, move into domain modules, use repositories and infrastructure clients for persistence, and return typed schema responses.
The local runtime is defined by Docker Compose. The API container depends on durable storage, object storage, message broker infrastructure, and identity infrastructure. The Celery worker shares key backend dependencies and executes background work through the configured broker.
A normal API request enters FastAPI, receives request context and observability metadata, reaches a router, calls domain logic, and uses repositories or runtime engines to perform the work. Responses are returned through typed schemas or explicit response classes.
sequenceDiagram
participant Client
participant FastAPI
participant Router
participant Domain
participant Storage
participant Runtime
Client->>FastAPI: HTTP request
FastAPI->>FastAPI: request id and observability context
FastAPI->>Router: route handler
Router->>Domain: service / engine call
Domain->>Storage: repository read/write when needed
Domain->>Runtime: compile, evaluate, parse, or transform when needed
Runtime-->>Domain: computed result
Storage-->>Domain: persisted artifact or metadata
Domain-->>Router: domain result
Router-->>Client: typed response
This flow is visible in app/main.py, where routers are registered and request observability middleware wraps each request.
5. API Surface
The API surface is grouped by FastAPI routers. Each router maps a bounded functional area to a URL prefix. The current architecture view detects 11 routers and 118 route decorators.
GET /checks/health<br>POST /checks/run<br>POST /checks/run-vertical<br>POST /checks/run-horisontal<br>POST /checks/run-diagnostic<br>POST /checks/run-blind<br>POST /checks/compatibility
/graphs
app.api.graphs
6
GET /graphs/health<br>GET /graphs<br>POST /graphs/publish<br>DELETE /graphs/{graph_id}<br>GET /graphs/{graph_id}<br>POST /graphs/extract-schema
/
app.api.health
1
GET /health
/ids-files
app.api.ids
4
POST /ids-files<br>GET /ids-files/{id}<br>GET /ids-files<br>GET /ids-files/{id}/download
/lexicon
app.api.lexicon
41
GET /lexicon/health<br>GET /lexicon/catalog/{ontology_family}/{country}/{version}/terms<br>GET /lexicon/catalog/{ontology_family}/{country}/{version}/terms/{term_id}<br>POST /lexicon/catalog/resolve-terms<br>POST /lexicon/catalog/compare<br>POST /lexicon/catalog/similarity<br>POST /lexicon/catalog/similarity-matrix<br>POST /lexicon/catalog/rule-ontology-similarity<br>... 33 more
/ifc-models
app.api.models
4
POST /ifc-models<br>GET /ifc-models/{id}<br>GET /ifc-models<br>GET /ifc-models/{id}/download
/ontologies
app.api.ontologies
20
GET /ontologies/health<br>POST /ontologies/publish<br>POST /ontologies/conversions/dictionary-json-to-ttl<br>POST /ontologies/candidates/dictionaries<br>GET /ontologies/candidates/dictionaries<br>GET /ontologies/candidates/dictionaries/{candidate_id}<br>GET /ontologies/candidates/dictionaries/{candidate_id}/summary<br>GET /ontologies/candidates/dictionaries/{candidate_id}/json<br>... 12 more
/rulebuilder
app.api.rulebuilder
8
POST /rulebuilder/workspaces<br>POST /rulebuilder/rules/{rule_id}/workspace<br>PUT /rulebuilder/workspaces/{workspace_id}<br>GET /rulebuilder/workspaces<br>GET /rulebuilder/workspaces/{workspace_id}<br>DELETE /rulebuilder/workspaces/{workspace_id}<br>POST /rulebuilder/workspaces/delete-batch<br>POST /rulebuilder/workspaces/{workspace_id}/export-rule-elements
/rules
app.api.rules
25
GET /rules/health<br>POST /rules/validate<br>POST /rules/compile<br>POST /rules/decompile<br>POST /rules/publish<br>GET /rules/list<br>POST /rules/fetch<br>POST /rules/delete<br>... 17 more
/
app.auth.router
1
GET /users/me
The API surface currently exposes capabilities for authentication, health/build metadata, model and IDS file handling, graph publication, ontology workflows, lexicon workflows, rule authoring, rule publishing, rulebuilder workspaces, and check execution.
6. Internal Components
The internal module graph collapses app.* imports to first-level packages. This keeps the assembled diagram high-level enough for architecture review while still showing actual dependency direction from the codebase.
app.checks: check compilation, solver selection, runtime execution, diagnostics, and result models.
app.storage: repositories and graph/object persistence adapters.
app.lexicon and app.ontologies: vocabulary, ontology, mapping, and query-oriented domain logic.
app.workers: asynchronous worker entrypoint and Celery application setup.
7. Data And Storage Flow
Durable state is represented through repository modules, PostgreSQL-backed models, S3/MinIO object storage, RDF/TTL resources, and assembled ontology/demo content bootstrapping.
flowchart LR
api["API routes"]
checks["Checks engine"]
rules["Rules / DSL / SHACL"]
lexicon["Lexicon and ontology runtime"]
storage["Repository layer"]
db[("PostgreSQL")]
s3[("S3 / MinIO")]
rdf[("RDF / TTL resources")]
api --> checks
api --> rules
api --> lexicon
checks --> storage
rules --> storage
lexicon --> storage
storage --> db
storage --> s3
lexicon --> rdf
The storage model is graph-oriented. Rules, building graphs, ontology resources, lexicon mappings, and assembled demo content are treated as artifacts that can be published, fetched, transformed, and analyzed.
8. Rules, Graphs, And Checks Layer
Rules, Graphs, and Checks form a core architecture axis in the API server.
This layer is described in detail in rules-graphs-checks-synergies.md. In this architecture view the layer is represented as a technical fact: rules and building graphs are stored as graph-compatible artifacts, and checks execute one against the other with compatibility, compilation, solver selection, and diagnostics.
9. Architecture Evidence
The architecture view is assembled from these source signals:
The architecture document directory contains this Markdown file, a machine-readable inventory.json, and standalone Mermaid diagram files under diagrams/.
The standalone diagram files are:
01-system-context.mmd
02-container-view.mmd
03-api-routes.mmd
04-python-modules.mmd
05-data-flow.mmd
These files can be embedded in documentation systems or rendered independently when a Markdown renderer does not support Mermaid directly.
Chapter 03
Rules, Graphs And Checks
# Rules, Graphs And Checks: Architecture, Synergies, And Product Potential
Source: firebim-api-server Primary audience: developers building and extending FireBIM. Frontend experiences, rule-authoring tools, product workflows, and audit-facing views are built on top of this architecture.
Purpose
FireBIM uses rules, graphs, and checks as three connected architectural concepts:
Graphs describe building data as RDF/Turtle graph data.
Checks execute a selected rule against a selected building graph and return transparent, traceable outcomes.
The architecture is graph-oriented by design. Rules and building data are both represented as graph-compatible artifacts, which allows FireBIM to reason about requirements, available data, missing information, ontology mappings, runtime behavior, and explainability in one connected model.
System Model
The system flow is:
1. Rule authoring sends rule definitions to the Rules API. 2. Building graph import sends building graph TTL to the Graphs API. 3. The Rules API stores rule TTL in the rulebook dataset. 4. The Graphs API stores building graph TTL in the buildings dataset. 5. The Checks API fetches both artifacts, computes compatibility, compiles the rule, selects a solver, and returns traceable results.
The model has a deliberate separation of concerns:
Rules define what can be evaluated and how every branch behaves.
Graphs define what building information exists.
Checks determine how a rule behaves against a specific building graph.
This separation allows FireBIM to validate rule structure, inspect building data readiness, execute checks, and explain outcomes without collapsing all logic into one opaque validation step.
Rules
Rules are stable compliance artifacts. They can exist in many versions, and those versions can later be transformed, migrated, or mapped when ontologies evolve. The lexicon architecture is the natural place for ontology-aware rule transformation and mapping; that topic belongs in a separate document.
Rules API responsibilities include:
validating rule payloads
compiling rule payloads to SHACL/Turtle
publishing full rules to the rulebook dataset
publishing reusable rule elements
fetching and decompiling rules back into structured JSON-like data
assembling rules from stored rule elements
connecting and disconnecting rule branches
checking rule completeness
extracting target classes, property paths, and target/property pairs
Rules are not only stored. They are analyzable graph artifacts.
A rule element contains explicit branch behavior. Decision nodes include true, false, and unknown paths. This is a core FireBIM design decision and not a conventional SHACL-only interpretation.
Unknown is a first-class rule outcome. It is not an accidental runtime failure.
FireBIM assumes that users and building models may not contain all information required by a rule. A rule author with domain knowledge decides what happens when information cannot be found. Every unknown must therefore have an explicit path in the rule graph.
Examples of valid unknown behavior:
Stop with a terminal message such as: “Unknown: please provide the room area; the rule cannot continue without it.”
Continue into a conservative branch such as “treat the room as below 50 m2 when area is missing.”
Route to a domain-specific assessment path that asks for further clarification.
This makes unknown behavior transparent and intentional. The runtime does not guess what missing information means. The rule graph encodes the decision.
This supports the intended FireBIM modeling strategy: trust and validity are built one step at a time. Authority rules often contain many scenarios, exceptions, and assessments. FireBIM can eventually model complete rule sets with all scenarios and all combinations, but the practical path is incremental rule construction where each explicit decision can be inspected, tested, and trusted.
Graphs
Graphs represent building data as RDF/Turtle artifacts in the buildings dataset.
Graphs API responsibilities include:
publishing building graph TTL
fetching building graph TTL
deleting building graphs
listing available building graphs
checking storage health
extracting graph schema information
Graph schema extraction is central to the architecture. It identifies:
observed classes
observed properties
class-to-class edges
forward and reverse predicates by class pair
warnings about schema extraction issues
This allows FireBIM to understand what a building graph can support before or during check execution.
Checks
Checks connect one rule artifact with one building graph artifact.
Checks API responsibilities include:
fetching rule TTL from rulebook
fetching building graph TTL from buildings
computing compatibility between required rule terms and observed graph terms
compiling rule TTL into FireBIM runtime structures
selecting and running a solver
returning summaries, target traces, terminal outputs, timings, diagnostics, and compatibility data
A check result is not just pass/fail. It is an explainable traversal of rule logic over building data.
SHACL And FireBIM Solvers
SHACL is a central architectural choice because it is graph-oriented, standardized, and usable outside the FireBIM backend. Rules can be serialized as Turtle and understood as graph artifacts, which supports interoperability, auditability, and future integration with other graph-based systems.
FireBIM also extends the execution model with explicit unknown paths. This is why the backend contains custom solvers. Standard SHACL validation alone does not express the full FireBIM rule traversal model where true, false, and unknown are all explicit domain decisions.
The current solver entrypoint is app.checks.solver_selector.CheckSolverSelector, which builds a CheckEngine with one of three implemented runtime strategies.
Solver: Standard
Source module: app.checks.runtime.CheckRuntime
Standard solver flow:
1. Rule TTL is compiled by RuleCompiler into a CompiledRuleSet. 2. Building graph TTL is loaded and target nodes are resolved by TargetResolver. 3. CheckRuntime traverses the compiled rule graph for each target. 4. Each decision node evaluates evidence and follows the explicit true, false, or unknown branch. 5. The runtime returns a RuleRunResult with summaries, traces, evidence, and terminal outcomes.
The standard solver is the default compiled runtime traversal. It compiles rule TTL, resolves targets in the building graph, evaluates decision nodes, follows true/false/unknown branches, and produces a traceable result.
The standard solver is the baseline implementation. It is the easiest mode to reason about, debug, and compare against other solver strategies.
1. All relevant targets are grouped for evaluation. 2. The runtime evaluates one decision layer across the target set. 3. Targets are grouped by branch outcome. 4. The next decision layer is evaluated for each branch group. 5. Terminal outcomes are aggregated by target, branch, and end node.
The horizontal solver evaluates rule logic layer by layer across many targets. It is designed for situations where many building objects move through similar decision stages.
This strategy creates room for performance improvements because work can be grouped by decision layer, target class, property path, and branch outcome. It is also useful for aggregate diagnostics because many targets are evaluated in comparable batches.
1. A target enters the rule graph at the entry node. 2. The runtime evaluates the current decision node. 3. The selected branch determines the next node. 4. The target continues through the pathway until it reaches a terminal outcome. 5. The result preserves the pathway as an explanation trace.
The vertical solver walks pathway segments through the rule graph. It emphasizes step-by-step traversal and is well aligned with explainability.
This strategy is useful when FireBIM needs to show how a specific building object reached a specific terminal outcome. It supports transparent reasoning from requirement to rule node, from rule node to observed evidence, and from observed evidence to pass, fail, or unknown.
1. Rule TTL and building graph TTL are passed into the SHACL construct runner. 2. The runner executes the construct-oriented validation path. 3. The output contains terminal outputs and aggregate counts. 4. The output does not contain the same per-target decision trace as the compiled FireBIM runtimes.
The blind SHACL construct runner is an alternative execution path. It returns terminal outputs and aggregate counts, but it does not provide the same per-target decision trace as the FireBIM compiled runtimes.
This mode is valuable as a comparison point, benchmark path, and interoperability-oriented execution mode. It is not the primary explanation model.
Explainability First
Checks optimize for explainability before raw speed.
FireBIM is built for transparent validation. A user must be able to understand why a rule passed, failed, or followed an unknown path. Performance remains important, and the multiple solver strategies create room for commercial optimization, open-source experimentation, and future runtime innovation. The architectural priority is still clear: validation must be inspectable and trustworthy.
Compatibility And Readiness
Compatibility is the bridge between rule structure and graph structure.
Compatibility flow:
1. The rule graph exposes required target classes and required properties. 2. The building graph exposes observed classes, properties, and class-to-class edges. 3. Compatibility analysis compares required terms with observed terms. 4. The result becomes a readiness signal for execution, authoring feedback, data-quality feedback, and frontend workflow decisions.
The backend already supports compatibility analysis through /checks/compatibility. This compares required rule classes and properties against observed graph classes and properties.
Compatibility is a backend capability. Whether compatibility blocks execution is a frontend and product decision. The backend exposes the signal; the frontend decides how strongly to enforce it in a specific workflow.
Compatibility supports:
rule readiness checks
graph readiness checks
authoring feedback
data-quality feedback
namespace and ontology mapping workflows
solver selection inputs
Rule Authoring Synergy
Rules and graph schema extraction together enable data-aware rule authoring.
A frontend can use the backend architecture to show:
target classes that actually exist in selected building graphs
property paths observed for a selected target class
rules that cannot currently run meaningfully on a selected graph
rule elements that are reused across multiple rules
target/property pairs shared by related rules
namespace drift between rule terms and graph terms
This turns rule authoring into an evidence-based workflow. The rule author still makes the domain decision, but the system exposes the available data and the consequences of missing data.
Unknown As User-Defined Behavior
Unknown does not automatically count as a compliance failure. Unknown is user-defined rule behavior.
The rule author decides whether missing data:
stops execution
routes to a conservative branch
routes to a request-for-information branch
routes to an alternative assessment path
routes to an explicit failure or explicit pass
The compliance meaning of unknown is therefore encoded in the rule graph. FireBIM does not impose one global interpretation.
This is a major difference from validation systems where missing data is treated as an implicit failure, warning, or engine error. In FireBIM, missing data is part of the modeled decision process.
Traceability From Requirement To Building Object
Traceability flow:
1. A requirement is represented by a stable rule artifact. 2. The rule artifact is compiled into rule nodes. 3. A rule node evaluates a building object. 4. The evaluator reads observed evidence from the building graph. 5. The evidence selects a true, false, or unknown branch. 6. The branch leads to a terminal outcome with an explainable path.
Traceability From Requirement To Building ObjectOpen full screenCloseDiagram definition
regression testing between building graph versions
comparison between rule versions
The check result can explain not only what happened, but where in the rule graph it happened and which building data caused that path.
Versioned Rule Artifacts And Ontology Change
Rules are stable artifacts, but they are not frozen forever. They can exist in many versions and be transformed when ontology terms change.
The lexicon layer is the architectural foundation for mapping and transformation. It can support workflows such as:
adapting rules to ontology updates
mapping rules from one ontology family to another
comparing term usage across rule versions
identifying local-name collisions and namespace drift
preserving stable compliance semantics while changing the underlying vocabulary
This topic requires its own document because it connects rules, lexicon, ontology management, and transformation strategy.
Product Capabilities Built On This Architecture
The architecture enables several concrete capabilities.
Compatibility Matrix
A compatibility matrix compares multiple rules against one graph or multiple graphs against one rule.
It contains:
required target classes
required properties
observed matching classes
observed matching properties
missing terms
compatibility score
readiness status
This is the natural foundation for “which checks can this model support?” workflows.
Graph Readiness
Graph readiness evaluates whether a building graph contains enough information to support a selected rule package.
It can answer:
which rules are ready to run
which rules will likely route to unknown
which missing properties affect the largest number of rules
which ontology mappings would unlock the most checks
Rule Readiness
Rule readiness evaluates whether a rule is complete, executable, versioned, and compatible with selected building graph schemas.
It combines:
branch completeness
entry node validity
terminal node coverage
target/property availability
ontology mapping status
Unknown Reason Classification
Unknown reason classification makes unknown outcomes actionable.
A check can classify unknown paths by cause:
missing target class
missing property
property exists but not on the relevant target
datatype mismatch
relationship/pathway not present
explicitly modeled request for information
explicitly modeled conservative assumption
The classification belongs in the result model and supports frontend explanation, reporting, and model improvement workflows.
Solver Recommendation
Solver recommendation selects the most appropriate runtime strategy based on rule structure, graph shape, target count, and output needs.
The decision model can use:
number of targets
number of decision nodes
rule graph depth
branch fan-out
required trace detail
diagnostic mode
graph schema complexity
The recommendation remains explainability-first. Performance is optimized within that constraint.
Architectural Position
FireBIM rules are graph-native, stable, versioned artifacts with explicit unknown behavior. FireBIM building models are graph-native data artifacts. FireBIM checks are transparent executions that connect these artifacts and expose both results and reasoning.
The system is not only a validation engine. It is a platform for rule authoring, graph readiness, compliance traceability, ontology-aware transformation, and explainable model checking.
Chapter 04
Lexicon Architecture
# Lexicon Architecture: Ontology-Aware Rules, Mappings, And Evidence
Source: firebim-api-server Primary audience: developers building and extending FireBIM.
Purpose
The Lexicon layer is the ontology-aware interpretation layer in FireBIM. It connects rules, ontology catalogs, building graph evidence, mappings, and user-confirmed reconstruction workflows.
The Lexicon is not only a term lookup API. It is the backend layer that makes rule execution portable across vocabularies, countries, ontology versions, and model data realities.
Lexicon supports these core responsibilities:
expose ontology terms as navigable catalogs
resolve and compare terms across selected ontologies
score similarity between terms and between rules and ontologies
derive execution profiles from rules
evaluate whether profiles are covered by building graphs
validate and persist mappings
support handshakes where users accept evidence and mappings
reconstruct canonical graph data from accepted lexicon evidence
check reconstructed graph conformity against expected ontology/profile requirements
Catalog terms are not simple labels. A term can expose structural relationships that frontend tools and rule authoring flows can use directly:
Term field
Meaning
term_id and uri
Local and fully qualified identity
kind
Class or property
label, definition, description
Human-facing term metadata
parent_term_ids, child_term_ids
Class hierarchy navigation
property_term_ids
Properties associated with a class or property set
property_set_term_ids
Property sets that contain or relate to the term
belongs_to_class_term_ids
Classes associated with a property
related_property_term_ids
Explicit related-property metadata
unit
Expected unit metadata when available
is_property_set
Class-like property grouping
is_predefined_type
Class-like predefined type marker
Term Resolution And Similarity
Lexicon can build a merged runtime from selected ontologies. The merged runtime is used for term resolution, similarity scoring, and graph evidence interpretation.
Term resolution supports direct URI matches, exact term IDs, exact labels, contains matches, and definition-based matches. Similarity scoring compares catalog terms through multiple components rather than treating ontology mapping as a raw string comparison problem.
This is important for FireBIM because rule terms can be stable compliance concepts while ontology terms evolve over time or differ across countries and ontology families.
Rule-Ontology Similarity
Lexicon can compare rule terms against selected ontologies. It extracts target classes and property paths from rules, resolves them against ontology catalogs, and returns matches and summary scores.
This capability is the foundation for ontology migration and mapping workflows. It can identify which rule terms already align with a target ontology and which terms require mapping or transformation.
Execution Profiles
A Lexicon execution profile is a structured view of what a rule needs from a graph. It is derived from one or more rules and contains:
flowchart LR
ruleSource["Rule id, rule ids, rule draft, or rule drafts"] --> load["Load and normalize rules"]
load --> decompile["Decompile rule TTL when needed"]
decompile --> profile["LexiconExecutionProfile"]
profile --> summary["Profile summary"]
profile --> storage["Optional stored profile"]
Execution profiles are the bridge between authoring and evidence. They describe the information that rules require without running the full check engine.
Profile Coverage
Stored or derived profiles can be checked against rules and building graphs.
Rules Coverage
Rules coverage compares a base profile against one or more rules. It answers whether those rules are fully supported, partially supported, or unsupported by the profile.
Graph Coverage
Graph coverage compares an execution profile against a building graph evidence summary. It answers which target classes and required properties are present in the graph, and which are missing.
flowchart LR
source["Source term or source pattern"] --> mapping["Lexicon mapping"]
mapping --> target["Target term or target assertions"]
graph["Building graph"] --> evaluate["Evaluate mapping"]
mapping --> evaluate
evaluate --> matches["Matched source objects"]
evaluate --> missing["Missing conditions"]
Mappings are validated before persistence. Validation checks that source and target terms resolve to the expected kind and that pattern/assertion shapes are structurally valid.
Handshakes
A handshake stores the user's accepted interpretation of rule needs, evidence, mappings, and target objects.
The handshake workflow is the explicit human-in-the-loop part of Lexicon. It allows FireBIM to ask for missing or ambiguous evidence, let the user accept mappings and targets, and then reconstruct canonical graph data from the accepted payload.
The next-needed operation compares the accepted payload against the profile and returns remaining target classes or properties. This makes missing information actionable and explicit.
Reconstruction And Conformity
Lexicon reconstruction builds canonical RDF/Turtle graph data from accepted entities or handshake evidence.
Reconstruction inputs can come from:
explicit LexiconEntityInput values
accepted handshake targets
mapping-derived target assertions
evidence values accepted by the user
Conformity checks validate reconstructed TTL against the selected ontology context and, optionally, an expected execution profile.
Lexicon does not replace Rules, Graphs, or Checks. It makes them more portable and explainable.
Layer
Lexicon contribution
Rules
Extracts execution profiles and rule terms, supports ontology similarity and future rule transformation
Graphs
Summarizes observed evidence and measures profile coverage
Checks
Provides readiness, mapping, and reconstructed canonical graph inputs that can improve check execution
Frontend
Supplies term catalogs, mapping candidates, next-needed prompts, and user-confirmed evidence workflows
The Lexicon is therefore the natural home for ontology migration and rule transformation work. Stable rule artifacts can remain compliance artifacts while Lexicon provides the machinery to adapt their vocabulary to evolving or alternative ontologies.
/profiles/derive, /profiles/summary, /profiles, /profiles/{id}, coverage and mapping candidate endpoints
Reconstruction and conformity
/reconstruction, /conformity/check
Architectural Position
Lexicon is the ontology-aware adaptation layer in FireBIM. It keeps the rule system stable while allowing ontology terms, country variants, building graph evidence, and user-approved mappings to evolve.
The layer supports a key product principle: FireBIM can build trust step by step. A rule can define what it needs, Lexicon can expose what the ontology and building graph can provide, the user can accept or add evidence, and the backend can reconstruct canonical graph data for transparent validation.
Chapter 05
IFC And IDS
# IFC And IDS Architecture: Source Models, Specifications, And Graph-Native Validation
Source: firebim-api-server Primary audience: developers building and extending FireBIM.
Purpose
IFC and IDS represent the file-based BIM interoperability layer in FireBIM.
IFC files provide source building model data.
IDS files provide exchange requirements and model checking specifications.
FireBIM Graphs provide the graph-native representation used by Rules, Lexicon, and Checks.
FireBIM Rules provide explicit decision logic, including true, false, and unknown paths.
The current backend supports IFC and IDS as uploaded user-owned artifacts stored in S3/MinIO and tracked in PostgreSQL. IFC files can be processed asynchronously by a Celery worker with IfcOpenShell. The worker also contains an IDS validation task using IfcTester.
The strategic architecture is that IFC and IDS are not the final validation model. They are important source and interoperability formats that can feed FireBIM's graph-native rule, lexicon, and check architecture.
sequenceDiagram
participant Client
participant API as IFC API
participant S3 as S3 / MinIO
participant DB as PostgreSQL
participant Celery
participant Worker
Client->>API: Upload .ifc file
API->>API: Validate .ifc extension
API->>S3: Store models/{model_id}/{filename}
API->>DB: Create IfcModel row with pending status
API->>Celery: Queue process_model(model_id, s3_key)
API->>DB: Store task id and processing status
Celery->>Worker: Execute process_model
Worker->>S3: Download IFC source file
Worker->>Worker: Parse with IfcOpenShell
Worker->>S3: Store results/{model_id}/stats.json
Worker->>DB: Mark model processed and store result_key
The current worker processing extracts a simple object count by IFC element type. This establishes the asynchronous processing pipeline and proves that IFC files can be opened and inspected in the worker runtime.
Current IFC metadata includes:
Field
Meaning
id
Stable model identifier
filename
Original uploaded filename
s3_key
Object storage location
user_id
Owner used for authorization
processed
Worker processing completion flag
task_id
Celery task id
result_key
S3 key for assembled processing result
processing_status
Pending/processing style status field
created_at, updated_at
Metadata timestamps
IDS File Lifecycle
The IDS upload lifecycle is implemented by /ids-files.
1. Download the IFC file from S3/MinIO. 2. Download the IDS file from S3/MinIO. 3. Open the IFC model with IfcOpenShell. 4. Open and validate the IDS file with IfcTester. 5. Run the IDS validation against the IFC model. 6. Produce a JSON report with ifctester.reporter.Json. 7. Store the check result JSON in S3/MinIO under checks/{check_id}/result.json.
The current API layer does not expose a dedicated endpoint that starts check_model_with_ids. The task exists in the worker layer and the CheckResult table exists as a persistence shape, but the public orchestration endpoint is not part of the current implemented router surface.
File-Based Validation And Graph-Native Validation
IFC/IDS validation and FireBIM graph-native checks solve related but different problems.
Validation path
Primary input
Execution model
Output shape
IFC + IDS
IFC STEP file and IDS XML file
IfcTester validation
IDS-oriented JSON report
FireBIM Graphs + Rules
Building graph TTL and rule TTL
FireBIM compiled solvers
Traceable pass/fail/unknown results
Lexicon-assisted path
Building evidence, ontology terms, mappings, profiles
Ontology-aware reconstruction and coverage
Canonical graph readiness and conformity
The file-based path is valuable for interoperability and standards alignment. The graph-native path is valuable for explicit rule traversal, explainability, unknown handling, ontology transformation, and long-term FireBIM compliance workflows.
Bridge To Graphs
The current Graphs layer expects building graph Turtle published to the buildings dataset. IFC source files are not yet automatically converted into building graph TTL by the current IFC upload endpoint.
This bridge turns IFC from a file artifact into graph-native FireBIM evidence. Once a building graph exists, the existing Rules, Lexicon, and Checks layers can evaluate it.
Bridge To Lexicon
Lexicon is the natural adaptation layer between IFC terms and FireBIM rule terminology.
The codebase already contains IFC ontology resources and Lexicon support for:
IFC catalog browsing through ontology_family=ifc
rule-ontology similarity against IFC terms
graph evidence summaries using selected ontologies
mappings from source IFC terms or patterns to target ontology assertions
handshake workflows where users accept evidence and mappings
canonical graph reconstruction and conformity checks
This is the key FireBIM direction: IFC can remain a source/interoperability format while Lexicon and Graphs provide the vocabulary adaptation and execution substrate.
Bridge To IDS
IDS is a standardized way to express information delivery requirements for IFC models. FireBIM can use IDS in two complementary ways.
IDS As Direct Validation Artifact
The worker can run IfcTester directly against IFC and IDS files. This produces an IDS-oriented report that is useful for standards-aligned validation.
IDS As Rule And Profile Input
IDS can also be treated as a source of structured requirements that can inform FireBIM rules or Lexicon profiles. In this direction, IDS requirements become part of the graph-native readiness and rule authoring workflow.
The current backend stores IDS files and contains worker support for IfcTester validation. IDS-to-FireBIM-rule transformation is a future architecture capability rather than an implemented API flow in the current code architecture view.
Relationship To Rules, Graphs, Checks, And Lexicon
Layer
IFC/IDS role
IFC Models
Source model files uploaded by users; parsed asynchronously by worker tasks
IDS Files
Source specification files uploaded by users; usable for IfcTester validation
Graphs
Target graph-native building representation used by FireBIM Checks
Rules
Stable FireBIM compliance artifacts with explicit true/false/unknown behavior
Checks
FireBIM graph-native execution against published building graphs and rules
Lexicon
Ontology mapping and reconstruction layer between IFC/FBO/RIR/national vocabularies
IFC and IDS are therefore not isolated upload features. They are the outer interoperability layer around the graph-native FireBIM architecture.
Counts IFC elements by type and stores result JSON
Worker validation
check_model_with_ids
Runs IfcTester validation and stores result JSON
Technical Dependencies
The worker dependency group includes:
ifcopenshell==0.8.5
ifctester==0.8.5
bcf-client==0.8.5
The API image installs the default backend dependencies. The worker image installs the additional worker dependency group, which is where IFC/IDS processing libraries are available.
Architectural Position
IFC and IDS are the standards-facing input layer for FireBIM. They provide compatibility with BIM authoring and information delivery workflows. FireBIM's deeper validation model is graph-native: IFC-derived evidence should be transformed into building graphs, IDS-derived requirements can inform profiles or rules, and Lexicon provides the vocabulary adaptation between source standards and FireBIM's stable rule artifacts.
The long-term architecture is not IFC versus graphs or IDS versus rules. It is a layered model:
1. IFC and IDS provide interoperable source artifacts. 2. Workers parse, validate, and extract evidence. 3. Lexicon maps and reconstructs canonical graph data. 4. Graphs store building evidence as RDF/Turtle. 5. Rules define explicit compliance logic. 6. Checks execute traceable validation with true, false, and unknown paths.
Chapter 06
Authentication, Admin, Users And Security
# Authentication, Users, Admin, And Security Architecture
Source: firebim-api-server Primary audience: developers building and extending FireBIM.
Purpose
Authentication in firebim-api-server is delegated to Authentik through OAuth2/OpenID Connect. The API validates Authentik-issued Bearer tokens, auto-provisions local user rows, and uses the local User model as the ownership anchor for user-scoped resources.
The current backend has authentication and user ownership. It does not yet implement a first-party role-based admin system inside the API. Administrative capabilities currently live in Authentik, infrastructure tooling, and operational access to backend services.
flowchart LR
user["User"] --> frontend["Frontend / API client"]
frontend --> authentik["Authentik OIDC"]
authentik --> token["Access token"]
token --> api["FireBIM API"]
api --> jwks["Authentik JWKS"]
api --> users[("users table")]
api --> resources["User-scoped resources"]
The API trusts Authentik as the identity provider. The backend owns local user metadata only to support application authorization, ownership, and persistence relationships.
Main Backend Modules
Module
Responsibility
app.auth.jwt
Bearer token extraction, JWKS lookup, JWT validation, local user provisioning, active-user checks
app.auth.router
/users/me endpoint for the current authenticated user
app.schemas.auth
User response schema
app.models.models.User
Local SQLModel user table
app.models.database
Database session management for request and auth flows
app.core.config
Authentik issuer/internal URLs and environment-driven security configuration
sequenceDiagram
participant Client
participant API
participant JWKS as Authentik JWKS
participant DB as PostgreSQL
Client->>API: Request with Authorization: Bearer token
API->>API: Extract HTTP Bearer credentials
API->>JWKS: Resolve signing key from token
API->>API: Verify JWT signature and issuer
API->>API: Read sub, email, preferred_username claims
API->>DB: Find user by authentik_sub
alt user exists
API->>DB: Sync email / username if claims changed
else first login
API->>DB: Create local User row
end
API->>API: Check is_active
API-->>Client: Authorized route response
flowchart LR
tokenClaims["JWT claims"] --> lookup["Lookup by authentik_sub"]
lookup --> exists{"User exists?"}
exists -->|yes| sync["Sync email / username"]
exists -->|no| create["Create local User"]
sync --> active["Check is_active"]
create --> active
active --> route["Protected route"]
User-Scoped Resources
The local User.id is used to scope application data.
Current user-scoped areas include:
Resource area
Ownership mechanism
IFC models
IfcModel.user_id and explicit ownership checks
IDS files
IdsFile.user_id and explicit ownership checks
Rulebuilder workspaces
Repository methods receive current_user
Ontology candidates
Repository methods receive current_user
Lexicon mappings
User-scoped S3 JSON repository
Lexicon profiles
User-scoped S3 JSON repository
Lexicon handshakes
User-scoped S3 JSON repository
Some API areas are public or system-level by design, such as health/build metadata and graph/rule operations that do not currently require a user dependency on every endpoint. Authentication coverage is therefore endpoint-specific in the current codebase.
Admin Model
The current API does not define first-party admin roles, admin claims, or an is_admin field. There is no internal RBAC/ABAC model in the SQLModel user table.
Admin responsibility currently exists in these external or operational layers:
Declarative local application/provider/enrollment/recovery setup
PgAdmin
Local database administration in Docker Compose
Docker Compose environment
Local dev credentials, service wiring, bootstrap values
Infrastructure secrets
Runtime credentials for PostgreSQL, S3/MinIO, Authentik, RabbitMQ
A future FireBIM admin layer can be built on top of Authentik claims or groups. The backend would then need explicit role extraction, role persistence or claim evaluation, and protected admin dependencies such as get_current_admin_user.
Authentik provider uses strict redirect URI matching
Request observability
Authentication timings, DB lookup/provision/sync metrics, request id middleware
Secret handling
Pydantic SecretStr is used for configured backend secrets
Security-Relevant Design Notes
Audience verification is currently disabled in JWT validation. This is acceptable only when the issuer and token source are tightly controlled and the API is intentionally accepting issuer-scoped tokens without audience enforcement. For production hardening, the API should validate audience or client id expectations explicitly.
Admin authorization is not implemented in the API. Any future admin endpoint must not rely only on is_active; it must use explicit role/group/claim checks.
Local development credentials appear in Docker Compose for Authentik, RabbitMQ, MinIO, PgAdmin, and related services. These are local-dev values and must not be reused in production environments.
The API auto-provisions users on first valid token. This is convenient and aligned with Authentik as source of identity, but it means access policy belongs primarily in Authentik and token issuance. If self-enrollment is enabled, product-level entitlement may require an additional authorization layer.
The is_active flag is local and enforced by the API, but there is no API endpoint in the current codebase for administrators to deactivate users. Operational deactivation currently belongs to database operations or future admin tooling.
Security Gaps And Future Hardening
Area
Current state
Hardening direction
Audience validation
Disabled
Validate expected audience/client id for API tokens
Admin roles
Not implemented
Introduce Authentik group/claim mapping and backend admin dependency
Authorization policy
Endpoint-specific ownership checks
Centralize permission model for user, project, organization, and admin scopes
User lifecycle management
Auto-provision and sync from token
Add explicit admin/user management workflows if product requires them
Token claim model
Uses sub, email, preferred_username
Document required claims and reject incomplete production identities
Secret posture
Local Docker defaults exist
Separate local/dev/staging/prod secrets and enforce production checks
Protected surface consistency
Mixed public/protected endpoints
Classify endpoints as public, authenticated, owner-scoped, admin-scoped, or system-scoped
User And Admin Capability Model
The current capability model is:
Actor
Current capabilities
Unauthenticated caller
Public endpoints only, such as selected health/build/system routes
Authenticated active user
Access protected endpoints and own user-scoped resources
Resource owner
Read/write/delete resources where routers or repositories enforce ownership
The next architectural step for admin is to make “FireBIM application admin” explicit rather than implicit in infrastructure access.
Recommended Admin Architecture Direction
Future admin functionality should be layered on the existing Authentik integration:
1. Authentik owns identity, groups, and high-level policy. 2. Tokens include group or role claims relevant to FireBIM. 3. The API validates these claims after JWT verification. 4. The API exposes dedicated dependencies such as get_current_admin_user. 5. Admin endpoints are grouped under an explicit route namespace. 6. Admin actions are audited with user id, request id, action, target resource, and outcome.
Authentication is already a clear boundary: Authentik owns identity and the API owns local user projection and resource ownership. The current system is ready for user-scoped workflows, but not yet for first-party administrative workflows.
Security hardening should focus on explicit audience validation, explicit admin claims, endpoint classification, and a consistent authorization model across user-owned, shared, public, and system-level resources.