# paulodarosa7/judge0-kubernetes architecture

> Architecture diagram of the GitHub repository paulodarosa7/judge0-kubernetes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paulodarosa7/judge0-kubernetes
- Repository: https://github.com/paulodarosa7/judge0-kubernetes

## Overview

Este repositório configura uma infraestrutura Kubernetes para executar submissões do Judge0 e inclui clientes experimentais para medir carga e segurança. O fluxo principal vai do Dev³ ao Service da API, à fila Redis e aos Workers; o PostgreSQL persiste os dados. O README também documenta réplicas, escalabilidade dos Workers, monitoramento e recuperação de Pods. Os manifests amostrados não foram fornecidos como trechos, então relações entre componentes de infraestrutura se apoiam no README; os scripts de teste mostram chamadas HTTP, não a implementação interna do Judge0.

Main entry points: [`judge0/deployments.yaml`](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml) (Judge0 API), [`judge0/services.yaml`](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/services.yaml) (Service NodePort), [`judge0/db.yaml`](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/db.yaml) (PostgreSQL Primary), [`testes/tentativa.py`](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/tentativa.py) (Clientes de carga)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrada["Entrada e testes"]
  node_testes_carga["Clientes de carga<br/>[tentativa.py]"]
  node_teste_perfis["Carga por perfis"]
  node_teste_simples["Teste concorrente<br/>[main.py]"]
  node_seguranca["Teste de segurança<br/>[teste_seguranca.py]"]
end

subgraph group_execucao["Execução Judge0"]
  node_api["Judge0 API<br/>[deployments.yaml]"]
  node_service["Service NodePort<br/>[services.yaml]"]
  node_workers["Judge0 Workers<br/>[deployments.yaml]"]
  node_config["Configuração Judge0<br/>[judge0.conf]"]
  node_env["Ambiente Judge0<br/>[.env]"]
end

subgraph group_dados["Persistência"]
  node_redis_primary[("Redis Primary<br/>[deployments.yaml]")]
  node_redis_replica[("Redis Replica<br/>[deployments.yaml]")]
  node_postgres_primary[("PostgreSQL Primary<br/>[db.yaml]")]
  node_postgres_replica[("PostgreSQL Replica<br/>[db.yaml]")]
end

subgraph group_operacao["Operação e monitoramento"]
  node_hpa["Escala de Workers<br/>[hpa.yaml]"]
  node_monitoramento["Métricas e dashboards<br/>[monitor.yaml]"]
  node_automacao["Ajuste de contagem<br/>[trocar_count.sh]"]
end

node_dev3(("Plataforma Dev³"))
node_cluster{{"Cluster Kubernetes"}}

node_dev3 -->|"envia submissões"| node_service
node_service -->|"encaminha requisições"| node_api
node_testes_carga -->|"envia e consulta"| node_service
node_teste_perfis -->|"envia e consulta"| node_service
node_teste_simples -->|"envia e consulta"| node_service
node_api -->|"enfileira submissões"| node_redis_primary
node_workers -->|"consome fila"| node_redis_primary
node_workers -->|"executa submissões"| node_api
node_api -->|"persiste dados"| node_postgres_primary
node_redis_primary -->|"replica fila"| node_redis_replica
node_postgres_primary -->|"replica por streaming"| node_postgres_replica
node_api -.->|"usa configuração"| node_config
node_api -.->|"usa ambiente"| node_env
node_hpa -->|"escala horizontalmente"| node_workers
node_monitoramento -->|"coleta métricas"| node_cluster
node_cluster -->|"agenda e recupera Pods"| node_api
node_cluster -->|"agenda e recupera Pods"| node_workers
node_automacao -.->|"ajusta contagem"| node_workers
node_seguranca -->|"verifica acesso local"| node_cluster

click node_testes_carga "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/tentativa.py"
click node_teste_perfis "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/tentativa_com_perfis.py"
click node_teste_simples "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/main.py"
click node_seguranca "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/teste_seguranca.py"
click node_api "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml"
click node_service "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/services.yaml"
click node_redis_primary "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml"
click node_redis_replica "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml"
click node_workers "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml"
click node_postgres_primary "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/db.yaml"
click node_postgres_replica "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/db.yaml"
click node_config "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/config/judge0.conf"
click node_env "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/config/.env"
click node_hpa "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/hpa.yaml"
click node_monitoramento "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/monitor/monitor.yaml"
click node_automacao "https://github.com/paulodarosa7/judge0-kubernetes/blob/main/automacao/trocar_count.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_testes_carga,node_teste_perfis,node_teste_simples,node_seguranca toneBlue
class node_api,node_service,node_workers,node_config,node_env toneAmber
class node_redis_primary,node_redis_replica,node_postgres_primary,node_postgres_replica toneMint
class node_hpa,node_monitoramento,node_automacao toneRose
class node_dev3,node_cluster toneIndigo
```

## Components

### Entrada e testes

- [Clientes de carga](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/tentativa.py): `testes/tentativa.py`
- [Carga por perfis](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/tentativa_com_perfis.py): `testes/tentativa_com_perfis.py`
- [Teste concorrente](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/main.py): `testes/main.py`
- [Teste de segurança](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/testes/teste_seguranca.py): `testes/teste_seguranca.py`

### Execução Judge0

- [Judge0 API](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml): `judge0/deployments.yaml`
- [Service NodePort](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/services.yaml): `judge0/services.yaml`
- [Judge0 Workers](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml): `judge0/deployments.yaml`
- [Configuração Judge0](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/config/judge0.conf): `judge0/config/judge0.conf`
- [Ambiente Judge0](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/config/.env): `judge0/config/.env`

### Persistência

- [Redis Primary](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml): `judge0/deployments.yaml`
- [Redis Replica](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/deployments.yaml): `judge0/deployments.yaml`
- [PostgreSQL Primary](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/db.yaml): `judge0/db.yaml`
- [PostgreSQL Replica](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/db.yaml): `judge0/db.yaml`

### Operação e monitoramento

- [Escala de Workers](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/judge0/hpa.yaml): `judge0/hpa.yaml`
- [Métricas e dashboards](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/monitor/monitor.yaml): `monitor/monitor.yaml`
- [Ajuste de contagem](https://github.com/paulodarosa7/judge0-kubernetes/blob/main/automacao/trocar_count.sh): `automacao/trocar_count.sh`

### Other components

- **Plataforma Dev³**
- **Cluster Kubernetes**

## Connections

- Plataforma Dev³ → Service NodePort: envia submissões (evidence: `README.md`)
- Service NodePort → Judge0 API: encaminha requisições (evidence: `README.md`)
- Clientes de carga → Service NodePort: envia e consulta (evidence: `testes/tentativa.py`)
- Carga por perfis → Service NodePort: envia e consulta (evidence: `testes/tentativa_com_perfis.py`)
- Teste concorrente → Service NodePort: envia e consulta (evidence: `testes/main.py`)
- Judge0 API → Redis Primary: enfileira submissões (evidence: `README.md`)
- Judge0 Workers → Redis Primary: consome fila (evidence: `README.md`)
- Judge0 Workers → Judge0 API: executa submissões (evidence: `README.md`)
- Judge0 API → PostgreSQL Primary: persiste dados (evidence: `README.md`)
- Redis Primary → Redis Replica: replica fila (evidence: `README.md`)
- PostgreSQL Primary → PostgreSQL Replica: replica por streaming (evidence: `README.md`)
- Judge0 API → Configuração Judge0: usa configuração
- Judge0 API → Ambiente Judge0: usa ambiente
- Escala de Workers → Judge0 Workers: escala horizontalmente (evidence: `README.md`)
- Métricas e dashboards → Cluster Kubernetes: coleta métricas (evidence: `README.md`)
- Cluster Kubernetes → Judge0 API: agenda e recupera Pods (evidence: `README.md`)
- Cluster Kubernetes → Judge0 Workers: agenda e recupera Pods (evidence: `README.md`)
- Ajuste de contagem → Judge0 Workers: ajusta contagem
- Teste de segurança → Cluster Kubernetes: verifica acesso local (evidence: `testes/teste_seguranca.py`)
