# ssi-dk/sofi_core architecture

> Architecture diagram of the GitHub repository ssi-dk/sofi_core, 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/sofi_core
- Repository: https://github.com/ssi-dk/sofi_core

## Overview

##### Main Components

a. Frontend Layer:
- React-based web application (in `/app` directory)
- Key modules:
- Analysis module
- Comparative Analysis module
- GDPR module
- Workspaces module
- Manual Upload module

b. Backend Services:
- Web Service (Flask-based, in `/web` directory)
- Bifrost Services:
- Bifrost Listener
- Bifrost Queue Broker
- SAP TBR Integration Service (.NET-based)
- Authentication Service (Keycloak)

c. Databases:
- MongoDB (Bifrost DB)
- PostgreSQL (Auth DB)

d. External Integrations:
- LIMS Service
- BioAPI Service
- Microreact Integration

**┌─────────────────── Client Layer ───────────────────┐**
- React Frontend (Analysis, Workspaces, GDPR, etc.)  │
- ┬────────────────────────────┘
- ↓
**┌─────────────────── Service Layer ──────────────────┐**
- ┌─────────┐ ┌────────┐ ┌─────────┐ ┌───────────┐  │
- Web    │ │Bifrost │ │  SAP    │ │ Keycloak  │  │
- Service │ │Services│ │  TBR    │ │  Auth     │  │
- ┘ └────────┘ └─────────┘ └───────────┘  │
- ┬────────────────────────────┘
- ↓
**┌─────────────────── Data Layer ────────────────────┐**
- ┌─────────┐ ┌────────┐    ┌────────────────────┐  │
- MongoDB │ │PostgreSQL│   │ External Services  │  │
- ┘ └────────┘    └────────────────────┘  │
- ┘

##### Key Relationships to Highlight

- Frontend to Backend communication via REST APIs (shown in `/sap-client/apis/`)
- Authentication flow through Keycloak
- Data flow between Bifrost services and MongoDB
- Integration points with external services (LIMS, BioAPI)
- Queue-based communication between services

##### Additional Details

Specific annotations for:
- Docker container boundaries (shown by Dockerfile presence)
- API endpoints (from OpenAPI specs in `/openapi_specs`)
- Data flow directions (based on service interactions)
- Security boundaries (TLS certificates, authentication requirements)

##### Implementation Notes

- Version information and date
- Document key technologies used:
- Node.js/React (Frontend)
- Python/Flask (Web Service)
- .NET (SAP TBR Integration)
- MongoDB/PostgreSQL (Databases)
- Docker/Docker Compose (Containerization)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style definitions
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef auth fill:#9b59b6,stroke:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        ReactApp["React Application"]
        Analysis["Analysis Module"]
        CompAnalysis["Comparative Analysis"]
        GDPR["GDPR Module"]
        Workspaces["Workspaces Module"]
        ManualUpload["Manual Upload Module"]
    end

    %% Service Layer
    subgraph Services
        WebService["Web Service"]
        BifrostListener["Bifrost Listener"]
        BifrostQueueBroker["Bifrost Queue Broker"]
        SAPTBR["SAP TBR Integration"]
        Keycloak["Authentication Service"]
    end

    %% Data Layer
    subgraph Data
        MongoDB[("MongoDB<br/>(Bifrost DB)")]
        PostgreSQL[("PostgreSQL<br/>(Auth DB)")]
    end

    %% External Services
    subgraph External
        LIMS["LIMS Service"]
        BioAPI["BioAPI Service"]
        Microreact["Microreact Integration"]
    end

    %% Relationships
    ReactApp --> WebService
    ReactApp --> Keycloak
    Analysis --> WebService
    CompAnalysis --> WebService
    GDPR --> WebService
    Workspaces --> WebService
    ManualUpload --> WebService

    WebService --> BifrostListener
    WebService --> SAPTBR
    WebService --> LIMS
    WebService --> BioAPI
    WebService --> Microreact

    BifrostListener --> BifrostQueueBroker
    BifrostQueueBroker --> MongoDB

    Keycloak --> PostgreSQL

    %% Click events
    click ReactApp "https://github.com/ssi-dk/sofi_core/tree/master/app/src/app/"
    click Analysis "https://github.com/ssi-dk/sofi_core/tree/master/app/src/app/analysis/"
    click CompAnalysis "https://github.com/ssi-dk/sofi_core/tree/master/app/src/app/comparative-analysis/"
    click GDPR "https://github.com/ssi-dk/sofi_core/tree/master/app/src/app/gdpr/"
    click Workspaces "https://github.com/ssi-dk/sofi_core/tree/master/app/src/app/workspaces/"
    click ManualUpload "https://github.com/ssi-dk/sofi_core/tree/master/app/src/app/manual-upload/"
    click WebService "https://github.com/ssi-dk/sofi_core/tree/master/web/"
    click BifrostListener "https://github.com/ssi-dk/sofi_core/tree/master/bifrost/bifrost_listener/"
    click BifrostQueueBroker "https://github.com/ssi-dk/sofi_core/tree/master/bifrost/bifrost_queue_broker/"
    click SAPTBR "https://github.com/ssi-dk/sofi_core/tree/master/sap_tbr_integration/"
    click Keycloak "https://github.com/ssi-dk/sofi_core/tree/master/auth/"
    click MongoDB "https://github.com/ssi-dk/sofi_core/tree/master/bifrost/bifrost_db/"
    click PostgreSQL "https://github.com/ssi-dk/sofi_core/tree/master/auth/pg/"
    click LIMS "https://github.com/ssi-dk/sofi_core/tree/master/web/src/services/lims/"
    click BioAPI "https://github.com/ssi-dk/sofi_core/tree/master/web/src/services/bio_api/"
    click Microreact "https://github.com/ssi-dk/sofi_core/tree/master/microreact/"

    %% Styling
    class ReactApp,Analysis,CompAnalysis,GDPR,Workspaces,ManualUpload frontend
    class WebService,BifrostListener,BifrostQueueBroker,SAPTBR backend
    class MongoDB,PostgreSQL database
    class LIMS,BioAPI,Microreact external
    class Keycloak auth
```
