# danskernesdigitalebibliotek/dpl-go architecture

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

- Interactive diagram: https://gitdiagram.com/danskernesdigitalebibliotek/dpl-go
- Repository: https://github.com/danskernesdigitalebibliotek/dpl-go

## Overview

##### Main System Components

a. Frontend Layer:
- Next.js App Router (app/*)
- Client-side Components (components/*)
- State Management (store/*)
- UI Component Library (shadcn/ui integration)

b. API/Integration Layer:
- GraphQL Services (lib/graphql/*)
- REST Services (lib/rest/*)
- Authentication Services (app/auth/*)

c. External Services:
- Drupal CMS
- Cover Service API
- Publizon API
- UniLogin Service

##### Component Relationships

a. Client-Side Flow:
**User Interface → Next.js App Router → React Query → API Layer → External Services**

b. Authentication Flow:
**User → Auth Routes → UniLogin Client → Session Management → Protected Routes**

c. Data Flow:
**GraphQL/REST Clients → External Services → Data Fetchers → React Components**

##### Specific Implementation Details

Technical elements:

a. State Management:
- XState Machines (lib/machines/*)
- React Query for server state
- Local stores for UI state

b. Component Architecture:
- Global Components
- Page Layouts
- Shared Components
- Shadcn/UI Components

##### Technical Stack Indicators

- Next.js
- React
- TypeScript
- Tailwind CSS
- GraphQL
- REST APIs

##### Development Environment

A separate section for:
- Storybook integration
- Testing infrastructure (Cypress, Vitest)
- Quality assurance workflows

##### Deployment Flow

A deployment section showing:
- GitHub workflows
- Environment configurations
- Lagoon deployment process

##### The modular architecture with clear separation between
- UI components
- Business logic
- Data fetching
- External service integration

##### The central role of Next.js App Router in handling
- Routing
- Server-side rendering
- API routes

##### The integration points with external services
- Drupal CMS for content
- Cover Service for images
- Publizon for digital publications
- UniLogin for authentication

##### The robust development infrastructure
- Component development (Storybook)
- Testing (Cypress, Vitest)
- Quality assurance (GitHub workflows)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        UI[User Interface]
        Router["Next.js App Router"]:::router
        Components["Client Components"]:::components
        ShadcnUI["Shadcn UI"]:::ui
    end

    subgraph "State Management"
        ReactQuery["React Query"]:::state
        XState["XState Machines"]:::state
        LocalStore["Local Stores"]:::state
    end

    subgraph "API/Integration Layer"
        GraphQL["GraphQL Services"]:::api
        REST["REST Services"]:::api
        Auth["Authentication Services"]:::auth
    end

    subgraph "External Services"
        Drupal["Drupal CMS"]:::external
        CoverService["Cover Service API"]:::external
        Publizon["Publizon API"]:::external
        UniLogin["UniLogin Service"]:::external
    end

    subgraph "Development Infrastructure"
        Storybook["Storybook"]:::dev
        Testing["Testing (Cypress/Vitest)"]:::dev
        CICD["CI/CD Workflows"]:::dev
    end

    subgraph "Session Management"
        SessionHandler["Session Handler"]:::auth
        AuthRoutes["Auth Routes"]:::auth
    end

    %% Connections
    UI --> Router
    Router --> Components
    Components --> ShadcnUI
    Components --> ReactQuery
    Components --> XState
    Components --> LocalStore

    ReactQuery --> GraphQL
    ReactQuery --> REST
    Auth --> UniLogin
    Auth --> SessionHandler
    SessionHandler --> AuthRoutes

    GraphQL --> Drupal
    REST --> CoverService
    REST --> Publizon

    %% Styling
    classDef router fill:#1E40AF,color:white
    classDef components fill:#3B82F6,color:white
    classDef ui fill:#60A5FA,color:white
    classDef state fill:#10B981,color:white
    classDef api fill:#059669,color:white
    classDef auth fill:#7C3AED,color:white
    classDef external fill:#F59E0B,color:white
    classDef dev fill:#6B7280,color:white

    %% Click Events
    click Router "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/app/*"
    click Components "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/components/*"
    click XState "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/lib/machines/*"
    click LocalStore "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/store/*"
    click ReactQuery "https://github.com/danskernesdigitalebibliotek/dpl-go/blob/main/lib/providers/ReactQueryProvider.tsx"
    click GraphQL "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/lib/graphql/*"
    click REST "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/lib/rest/*"
    click Auth "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/app/auth/*"
    click Drupal "https://github.com/danskernesdigitalebibliotek/dpl-go/blob/main/lib/config/dpl-cms/dplCmsConfig.ts"
    click CoverService "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/lib/rest/cover-service-api/*"
    click Publizon "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/lib/rest/publizon-api/*"
    click UniLogin "https://github.com/danskernesdigitalebibliotek/dpl-go/blob/main/lib/session/oauth/uniloginClient.ts"
    click ShadcnUI "https://github.com/danskernesdigitalebibliotek/dpl-go/blob/main/lib/shadcn/utils.ts"
    click Storybook "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/.storybook/*"
    click Testing "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/cypress/*"
    click CICD "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/.github/workflows/*"
    click SessionHandler "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/lib/session/*"
    click AuthRoutes "https://github.com/danskernesdigitalebibliotek/dpl-go/tree/main/app/auth/*"
```
