# dlr-sc/gitlab2prov architecture

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

- Interactive diagram: https://gitdiagram.com/dlr-sc/gitlab2prov
- Repository: https://github.com/dlr-sc/gitlab2prov

## Overview

##### Main Components

a. External Systems:
- GitLab Instance (API)
- Git Repositories
- File System (for output)

b. Core Application Components:
- CLI Interface (entrypoints/cli.py)
- Configuration Management (config/)
- Domain Layer (domain/)
- Service Layer (service_layer/)
- Adapters Layer (adapters/)
- PROV Model Generation (prov/)

##### Architecture Pattern
The project follows a clean architecture pattern with clear separation of concerns:

- Entrypoints (CLI)
- Service Layer (handlers, messagebus, unit of work)
- Domain Layer (business logic)
- Adapters (external integrations)

**[External Systems]**
**GitLab API <-----> Adapters Layer (gitlab.py)**
**Git Repos <-----> Adapters Layer (git.py)**

**[Core Application]**
**CLI Interface**

- v
**Configuration Management**

- v
**Service Layer (Message Bus)**

- v
**Domain Layer**

- v
**PROV Model Generation**

- v
**Output Formats (JSON/RDF/XML/DOT)**

##### Important Elements to Highlight

a. Data Flow:
- Command flow from CLI through the service layer
- Data fetching from GitLab/Git through adapters
- PROV model generation and transformation

b. Key Components:
- Message Bus pattern for command handling
- Unit of Work pattern for consistency
- Repository pattern for data access
- PROV model generation and transformation

##### Additional Details

Specific features like:
- Pseudonymization capability
- Graph combination functionality
- Multiple output format support
- Configuration validation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Systems
    subgraph External
        GitLabAPI[GitLab API]:::external
        GitRepos[Git Repositories]:::external
        FileSystem[File System]:::external
    end

    %% Core Application
    subgraph CoreApp
        %% CLI and Config
        CLI[CLI Interface]:::entrypoint
        click CLI "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/entrypoints/cli.py"
        
        Config[Configuration Management]:::config
        click Config "https://github.com/DLR-SC/gitlab2prov/tree/master/gitlab2prov/config/"
        
        Bootstrap[Bootstrap]:::core
        click Bootstrap "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/bootstrap.py"

        %% Service Layer
        subgraph ServiceLayer
            MessageBus[Message Bus]:::service
            click MessageBus "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/service_layer/messagebus.py"
            
            Handlers[Command Handlers]:::service
            click Handlers "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/service_layer/handlers.py"
            
            UnitOfWork[Unit of Work]:::service
            click UnitOfWork "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/service_layer/unit_of_work.py"
        end

        %% Domain Layer
        subgraph DomainLayer
            Commands[Commands]:::domain
            click Commands "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/domain/commands.py"
            
            DomainObjects[Domain Objects]:::domain
            click DomainObjects "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/domain/objects.py"
        end

        %% Adapters Layer
        subgraph AdaptersLayer
            GitLabAdapter[GitLab Adapter]:::adapter
            click GitLabAdapter "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/adapters/fetch/gitlab.py"
            
            GitAdapter[Git Adapter]:::adapter
            click GitAdapter "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/adapters/fetch/git.py"
            
            Repository[Repository]:::adapter
            click Repository "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/adapters/repository.py"
            
            Annotations[Data Annotations]:::adapter
            click Annotations "https://github.com/DLR-SC/gitlab2prov/tree/master/gitlab2prov/adapters/fetch/annotations/"
        end

        %% PROV Layer
        subgraph ProvLayer
            ProvModel[PROV Model]:::prov
            click ProvModel "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/prov/model.py"
            
            ProvOperations[PROV Operations]:::prov
            click ProvOperations "https://github.com/DLR-SC/gitlab2prov/blob/master/gitlab2prov/prov/operations.py"
        end

        %% Output Formats
        OutputFormats{"Output Formats<br/>(JSON/RDF/XML/DOT)"}:::output
    end

    %% Relationships
    CLI --> Config
    Config --> Bootstrap
    Bootstrap --> MessageBus
    MessageBus --> Handlers
    Handlers --> UnitOfWork
    UnitOfWork --> Repository
    Repository --> DomainObjects
    Commands --> MessageBus
    GitLabAdapter --> GitLabAPI
    GitAdapter --> GitRepos
    Repository --> GitLabAdapter
    Repository --> GitAdapter
    Annotations --> Repository
    Repository --> ProvModel
    ProvModel --> ProvOperations
    ProvOperations --> OutputFormats
    OutputFormats --> FileSystem

    %% Styles
    classDef external fill:#68a5ff,stroke:#333,stroke-width:2px
    classDef entrypoint fill:#a5d6a7,stroke:#333,stroke-width:2px
    classDef config fill:#fff59d,stroke:#333,stroke-width:2px
    classDef service fill:#ffcc80,stroke:#333,stroke-width:2px
    classDef domain fill:#81c784,stroke:#333,stroke-width:2px
    classDef adapter fill:#ff9e80,stroke:#333,stroke-width:2px
    classDef prov fill:#b39ddb,stroke:#333,stroke-width:2px
    classDef output fill:#90a4ae,stroke:#333,stroke-width:2px
    classDef core fill:#e0e0e0,stroke:#333,stroke-width:2px
```
