# viaacode/hetarchief-proxy architecture

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

- Interactive diagram: https://gitdiagram.com/viaacode/hetarchief-proxy
- Repository: https://github.com/viaacode/hetarchief-proxy

## Overview

##### Main System Components

a) Core Application Layer:
- NestJS Backend Proxy (Main Application)
- Authentication System
- GraphQL Integration (Hasura)
- Elasticsearch Integration
- Redis Cache
- Campaign Monitor Integration
- Zendesk Integration

b) External Services:
- Hasura GraphQL Engine
- Elasticsearch
- Campaign Monitor
- Zendesk

##### Module Organization

Following main functional modules:
- Auth Module (Authentication/Authorization)
- Users Module
- Content Partners Module
- IE Objects Module (Information Entity Objects)
- Visits Module
- Spaces Module
- Folders Module
- Notifications Module
- Material Requests Module

**┌─ Client Applications ─────────────────────┐**

- API Gateway Layer ──────────────────────┤
- [NestJS Backend Proxy]                   │

- Service Layer ───────────────────────────┤
- [Auth] [Users] [Content] [IE Objects]    │
- [Visits] [Spaces] [Folders] [Notifications]│

- Data Access Layer ────────────────────────┤
- [Hasura GraphQL] [Elasticsearch] [Redis]  │

- External Services ────────────────────────┤
- [Campaign Monitor] [Zendesk]             │
- ┘

##### Connection Types

- Cache interactions (wavy lines)

##### Environment Configuration

A separate section showing:
- Environment Variables
- Configuration Management
- Service Endpoints

##### Specific Implementation Details

Specialized components:
- Campaign Monitor Integration
- Elasticsearch Query Builder
- Notification System
- Material Request Handling

This system design should reflect the NestJS modular architecture while showing how the proxy serves as a middleware between client applications and various backend services, with special attention to the authentication and authorization flows that are crucial for this archival system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef client fill:#e1f5fe,stroke:#01579b
    classDef core fill:#bbdefb,stroke:#1565c0
    classDef external fill:#c8e6c9,stroke:#2e7d32
    classDef data fill:#ffe0b2,stroke:#ef6c00
    classDef auth fill:#e1bee7,stroke:#6a1b9a
    classDef api fill:#fff9c4,stroke:#f9a825

    %% Client Layer
    subgraph ClientLayer["Client Applications"]
        Client["Client Applications"]:::client
    end

    %% API Gateway Layer
    subgraph GatewayLayer["API Gateway Layer"]
        NestJS["NestJS Backend Proxy"]:::core
        Guards["Security Guards"]:::auth
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        AuthSystem["Authentication System"]:::auth
        UsersSystem["Users Management"]:::core
        ContentSystem["Content Partners"]:::core
        IESystem["IE Objects System"]:::core
        VisitsSystem["Visits Management"]:::core
        SpacesSystem["Spaces Management"]:::core
        FoldersSystem["Folders System"]:::core
        NotifSystem["Notifications System"]:::core
        MaterialSystem["Material Requests"]:::core
    end

    %% Authentication Components
    subgraph AuthComponents["Authentication Components"]
        SAML["SAML Service"]:::auth
        IDP["IDP Service"]:::auth
        Session["Session Management"]:::auth
    end

    %% Data Access Layer
    subgraph DataLayer["Data Access Layer"]
        Hasura["Hasura GraphQL"]:::data
        ES["Elasticsearch"]:::data
        Redis["Redis Cache"]:::data
    end

    %% External Services
    subgraph ExternalLayer["External Services"]
        Campaign["Campaign Monitor"]:::external
        Zendesk["Zendesk"]:::external
    end

    %% Connections
    Client --> NestJS
    NestJS --> Guards
    Guards --> AuthSystem
    AuthSystem --> SAML
    AuthSystem --> IDP
    AuthSystem --> Session
    NestJS --> UsersSystem
    NestJS --> ContentSystem
    NestJS --> IESystem
    NestJS --> VisitsSystem
    NestJS --> SpacesSystem
    NestJS --> FoldersSystem
    NestJS --> NotifSystem
    NestJS --> MaterialSystem
    
    IESystem --> ES
    AuthSystem --> Redis
    UsersSystem --> Hasura
    ContentSystem --> Hasura
    VisitsSystem --> Hasura
    SpacesSystem --> Hasura
    FoldersSystem --> Hasura
    NotifSystem --> Campaign
    MaterialSystem --> Zendesk

    %% Click events
    click AuthSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/auth/"
    click SAML "https://github.com/viaacode/hetarchief-proxy/blob/master/src/modules/auth/services/saml.service.ts"
    click IDP "https://github.com/viaacode/hetarchief-proxy/blob/master/src/modules/auth/services/idp.service.ts"
    click UsersSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/users/"
    click ContentSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/content-partners/"
    click IESystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/ie-objects/"
    click Campaign "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/campaign-monitor/"
    click Zendesk "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/zendesk/"
    click NotifSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/notifications/"
    click VisitsSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/visits/"
    click SpacesSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/spaces/"
    click FoldersSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/folders/"
    click MaterialSystem "https://github.com/viaacode/hetarchief-proxy/tree/master/src/modules/material-requests/"
    click Guards "https://github.com/viaacode/hetarchief-proxy/tree/master/src/shared/guards/"

    %% Legend
    subgraph Legend["Legend"]
        L1["Client Component"]:::client
        L2["Core Component"]:::core
        L3["External Service"]:::external
        L4["Data Store"]:::data
        L5["Auth Component"]:::auth
    end
```
