# remla2025-team10/operation architecture

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

- Interactive diagram: https://gitdiagram.com/remla2025-team10/operation
- Repository: https://github.com/remla2025-team10/operation

## Overview

##### Project type and purpose
- This is a full-stack web application for sentiment analysis of restaurant reviews.
- It comprises two microservices (app-service for the frontend+backend, model-service for ML inference) and extensive infrastructure code (Docker Compose, a Vagrant/Ansible-provisioned Kubernetes cluster, and a Helm chart with monitoring).

##### File structure
Top-level directories and files:
- Vagrantfile + ansible/: Infrastructure as code for spinning up a multi-node Kubernetes cluster (control plane + workers).
- docker-compose.yml + app-ingress/: Local Docker Compose deployment of app-service and model-service (with an NGINX ingress).
- deployment.yaml, finalization.yml, kubernetes-dashboard/: Raw Kubernetes manifests and playbooks for cluster finalization and dashboard setup.
- model-stack/: A Helm chart defining Kubernetes Deployments, Services, Ingress, ServiceMonitor, AlertManager rules, etc., for production-style deployment.
- model.json: The trained ML model artifact.

##### README for additional insights
- Two deployment modes: local Docker Compose vs. Vagrant-provisioned K8s vs. Minikube + Helm.
- The Kubernetes cluster uses Flannel (network), MetalLB (LoadBalancer), NGINX Ingress, the Dashboard, Prometheus + AlertManager + Grafana.
- App-service listens on port 8080 and proxies sentiment requests to model-service on port 3000.

##### Essential architectural elements to capture
- Infrastructure provisioning (Vagrant/Ansible) and Kubernetes cluster layout
- Service mesh boundaries (app vs. model service)
- External access path (DNS → MetalLB → Ingress → app)
- Monitoring & alerting pipeline
- Dependency on Helm for deployment templating

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef compute fill:#ccf,stroke:#333;
    classDef infra fill:#cfc,stroke:#333;
    classDef monitor fill:#fc9,stroke:#333;
    classDef external fill:#fff,stroke:#333;

    subgraph "Infrastructure Provisioning"
        Vagrant["Vagrantfile"]:::infra
        AnsibleGen["general.yaml"]:::infra
        AnsibleCtrl["ctrl.yaml"]:::infra
        AnsibleNode["node.yaml"]:::infra
        FinalizePlay["finalization.yml"]:::infra
    end

    Developer["Developer Workstation"]:::external
    Developer -->|runs| Vagrant
    Vagrant -->|uses| AnsibleGen
    AnsibleGen --> AnsibleCtrl
    AnsibleCtrl --> AnsibleNode
    AnsibleNode --> FinalizePlay

    subgraph "Kubernetes Cluster"
        Control["Control Plane (K8s Master)"]:::compute
        Workers["Worker Nodes"]:::compute
        CNI["Flannel CNI"]:::infra
        LB["MetalLB LoadBalancer"]:::infra
        IngressCtrl["NGINX Ingress Controller"]:::infra
        Dashboard["Kubernetes Dashboard"]:::infra
    end

    FinalizePlay --> Control
    Control --> Workers
    Control --> CNI --> LB --> IngressCtrl
    Control --> Dashboard

    subgraph "Deployment Tools"
        HelmChart["Helm Chart"]:::infra
        Values["values.yaml"]:::infra
    end

    click Vagrant "https://github.com/remla2025-team10/operation/tree/main/Vagrantfile"
    click AnsibleGen "https://github.com/remla2025-team10/operation/blob/main/ansible/general.yaml"
    click AnsibleCtrl "https://github.com/remla2025-team10/operation/blob/main/ansible/ctrl.yaml"
    click AnsibleNode "https://github.com/remla2025-team10/operation/blob/main/ansible/node.yaml"
    click FinalizePlay "https://github.com/remla2025-team10/operation/blob/main/finalization.yml"
    click HelmChart "https://github.com/remla2025-team10/operation/blob/main/model-stack/Chart.yaml"
    click Values "https://github.com/remla2025-team10/operation/blob/main/model-stack/values.yaml"

    Developer -->|helm deploy| HelmChart

    subgraph "Kubernetes Deployment (Helm model-stack)"
        AppPod["app-service Pod"]:::compute
        ModelPod["model-service Pod"]:::compute
        AppSvc["app-service Service"]:::infra
        ModelSvc["model-service Service (ClusterIP)"]:::infra
        K8sIngress["Ingress rule"]:::infra
    end

    click AppPod "https://github.com/remla2025-team10/operation/blob/main/model-stack/templates/deployment.yaml"
    click AppSvc "https://github.com/remla2025-team10/operation/blob/main/model-stack/templates/service.yaml"
    click ModelSvc "https://github.com/remla2025-team10/operation/blob/main/model-stack/templates/service.yaml"
    click K8sIngress "https://github.com/remla2025-team10/operation/blob/main/model-stack/templates/ingress.yaml"

    HelmChart --> AppPod
    HelmChart --> ModelPod
    HelmChart --> AppSvc
    HelmChart --> ModelSvc
    HelmChart --> K8sIngress

    subgraph "Local Docker Compose Deployment"
        DCApp["app-service (8080)"]:::compute
        DCModel["model-service (3000)"]:::compute
        DCIngress["app-ingress"]:::infra
    end

    click DCApp "https://github.com/remla2025-team10/operation/blob/main/docker-compose.yml"
    click DCIngress "https://github.com/remla2025-team10/operation/blob/main/app-ingress/app-ingress.yaml"

    User["User"]:::external
    User --> DCIngress --> DCApp
    DCApp -->|HTTP| DCModel

    User --> LB --> IngressCtrl --> K8sIngress --> AppSvc --> AppPod
    AppPod -->|HTTP| ModelSvc --> ModelPod

    subgraph "Observability"
        SM["ServiceMonitor"]:::monitor
        Prom["Prometheus"]:::monitor
        Alert["AlertManager"]:::monitor
        Graf["Grafana"]:::monitor
        TestRule["requests-rule"]:::monitor
    end

    click SM "https://github.com/remla2025-team10/operation/blob/main/model-stack/templates/servicemonitor.yaml"
    click Alert "https://github.com/remla2025-team10/operation/blob/main/model-stack/templates/alertmanager-config.yaml"
    click TestRule "https://github.com/remla2025-team10/operation/blob/main/model-stack/monitoring/rules/test.yaml"

    AppPod -->|metrics| SM
    ModelPod -->|metrics| SM
    SM --> Prom
    Prom --> Alert -->|emails| Developer
    Prom --> Graf
```
