# tristanmorgan/nomad-test architecture

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

- Interactive diagram: https://gitdiagram.com/tristanmorgan/nomad-test
- Repository: https://github.com/tristanmorgan/nomad-test

## Overview

##### Project Type and Purpose
- This project is a demo/test setup that leverages HashiCorp products – namely Nomad (for scheduling/container orchestration), Consul (for service discovery and DNS resolution), and Vault (for secrets management). It also makes use of Terraform for infrastructure as code.
- The README confirms roles and requirements such as running containers via Docker for Mac, setting up environment variables, and starting the key services in sequence.
- The goal is to demonstrate a local multi-node (even if single-node in practice) infrastructure with trusted configurations and load-balancing (e.g., Fabio) to preview features and interactions among these components.

##### File Structure
- Top-level directories – “consul”, “nomad”, “vault”, and “terraform” – correspond to the main components.
- Within “terraform”, you see job definitions for Nomad and various HCL configurations, including policies, job definitions, and disabled jobs. This represents declarative infrastructure and job configurations.
- Configuration files for Consul (under consul/config) and executable startup scripts (e.g., start.sh) indicate the initialization process for each component.
- Files such as .rubocop.yml and Gemfile indicate that there might be some Ruby tooling for testing or configuration management, but the core architecture is around the HashiCorp ecosystem.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Control Plane Components
    subgraph "Control Plane"
        T["Terraform (IAC)"] 
        C["Consul (Service Discovery & DNS)"]
        N["Nomad (Scheduler & Orchestrator)"]
        V["Vault (Secrets Management)"]
    end

    %% Runtime Environment Components
    subgraph "Runtime Environment"
        D["Docker Host (Container Runtime)"]
        F["Fabio Load Balancer"]
    end

    %% Relationships in Control Plane
    T -->|"configures"| C
    T -->|"configures"| N
    T -->|"configures"| V
    T -->|"configures"| F

    N -->|"registers"| C
    V -->|"stores_secrets_in"| C

    %% Relationships to Runtime Environment
    N -->|"deploys_jobs_on"| D
    D -->|"routes_traffic_to"| F

    %% Click Events for Terraform
    click T "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/terraform.tf"
    click T "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/consul_config.tf"
    click T "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/nomad_jobs.tf"
    click T "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/nomad_workloads.tf"

    %% Click Events for Consul
    click C "https://github.com/tristanmorgan/nomad-test/blob/main/consul/config/consul.hcl"
    click C "https://github.com/tristanmorgan/nomad-test/blob/main/consul/config/consul-api.hcl"
    click C "https://github.com/tristanmorgan/nomad-test/blob/main/consul/config/vault-service.hcl"
    click C "https://github.com/tristanmorgan/nomad-test/blob/main/consul/start.sh"

    %% Click Events for Nomad
    click N "https://github.com/tristanmorgan/nomad-test/blob/main/nomad/nomad.hcl"
    click N "https://github.com/tristanmorgan/nomad-test/blob/main/nomad/start.sh"
    click N "https://github.com/tristanmorgan/nomad-test/tree/main/terraform/jobs"

    %% Click Events for Vault
    click V "https://github.com/tristanmorgan/nomad-test/blob/main/vault/vault.hcl"
    click V "https://github.com/tristanmorgan/nomad-test/blob/main/vault/start.sh"

    %% Click Events for Fabio
    click F "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/cpol/fabio.hcl"
    click F "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/vpol/fabio.hcl"
    click F "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/fabio_config.tpl"
    click F "https://github.com/tristanmorgan/nomad-test/blob/main/terraform/jobs/fabio.nomad"

    %% Class Definitions for Colour Coding
    classDef controlPlane fill:#FFCC99,stroke:#B36B00,stroke-width:2px;
    classDef runtime fill:#CCF2FF,stroke:#006699,stroke-width:2px;

    class T,C,N,V controlPlane;
    class D,F runtime;
```
