# arquisoft/wiq_es05b architecture

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

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

## Overview

##### Main Components

Frontend Layer:
- React Webapp (port 3000)
- Features: Authentication, Game Interface, Social Features
- Context providers (Auth, Config, Game, Locale)

API Gateway Layer:
- Gateway Service (port 8000)
- Routing and middleware functionality
- Authentication/Authorization handlers
- Request validation

Microservices Layer:
- User Service (user management)
- Auth Service (authentication/authorization)
- Jordi Service (question generation)
- User History Service (game history)
- Ranking Service (scoring system)

Infrastructure Layer:
- MongoDB Database (shared between services)
- Monitoring Stack:
- Prometheus
- Grafana
- Logging Stack:
- Elasticsearch
- Logstash
- Kibana
- Nginx Proxy

**[Client Layer (Browser)]**
- ↓
**[Nginx Proxy]**
- ↓
**[API Gateway]**
- ↓
**[Microservices Layer]**
- ↓
**[Data Layer]**

##### Additional Elements
- Docker container boundaries (show containerization)
- Load balancing indicators
- Security components (Auth middleware)
- External service connections (Wikidata for questions)

##### Specific Details

For each microservice, show:
- Main responsibilities
- Key endpoints
- Database interactions
- Inter-service communication patterns

For monitoring/logging:
- Metrics collection paths
- Log aggregation flow
- Dashboard connections

##### Important Architectural Patterns to Highlight
- API Gateway Pattern
- Microservices Architecture
- Event-Driven Communication (where applicable)
- Circuit Breaker Pattern
- Authentication/Authorization Flow

##### Deployment Information
- Production vs development environments
- Container orchestration
- Service discovery
- Load balancing

##### Cross-Cutting Concerns
- i18n support (shown in utils)
- Logging mechanisms
- Error handling
- Security measures

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Client
        Browser["Browser"]:::client
    end

    %% Frontend Layer
    subgraph Frontend
        ReactApp["React Webapp (3000)"]:::frontend
        click ReactApp "https://github.com/Arquisoft/wiq_es05b/tree/master/webapp"
        AppMain["App.jsx"]:::frontend
        click AppMain "https://github.com/Arquisoft/wiq_es05b/blob/master/webapp/src/App.jsx"
        Views["Views"]:::frontend
        click Views "https://github.com/Arquisoft/wiq_es05b/tree/master/webapp/src/views"
        Contexts["Context Providers"]:::frontend
        click Contexts "https://github.com/Arquisoft/wiq_es05b/tree/master/webapp/src/views/context"
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        Nginx["Nginx Proxy"]:::infra
        click Nginx "https://github.com/Arquisoft/wiq_es05b/tree/master/proxy"
        NginxConf["Nginx Config"]:::infra
        click NginxConf "https://github.com/Arquisoft/wiq_es05b/blob/master/proxy/nginx.conf"
    end

    %% API Gateway Layer
    subgraph Gateway
        GatewayService["Gateway Service (8000)"]:::gateway
        click GatewayService "https://github.com/Arquisoft/wiq_es05b/tree/master/gatewayservice"
        AuthMiddleware["Auth Middleware"]:::gateway
        click AuthMiddleware "https://github.com/Arquisoft/wiq_es05b/blob/master/gatewayservice/middleware/AuthMiddleware.js"
        GatewayRoutes["Routes"]:::gateway
        click GatewayRoutes "https://github.com/Arquisoft/wiq_es05b/tree/master/gatewayservice/routes"
    end

    %% Microservices Layer
    subgraph Services
        UserService["User Service"]:::service
        click UserService "https://github.com/Arquisoft/wiq_es05b/tree/master/users/userservice"
        AuthService["Auth Service"]:::service
        click AuthService "https://github.com/Arquisoft/wiq_es05b/tree/master/users/authservice"
        JordiService["Jordi Service"]:::service
        click JordiService "https://github.com/Arquisoft/wiq_es05b/tree/master/jordi"
        HistoryService["User History Service"]:::service
        click HistoryService "https://github.com/Arquisoft/wiq_es05b/tree/master/userhistory"
    end

    %% Monitoring & Logging Layer
    subgraph Observability
        subgraph Monitoring
            Prometheus["Prometheus"]:::monitoring
            click Prometheus "https://github.com/Arquisoft/wiq_es05b/tree/master/monitoring/prometheus"
            Grafana["Grafana"]:::monitoring
            click Grafana "https://github.com/Arquisoft/wiq_es05b/tree/master/monitoring/grafana"
        end
        
        subgraph Logging
            Elasticsearch["Elasticsearch"]:::logging
            click Elasticsearch "https://github.com/Arquisoft/wiq_es05b/tree/master/logging/elastic"
            Logstash["Logstash"]:::logging
            click Logstash "https://github.com/Arquisoft/wiq_es05b/tree/master/logging/logstash"
            Kibana["Kibana"]:::logging
            click Kibana "https://github.com/Arquisoft/wiq_es05b/tree/master/logging/kibana"
        end
    end

    %% Shared Utils
    subgraph Utils
        SharedUtils["Shared Utils"]:::utils
        click SharedUtils "https://github.com/Arquisoft/wiq_es05b/tree/master/cyt-utils"
        I18n["i18n Support"]:::utils
        click I18n "https://github.com/Arquisoft/wiq_es05b/tree/master/cyt-utils/i18n"
        LoggingUtils["Logging"]:::utils
        click LoggingUtils "https://github.com/Arquisoft/wiq_es05b/tree/master/cyt-utils/logging"
    end

    %% Database Layer
    subgraph Database
        MongoDB[(MongoDB)]:::database
    end

    %% Connections
    Browser --> Nginx
    Nginx --> ReactApp
    ReactApp --> AppMain
    AppMain --> Views
    AppMain --> Contexts
    ReactApp --> GatewayService
    GatewayService --> AuthMiddleware
    GatewayService --> GatewayRoutes
    GatewayService --> UserService
    GatewayService --> AuthService
    GatewayService --> JordiService
    GatewayService --> HistoryService
    UserService --> MongoDB
    AuthService --> MongoDB
    JordiService --> MongoDB
    HistoryService --> MongoDB
    
    %% Monitoring Connections
    Services -.-> Prometheus
    Prometheus -.-> Grafana
    Services -.-> Logstash
    Logstash -.-> Elasticsearch
    Elasticsearch -.-> Kibana

    %% Shared Utils Connections
    SharedUtils --- I18n
    SharedUtils --- LoggingUtils
    Services --> SharedUtils
    
    %% Styles
    classDef client fill:#f9f,stroke:#333
    classDef frontend fill:#3498db,stroke:#333
    classDef infra fill:#95a5a6,stroke:#333
    classDef gateway fill:#2ecc71,stroke:#333
    classDef service fill:#f1c40f,stroke:#333
    classDef database fill:#e74c3c,stroke:#333
    classDef monitoring fill:#9b59b6,stroke:#333
    classDef logging fill:#8e44ad,stroke:#333
    classDef utils fill:#34495e,stroke:#333
```
