# dwdbk/appdemo architecture

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

- Interactive diagram: https://gitdiagram.com/dwdbk/appdemo
- Repository: https://github.com/dwdbk/appdemo

## Overview

##### Project type and purpose
- This is a microservices-based, full-stack backend system, comprised of an API Gateway plus two domain services (Opera Service and Shows Service).
- Purpose: provide a federated GraphQL API for managing operas and their show schedules, with built-in auth, caching, monitoring, and containerized deployment.

##### File structure
- Top-level directories:
- gateway-service-nodejs: Node.js-based API Gateway (Express + Apollo Federation proxy + cross-cutting middleware)
- opera-service: Spring Boot GraphQL microservice (manages operas, acts, scenes, characters)
- shows-service: Spring Boot GraphQL microservice (manages show schedules, singers, ticket availability)
- Each microservice has:
- src/main/java/... for code
- src/main/resources/db/changelog for Liquibase migrations
- src/main/resources/graphql for schema files
- application.yml for configuration
- gateway-service-nodejs has Dockerfiles, docker-compose, monitoring (Prometheus, Grafana, Logstash), middleware, proxy setup, health checks.

##### README for additional insights
- Confirms three main runtime components listening on ports 8080 (gateway), 8081 (opera), 8082 (shows).
- Uses Apollo Federation to stitch schemas at gateway.
- Uses custom scalars and directives, Liquibase migrations, Docker/Docker Compose, optional Kubernetes manifests.
- External dependencies: PostgreSQL (one DB per service), Keycloak (OAuth2/JWT), Prometheus, Grafana, Logstash.

##### Detail level
- Essential sub-components in the gateway: auth middleware, caching layer, proxy.
- Liquibase migrations as part of service startup.
- Monitoring pipelines: metrics endpoint → Prometheus → Grafana dashboards, logs → Logstash → Elasticsearch (if used).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Client["GraphQL Client / Playground"]:::api

    %% API Gateway Layer
    subgraph "API Gateway" 
        direction TB
        Gateway["Gateway: Node.js + Apollo Federation (port 8080)"]:::api
        GW_Auth["Auth Integration (Keycloak/JWT)"]:::api
        GW_MW["Cross-Cutting Middleware"]:::api
        GW_Fed["Federation Config"]:::api
        GW_Monitor["Monitoring Stack Configs"]:::api
        Gateway -->|"POST /graphql"| GW_Auth
        Gateway --> GW_MW
        Gateway --> GW_Fed
        Gateway --> GW_Monitor
    end

    %% Domain Services Layer
    subgraph "Domain Services"
        direction TB
        Opera["Opera Service (Spring Boot GraphQL, 8081)"]:::services
        Shows["Shows Service (Spring Boot GraphQL, 8082)"]:::services
        Feign["Feign Client"]:::services
        Shows --> Feign
    end

    %% Databases
    subgraph "Databases"
        direction TB
        OperaDB["opera_db (PostgreSQL)"]:::db
        ShowsDB["shows_db (PostgreSQL)"]:::db
    end

    %% External Infrastructure
    subgraph "External Infrastructure"
        direction TB
        Keycloak["Keycloak (OAuth2/JWT)"]:::infra
        Prometheus["Prometheus"]:::infra
        Grafana["Grafana"]:::infra
        Logstash["Logstash"]:::infra
    end

    %% Interactions
    Client -->|"POST /graphql"| Gateway
    Gateway -->|"GraphQL HTTP"| Opera
    Gateway -->|"GraphQL HTTP"| Shows
    Opera -->|"JDBC + Liquibase"| OperaDB
    Shows -->|"JDBC + Liquibase"| ShowsDB
    Gateway -->|"JWT Validation"| Keycloak
    Gateway -->|"Metrics endpoint"| Prometheus
    Opera -->|"Metrics endpoint"| Prometheus
    Shows -->|"Metrics endpoint"| Prometheus
    Prometheus -->|"Datasource"| Grafana
    Opera -->|"Log shipping"| Logstash
    Shows -->|"Log shipping"| Logstash

    %% Click Events
    click Gateway "https://github.com/dwdbk/appdemo/blob/main/gateway-service-nodejs/src/app.js"
    click GW_Auth "https://github.com/dwdbk/appdemo/blob/main/gateway-service-nodejs/src/config/auth.config.js"
    click GW_MW "https://github.com/dwdbk/appdemo/tree/main/gateway-service-nodejs/src/middleware/"
    click GW_Fed "https://github.com/dwdbk/appdemo/tree/main/gateway-service/src/main/java/com/opera/gateway/config/"
    click GW_Monitor "https://github.com/dwdbk/appdemo/tree/main/gateway-service-nodejs/monitoring/"
    click Opera "https://github.com/dwdbk/appdemo/tree/main/opera-service/src/main/java/com/opera/operaservice/"
    click Shows "https://github.com/dwdbk/appdemo/tree/main/shows-service/src/main/java/com/opera/shows/"
    click Feign "https://github.com/dwdbk/appdemo/blob/main/shows-service/src/main/java/com/opera/shows/client/OperaServiceClient.java"

    %% Styles
    classDef api fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef services fill:#90EE90,stroke:#000,stroke-width:1px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px
    classDef infra fill:#DDA0DD,stroke:#000,stroke-width:1px
```
