# astronomer/astronomer-cosmos architecture

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

- Interactive diagram: https://gitdiagram.com/astronomer/astronomer-cosmos
- Repository: https://github.com/astronomer/astronomer-cosmos

## Overview

##### Main Components

a) Core Integration Layer
- Core/graph and core/airflow components
- How it bridges Airflow and dbt

b) Execution Components
- Multiple operator types (shown in cosmos/operators/):
- Local
- Docker
- Kubernetes
- AWS EKS
- Azure Container Instance
- GCP Cloud Run Job
- VirtualEnv

c) Database Connection Layer
- Profile handlers for various databases:
- Snowflake
- BigQuery
- Postgres
- Redshift
- Databricks
- And others from the profiles/ directory

d) dbt Integration Components
- Project parser
- Graph handler
- Executable manager
- Selector system

e) Airflow Integration Points
- DAG generation
- Task Group handling
- Graph transformation
- Listeners and hooks

##### Relationship Flows

- User Input → Project Configuration
- Project Configuration → dbt Parser
- dbt Parser → Graph Generator
- Graph Generator → Airflow DAG Constructor
- Profile Configuration → Database Connections
- Operator Selection → Execution Environment

##### Component Grouping

- Execution Layer (containing all operators)
- Database Connection Layer (containing all profiles)
- Core Processing Layer (containing parser and graph components)
- Airflow Integration Layer (containing DAG and task group handlers)

##### Technical Details

Annotations for:
- Supported Python versions
- Key dependencies
- Configuration options
- Execution modes

##### Implementation Notes

- Maintain consistent spacing and alignment
- Version information
- Notes about scalability and deployment options

This architecture should be represented in a way that shows both the simplicity of use for end-users and the sophisticated internal architecture that makes it possible.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Integration Layer
    subgraph Core
        CoreAirflow["Core Airflow"]:::core
        CoreGraph["Core Graph"]:::core
        DbtParser["dbt Parser"]:::core
        GraphGen["Graph Generator"]:::core
    end

    %% Execution Layer
    subgraph Execution
        Local["Local Operator"]:::operator
        Docker["Docker Operator"]:::operator
        K8s["Kubernetes Operator"]:::operator
        EKS["AWS EKS Operator"]:::operator
        ACI["Azure Container Instance"]:::operator
        GCP["GCP Cloud Run Job"]:::operator
        VEnv["VirtualEnv Operator"]:::operator
    end

    %% Database Connection Layer
    subgraph Databases
        Snowflake["Snowflake"]:::db
        BigQuery["BigQuery"]:::db
        Postgres["Postgres"]:::db
        Redshift["Redshift"]:::db
        Databricks["Databricks"]:::db
    end

    %% Airflow Integration Layer
    subgraph AirflowInt
        DAGGen["DAG Generator"]:::airflow
        TaskGroup["Task Group Handler"]:::airflow
        Listeners["DAG Run Listeners"]:::airflow
        Hooks["Subprocess Hooks"]:::airflow
    end

    %% Supporting Components
    subgraph Support
        Cache["Caching System"]:::support
        Telemetry["Telemetry System"]:::support
        DocGen["Documentation Generator"]:::support
    end

    %% Relationships
    DbtParser --> GraphGen
    GraphGen --> CoreGraph
    CoreGraph --> CoreAirflow
    CoreAirflow --> DAGGen
    DAGGen --> TaskGroup
    TaskGroup --> Listeners
    Listeners --> Hooks

    CoreAirflow --> Execution
    Execution --> Databases

    Cache --> CoreAirflow
    Telemetry --> CoreAirflow
    DocGen --> DAGGen

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef operator fill:#e67e22,stroke:#d35400,color:white
    classDef db fill:#27ae60,stroke:#219a52,color:white
    classDef airflow fill:#9b59b6,stroke:#8e44ad,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Click Events
    click CoreAirflow "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/core/airflow.py"
    click CoreGraph "https://github.com/astronomer/astronomer-cosmos/tree/main/cosmos/core/graph/"
    click DAGGen "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/airflow/dag.py"
    click TaskGroup "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/airflow/task_group.py"
    click Local "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/local.py"
    click Docker "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/docker.py"
    click K8s "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/kubernetes.py"
    click EKS "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/aws_eks.py"
    click ACI "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/azure_container_instance.py"
    click GCP "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/gcp_cloud_run_job.py"
    click VEnv "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/virtualenv.py"
    click Snowflake "https://github.com/astronomer/astronomer-cosmos/tree/main/cosmos/profiles/snowflake/"
    click BigQuery "https://github.com/astronomer/astronomer-cosmos/tree/main/cosmos/profiles/bigquery/"
    click Postgres "https://github.com/astronomer/astronomer-cosmos/tree/main/cosmos/profiles/postgres/"
    click Redshift "https://github.com/astronomer/astronomer-cosmos/tree/main/cosmos/profiles/redshift/"
    click Databricks "https://github.com/astronomer/astronomer-cosmos/tree/main/cosmos/profiles/databricks/"
    click DbtParser "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/dbt/parser/project.py"
    click GraphGen "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/dbt/graph.py"
    click Listeners "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/listeners/dag_run_listener.py"
    click Hooks "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/hooks/subprocess.py"
    click Cache "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/cache.py"
    click Telemetry "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/telemetry.py"
    click DocGen "https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/plugin/templates/dbt_docs.html"
```
