# elifesciences/enhanced-preprints-import architecture

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

- Interactive diagram: https://gitdiagram.com/elifesciences/enhanced-preprints-import
- Repository: https://github.com/elifesciences/enhanced-preprints-import

## Overview

##### Core System Components
- Temporal Server (Workflow Orchestrator)
- Worker Service (Main Application)
- S3 Storage (Source and Destination)
- EPP Server (API Endpoint)
- DocMaps Provider
- IIIF Server (Cantaloupe - downstream consumer)

##### Workflow Components
- importDocmaps
- importDocmap
- importManuscriptData
- importContent

##### Activities Layer
Activities into functional categories:
- Document Processing (extract-meca, convert-xml-to-json)
- DocMap Handling (fetch-docmap, parse-docmap, create-docmap-hash)
- Content Management (copy-source-meca, fetch-review-content)
- Version Management (generate-version-json, generate-version-summary-json)

- [DocMaps Provider]
- ↓
- [Temporal Server]
- ↓
- [Worker Service]
- ↙     ↓     ↘
- [S3] [EPP] [IIIF]

- [importDocmaps]
- ↓
- [importDocmap]
- ↓
- [importManuscriptData]
- ↓
- [importContent]

##### Specific technical details
- S3 bucket connections for both source and destination
- MECA file processing flow
- XSL transformation points
- State management with S3 state files

##### Important configurations
- Docker container boundaries
- Network connections
- Configuration injection points

Specific Implementation Guidelines:

##### Use standardized symbols
- Rectangles for services
- Rounded rectangles for workflows
- Hexagons for activities

- External Services
- Core Processing
- Storage Layer
- Workflow Execution

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Services Layer
    subgraph External
        DocMaps["DocMaps Provider"]
        EPPServer["EPP Server"]
        IIIF["IIIF Server\n(Cantaloupe)"]
    end

    %% Core Processing Layer
    subgraph Core
        Temporal["Temporal Server"]
        Worker["Worker Service"]:::worker
        click Worker "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/worker.ts"
        Config["Configuration"]:::config
        click Config "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/config.ts"
    end

    %% Storage Layer
    subgraph Storage
        S3["S3 Storage"]:::storage
        click S3 "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/S3Bucket.ts"
    end

    %% Workflow Layer
    subgraph Workflows
        ImportDocmaps["Import Docmaps"]:::workflow
        click ImportDocmaps "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/workflows/import-docmaps.ts"
        ImportDocmap["Import Docmap"]:::workflow
        click ImportDocmap "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/workflows/import-docmap.ts"
        ImportManuscript["Import Manuscript Data"]:::workflow
        click ImportManuscript "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/workflows/import-manuscript-data.ts"
        ImportContent["Import Content"]:::workflow
        click ImportContent "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/workflows/import-content.ts"
    end

    %% Activities Layer
    subgraph "Document Processing"
        ExtractMECA["Extract MECA"]:::activity
        click ExtractMECA "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/extract-meca.ts"
        ConvertXML["Convert XML to JSON"]:::activity
        click ConvertXML "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/convert-xml-to-json.ts"
    end

    subgraph "DocMap Processing"
        FetchDocmap["Fetch DocMap"]:::activity
        click FetchDocmap "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/fetch-docmap.ts"
        ParseDocmap["Parse DocMap"]:::activity
        click ParseDocmap "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/parse-docmap.ts"
        CreateHash["Create DocMap Hash"]:::activity
        click CreateHash "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/create-docmap-hash.ts"
    end

    subgraph "Content Management"
        CopyMECA["Copy Source MECA"]:::activity
        click CopyMECA "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/copy-source-meca.ts"
        FetchReview["Fetch Review Content"]:::activity
        click FetchReview "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/fetch-review-content.ts"
    end

    subgraph "Version Management"
        GenVersion["Generate Version JSON"]:::activity
        click GenVersion "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/generate-version-json.ts"
        GenSummary["Generate Version Summary"]:::activity
        click GenSummary "https://github.com/elifesciences/enhanced-preprints-import/blob/master/src/activities/generate-version-summary-json.ts"
    end

    %% Mock Data
    subgraph "Test Data"
        DocMapsMock["DocMaps Mock Data"]:::mock
        click DocMapsMock "https://github.com/elifesciences/enhanced-preprints-import/tree/master/mock-data/docmaps/"
        MECAMock["MECA Mock Data"]:::mock
        click MECAMock "https://github.com/elifesciences/enhanced-preprints-import/tree/master/mock-data/meca/"
    end

    %% Relationships
    DocMaps --> Temporal
    Temporal --> Worker
    Worker --> S3
    Worker --> EPPServer
    Worker --> IIIF
    Config --> Worker

    ImportDocmaps --> ImportDocmap
    ImportDocmap --> ImportManuscript
    ImportManuscript --> ImportContent

    %% Activity Relationships
    ImportContent --> ExtractMECA
    ExtractMECA --> ConvertXML
    ImportDocmap --> FetchDocmap
    FetchDocmap --> ParseDocmap
    ParseDocmap --> CreateHash
    ImportContent --> CopyMECA
    ImportContent --> FetchReview
    ImportManuscript --> GenVersion
    ImportManuscript --> GenSummary

    %% Styling
    classDef external fill:#ADD8E6
    classDef core fill:#90EE90
    classDef storage fill:#FFD700
    classDef workflow fill:#FFA500
    classDef activity fill:#F0F0F0
    classDef mock fill:#D3D3D3
    classDef worker fill:#90EE90
    classDef config fill:#90EE90

    class DocMaps,EPPServer,IIIF external
    class Temporal core
    class S3 storage
    class ImportDocmaps,ImportDocmap,ImportManuscript,ImportContent workflow
    class ExtractMECA,ConvertXML,FetchDocmap,ParseDocmap,CreateHash,CopyMECA,FetchReview,GenVersion,GenSummary activity
    class DocMapsMock,MECAMock mock
```
