# kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway architecture

> Architecture diagram of the GitHub repository kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway
- Repository: https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway

## Overview

This repository is an infrastructure-as-code project built with Terraform. The single README title indicates the target architecture is a hybrid network foundation using a hub-and-spoke topology with a VPN gateway, so the repo is focused on cloud networking rather than application code.

The core design pattern is a centralized hub network that provides shared connectivity services, with one or more spoke networks attached to it. In a typical diagram, the hub is the transit point for VPN connectivity and possibly shared routing, while spokes represent isolated workload networks that reach shared services through the hub.

The main data flow is network traffic, not business data: traffic from an external/on-prem network enters through the VPN gateway in the hub, then is routed to spoke networks according to peering and route configuration. Spoke-to-spoke communication, if allowed, would usually be forced through the hub rather than directly.

The Terraform entry points are the standard `provider.tf`, `main.tf`, `outputs.tf`, and `varibles.tf` files. `provider.tf` defines the cloud provider and any required authentication or region/subscription settings. `main.tf` likely contains the actual network resources and relationships. `varibles.tf` holds the configurable inputs for network ranges, naming, and topology choices. `outputs.tf` exposes IDs, addresses, or connection details needed by operators or downstream modules.

The presence of `terraform.tfstate` and `terraform.tfstate.backup` shows that Terraform state is stored in the repository right now, so the repo is managing live infrastructure state locally rather than only declarative code. That is important for the architecture diagram because the Terraform layer is part of the control plane, not the runtime network itself.

`.terraform.lock.hcl` indicates provider version pinning, which stabilizes the infrastructure build by ensuring the same Terraform provider versions are used across runs. This matters operationally because networking resources are sensitive to provider behavior and version changes.

The repository likely has a single infrastructure boundary: Terraform is the authoring and provisioning layer, and the target boundary is the cloud networking environment. There is no sign of application services, containers, or compute workloads in the file tree, so the diagram should center on networking primitives and not app tiers.

A likely external boundary in the diagram is the on-premises or branch network connected through VPN. The hub-spoke setup implies an edge connection between the enterprise network and the cloud hub, with the hub acting as the ingress/egress and transit layer.

The most important components to draw are:
- Terraform as the provisioning system
- The hub network
- The VPN gateway in the hub
- One or more spoke networks
- Peering or routing links between hub and spokes
- The external/on-premises network connected over VPN

Because the repo is compact, the architecture is probably monolithic from an IaC perspective: one Terraform root module manages the full network foundation. Any diagram should therefore show a single provisioning boundary feeding multiple cloud networking resources rather than a distributed microservice-style architecture.

Main entry points: [`main.tf`](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/main.tf) (Root module), [`provider.tf`](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/provider.tf) (Provider), [`varibles.tf`](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/varibles.tf) (Variables), [`outputs.tf`](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/outputs.tf) (Outputs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terraform["Terraform root"]
  node_root_module["Root module<br/>terraform module<br/>[main.tf]"]
  node_provider["Provider<br/>terraform config<br/>[provider.tf]"]
  node_variables["Variables<br/>terraform inputs<br/>[varibles.tf]"]
  node_outputs["Outputs<br/>[outputs.tf]"]
  node_state[("State<br/>[terraform.tfstate]")]
  node_lockfile["Provider lock<br/>dependency lock"]
end

subgraph group_network["Cloud network"]
  node_hub_network{{"Hub network<br/>network hub"}}
  node_vpn_gateway(("VPN gateway"))
  node_route_policy["Routing<br/>route control"]
  node_spoke_networks{{"Spoke networks<br/>network spokes"}}
  node_peering["Peering<br/>network attachment"]
end

subgraph group_external["External side"]
  node_external_net["On-prem network<br/>external network"]
  node_vpn_tunnel(("VPN link<br/>secure tunnel"))
end

node_root_module -->|"uses"| node_provider
node_root_module -->|"parameterized by"| node_variables
node_root_module -->|"publishes"| node_outputs
node_root_module -->|"persists"| node_state
node_root_module -->|"pins"| node_lockfile
node_root_module -->|"provisions"| node_hub_network
node_root_module -->|"provisions"| node_vpn_gateway
node_root_module -->|"provisions"| node_spoke_networks
node_root_module -->|"configures"| node_peering
node_root_module -->|"configures"| node_route_policy
node_external_net -->|"connects via"| node_vpn_tunnel
node_vpn_tunnel -->|"terminates at"| node_vpn_gateway
node_vpn_gateway -->|"anchors"| node_hub_network
node_hub_network -->|"transits through"| node_peering
node_peering -->|"reaches"| node_spoke_networks
node_route_policy -->|"routes within"| node_hub_network
node_route_policy -->|"controls"| node_spoke_networks

click node_root_module "https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/main.tf"
click node_provider "https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/provider.tf"
click node_variables "https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/varibles.tf"
click node_outputs "https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/outputs.tf"
click node_state "https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/terraform.tfstate"
click node_lockfile "https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/.terraform.lock.hcl"

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_root_module,node_provider,node_variables,node_outputs,node_state,node_lockfile toneBlue
class node_hub_network,node_vpn_gateway,node_route_policy,node_spoke_networks,node_peering toneAmber
class node_external_net,node_vpn_tunnel toneMint
```

## Components

### Terraform root

IaC authoring and state boundary

- [Root module](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/main.tf): terraform module · Single Terraform stack for the network foundation · `main.tf`
- [Provider](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/provider.tf): terraform config · Cloud provider and authentication settings · `provider.tf`
- [Variables](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/varibles.tf): terraform inputs · Configurable network and topology parameters · `varibles.tf`
- [Outputs](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/outputs.tf): terraform outputs · Exported IDs and connection details · `outputs.tf`
- [State](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/terraform.tfstate): terraform state · Local live infrastructure state · `terraform.tfstate`
- [Provider lock](https://github.com/kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway/blob/main/.terraform.lock.hcl): dependency lock · Pinned Terraform provider versions · `.terraform.lock.hcl`

### Cloud network

Hub-spoke foundation deployed by Terraform

- **Hub network**: network hub · Central transit and shared services network
- **VPN gateway**: gateway · Edge entry point for external connectivity
- **Routing**: route control · Routes and transit rules between hub and spokes
- **Spoke networks**: network spokes · Attached workload networks behind the hub
- **Peering**: network attachment · Hub-to-spoke connectivity boundary

### External side

On-prem or branch network reaching the hub

- **On-prem network**: external network · Enterprise or branch network outside the cloud
- **VPN link**: secure tunnel · Encrypted connection from external network into the hub

## Connections

- Root module → Provider: uses · Terraform is configured through the provider block
- Root module → Variables: parameterized by · Inputs shape the hub-spoke topology
- Root module → Outputs: publishes · Exports operational connection details
- Root module → State: persists · Managed infrastructure state is stored locally
- Root module → Provider lock: pins · Provider versions are constrained for repeatability
- Root module → Hub network: provisions · Main Terraform stack creates the central network
- Root module → VPN gateway: provisions · Main Terraform stack creates VPN ingress
- Root module → Spoke networks: provisions · Main Terraform stack defines attached spoke networks
- Root module → Peering: configures · Main Terraform stack wires hub-to-spoke attachment
- Root module → Routing: configures · Main Terraform stack defines routing and transit rules
- On-prem network → VPN link: connects via · External traffic enters over a VPN tunnel
- VPN link → VPN gateway: terminates at · The tunnel lands on the hub gateway
- VPN gateway → Hub network: anchors · Gateway is hosted in the hub boundary
- Hub network → Peering: transits through · Hub acts as the central attachment point
- Peering → Spoke networks: reaches · Spokes attach behind the hub
- Routing → Hub network: routes within · Shared routing is centered in the hub
- Routing → Spoke networks: controls · Traffic toward spokes follows defined routes
