# victornwoke/cloudops-goal-tracker--three-tier-architecture architecture

> Architecture diagram of the GitHub repository victornwoke/cloudops-goal-tracker--three-tier-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/victornwoke/cloudops-goal-tracker--three-tier-architecture
- Repository: https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture

## Overview

#### Purpose and Entry Points
CloudOps Goal Tracker is a containerized three-tier goal-tracking system with Azure Terraform deployment. Runtime entry points are the Go API at `backend/main.go`, the Node/Express frontend server at `frontend/server.js`, and the local stack definition at `docker-local-deployment/docker-compose.yml`. Production deployment is initiated by `deploy.sh`, which builds/pushes Docker Hub images and applies Terraform.

#### Presentation and API Gateway
The frontend is a Node.js/Express process that serves browser assets and proxies same-origin `/api/goals` requests to the backend. Static UI content is rooted in `frontend/public/index.html`; server/proxy behavior is in `frontend/server.js`. This tier is the public application boundary: local Docker exposes port 3000, while Azure places it behind an Application Gateway/WAF.

#### Go Business Service
`backend/main.go` implements the REST API and business/data-access layer: goal listing and creation/deletion, plus `/health` and Prometheus `/metrics`. It is packaged independently by `backend/Dockerfile`. The backend accepts frontend-proxied calls and owns database connectivity; it is separately exposed locally on 8080 but designed for private, internal Azure access.

#### PostgreSQL Data Tier
PostgreSQL persists goal data, with local schema/bootstrap SQL in `docker-local-deployment/database/init.sql`. The local Compose topology wires backend database configuration and service dependencies in `docker-local-deployment/docker-compose.yml`. In Azure, the database module provisions PostgreSQL Flexible Server and a read replica; network access is intended to remain private.

#### Local Container Topology
`docker-local-deployment/docker-compose.yml` composes frontend, backend, and PostgreSQL for development or demonstration. Service images are built from `frontend/Dockerfile` and `backend/Dockerfile`; the database initialization script establishes the data contract. The main request flow is browser → frontend `/api/*` proxy → Go API → PostgreSQL.

#### Azure Infrastructure Composition
The Terraform root assembles reusable infrastructure modules in `infra/main.tf`. Networking establishes VNet/subnet segmentation, NSGs, and Bastion in `infra/modules/networking/main.tf`; compute creates frontend/backend VM Scale Sets and their public/internal traffic paths in `infra/modules/compute/main.tf`; database infrastructure is defined by `infra/modules/database/main.tf`. DNS and secret-management boundaries are provided by `infra/modules/dns/main.tf` and `infra/modules/keyvault/main.tf`.

#### Deployment, Secrets, and Environments
Compute provisioning scripts pull Docker Hub images and configure frontend/backend VM instances: `infra/modules/compute/scripts/frontend_provision.sh` and `infra/modules/compute/scripts/backend_provision.sh`. Docker Hub credentials are passed to Terraform and stored through the Key Vault module rather than embedded in images. Environment-specific Terraform roots for dev, test, and prod live under `infra/environments/dev/main.tf`, `infra/environments/test/main.tf`, and `infra/environments/prod/main.tf`; Terraform remote-state configuration is represented by `infra/backend.tf`.

Main entry points: [`infra/main.tf`](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/main.tf) (Terraform composition), [`infra/modules/compute/main.tf`](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/compute/main.tf) (Application compute), [`frontend/server.js`](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/server.js) (Express frontend), [`docker-local-deployment/docker-compose.yml`](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/docker-local-deployment/docker-compose.yml) (Local Compose stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_browser(("Browser<br/>client"))
  node_frontend["Express frontend<br/>Node.js server<br/>[server.js]"]
  node_ui["Static UI<br/>browser assets<br/>[index.html]"]
  node_api["Go API<br/>REST business service<br/>[main.go]"]
  node_postgres[("PostgreSQL<br/>goal data store")]
end

subgraph group_local["Local Containers"]
  node_compose["Local Compose stack<br/>container topology<br/>[docker-compose.yml]"]
  node_frontend_image["Frontend image<br/>Docker build"]
  node_backend_image["Backend image<br/>Docker build"]
  node_db_init["Database bootstrap<br/>SQL schema<br/>[init.sql]"]
end

subgraph group_azure["Azure Infrastructure"]
  node_terraform_root["Terraform composition<br/>infrastructure root<br/>[main.tf]"]
  node_networking{{"Network boundary<br/>VNet, subnets, NSGs<br/>[main.tf]"}}
  node_compute["Application compute<br/>frontend/backend VMSS<br/>[main.tf]"]
  node_gateway{{"Application Gateway / WAF<br/>public ingress"}}
  node_azure_db[("Azure PostgreSQL<br/>Flexible Server + replica<br/>[main.tf]")]
  node_keyvault{{"Key Vault<br/>secret boundary<br/>[main.tf]"}}
  node_dns{{"DNS<br/>name resolution<br/>[main.tf]"}}
  node_provisioning["VM provisioning<br/>instance bootstrap scripts"]
end

subgraph group_delivery["Deployment &amp; Environments"]
  node_deploy["Deployment script<br/>build, push, apply<br/>[deploy.sh]"]
  node_environments["Dev, test, prod roots<br/>Terraform environments<br/>[main.tf]"]
  node_remote_state["Terraform remote state<br/>state backend<br/>[backend.tf]"]
end

node_browser -->|"HTTP"| node_frontend
node_ui -->|"served by"| node_frontend
node_frontend -->|"/api/goals proxy"| node_api
node_api -->|"reads and writes goals"| node_postgres
node_compose -->|"builds"| node_frontend_image
node_compose -->|"builds"| node_backend_image
node_compose -->|"initializes database"| node_db_init
node_frontend_image -.->|"local container"| node_frontend
node_backend_image -.->|"local container"| node_api
node_db_init -.->|"schema"| node_postgres
node_deploy -->|"applies"| node_terraform_root
node_deploy -->|"builds and pushes"| node_frontend_image
node_deploy -->|"builds and pushes"| node_backend_image
node_terraform_root -->|"provisions"| node_networking
node_terraform_root -->|"provisions"| node_compute
node_terraform_root -->|"provisions"| node_azure_db
node_terraform_root -->|"provisions"| node_keyvault
node_terraform_root -->|"provisions"| node_dns
node_gateway -->|"routes public traffic"| node_compute
node_compute -->|"private database access"| node_azure_db
node_networking -->|"ingress network"| node_gateway
node_keyvault -->|"image credentials"| node_compute
node_provisioning -->|"configures VM instances"| node_compute
node_environments -.->|"selects module composition"| node_terraform_root
node_remote_state -.->|"stores state"| node_terraform_root

click node_frontend "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/server.js"
click node_ui "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/public/index.html"
click node_api "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/backend/main.go"
click node_compose "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/docker-local-deployment/docker-compose.yml"
click node_frontend_image "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/Dockerfile"
click node_backend_image "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/backend/Dockerfile"
click node_db_init "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/docker-local-deployment/database/init.sql"
click node_deploy "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/deploy.sh"
click node_terraform_root "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/main.tf"
click node_networking "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/networking/main.tf"
click node_compute "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/compute/main.tf"
click node_azure_db "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/database/main.tf"
click node_keyvault "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/keyvault/main.tf"
click node_dns "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/dns/main.tf"
click node_provisioning "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/compute/scripts/frontend_provision.sh"
click node_environments "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/environments/prod/main.tf"
click node_remote_state "https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/backend.tf"

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_browser,node_frontend,node_ui,node_api,node_postgres toneBlue
class node_compose,node_frontend_image,node_backend_image,node_db_init toneAmber
class node_terraform_root,node_networking,node_compute,node_gateway,node_azure_db,node_keyvault,node_dns,node_provisioning toneMint
class node_deploy,node_environments,node_remote_state toneRose
```

## Components

### Application Runtime

- **Browser**: client
- [Express frontend](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/server.js): Node.js server · Serves UI and proxies same-origin API calls. · `frontend/server.js`
- [Static UI](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/public/index.html): browser assets · `frontend/public/index.html`
- [Go API](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/backend/main.go): REST business service · Provides goals, health, and Prometheus metrics. · `backend/main.go`
- **PostgreSQL**: goal data store

### Local Containers

- [Local Compose stack](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/docker-local-deployment/docker-compose.yml): container topology · Builds and wires frontend, backend, and database locally. · `docker-local-deployment/docker-compose.yml`
- [Frontend image](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/frontend/Dockerfile): Docker build · `frontend/Dockerfile`
- [Backend image](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/backend/Dockerfile): Docker build · `backend/Dockerfile`
- [Database bootstrap](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/docker-local-deployment/database/init.sql): SQL schema · `docker-local-deployment/database/init.sql`

### Azure Infrastructure

- [Terraform composition](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/main.tf): infrastructure root · Assembles reusable Azure modules. · `infra/main.tf`
- [Network boundary](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/networking/main.tf): VNet, subnets, NSGs · Includes Bastion and segmented application access. · `infra/modules/networking/main.tf`
- [Application compute](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/compute/main.tf): frontend/backend VMSS · Creates public frontend and internal backend traffic paths. · `infra/modules/compute/main.tf`
- **Application Gateway / WAF**: public ingress
- [Azure PostgreSQL](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/database/main.tf): Flexible Server + replica · Private production data tier. · `infra/modules/database/main.tf`
- [Key Vault](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/keyvault/main.tf): secret boundary · Stores Docker Hub credentials supplied to Terraform. · `infra/modules/keyvault/main.tf`
- [DNS](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/dns/main.tf): name resolution · `infra/modules/dns/main.tf`
- [VM provisioning](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/modules/compute/scripts/frontend_provision.sh): instance bootstrap scripts · Pulls and configures frontend and backend container images. · `infra/modules/compute/scripts/frontend_provision.sh`

### Deployment & Environments

- [Deployment script](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/deploy.sh): build, push, apply · Builds and pushes images, then applies Terraform. · `deploy.sh`
- [Dev, test, prod roots](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/environments/prod/main.tf): Terraform environments · Environment-specific infrastructure entry points. · `infra/environments/prod/main.tf`
- [Terraform remote state](https://github.com/victornwoke/cloudops-goal-tracker--three-tier-architecture/blob/main/infra/backend.tf): state backend · `infra/backend.tf`

## Connections

- Browser → Express frontend: HTTP
- Static UI → Express frontend: served by
- Express frontend → Go API: /api/goals proxy
- Go API → PostgreSQL: reads and writes goals
- Local Compose stack → Frontend image: builds
- Local Compose stack → Backend image: builds
- Local Compose stack → Database bootstrap: initializes database
- Frontend image → Express frontend: local container
- Backend image → Go API: local container
- Database bootstrap → PostgreSQL: schema
- Deployment script → Terraform composition: applies
- Deployment script → Frontend image: builds and pushes
- Deployment script → Backend image: builds and pushes
- Terraform composition → Network boundary: provisions
- Terraform composition → Application compute: provisions
- Terraform composition → Azure PostgreSQL: provisions
- Terraform composition → Key Vault: provisions
- Terraform composition → DNS: provisions
- Application Gateway / WAF → Application compute: routes public traffic
- Application compute → Azure PostgreSQL: private database access
- Network boundary → Application Gateway / WAF: ingress network
- Key Vault → Application compute: image credentials
- VM provisioning → Application compute: configures VM instances
- Dev, test, prod roots → Terraform composition: selects module composition
- Terraform remote state → Terraform composition: stores state
