# arquisoft/wichat_es1a architecture

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

- Interactive diagram: https://gitdiagram.com/arquisoft/wichat_es1a
- Repository: https://github.com/arquisoft/wichat_es1a

## Overview

##### Project type and purpose
- This is a full-stack, containerized, microservice-based web application (“wichat_es1a”) composed of a React frontend and five back-end services (user, questions, LLM, multiplayer, gateway), all orchestrated via Docker Compose. It implements an API Gateway pattern, each service has a single responsibility, and it uses MongoDB and external APIs (Wikidata and an LLM provider).

##### File structure
- Top-level services (each in its own folder with Dockerfile, package.json, tests):
- gatewayservice (proxies public requests to internal services, exposes OpenAPI specs)
- users (handles user registration and authentication, uses Mongoose/MongoDB)
- questions (generates questions via Wikidata, TypeScript + Express)
- llmservice (wraps calls to an external LLM provider, React public folder for any simple UI)
- multiplayer (real-time game coordination via WebSockets)
- webapp (React single-page app served to users)
- Shared resources and infra files: docker-compose.yml, .env templates, CI workflows, monitoring configs (Prometheus + Grafana under gatewayservice/monitoring), SonarQube, CodeScene, ADRs, Arc42 docs under docs/.

##### README for additional insights
- Describes components, their interactions, deployment via Docker Compose, LLM API configuration, Swagger API docs for users and questions, CI/CD via GitHub Actions, and deployment over SSH.
- Mentions MongoDB shared by “user and auth” (in practice it’s the users service doing both roles).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        Browser["Browser"]:::frontend
        Webapp["Webapp (React SPA)"]:::frontend
    end

    subgraph "API Layer"
        Gateway["API Gateway"]:::backend
    end

    subgraph "Microservices Layer"
        Users["User Service"]:::backend
        Questions["Questions Service"]:::backend
        LLMsvc["LLM Service"]:::backend
        Multiplayer["Multiplayer Service"]:::backend
    end

    subgraph "Data Layer"
        MongoDB["MongoDB"]:::db
        Wikidata["Wikidata API"]:::external
        LLMProvider["LLM Provider API"]:::external
    end

    subgraph "Infra & Ops"
        Prometheus["Prometheus"]:::infra
        Grafana["Grafana"]:::infra
        CICD["CI/CD (GitHub Actions)"]:::infra
        DockerCompose["Docker Compose"]:::infra
    end

    Browser -->|HTTP| Webapp
    Webapp -->|HTTPS| Gateway
    Gateway -->|HTTP| Users
    Gateway -->|HTTP| Questions
    Gateway -->|HTTP| LLMsvc
    Gateway -->|HTTP| Multiplayer
    Users -->|connects| MongoDB
    Questions -->|HTTP| Wikidata
    LLMsvc -->|HTTP| LLMProvider
    Multiplayer <-->|WebSocket| Browser

    Gateway -->|metrics| Prometheus
    Users -->|metrics| Prometheus
    Questions -->|metrics| Prometheus
    LLMsvc -->|metrics| Prometheus
    Multiplayer -->|metrics| Prometheus
    Prometheus -->|scrapes| Grafana

    CICD -->|deploy via SSH & Docker Compose| DockerCompose

    classDef frontend fill:#cfe2f3,stroke:#0366d6,color:#000;
    classDef backend fill:#d9ead3,stroke:#137333,color:#000;
    classDef db fill:#ececec,stroke:#6c6c6c,color:#000,stroke-dasharray: 2 2;
    classDef external fill:#f3f3f3,stroke:#8c8c8c,color:#000,stroke-dasharray: 2 2;
    classDef infra fill:#fce5cd,stroke:#bf9000,color:#000;

    click Webapp "https://github.com/arquisoft/wichat_es1a/tree/master/webapp/"
    click Gateway "https://github.com/arquisoft/wichat_es1a/tree/master/gatewayservice/"
    click Users "https://github.com/arquisoft/wichat_es1a/tree/master/users/"
    click Questions "https://github.com/arquisoft/wichat_es1a/tree/master/questions/"
    click LLMsvc "https://github.com/arquisoft/wichat_es1a/tree/master/llmservice/"
    click Multiplayer "https://github.com/arquisoft/wichat_es1a/tree/master/multiplayer/"
    click DockerCompose "https://github.com/arquisoft/wichat_es1a/blob/master/docker-compose.yml"
    click Prometheus "https://github.com/arquisoft/wichat_es1a/blob/master/gatewayservice/monitoring/prometheus/prometheus.yml"
    click Grafana "https://github.com/arquisoft/wichat_es1a/blob/master/gatewayservice/monitoring/grafana/provisioning/dashboards/wichat_es1a.json"
    click CICD "https://github.com/arquisoft/wichat_es1a/tree/master/.github/workflows/"
```
