# ssi-dk/bifrostlib architecture

> Architecture diagram of the GitHub repository ssi-dk/bifrostlib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ssi-dk/bifrostlib
- Repository: https://github.com/ssi-dk/bifrostlib

## Overview

##### Main Components

a) Core Library Components:
- Data Handling Module (datahandling.py)
- Database Interface (database_interface.py)
- Common Utilities (common.py)
- Schema Definitions (schemas/bifrost.jsonc)

b) External Interfaces:
- File System Interface (for reading directories of reads)
- Database Connection Layer
- PyPI Distribution System

c) Workflow Components:
- Sample Processing Pipeline
- Run Management System
- Component Execution Engine

**Top Layer: Client Applications/Users**

**Middle Layer: Core Library Components**

**Bottom Layer: Storage & External Systems**

##### Specific Elements

a) Data Flow Components:
- Read Directory
- Metadata.tsv
- Configuration Files

- Sample Object Creation
- Run Object Management
- Component Execution

- Sample Components
- Results Storage
- Execution Reports

b) Key Relationships:

##### Specific Implementation Details

**[Input Files] → [Sample Creation] → [Run Object] → [Component Execution] → [Results]**
- ↕                   ↕                  ↕
- [Database Interface] ← [Common Utilities] → [Schema Validation]

##### Technical Notes

- Use standardized UML or C4 model notation
- Version/release management flow
- Test integration points
- Configuration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef input fill:#2ecc71,stroke:#27ae60,color:white
    classDef process fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    
    %% Input Layer
    subgraph Input
        ReadDir["Read Directory"]:::input
        MetadataTSV["Metadata.tsv"]:::input
        ConfigFiles["Configuration Files"]:::input
    end

    %% Core Library Layer
    subgraph CoreLibrary
        DataHandling["Data Handling Module"]:::core
        DBInterface["Database Interface"]:::core
        CommonUtils["Common Utilities"]:::core
        SchemaVal["Schema Definitions"]:::core
        LibEntry["Library Entry Point"]:::core
    end

    %% Processing Layer
    subgraph Processing
        SampleCreate["Sample Creation"]:::process
        RunMgmt["Run Management"]:::process
        CompExec["Component Execution"]:::process
    end

    %% External Systems
    subgraph External
        Docker["Docker Container"]:::external
        PyPI["PyPI Distribution"]:::external
        TestFrame["Testing Framework"]:::external
        Docs["Documentation"]:::external
        PackageConfig["Package Configuration"]:::external
    end

    %% Database Layer
    DB[(Database)]:::database

    %% Relationships
    ReadDir --> DataHandling
    MetadataTSV --> DataHandling
    ConfigFiles --> DataHandling

    DataHandling --> SampleCreate
    SampleCreate --> RunMgmt
    RunMgmt --> CompExec

    DBInterface <--> DB
    CommonUtils --> DBInterface
    CommonUtils --> SchemaVal
    LibEntry --> DataHandling

    SampleCreate <--> DBInterface
    RunMgmt <--> DBInterface
    CompExec <--> DBInterface

    %% Click Events
    click DataHandling "https://github.com/ssi-dk/bifrostlib/blob/master/bifrostlib/datahandling.py"
    click DBInterface "https://github.com/ssi-dk/bifrostlib/blob/master/bifrostlib/database_interface.py"
    click CommonUtils "https://github.com/ssi-dk/bifrostlib/blob/master/bifrostlib/common.py"
    click SchemaVal "https://github.com/ssi-dk/bifrostlib/blob/master/bifrostlib/schemas/bifrost.jsonc"
    click PyPI "https://github.com/ssi-dk/bifrostlib/blob/master/.github/workflows/publish_to_pypi.yml"
    click TestFrame "https://github.com/ssi-dk/bifrostlib/blob/master/tests/test_simple.py"
    click Docs "https://github.com/ssi-dk/bifrostlib/tree/master/docs/"
    click Docker "https://github.com/ssi-dk/bifrostlib/tree/master/Dockerfile"
    click PackageConfig "https://github.com/ssi-dk/bifrostlib/blob/master/setup.py"
    click LibEntry "https://github.com/ssi-dk/bifrostlib/blob/master/bifrostlib/__init__.py"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Input Elements"]:::input
        L3["Processing Steps"]:::process
        L4["External Systems"]:::external
        L5["Database"]:::database
    end
```
