Files
eveAI/documentation/Production Setup/eveai_architecture.md

15 KiB

EveAI Cloud Architectuur

Overzicht

De EveAI applicatie draait op een moderne cloud-native architectuur met Kubernetes op Scaleway, beschermd door Bunny.net CDN en ondersteund door diverse managed services.

Architectuurdiagram (Aanbevolen Setup)

Internet
    ↓
DNS (askeveai.com - alle subdomains)
    ↓
Bunny.net CDN (Multi-domain setup)
    ├─ askeveai.com → WordPress Hosting -> Scaleway hosting (voorlopig enkel via plugin)
    ├─ evie-staging.askeveai.com → Scaleway LB → Staging Cluster  
    └─ evie.askeveai.com → Scaleway LB → Production Cluster
    ↓
Scaleway Load Balancer (Statisch IP)
    ↓
Kubernetes Cluster (Scaleway)
    ↓
Ingress Controller
    ↓
┌─────────────────────────────────────┐
│              Applicaties            │
├─────────────────────────────────────┤
│ • eveai_app (staging/production)   │
│ • eveai_api (staging/production)   │  
│ • eveai_workers (staging/production)│
│ • [andere pods]                    │
└─────────────────────────────────────┘
    ↓
┌─────────────────────────────────────┐
│          Managed Services           │
├─────────────────────────────────────┤
│ • Redis (per environment)          │
│ • PostgreSQL (per environment)     │
│ • Object Storage (S3/Minio)       │
└─────────────────────────────────────┘

Componenten

1. CDN & Security Layer

Bunny.net CDN

  • Functie: Content Delivery Network en security gateway
  • Voordelen:
    • DDoS bescherming en attack mitigation
    • Caching van statische bestanden
    • Ontlasting van de backend cluster
    • Verbeterde loading times voor eindgebruikers
    • Web Application Firewall functionaliteit

2. DNS & Multi-Domain Routing

DNS Provider: EuroDNS

  • Hosting: hosting.com (alleen WordPress hosting)
  • Email: ProtonMail (via domein records)
  • Application: Scaleway cluster

Bunny.net Pull Zone Setup

  • Zone 1: askeveai.com → Origin: hosting.com WordPress
  • Zone 2: evie-staging.askeveai.com → Origin: Scaleway LB IP
  • Zone 3: evie.askeveai.com → Origin: Scaleway LB IP

DNS Records (EuroDNS) - Uitgebreid

; Web traffic via Bunny.net
A    askeveai.com                 → Scaleway hosting IP
A    evie-staging.askeveai.com    → Bunny.net IP
A    evie.askeveai.com            → Bunny.net IP
A    static.askeveai.com          → Bunny.net IP (voor static assets)

; Email records (ProtonMail) - blijven direct
MX   askeveai.com                 → mail.protonmail.ch (priority 10)
MX   askeveai.com                 → mailsec.protonmail.ch (priority 20)
TXT  askeveai.com                 → "v=spf1 include:_spf.protonmail.ch ~all"
TXT  protonmail._domainkey.askeveai.com → [DKIM key van ProtonMail]
TXT  _dmarc.askeveai.com          → "v=DMARC1; p=quarantine; rua=..."

; Subdomains for email (if needed)
CNAME autodiscover.askeveai.com   → autodiscover.protonmail.ch
CNAME autoconfig.askeveai.com     → autoconfig.protonmail.ch

3. Infrastructure Layer

Scaleway Load Balancer

  • Type: Statisch extern IP adres
  • Functie: Entry point naar Kubernetes cluster
  • Locatie: Voor de cluster, distribueert verkeer naar Ingress

Kubernetes Cluster (Scaleway)

  • Ingress Controller: Routeert aanvragen naar juiste services
  • Workloads:
    • eveai_app: Frontend applicatie
    • eveai_api: Backend API services
    • eveai_workers: Background processing
    • Aanvullende applicatieve pods

4. Monitoring & Observability

Prometheus Stack (In-cluster)

  • Functie: Business events monitoring
  • Scope: Applicatie-specifieke metrics en events

Scaleway Cockpit

  • Functie: Infrastructure monitoring
  • Scope: Performance en infrastructuur componenten

5. Managed Services

Redis (Scaleway Managed)

  • Functie: Caching layer
  • Voordeel: Reduced latency, session storage

PostgreSQL (Scaleway Managed)

  • Functie: Primaire database
  • Voordeel: Managed backups, high availability

Object Storage (Scaleway)

  • Interface: S3-compatible via Minio client
  • Functie: File storage, static assets, backups

Architectuuroverwegingen

Huidige Setup Evaluatie

Sterke Punten:

  • Goede separation of concerns
  • Gebruik van managed services vermindert operationele overhead
  • CDN voor performance en security
  • Container-native met Kubernetes
  • Comprehensive monitoring setup

Potentiële Verbeteringen:

  • Multi-domain setup via Bunny.net: Alle traffic via CDN
  • Environment isolation: Aparte origins voor staging/production
  • 🤔 Origin Protection: Firewall rules om direct access te voorkomen
  • 🤔 Kubernetes Ingress: Host-based routing configureren voor multi-environment

Email & DNS Overwegingen

Email via ProtonMail (Blijft Direct)

Belangrijke opmerking: Email records gaan NIET via Bunny.net. CDN's zijn alleen voor web traffic (HTTP/HTTPS). Email gebruikt andere protocollen (SMTP, IMAP, POP3) die niet via een CDN kunnen.

Wat blijft hetzelfde:

  • MX records blijven wijzen naar ProtonMail servers
  • SPF, DKIM, DMARC records blijven ongewijzigd
  • Email functionaliteit wordt niet beïnvloed door Bunny.net

Voordeel van je setup:

  • DNS bij EuroDNS: Flexibel om records te beheren
  • Hosting bij hosting.com: Makkelijk te migreren later
  • Email bij ProtonMail: Blijft stabiel tijdens migraties

DNS Migratie Strategie (Vereenvoudigd)

Huidige situatie:

EuroDNS → hosting.com (WordPress + email config via cPanel)

Nieuwe situatie:

EuroDNS → Bunny.net (web) + ProtonMail (email direct)

Migratiestappen:

  1. Preparatie: Email records van cPanel naar EuroDNS overbrengen
  2. Bunny.net setup: Pull zones configureren
  3. DNS switch: A records naar Bunny.net, MX records direct naar ProtonMail
  4. Later: hosting.com opzeggen

Bunny.net Setup Guide

Stap 1: Pull Zones Aanmaken

Pull Zone 1: WordPress Site

Name: askeveai-wordpress
Hostname: askeveai.com
Origin URL: [hosting.com server IP/URL]

Pull Zone 2: Staging Environment

Name: evie-staging
Hostname: evie-staging.askeveai.com
Origin URL: http://[scaleway-lb-ip]
Host Header: evie-staging.askeveai.com

Pull Zone 3: Production Environment

Name: evie-production  
Hostname: evie.askeveai.com
Origin URL: http://[scaleway-lb-ip]
Host Header: evie.askeveai.com

Pull Zone 4: Static Assets - Bunny Storage (Aanbevolen)

Name: static-assets
Type: Push Zone (Bunny Storage)
Hostname: static.askeveai.com
Storage: Direct upload to Bunny Storage
API: FTP/SFTP/REST API upload

Alternatief: Pull Zone van Scaleway S3

Name: static-assets-s3
Type: Pull Zone  
Hostname: static.askeveai.com
Origin URL: https://[scaleway-s3-bucket].s3.fr-par.scw.cloud

Stap 2: SSL/TLS Configuratie

  • Force SSL: Aan voor alle zones
  • SSL Certificate: Let's Encrypt (gratis) of Bunny.net certificates
  • Origin Shield: Europa (voor betere performance naar Scaleway)

Stap 3: Security Settings

  • Origin Shield Protection: Alleen Bunny.net IP's kunnen origin bereiken
  • WAF Rules: Basis DDoS en attack protection
  • Rate Limiting: Per domain/endpoint configureren

Static Assets Optimalisatie

Huidige Aanpak (Sub-optimaal)

Browser → Bunny.net → Scaleway LB → Ingress → App Pod → Static file

Aanbevolen Aanpak: Direct Static Delivery

Browser → Bunny.net Edge → Static file (gecached op edge)

Implementatie Strategieën

Optie 1: Bunny Storage (Aanbevolen)

Build Process → Bunny Storage → Bunny CDN Edge → Browser
- Upload: Direct naar Bunny Storage via API/FTP
- Serve: Native performance, geen extra hops
- Cost: Meestal goedkoper dan S3 + CDN
- Speed: Optimaal, storage en CDN geïntegreerd

Optie 2: Scaleway Object Storage + Pull Zone

Build Process → Scaleway S3 → Bunny Pull Zone → Browser
- Upload: App → Scaleway S3 bucket
- Serve: Bunny.net cache van S3 bucket
- Voordeel: Backup in je eigen cloud, data sovereignty
- Nadeel: Extra latency voor eerste request

Optie 3: Hybrid Approach

- Critical assets: Bunny Storage (logo, CSS, JS)
- User uploads: Scaleway S3 → Bunny Pull Zone
- Development: Local static serving

Bunny Storage vs Scaleway S3

Aspect Bunny Storage Scaleway S3 + Pull Zone
Performance Native CDN Extra hop
Cost Integrated pricing S3 + CDN costs
Simplicity One provider Two systems
Data Control At Bunny In your cloud
Backup/Sync Bunny dependent Full control

File Types voor Static Delivery

Ideaal voor CDN:

  • Images (JPG, PNG, WebP, SVG)
  • CSS files
  • JavaScript bundles
  • Fonts (WOFF2, etc.)
  • Videos/audio files
  • PDF documents
  • Icons en favicons

Blijven via app:

  • Dynamic API responses
  • User-generated content (tenzij via upload flow)
  • Authentication-required files

Kubernetes Ingress Configuratie

Met de multi-domain setup via Bunny.net moet je Ingress ook aangepast worden:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: eveai-ingress
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false" # SSL handled by Bunny.net
spec:
  rules:
  - host: evie-staging.askeveai.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: eveai-staging-service
            port:
              number: 80
  - host: evie.askeveai.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: eveai-production-service
            port:
              number: 80

Migratiestrategie (Uitgebreid)

Fase 1: Bunny.net Setup (Geen downtime)

  1. Maak Pull Zones aan in Bunny.net
  2. Test via Bunny.net hostnames (zonder DNS wijziging)
  3. Configureer caching en security rules

Fase 2: DNS Migratie (Minimale downtime)

  1. Kopieer email records van cPanel naar EuroDNS
  2. Verlaag TTL van huidige DNS records (1 uur van tevoren)
  3. Wijzig A records naar Bunny.net (MX records blijven ProtonMail)
  4. Monitor traffic en performance

Fase 3: Origin Protection

  1. Configureer Scaleway firewall om alleen Bunny.net IP's toe te laten
  2. Test alle functionaliteit
  3. Monitor security logs

Fase 4: WordPress Migratie naar Scaleway (Optioneel)

Planning overwegingen:

  • Database: WordPress DB naar Scaleway PostgreSQL of aparte MySQL
  • Files: wp-content naar Scaleway Object Storage
  • SSL: Blijft via Bunny.net (geen wijzigingen)
  • Performance: Mogelijk sneller door proximity met EveAI

Migratie opties:

  1. Lift & Shift: VM op Scaleway met traditionele LAMP stack
  2. Modernisering: WordPress in Kubernetes container
  3. Hybrid: Behoud hosting.com tot je tevreden bent met K8s setup

Fase 5: Hosting.com Opzegging

  1. Bevestig WordPress werkt 100% op Scaleway
  2. Final backup van hosting.com
  3. Annuleer hosting.com contract
  4. Email en EveAI blijven ongestoord werken

Toekomstige Evolutie: WordPress op Scaleway

Optie 1: WordPress als Managed Service

Scaleway WordPress Hosting (als beschikbaar)

  • Managed WordPress environment
  • Automatische updates en backups
  • Geïntegreerd met andere Scaleway services

Optie 2: WordPress in Kubernetes Cluster

Voordelen:

  • Alles op één platform (Scaleway)
  • Gedeelde resources en monitoring
  • Consistent deployment pipeline
  • Cost optimization
  • Uniform backup/disaster recovery

WordPress in K8s Setup:

# WordPress Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: wordpress
  template:
    spec:
      containers:
      - name: wordpress
        image: wordpress:6-apache
        env:
        - name: WORDPRESS_DB_HOST
          value: [scaleway-postgresql-endpoint]
        - name: WORDPRESS_DB_NAME  
          value: wordpress_db
        volumeMounts:
        - name: wordpress-storage
          mountPath: /var/www/html/wp-content
      volumes:
      - name: wordpress-storage
        persistentVolumeClaim:
          claimName: wordpress-pvc

Optie 3: WordPress op Scaleway Instances

Instance-based hosting:

  • Dedicated VM voor WordPress
  • Meer controle over environment
  • Traditionele hosting aanpak op moderne cloud

Aanbevolen Aanpak: Kubernetes

Architectuur zou worden:

Bunny.net CDN
    ├─ askeveai.com → Scaleway LB → WordPress Pod
    ├─ evie-staging.askeveai.com → Scaleway LB → EveAI Staging
    └─ evie.askeveai.com → Scaleway LB → EveAI Production

Gedeelde Resources:

  • PostgreSQL: Aparte database voor WordPress + EveAI
  • Object Storage: WordPress media + EveAI assets
  • Redis: WordPress caching + EveAI caching
  • Monitoring: Unified observability voor alles

Disaster Recovery & Backup

  • Database: Managed PostgreSQL automated backups
  • Object Storage: Cross-region replication overwegen
  • Application State: Stateless design waar mogelijk
  • Configuration: GitOps approach voor cluster configuration

Conclusie

De voorgestelde architectuur biedt een uitstekende balans tussen performance, security en operationele eenvoud. Door alles via Bunny.net te routeren krijg je:

Directe voordelen:

  • Uniforme security en performance voor alle domeinen
  • Eenvoudige SSL management
  • Cost-effective CDN voor alle content
  • Flexibiliteit voor toekomstige migraties

Strategische voordelen:

  • Scaleway consolidatie: Mogelijk om WordPress ook naar Scaleway te migreren
  • Operational simplicity: Eén cloud provider voor applicatie infrastructure
  • Cost optimization: Gedeelde resources en bundelvoordelen
  • Technical consistency: Uniform tooling en monitoring

Aanbevolen roadmap:

  1. Nu: Bunny.net implementeren voor alle domeinen
  2. Q1 2026: WordPress evalueren voor Scaleway migratie
  3. Q2 2026: hosting.com contract beëindigen
  4. Resultaat: Volledig cloud-native platform op Scaleway + Bunny.net

Deze aanpak maximaliseert flexibiliteit terwijl risico's worden geminimaliseerd door gefaseerde implementatie.


Architectuurdocument gegenereerd op: Augustus 2025