# mojeeeb/spezielleprog architecture

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

- Interactive diagram: https://gitdiagram.com/mojeeeb/spezielleprog
- Repository: https://github.com/mojeeeb/spezielleprog

## Overview

##### Project type and purpose
- This is a security‐automation pipeline for Kubernetes‐based workloads. It uses Trivy to scan images or clusters for vulnerabilities, a “bot” microservice to ingest and forward scan results, and n8n (an external workflow/orchestration tool) to process and notify about those results. Deployment and configuration are managed via Helm charts and ArgoCD manifests.

##### File structure
- Top-level scripts:
- auto.py – likely the scheduler or orchestrator that triggers Trivy scans.
- bot.py – a small service that receives Trivy JSON output and pushes it to n8n.
- Configuration for containerization and CI/CD:
- Dockerfile – builds container images for the services.
- requirements.txt – Python dependencies (Trivy SDK, HTTP libraries, etc.).
- .github/renovate.json – dependency updates configuration.
- Kubernetes/Helm:
- helm/smartops – Helm chart defining:
– auto-job.yaml (Kubernetes CronJob to run auto.py)
– deployment.yaml (bot.py deployment)
– monitoring.yaml (service-monitor rules)
– security-scan.yaml (maybe a custom resource to trigger scans)
– values.yaml (chart customization)
- kubernetes/argocd-app.yaml – ArgoCD Application manifest for GitOps deployment.
- kubernetes/namespace.yaml – Kubernetes namespace definition.
- trivy-results.json – sample output from a Trivy scan used by the bot.

##### Main components
a. Trivy Scanner
– Runs as a Kubernetes CronJob (auto.py).
– Reads container images or Kubernetes resources.
– Emits JSON results (trivy-results.json).
b. Bot Service
– Deploys as a Deployment (bot.py).
– Exposes an HTTP endpoint or reads from a shared volume.
– Forwards results to n8n via HTTP/webhook.
c. n8n Orchestration
– External SaaS or self-hosted workflow engine.
– Receives payloads from Bot.
– Runs workflows (alerts, ticket creation, dashboards).
d. GitOps/CD Pipeline
– ArgoCD watches the git repo (helm charts + manifests).
– Syncs changes into the Kubernetes cluster.
e. Kubernetes Cluster
– Namespace for smartops.
– CronJobs, Deployments, Services, ServiceMonitors.

##### Relationships and interactions
- [ArgoCD] ──(sync Helm charts)──> [K8s Cluster]
- [K8s CronJob(auto.py/Trivy)] ──(scan)──> [Container Registry/K8s API]
- [K8s CronJob] ──(output JSON)──> [Bot Service]
- [Bot Service] ──(HTTP POST)──> [n8n Endpoint]
- [n8n] ──(workflow results/notifications)──> [Slack/Email/Issue Tracker]

##### Architectural patterns and principles
- Micro-services: Trivy runner (stateless cronjob) + Bot (small HTTP service).
- GitOps: Helm + ArgoCD for declarative deployment.
- Event-driven: JSON scan results trigger workflows.
- Infrastructure as Code: Helm templates and Kubernetes YAMLs.

##### Technologies and frameworks
- Python (auto.py, bot.py)
- Trivy (security scanner)
- Docker (container images)
- Kubernetes (CronJob, Deployment)
- Helm (templating)
- ArgoCD (GitOps)
- n8n (workflow automation)
- Optional: Prometheus/ServiceMonitor for monitoring.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CI/CD / GitOps"
        Repo["Git Repository"]:::gitops
        ArgoCD["ArgoCD"]:::gitops
        Helm["Helm Chart (smartops)"]:::gitops
    end

    subgraph "Kubernetes Cluster (smartops namespace)"
        Namespace["Namespace: smartops"]:::cluster
        subgraph "Helm Chart Deployment"
            AutoJob["Trivy Scanner (CronJob)"]:::cron
            Bot["Bot Service (Deployment)"]:::svc
            ServiceMon["ServiceMonitor"]:::monitor
            SecScanCR["SecurityScan CR"]:::custom
        end
    end

    subgraph "Runtime Data"
        TrivyOut["trivy-results.json"]:::data
    end

    subgraph "External Systems"
        Registry["Container Registry / K8s API"]:::external
        n8n["n8n Workflow Engine"]:::external
        Notifications["Slack / Email / Issue Tracker"]:::external
    end

    Repo -->|git push| ArgoCD
    ArgoCD -->|sync Helm charts| Helm
    Helm --> Namespace
    Helm --> AutoJob
    Helm --> Bot
    Helm --> ServiceMon
    Helm --> SecScanCR

    AutoJob -->|scan| Registry
    AutoJob -->|produce JSON| TrivyOut
    TrivyOut -->|read JSON| Bot
    Bot -->|HTTP POST /scan-results| n8n
    n8n -->|workflow notifications| Notifications

    click AutoJob "https://github.com/mojeeeb/spezielleprog/blob/main/auto.py"
    click AutoJob "https://github.com/mojeeeb/spezielleprog/blob/main/helm/smartops/templates/auto-job.yaml"
    click Bot "https://github.com/mojeeeb/spezielleprog/blob/main/bot.py"
    click Bot "https://github.com/mojeeeb/spezielleprog/blob/main/helm/smartops/templates/deployment.yaml"
    click Helm "https://github.com/mojeeeb/spezielleprog/blob/main/helm/smartops/Chart.yaml"
    click Helm "https://github.com/mojeeeb/spezielleprog/blob/main/helm/smartops/values.yaml"
    click Helm "https://github.com/mojeeeb/spezielleprog/tree/main/helm/smartops/templates/"
    click ArgoCD "https://github.com/mojeeeb/spezielleprog/blob/main/kubernetes/argocd-app.yaml"
    click Namespace "https://github.com/mojeeeb/spezielleprog/blob/main/kubernetes/namespace.yaml"
    click ServiceMon "https://github.com/mojeeeb/spezielleprog/blob/main/helm/smartops/templates/monitoring.yaml"
    click SecScanCR "https://github.com/mojeeeb/spezielleprog/blob/main/helm/smartops/templates/security-scan.yaml"
    click Registry "https://github.com/mojeeeb/spezielleprog/tree/main/Dockerfile"
    click Registry "https://github.com/mojeeeb/spezielleprog/blob/main/requirements.txt"
    click TrivyOut "https://github.com/mojeeeb/spezielleprog/blob/main/trivy-results.json"
    click Repo "https://github.com/mojeeeb/spezielleprog/blob/main/.github/renovate.json"

    classDef gitops fill:#e0f7fa,stroke:#006064,color:#006064
    classDef cluster fill:#e3f2fd,stroke:#0d47a1,color:#0d47a1
    classDef cron fill:#fff3e0,stroke:#e65100,color:#e65100
    classDef svc fill:#f3e5f5,stroke:#6a1b9a,color:#6a1b9a
    classDef monitor fill:#ffebee,stroke:#b71c1c,color:#b71c1c
    classDef custom fill:#eceff1,stroke:#37474f,color:#37474f
    classDef data fill:#fffde7,stroke:#f9a825,color:#f9a825
    classDef external fill:#e8f5e9,stroke:#1b5e20,color:#1b5e20
```
