# aziontech/azion architecture

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

- Interactive diagram: https://gitdiagram.com/aziontech/azion
- Repository: https://github.com/aziontech/azion

## Overview

##### Project type and purpose
- This is a Go-based command-line interface (CLI) named “azion” for creating and managing applications on the Azion Edge Platform.
- It uses Cobra (in cmd/azion) to expose dozens of subcommands (create, delete, deploy, describe, etc.) and bundles API clients to interact with Azion’s REST/GraphQL endpoints.
- The CLI also supports config management, manifest generation, metrics, logging, testing, packaging (Docker, Chocolatey, Homebrew, DEB/RPM/APK via goreleaser), and CI/CD via GitHub Actions.

##### File structure
- Top level:
- cmd/azion – root command
- cmd/gen_docs – docs generator
- pkg/ – core libraries
- pkg/api – service-specific API clients and models
- pkg/cmd – implementations of each subcommand’s business logic
- pkg/config, pkg/token, pkg/manifest, pkg/logger, pkg/metric – cross-cutting concerns
- chocolatey/, Dockerfile, goreleaser.yaml – packaging
- .github/workflows – CI/CD pipelines
- env/ – environment-specific configs (local, stage, prod)
- Pattern: a layered/hexagonal architecture where the CLI invoker sits at the outer layer, invokes command handlers in pkg/cmd, which in turn call adapters in pkg/api, feeding into external Azion services.

##### README for additional insights
- Emphasizes user flows: authentication (token, login), command reference, autocomplete, build and cross-build, packaging options.
- Mentions the update policy for Go, hinting at stable release-based dependency management.

##### Final advice
- Cross-cutting modules (config, token, logger) once and show their injection to every handler.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Layers and Components

  %% User
  User["User"]:::external

  %% CLI Layer
  subgraph "CLI Layer"
    direction TB
    CLI["CLI Frontend"]:::internal
    DocsGen["Documentation Generator CLI"]:::internal
  end

  %% Command Handlers
  subgraph "Command Handlers"
    direction TB
    Handlers["pkg/cmd (Subcommands)"]:::internal
  end

  %% Core Services
  subgraph "Core Services"
    direction TB
    ConfigSvc["Configuration Service"]:::internal
    TokenSvc["Token Service"]:::internal
    ManifestBld["Manifest Builder"]:::internal
    LoggerSvc["Logger Service"]:::internal
    MetricsSvc["Metrics Service"]:::internal
    SchedulerSvc["Scheduler Service"]:::internal
    Factory["Core Utilities/Factories"]:::internal
  end

  %% API Layer
  subgraph "API Layer"
    direction TB
    API["pkg/api (REST/GraphQL Clients & Models)"]:::internal
  end

  %% Output Renderer
  subgraph "Output Renderer"
    direction TB
    Output["pkg/output"]:::internal
    Printer["Printer Formatter"]:::internal
  end

  %% External Systems
  subgraph "External Systems"
    direction TB
    AzionAPI["Azion Edge Platform APIs"]:::external
    S3["S3 Edge Storage"]:::external
    CIExternal["GitHub Actions"]:::external
    PackageRepo["Package Repositories"]:::external
  end

  %% Packaging/CI Pipeline
  subgraph "Packaging & CI/CD Pipeline"
    direction TB
    Workflows["CI/CD Workflows"]:::pipeline
    DockerPkg["Docker Image Packaging"]:::pipeline
    GoReleaser["GoReleaser Configuration"]:::pipeline
    Choco["Chocolatey Package Definition"]:::pipeline
    EnvConfigs["Environment Configurations"]:::pipeline
  end

  %% Data Flows
  User -->|"inputs/flags"| CLI
  CLI -->|"invoke handlers"| Handlers
  CLI -->|"generate docs"| DocsGen

  Handlers -->|"use services"| ConfigSvc
  Handlers -->|"use services"| TokenSvc
  Handlers -->|"use services"| ManifestBld
  Handlers -->|"use services"| LoggerSvc
  Handlers -->|"use services"| MetricsSvc
  Handlers -->|"use services"| SchedulerSvc
  Handlers -->|"inject via factory"| Factory

  Handlers -->|"call API"| API
  ConfigSvc -->|"provide config"| API
  TokenSvc -->|"provide token"| API

  API -->|HTTPS/GraphQL| AzionAPI
  AzionAPI -->|response| API
  API -->|store/retrieve| S3
  API -->|"return data"| Handlers

  Handlers -->|"format output"| Output
  Output -->|"use formatter"| Printer
  Printer -->|"render to"| User

  %% Packaging Pipeline Flows
  CIExternal -->|"trigger pipelines"| Workflows
  Workflows -->|"build docker"| DockerPkg
  Workflows -->|"run goreleaser"| GoReleaser
  Workflows -->|"create chocolatey"| Choco
  Workflows -->|"use env configs"| EnvConfigs
  DockerPkg -->|publish| PackageRepo
  GoReleaser -->|publish| PackageRepo
  Choco -->|publish| PackageRepo

  %% Click Events
  click CLI "https://github.com/aziontech/azion/blob/dev/cmd/azion/main.go"
  click DocsGen "https://github.com/aziontech/azion/blob/dev/cmd/gen_docs/main.go"
  click Handlers "https://github.com/aziontech/azion/tree/dev/pkg/cmd"
  click API "https://github.com/aziontech/azion/tree/dev/pkg/api"
  click ConfigSvc "https://github.com/aziontech/azion/blob/dev/pkg/config/config.go"
  click TokenSvc "https://github.com/aziontech/azion/blob/dev/pkg/token/token.go"
  click ManifestBld "https://github.com/aziontech/azion/blob/dev/pkg/manifest/manifest.go"
  click LoggerSvc "https://github.com/aziontech/azion/blob/dev/pkg/logger/logger.go"
  click MetricsSvc "https://github.com/aziontech/azion/blob/dev/pkg/metric/count.go"
  click SchedulerSvc "https://github.com/aziontech/azion/blob/dev/pkg/schedule/schedule.go"
  click Factory "https://github.com/aziontech/azion/blob/dev/pkg/cmdutil/factory.go"
  click Output "https://github.com/aziontech/azion/tree/dev/pkg/output"
  click Printer "https://github.com/aziontech/azion/blob/dev/pkg/printer/printer.go"
  click Workflows "https://github.com/aziontech/azion/tree/dev/.github/workflows"
  click DockerPkg "https://github.com/aziontech/azion/tree/dev/Dockerfile"
  click GoReleaser "https://github.com/aziontech/azion/blob/dev/.goreleaser.yaml"
  click Choco "https://github.com/aziontech/azion/blob/dev/chocolatey/azion.nuspec"
  click EnvConfigs "https://github.com/aziontech/azion/tree/dev/env"

  %% Styles
  classDef internal fill:#ccffcc,stroke:#008000
  classDef external fill:#ccccff,stroke:#0000ff
  classDef pipeline fill:#ffebcc,stroke:#ff6600
```
