# alexdragnea/upb-disertatie architecture

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

- Interactive diagram: https://gitdiagram.com/alexdragnea/upb-disertatie
- Repository: https://github.com/alexdragnea/upb-disertatie

## Overview

- Microservices Group:
- iot-bridge-service: Handles device communication and Kafka message production.
- iot-core-service: Acts as the core IoT service managing measurements, caching, and inter-service communication.
- iot-discovery-service: Enables dynamic registration/discovery of services.
- iot-gateway-service: Manages network entry, authentication, and routing (including Netty configurations).
- iot-user-service: Manages user accounts, API keys, authentication, and authorization.
- Front-end:
- iot-dashboard: A React-based application serving as the user interface.
- Shared Components:
- iot-commons: Contains common libraries, constants, DTOs, and Avro schemas used across services.
- Additional utilities such as performance testing (iot-performance-testing) which simulates IoT data flows.
- External / Infrastructure Services:
- Databases: MongoDB (document-store) and InfluxDB (time-series).
- Message Broker: Kafka (for asynchronous inter-service messaging).
- Cache and Additional services: Redis.
- Monitoring & Visualization: Prometheus (using prometheus.yml), Grafana (with dashboard JSONs), and possibly custom alerting.
- Certificates: Managed under the cert folder for secure communications.

##### Relationships and Interactions
- Directional data flows:
- REST interactions from the iot-dashboard (frontend) to the backend microservices (through API gateways) for data visualization.
- Kafka as the central event bus where the iot-bridge-service produces messages and the iot-core-service (among others) may consume these messages.
- That the microservices share a common library (iot-commons) to ensure consistency.
- Infrastructure connections from services to databases (InfluxDB, MongoDB) and caching solutions (Redis).

##### Architectural Patterns / Design Principles
- Microservices Architecture: Each service is independently deployable (evidenced by separate Maven projects, Dockerfiles, and Kubernetes manifests).
- API Gateway/Discovery: The presence of iot-gateway-service and iot-discovery-service implies dynamic routing and service discovery.
- Event-Driven and Asynchronous Communication: The use of Kafka along with Avro messages shows an event-driven design.
- Containerization and Orchestration: Use of Docker-compose files and various k8s YAML files emphasizes container-based deployments.
- Observability and Monitoring: Separate directories with monitoring dashboards and configuration files for InfluxDB, Prometheus, and Grafana.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Users["External Clients"]:::external
    click Users "https://github.com/alexdragnea/upb-disertatie/tree/master/ "

    %% Frontend
    dashboard["iot-dashboard (React, Tailwind)"]:::frontend

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        direction TB
        microservices["IoT Microservices"]:::group
        subgraph "Microservices"
            direction TB
            bridge["iot-bridge-service (Kafka Producer)"]:::microservice
            core["iot-core-service (Core, Caching)"]:::microservice
            discovery["iot-discovery-service (Service Discovery)"]:::microservice
            gateway["iot-gateway-service (API Gateway, Netty)"]:::microservice
            userService["iot-user-service (User Management)"]:::microservice
        end
        shared["iot-commons (Shared Library)"]:::shared
        performance["iot-performance-testing (Simulated IoT Data)"]:::shared
    end

    %% Infrastructure & External Services
    subgraph "Infrastructure & External Services"
        direction TB
        kafka["Kafka (Message Broker)"]:::infra
        mongo["MongoDB (Document Store)"]:::database
        influx["InfluxDB (Time-series DB)"]:::database
        redis["Redis (Cache)"]:::infra
        prometheus["Prometheus (Monitoring)"]:::monitor
        grafana["Grafana (Visualization)"]:::monitor
        certificates["Certificates (Secure Comm)"]:::infra
        dockerCompose["Docker Compose Deployment"]:::infra
    end

    %% Relationships
    Users -->|"accesses"| dashboard

    dashboard -->|"REST API Call"| gateway

    gateway -->|"Routes Request"| core
    gateway -->|"Routes Request"| userService
    gateway -->|"Secured by"| certificates

    bridge -->|"Produces Data"| kafka
    kafka -->|"Delivers Data"| core

    core -->|"Stores/Retrieves Data"| mongo
    core -->|"Stores/Retrieves Data"| influx
    core -->|"Caches Data"| redis

    %% Shared library usage (dashed)
    bridge ---|"Uses"| shared
    core ---|"Uses"| shared
    discovery ---|"Uses"| shared
    gateway ---|"Uses"| shared
    userService ---|"Uses"| shared

    %% Monitoring: All microservices send metrics 
    core -->|"Metrics"| prometheus
    gateway -->|"Metrics"| prometheus
    userService -->|"Metrics"| prometheus

    prometheus -->|"Visualizes"| grafana

    %% Kubernetes Deployment & Alternate Deployment
    microservices ---|"Deployed via"| dockerCompose
    microservices ---|"Managed by"| certificates

    %% Click Events
    click bridge "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-bridge-service/"
    click core "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-core-service/"
    click discovery "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-discovery-service/"
    click gateway "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-gateway-service/"
    click userService "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-user-service/"
    click dashboard "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-dashboard/"
    click shared "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-commons/"
    click performance "https://github.com/alexdragnea/upb-disertatie/tree/master/iot-performance-testing/"
    click mongo "https://github.com/alexdragnea/upb-disertatie/blob/master/infra/db/mongo.yaml"
    click influx "https://github.com/alexdragnea/upb-disertatie/blob/master/infra/db/influxdb.yaml"
    click kafka "https://github.com/alexdragnea/upb-disertatie/blob/master/infra/kafka/kafka.yaml"
    click redis "https://github.com/alexdragnea/upb-disertatie/blob/master/infra/redis/redis.yaml"
    click grafana "https://github.com/alexdragnea/upb-disertatie/tree/master/infra/grafana-dashboards/"
    click prometheus "https://github.com/alexdragnea/upb-disertatie/blob/master/prometheus.yml"
    click certificates "https://github.com/alexdragnea/upb-disertatie/tree/master/cert/"
    click dockerCompose "https://github.com/alexdragnea/upb-disertatie/blob/master/docker-compose.yml"

    %% Styles
    classDef external fill:#ffeead,stroke:#333,stroke-width:2px;
    classDef frontend fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef microservice fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef shared fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef infra fill:#577590,stroke:#fff,stroke-width:2px;
    classDef database fill:#277da1,stroke:#fff,stroke-width:2px;
    classDef monitor fill:#4d908e,stroke:#fff,stroke-width:2px;
    classDef group fill:#c0e0de,stroke:#333,stroke-dasharray: 5 5,stroke-width:2px;
```
