# visualize-admin/visualization-tool architecture

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

- Interactive diagram: https://gitdiagram.com/visualize-admin/visualization-tool
- Repository: https://github.com/visualize-admin/visualization-tool

## Overview

##### Main System Components

a. Frontend Layer:
- Next.js application (/app directory)
- Chart visualization components (/app/charts)
- Configuration interface (/app/configurator)
- Authentication system (Next-auth)
- Internationalization support (/app/locales)

b. Backend Layer:
- GraphQL API (/app/graphql)
- Database layer (PostgreSQL)
- RDF data handling (/app/rdf)
- Authentication providers (/app/auth-providers)

c. External Services:
- eIAM (Swiss federal government authentication)
- Accent (Translation management)
- Prometheus/Grafana (Performance monitoring)
- Percy (Visual regression testing)

**┌─ Client Layer ─────────────────────────────────────┐**
- Browser                                          │
- Embed Script                                     │
- ┘
- ↕ (HTTP/HTTPS)
**┌─ Application Layer ──────────────────────────────────┐**
- ┌─ Frontend ─────┐  ┌─ API Layer ─────────────────┐ │
- Next.js      │  │ - GraphQL API               │ │
- React        │  │ - RDF Query Handler         │ │
- Charts       │  │ - Authentication Middleware  │ │
- ┘  └───────────────────────────────┘│
- ┘
- ↕
**┌─ Data Layer ───────────────────────────────────────┐**
- PostgreSQL Database                              │
- RDF Data Store                                   │
- ┘
- ↕
**┌─ External Services ─────────────────────────────────┐**
- eIAM Authentication                              │
- Accent Translation Service                       │
- Monitoring (Prometheus/Grafana)                  │
- Visual Testing (Percy)                           │
- ┘

##### Key Interactions to Highlight

a. Data Flow:
- Client requests → Next.js → GraphQL API → RDF/Database
- Authentication flow through eIAM
- Translation management through Accent
- Performance metrics to Prometheus/Grafana

b. Development Workflow:
- E2E testing pipeline
- Visual regression testing
- Load testing with k6
- CI/CD pipeline

##### Important Architectural Patterns

- GraphQL-based API architecture
- Component-based visualization system
- Microservices integration (auth, translations)
- Multi-environment deployment (dev, int, prod)

##### Additional Elements

Specific sections for:
- Development tools and environments
- Testing infrastructure
- Deployment pipelines
- Monitoring and observability

##### The comprehensive testing and monitoring infrastructure

Remember to maintain a balance between detail and clarity, focusing on the key architectural decisions while avoiding overwhelming detail at the component level.

This system design should help developers understand both the high-level architecture and the specific implementation details of the Visualization Tool project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Client Layer
    subgraph ClientLayer
        Browser["Browser"]
        EmbedScript["Embed Script"]
    end

    %% Application Layer
    subgraph AppLayer
        %% Frontend
        subgraph FrontendLayer
            NextJS["Next.js App"]
            Charts["Chart Components"]:::frontend
            Config["Configuration Interface"]:::frontend
            I18n["Internationalization"]:::frontend
            AuthUI["Authentication UI"]:::frontend
            FrontComps["Frontend Components"]:::frontend
            AppPages["Application Pages"]:::frontend
        end

        %% Backend
        subgraph BackendLayer
            GraphQL["GraphQL API"]:::backend
            RDFHandler["RDF Query Handler"]:::backend
            AuthMiddleware["Auth Middleware"]:::backend
        end
    end

    %% Data Layer
    subgraph DataLayer
        PostgreSQL[(PostgreSQL DB)]:::database
        RDFStore[(RDF Data Store)]:::database
    end

    %% External Services
    subgraph ExternalServices
        eIAM["eIAM Auth"]:::external
        Accent["Accent Translation"]:::external
        Monitoring["Prometheus/Grafana"]:::external
        Percy["Percy Visual Testing"]:::external
    end

    %% Testing Infrastructure
    subgraph TestingLayer
        E2E["E2E Tests"]
        K6["K6 Performance Tests"]
        Docs["Documentation"]
    end

    %% Connections
    Browser --> NextJS
    EmbedScript --> NextJS
    NextJS --> Charts
    NextJS --> Config
    NextJS --> I18n
    NextJS --> AuthUI
    NextJS --> FrontComps
    NextJS --> AppPages
    NextJS --> GraphQL
    GraphQL --> RDFHandler
    GraphQL --> AuthMiddleware
    RDFHandler --> RDFStore
    RDFHandler --> PostgreSQL
    AuthMiddleware --> eIAM
    I18n --> Accent
    AppLayer --> Monitoring
    TestingLayer --> Percy

    %% Click Events
    click Charts "https://github.com/visualize-admin/visualization-tool/tree/main/app/charts/"
    click Config "https://github.com/visualize-admin/visualization-tool/tree/main/app/configurator/"
    click I18n "https://github.com/visualize-admin/visualization-tool/tree/main/app/locales/"
    click AuthMiddleware "https://github.com/visualize-admin/visualization-tool/tree/main/app/auth-providers/"
    click GraphQL "https://github.com/visualize-admin/visualization-tool/tree/main/app/graphql/"
    click PostgreSQL "https://github.com/visualize-admin/visualization-tool/tree/main/app/db/"
    click RDFHandler "https://github.com/visualize-admin/visualization-tool/tree/main/app/rdf/"
    click AuthUI "https://github.com/visualize-admin/visualization-tool/tree/main/app/login/"
    click FrontComps "https://github.com/visualize-admin/visualization-tool/tree/main/app/components/"
    click AppPages "https://github.com/visualize-admin/visualization-tool/tree/main/app/pages/"
    click Percy "https://github.com/visualize-admin/visualization-tool/blob/main/.github/workflows/chromatic.yml"
    click Accent "https://github.com/visualize-admin/visualization-tool/blob/main/accent.json"
    click E2E "https://github.com/visualize-admin/visualization-tool/tree/main/e2e/"
    click K6 "https://github.com/visualize-admin/visualization-tool/tree/main/k6/"
    click Docs "https://github.com/visualize-admin/visualization-tool/tree/main/app/docs/"

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        DB["Database"]:::database
        Ext["External Service"]:::external
        Sec["Security Component"]:::security
    end
```
