# dbos-inc/dbos-transact-ts architecture

> Architecture diagram of the GitHub repository dbos-inc/dbos-transact-ts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dbos-inc/dbos-transact-ts
- Repository: https://github.com/dbos-inc/dbos-transact-ts

## Overview

##### Main Components

a) Core Runtime Layer:
- Main runtime components from src/dbos-runtime
- Workflow engine (src/workflow.ts)
- Transaction manager (src/transaction.ts)
- Scheduler system (src/scheduler)

b) Database Layer:
- At the bottom
- Both system database and user database connections
- Support for multiple ORMs (Drizzle, Knex, TypeORM, Prisma)
- FoundationDB integration for durability

c) Communication Layer:
- On the sides
- HTTP Server component (src/httpServer)
- Event receivers (src/eventreceiver.ts)
- Kafka integration (src/kafka)
- SQS integration (packages/dbos-sqs)

d) Observability Layer:
- At the top
- OpenTelemetry integration (src/telemetry)
- Logging system
- Tracing system

e) Development Tools:
- As a separate section
- Compiler (packages/dbos-compiler)
- CLI tools (packages/dbos-cloud/cli.ts)
- Testing framework (src/testing)
- Debugger (src/debugger)

##### Specific Implementation Details

a) Core Runtime:
**[HTTP Server] → [Runtime Manager] → [Workflow Engine]**
- ↓
- [Transaction Manager] ← [Scheduler]
- ↓
- [Database Abstraction Layer]

b) Database Integration:
**[Database Abstraction Layer]**
- ↓
**[ORM Adapters (Drizzle/Knex/TypeORM/Prisma)]**
- ↓
**[System DB] [User DB] [FoundationDB]**

c) Communication Patterns:
**[External Systems] → [Event Receivers]**
- ↓
**[Kafka/SQS] → [Message Handlers] → [Workflow Engine]**

##### Additional Elements

- Configuration management components
- Security layers (authentication/authorization)
- Error handling and recovery paths

##### Notes for Implementation

- Keep the core runtime components tightly coupled in the center
- Clear boundaries between different layers
- Durability aspects with recovery paths
- Observability integrations
- Version control and deployment workflows

- Durable execution capabilities
- Built-in observability
- Database integration flexibility
- Serverless deployment options
- Development tooling

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#4d88ff
    classDef db fill:#90EE90,stroke:#006400
    classDef comm fill:#FFB366,stroke:#CC7A00
    classDef obs fill:#DDA0DD,stroke:#800080
    classDef dev fill:#D3D3D3,stroke:#696969

    %% Observability Layer
    subgraph Observability
        OpenTelemetry["OpenTelemetry Integration"]:::obs
        Logging["Logging System"]:::obs
        Tracing["Tracing System"]:::obs
    end

    %% Core Runtime Layer
    subgraph CoreRuntime
        RuntimeMgr["Runtime Manager"]:::core
        WorkflowEngine["Workflow Engine"]:::core
        TransactionMgr["Transaction Manager"]:::core
        Scheduler["Scheduler System"]:::core
        ErrorHandler["Error Handler"]:::core
        Config["Configuration"]:::core
    end

    %% Communication Layer
    subgraph Communication
        HTTPServer["HTTP Server"]:::comm
        EventReceivers["Event Receivers"]:::comm
        KafkaInteg["Kafka Integration"]:::comm
        SQSInteg["SQS Integration"]:::comm
    end

    %% Database Layer
    subgraph Database
        DBAbstraction["Database Abstraction Layer"]:::db
        SystemDB["System Database"]:::db
        UserDB["User Database"]:::db
        FoundationDB["FoundationDB"]:::db
        ORMAdapters["ORM Adapters<br/>(Drizzle/Knex/TypeORM/Prisma)"]:::db
    end

    %% Development Tools
    subgraph DevTools
        Compiler["Compiler"]:::dev
        CLI["CLI Tools"]:::dev
        Testing["Testing Framework"]:::dev
        Debugger["Debugger"]:::dev
        CloudInteg["Cloud Integration"]:::dev
    end

    %% Relationships
    HTTPServer --> RuntimeMgr
    EventReceivers --> RuntimeMgr
    KafkaInteg --> RuntimeMgr
    SQSInteg --> RuntimeMgr

    RuntimeMgr --> WorkflowEngine
    RuntimeMgr --> TransactionMgr
    WorkflowEngine --> TransactionMgr
    Scheduler --> TransactionMgr

    TransactionMgr --> DBAbstraction
    DBAbstraction --> ORMAdapters
    ORMAdapters --> SystemDB
    ORMAdapters --> UserDB
    ORMAdapters --> FoundationDB

    CoreRuntime --> OpenTelemetry
    OpenTelemetry --> Logging
    OpenTelemetry --> Tracing

    %% Click Events
    click WorkflowEngine "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/workflow.ts"
    click TransactionMgr "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/transaction.ts"
    click Scheduler "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/scheduler/scheduler.ts"
    click RuntimeMgr "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/dbos-runtime/runtime.ts"
    click SystemDB "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/system_database.ts"
    click UserDB "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/user_database.ts"
    click FoundationDB "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/foundationdb/fdb_system_database.ts"
    click HTTPServer "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/httpServer/server.ts"
    click EventReceivers "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/eventreceiver.ts"
    click KafkaInteg "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/kafka/kafka.ts"
    click SQSInteg "https://github.com/dbos-inc/dbos-transact-ts/blob/main/packages/dbos-sqs/index.ts"
    click OpenTelemetry "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/telemetry/index.ts"
    click Logging "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/telemetry/logs.ts"
    click Tracing "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/telemetry/traces.ts"
    click Compiler "https://github.com/dbos-inc/dbos-transact-ts/blob/main/packages/dbos-compiler/compiler.ts"
    click CLI "https://github.com/dbos-inc/dbos-transact-ts/blob/main/packages/dbos-cloud/cli.ts"
    click Testing "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/testing/testing_runtime.ts"
    click Debugger "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/debugger/debug_workflow.ts"
    click Config "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/dbos-runtime/config.ts"
    click ErrorHandler "https://github.com/dbos-inc/dbos-transact-ts/blob/main/src/error.ts"
    click CloudInteg "https://github.com/dbos-inc/dbos-transact-ts/blob/main/packages/dbos-cloud/cloudutils.ts"
```
