# 4turesearchdata/djehuty architecture

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

- Interactive diagram: https://gitdiagram.com/4turesearchdata/djehuty
- Repository: https://github.com/4turesearchdata/djehuty

## Overview

##### Main System Components

a) Web Interface Layer
- HTTP/WSGI Server (supports both built-in and uWSGI)
- Web UI components (under src/djehuty/web/)
- Template system (HTML templates under web/resources/)
- Static assets (CSS, JS, images)

b) Core Application Layer
- Authentication/Session Management
- Data Validation (validator.py)
- Email Handling (email_handler.py)
- Caching System (cache.py)
- Formatting Services (formatter.py, xml_formatter.py)

c) Data Layer
- SPARQL 1.1 Database Interface
- RDF Data Management (utils/rdf.py)
- Database Backup System (backup/)

d) External Services Integration
- SPARQL 1.1 Endpoint (Virtuoso OSE or Jena Fuseki)
- Email Service
- File Storage System

##### Relationships and Data Flow

a) Client-Server Communication
**Web Client → HTTP/WSGI Server → Web UI Layer → Core Application Layer**

b) Data Flow
**Core Application Layer ↔ SPARQL Database**
**Core Application Layer ↔ File Storage**
**Core Application Layer → Email Service**

##### Key Design Elements

- Blue rectangles: Web components
- Green rectangles: Core application services
- Yellow diamonds: External services
- Purple rectangles: Storage systems
- Red lines: Authentication flows
- Blue lines: Data flows
- Green lines: File operations

##### Implementation Details

Specific technical implementations:

**Web Layer:**
- WSGI Application
- Template Engine
- Static File Serving

**Core Services:**
- RDF Data Management
- SPARQL Query Processing
- Email Notifications
- Cache Management

**Storage:**
- SPARQL 1.1 Database
- File Storage System
- Backup Management

##### Additional Elements

Annotations for:

- Configuration management (XML-based)
- Development vs. Production environments
- Scaling capabilities (worker processes/threading)
- Backup and recovery paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WC[Web Client]
    end

    subgraph "Web Interface Layer"
        WS["WSGI Server"]:::server
        WUI["Web UI"]:::ui
        HT["HTML Templates"]:::templates
        SA["Static Assets"]:::static
    end

    subgraph "Core Application Layer"
        DV["Data Validator"]:::core
        EH["Email Handler"]:::core
        CS["Cache System"]:::core
        FS["Formatting Services"]:::core
        LM["Locking Mechanism"]:::core
    end

    subgraph "Data Layer"
        DBI["Database Interface"]:::data
        RDF["RDF Management"]:::data
        ST["SPARQL Templates"]:::data
        BS["Backup System"]:::data
    end

    subgraph "External Services"
        SPARQL["SPARQL 1.1 Endpoint"]:::external
        EMAIL["Email Service"]:::external
        FS_EXT["File Storage"]:::external
    end

    subgraph "Configuration"
        CONF["System Config"]:::config
        CONST["Constants"]:::config
    end

    subgraph "Metadata Management"
        MT["Metadata Templates"]:::meta
        ET["Email Templates"]:::meta
    end

    %% Relationships
    WC --> WS
    WS --> WUI
    WUI --> HT
    WUI --> SA
    WUI --> DV
    WUI --> EH
    WUI --> CS
    WUI --> FS
    WUI --> LM
    DV --> DBI
    EH --> EMAIL
    CS --> DBI
    FS --> DBI
    LM --> DBI
    DBI --> RDF
    DBI --> ST
    RDF --> SPARQL
    BS --> SPARQL
    BS --> FS_EXT
    EH --> ET
    DBI --> MT

    %% Click Events
    click WS "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/wsgi.py"
    click WUI "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/ui.py"
    click HT "https://github.com/4TUResearchData/djehuty/tree/main/src/djehuty/web/resources/html_templates/"
    click SA "https://github.com/4TUResearchData/djehuty/tree/main/src/djehuty/web/resources/static/"
    click DV "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/validator.py"
    click EH "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/email_handler.py"
    click CS "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/cache.py"
    click FS "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/formatter.py"
    click LM "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/locks.py"
    click DBI "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/web/database.py"
    click RDF "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/utils/rdf.py"
    click ST "https://github.com/4TUResearchData/djehuty/tree/main/src/djehuty/web/resources/sparql_templates/"
    click BS "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/backup/database.py"
    click CONF "https://github.com/4TUResearchData/djehuty/blob/main/etc/djehuty/djehuty-example-config.xml"
    click CONST "https://github.com/4TUResearchData/djehuty/blob/main/src/djehuty/utils/constants.py"
    click MT "https://github.com/4TUResearchData/djehuty/tree/main/src/djehuty/web/resources/metadata_templates/"
    click ET "https://github.com/4TUResearchData/djehuty/tree/main/src/djehuty/web/resources/html_templates/email/"

    %% Styling
    classDef server fill:#6495ED
    classDef ui fill:#4169E1
    classDef templates fill:#87CEEB
    classDef static fill:#ADD8E6
    classDef core fill:#90EE90
    classDef data fill:#DDA0DD
    classDef external fill:#FFD700
    classDef config fill:#F0E68C
    classDef meta fill:#FFA07A

    %% Legend
    subgraph Legend
        L1["Web Server"]:::server
        L2["UI Components"]:::ui
        L3["Templates"]:::templates
        L4["Static Content"]:::static
        L5["Core Services"]:::core
        L6["Data Services"]:::data
        L7["External Services"]:::external
        L8["Configuration"]:::config
        L9["Metadata"]:::meta
    end
```
