# afontana1/fault-tree architecture

> Architecture diagram of the GitHub repository afontana1/fault-tree, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/afontana1/fault-tree
- Repository: https://github.com/afontana1/fault-tree

## Overview

faulttree is a visual fault-tree modeling and probability-analysis application: users construct an event/gate graph, choose a top event and analysis method, submit the model, and inspect the resulting probability and solver details. The graph follows the frontend request into API validation and solver dispatch, then shows the model-to-expression and analysis layers. Solver capabilities are documented in the README; source excerpts for several solver implementations and frontend request helpers were not sampled, so their internal wiring is omitted.

Main entry points: [`src/app/main.py`](https://github.com/afontana1/fault-tree/blob/main/src/app/main.py) (FastAPI Routes), [`frontend/src/App.tsx`](https://github.com/afontana1/fault-tree/blob/main/frontend/src/App.tsx) (Builder App), [`src/faulttree/core/graph.py`](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/graph.py) (Fault Tree Graph), [`src/faulttree/solvers/interfaces.py`](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/interfaces.py) (Solver Contracts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_builder["Model Builder UI"]
  node_app["Builder App<br/>[App.tsx]"]
  node_toolbar["Model Toolbar<br/>[Toolbar.tsx]"]
  node_canvas["Graph Canvas<br/>[App.tsx]"]
  node_inspector["Node Inspector<br/>[Inspector.tsx]"]
  node_config_builder["Config Builder<br/>[buildConfig.ts]"]
  node_api_client["API Client<br/>[api.ts]"]
  node_results["Results Panel<br/>[ResultsPanel.tsx]"]
end

subgraph group_service["API Service"]
  node_backend["FastAPI Routes<br/>[main.py]"]
  node_request_schema["Request Schemas<br/>[schemas.py]"]
  node_api_response["Solve Response<br/>[schemas.py]"]
end

subgraph group_model["Fault Tree Model"]
  node_config_loader["Config Loader<br/>[config.py]"]
  node_fault_tree["Fault Tree Graph<br/>[graph.py]"]
  node_events["Event Primitives<br/>[events.py]"]
  node_gates["Gate Primitives<br/>[gates.py]"]
  node_dependencies["Dependency Primitives<br/>[dependencies.py]"]
  node_expression["Boolean Expressions<br/>[expr.py]"]
  node_schema_export["DSL Schema Export<br/>[schema_export.py]"]
end

subgraph group_analysis["Analysis Solvers"]
  node_solver_interfaces["Solver Contracts<br/>[interfaces.py]"]
  node_bdd_solver["BDD Exact Solver<br/>[bdd.py]"]
  node_closed_solver["Closed-Form Solver<br/>[closed_form.py]"]
  node_cut_solver["Cut-Set Solver<br/>[cut_sets.py]"]
  node_mc_solver["Monte Carlo Solver<br/>[monte_carlo.py]"]
end

node_engineer(("Modeler"))

node_engineer -->|"sets options"| node_toolbar
node_engineer -->|"edits graph"| node_canvas
node_canvas -->|"updates state"| node_app
node_toolbar -->|"invokes actions"| node_app
node_app -->|"passes selection"| node_inspector
node_inspector -->|"updates node"| node_app
node_app -->|"builds config"| node_config_builder
node_app -->|"submits request"| node_api_client
node_api_client -->|"HTTP request"| node_backend
node_backend -->|"parses body"| node_request_schema
node_backend -->|"loads config"| node_config_loader
node_config_loader -->|"constructs model"| node_fault_tree
node_fault_tree -->|"uses event types"| node_events
node_fault_tree -->|"uses gate types"| node_gates
node_fault_tree -->|"expands dependencies"| node_dependencies
node_backend -->|"validates model"| node_fault_tree
node_backend -->|"serves DSL schema"| node_schema_export
node_backend -->|"builds solve request"| node_solver_interfaces
node_backend -->|"dispatches method"| node_bdd_solver
node_backend -->|"dispatches method"| node_closed_solver
node_backend -->|"dispatches method"| node_cut_solver
node_backend -->|"dispatches method"| node_mc_solver
node_bdd_solver -->|"translates model"| node_fault_tree
node_fault_tree -->|"produces expression"| node_expression
node_bdd_solver -->|"builds decision diagram"| node_expression
node_bdd_solver -->|"returns result"| node_solver_interfaces
node_closed_solver -->|"returns result"| node_solver_interfaces
node_cut_solver -->|"returns result"| node_solver_interfaces
node_mc_solver -->|"returns result"| node_solver_interfaces
node_solver_interfaces -->|"provides result"| node_api_response
node_api_response -->|"serializes response"| node_backend
node_backend -->|"returns response"| node_api_client
node_api_client -->|"resolves result"| node_app
node_app -->|"shows output"| node_results

click node_app "https://github.com/afontana1/fault-tree/blob/main/frontend/src/App.tsx"
click node_toolbar "https://github.com/afontana1/fault-tree/blob/main/frontend/src/components/Toolbar.tsx"
click node_canvas "https://github.com/afontana1/fault-tree/blob/main/frontend/src/App.tsx"
click node_inspector "https://github.com/afontana1/fault-tree/blob/main/frontend/src/components/Inspector.tsx"
click node_config_builder "https://github.com/afontana1/fault-tree/blob/main/frontend/src/faulttree/buildConfig.ts"
click node_api_client "https://github.com/afontana1/fault-tree/blob/main/frontend/src/api.ts"
click node_results "https://github.com/afontana1/fault-tree/blob/main/frontend/src/components/ResultsPanel.tsx"
click node_backend "https://github.com/afontana1/fault-tree/blob/main/src/app/main.py"
click node_request_schema "https://github.com/afontana1/fault-tree/blob/main/src/app/schemas.py"
click node_config_loader "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/config.py"
click node_fault_tree "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/graph.py"
click node_events "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/events.py"
click node_gates "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/gates.py"
click node_dependencies "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/dependencies.py"
click node_expression "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/expr.py"
click node_schema_export "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/schema_export.py"
click node_solver_interfaces "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/interfaces.py"
click node_bdd_solver "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/bdd.py"
click node_closed_solver "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/closed_form.py"
click node_cut_solver "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/cut_sets.py"
click node_mc_solver "https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/monte_carlo.py"
click node_api_response "https://github.com/afontana1/fault-tree/blob/main/src/app/schemas.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_toolbar,node_canvas,node_inspector,node_config_builder,node_api_client,node_results toneBlue
class node_backend,node_request_schema,node_api_response toneAmber
class node_config_loader,node_fault_tree,node_events,node_gates,node_dependencies,node_expression,node_schema_export toneMint
class node_solver_interfaces,node_bdd_solver,node_closed_solver,node_cut_solver,node_mc_solver toneRose
class node_engineer toneIndigo
```

## Components

### Model Builder UI

- [Builder App](https://github.com/afontana1/fault-tree/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Model Toolbar](https://github.com/afontana1/fault-tree/blob/main/frontend/src/components/Toolbar.tsx): `frontend/src/components/Toolbar.tsx`
- [Graph Canvas](https://github.com/afontana1/fault-tree/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Node Inspector](https://github.com/afontana1/fault-tree/blob/main/frontend/src/components/Inspector.tsx): `frontend/src/components/Inspector.tsx`
- [Config Builder](https://github.com/afontana1/fault-tree/blob/main/frontend/src/faulttree/buildConfig.ts): `frontend/src/faulttree/buildConfig.ts`
- [API Client](https://github.com/afontana1/fault-tree/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Results Panel](https://github.com/afontana1/fault-tree/blob/main/frontend/src/components/ResultsPanel.tsx): `frontend/src/components/ResultsPanel.tsx`

### API Service

- [FastAPI Routes](https://github.com/afontana1/fault-tree/blob/main/src/app/main.py): `src/app/main.py`
- [Request Schemas](https://github.com/afontana1/fault-tree/blob/main/src/app/schemas.py): `src/app/schemas.py`
- [Solve Response](https://github.com/afontana1/fault-tree/blob/main/src/app/schemas.py): `src/app/schemas.py`

### Fault Tree Model

- [Config Loader](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/config.py): `src/faulttree/core/config.py`
- [Fault Tree Graph](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/graph.py): `src/faulttree/core/graph.py`
- [Event Primitives](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/events.py): `src/faulttree/core/events.py`
- [Gate Primitives](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/gates.py): `src/faulttree/core/gates.py`
- [Dependency Primitives](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/dependencies.py): `src/faulttree/core/dependencies.py`
- [Boolean Expressions](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/expr.py): `src/faulttree/core/expr.py`
- [DSL Schema Export](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/core/schema_export.py): `src/faulttree/core/schema_export.py`

### Analysis Solvers

- [Solver Contracts](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/interfaces.py): `src/faulttree/solvers/interfaces.py`
- [BDD Exact Solver](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/bdd.py): `src/faulttree/solvers/bdd.py`
- [Closed-Form Solver](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/closed_form.py): `src/faulttree/solvers/closed_form.py`
- [Cut-Set Solver](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/cut_sets.py): `src/faulttree/solvers/cut_sets.py`
- [Monte Carlo Solver](https://github.com/afontana1/fault-tree/blob/main/src/faulttree/solvers/monte_carlo.py): `src/faulttree/solvers/monte_carlo.py`

### Other components

- **Modeler**

## Connections

- Modeler → Model Toolbar: sets options
- Modeler → Graph Canvas: edits graph
- Graph Canvas → Builder App: updates state
- Model Toolbar → Builder App: invokes actions
- Builder App → Node Inspector: passes selection
- Node Inspector → Builder App: updates node
- Builder App → Config Builder: builds config
- Builder App → API Client: submits request
- API Client → FastAPI Routes: HTTP request
- FastAPI Routes → Request Schemas: parses body
- FastAPI Routes → Config Loader: loads config
- Config Loader → Fault Tree Graph: constructs model
- Fault Tree Graph → Event Primitives: uses event types
- Fault Tree Graph → Gate Primitives: uses gate types
- Fault Tree Graph → Dependency Primitives: expands dependencies
- FastAPI Routes → Fault Tree Graph: validates model
- FastAPI Routes → DSL Schema Export: serves DSL schema
- FastAPI Routes → Solver Contracts: builds solve request
- FastAPI Routes → BDD Exact Solver: dispatches method
- FastAPI Routes → Closed-Form Solver: dispatches method
- FastAPI Routes → Cut-Set Solver: dispatches method
- FastAPI Routes → Monte Carlo Solver: dispatches method
- BDD Exact Solver → Fault Tree Graph: translates model
- Fault Tree Graph → Boolean Expressions: produces expression
- BDD Exact Solver → Boolean Expressions: builds decision diagram
- BDD Exact Solver → Solver Contracts: returns result
- Closed-Form Solver → Solver Contracts: returns result
- Cut-Set Solver → Solver Contracts: returns result
- Monte Carlo Solver → Solver Contracts: returns result
- Solver Contracts → Solve Response: provides result
- Solve Response → FastAPI Routes: serializes response
- FastAPI Routes → API Client: returns response
- API Client → Builder App: resolves result
- Builder App → Results Panel: shows output
