# plenituz/anyfront architecture

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

- Interactive diagram: https://gitdiagram.com/plenituz/anyfront
- Repository: https://github.com/plenituz/anyfront

## Overview

##### Main Components
- Deployment CLI/Command Interpreter: Represent how the user invokes the tool with commands such as “barbe apply anyfront/aws.hcl” from the terminal.
- Core Deployment Engine (Anyfront Pipeline):
– This includes modules in the “src” directory (e.g., src/anyfront.ts, src/anyfront-lib/) that implement the deployment logic.
– The library offers common constants, utilities, and pipeline orchestration.
- Build and Pipeline Modules:
– Separate pipelines that handle deployments tailored by framework and platform. For example:
○ AWS-specific pipelines: (aws_next_js.ts, aws_sveltekit/aws_sveltekit.ts, aws_cloudfront_static_hosting, aws_s3_sync_files.ts)
○ GCP-specific pipelines: (gcp_cloudrun_static_hosting, gcp_next_js.ts, gcp_project_setup.ts)
○ A generic static hosting module (static_hosting.ts)
- Cloud Provider Integration:
– Highlight integration with AWS (via CloudFormation or CloudFront) and GCP (via Cloud Run and related project setup).
– Include configuration files (aws.hcl, gcp.hcl, git-aws.hcl, git-gcp.hcl) that drive the deployments.
- Build System / Scripts:
– There is a “build” directory (with build.mjs and submodules) that compiles or packages final deployment artifacts.
- Examples and Documentation:
– The “examples” folder lists various sample implementations for different frameworks and platforms.
– The “docs” section provides guides and troubleshooting, making it clear how the system supports multiple environments.

##### Relationships and Interactions
- The Developer/User interacts with the system via a CLI command, which reads the appropriate HCL configuration.
- The CLI invokes the Core Deployment Engine, which in turn selects the correct pipeline from its library.
- The pipeline uses build scripts (in the “src/build” area) to compile or prepare the application based on the chosen framework.
- The deployment modules then interact with cloud provider APIs (for AWS, GCP) to create or update cloud resources (for example, uploading to S3/CloudFront or spinning up containers on Cloud Run).
- The Examples directory functions as proof-of-concept samples that help users understand how to integrate their projects with Anyfront.

##### Architectural Patterns and Technologies
- Modular design – each cloud provider and framework has its own pipeline module.
- Separation of concerns – the tool is split into configuration management (HCL files), build orchestration, and cloud provider integration.
- Use of infrastructure as code – HCL and cloud deployment scripts (CloudFormation for AWS, Dockerfiles and nginx config for GCP) emphasize declarative deployment.
- Technologies include Node.js/JavaScript (with .js, .ts, and build scripts), HCL for configuration, Docker for containerized deployments, and provider-specific APIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User/CLI Layer
    subgraph "User/CLI Layer"
        dev("Developer"):::cli
        cli("Deployment CLI"):::cli
    end
    dev --> cli

    %% Core Engine Layer
    subgraph "Core Engine Layer"
        engine("Anyfront Core Engine"):::engine
    end
    cli --> engine

    %% Pipeline Modules
    subgraph "Pipeline Modules"
        direction TB
        aws1("AWS Next.js Pipeline"):::pipeline
        aws2("AWS S3 Sync Pipeline"):::pipeline
        aws3("AWS SvelteKit Pipeline"):::pipeline
        aws4("AWS CloudFront Static Hosting Pipeline"):::pipeline
        gcp1("GCP Cloud Run Pipeline"):::pipeline
        gcp2("GCP Next.js Pipeline"):::pipeline
        gcp3("GCP Project Setup Pipeline"):::pipeline
        generic("Generic Static Hosting Module"):::pipeline
    end
    engine --> aws1
    engine --> aws2
    engine --> aws3
    engine --> aws4
    engine --> gcp1
    engine --> gcp2
    engine --> gcp3
    engine --> generic

    %% Build System / Packaging Layer
    subgraph "Build System / Packaging"
        buildscript("Build Script"):::build
        builddir("Build Modules"):::build
        frontend("Frontend Build Module"):::build
    end
    aws1 --> buildscript
    aws2 --> buildscript
    aws3 --> buildscript
    aws4 --> buildscript
    gcp1 --> buildscript
    gcp2 --> buildscript
    gcp3 --> buildscript
    generic --> buildscript

    buildscript --> builddir
    builddir --> frontend

    %% Cloud Provider Integration Layer
    subgraph "Cloud Provider Integration"
        cloudapi("Cloud Provider API"):::cloud
        aws_config("AWS Config (aws.hcl)"):::cloud
        aws_git("AWS Git Config (git-aws.hcl)"):::cloud
        gcp_config("GCP Config (gcp.hcl)"):::cloud
        gcp_git("GCP Git Config (git-gcp.hcl)"):::cloud
    end
    frontend --> cloudapi
    cloudapi --> aws_config
    cloudapi --> aws_git
    cloudapi --> gcp_config
    cloudapi --> gcp_git

    %% Examples & Documentation Layer
    subgraph "Examples & Documentation"
        docs("Documentation"):::docs
        examples("Examples"):::docs
    end
    dev --> docs
    dev --> examples

    %% Click Events
    click cli "https://github.com/plenituz/anyfront/blob/main/src/anyfront.ts"
    click engine "https://github.com/plenituz/anyfront/tree/main/src/anyfront-lib/"
    click aws1 "https://github.com/plenituz/anyfront/blob/main/src/aws_next_js.ts"
    click aws2 "https://github.com/plenituz/anyfront/blob/main/src/aws_s3_sync_files.ts"
    click aws3 "https://github.com/plenituz/anyfront/tree/main/src/aws_sveltekit/"
    click aws4 "https://github.com/plenituz/anyfront/tree/main/src/aws_cloudfront_static_hosting/"
    click gcp1 "https://github.com/plenituz/anyfront/tree/main/src/gcp_cloudrun_static_hosting/"
    click gcp2 "https://github.com/plenituz/anyfront/tree/main/src/gcp_next_js"
    click gcp3 "https://github.com/plenituz/anyfront/blob/main/src/gcp_project_setup.ts"
    click generic "https://github.com/plenituz/anyfront/blob/main/src/static_hosting.ts"
    click buildscript "https://github.com/plenituz/anyfront/blob/main/build.mjs"
    click builddir "https://github.com/plenituz/anyfront/tree/main/src/build/"
    click frontend "https://github.com/plenituz/anyfront/tree/main/src/frontend_build/"
    click aws_config "https://github.com/plenituz/anyfront/blob/main/aws.hcl"
    click aws_git "https://github.com/plenituz/anyfront/blob/main/git-aws.hcl"
    click gcp_config "https://github.com/plenituz/anyfront/blob/main/gcp.hcl"
    click gcp_git "https://github.com/plenituz/anyfront/blob/main/git-gcp.hcl"
    click docs "https://github.com/plenituz/anyfront/tree/main/docs/"
    click examples "https://github.com/plenituz/anyfront/tree/main/examples/"

    %% Styles
    classDef cli fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef engine fill:#aed6f1,stroke:#2e86c1,stroke-width:2px;
    classDef pipeline fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef build fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef cloud fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef docs fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
```
