# vitabaks/autobase architecture

> Architecture diagram of the GitHub repository vitabaks/autobase, 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/vitabaks/autobase
- Repository: https://github.com/vitabaks/autobase

## Overview

##### Main Components Overview

The system consists of three major parts:
a) Automation Layer (Ansible-based)
b) Console/UI Layer
c) Database Cluster Layer

##### Key Architectural Components

A. Console Components:
- UI Frontend (React-based)
- Backend Service (Go)
- Console Database (PostgreSQL)
- Docker Integration

B. Database Cluster Components:
- PostgreSQL Instances (Primary/Replicas)
- Patroni (HA Controller)
- DCS (etcd/Consul)
- Load Balancers (HAProxy/Cloud LB)
- Connection Pooler (PgBouncer)
- Monitoring (Netdata)

- Client Layer                                        |

- ↓

- Console Layer                                        |

- UI       |→|  API Service   |←-|  Console DB    |  |   Docker Engine     |       |
- (React)     |  |    (Go)       |  |  (PostgreSQL)  |  |                     |       |

- ↓

- Automation Layer                                        |

- Ansible Core   |→| Playbooks      |→| Roles & Tasks     |                          |

- ↓

- Database Cluster Layer                                    |

- PostgreSQL      |←-|    Patroni     |←-|  DCS (etcd/   |  |   Load Balancer   |     |
- (Primary/Replica)|  |               |  |    Consul)    |  | (HAProxy/Cloud LB) |     |

- PgBouncer     |  |   Netdata      |  | VIP Manager   |                           |
- (Connection Pool)|  |  (Monitoring)  |  |               |                           |

##### Component Relationships

Clearly indicate:
- Primary-replica relationships
- Load balancer distribution
- DCS communication paths
- Monitoring data collection
- Console management flow

##### Additional Details

Annotations for:
- Port numbers for key services
- Failover paths
- Backup flows
- Management API endpoints
- Authentication boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Client
        Client1[Client Applications]
    end

    %% Console Layer
    subgraph Console
        UI["Console UI Frontend"]:::frontend
        API["Console Backend Service"]:::backend
        ConsoleDB[(Console Database)]:::database
        Docker["Docker Engine"]:::infra
        
        UI --> API
        API --> ConsoleDB
        API --> Docker
    end

    %% Automation Layer
    subgraph Automation
        AnsibleCore["Ansible Core"]:::automation
        Playbooks["Deployment Playbooks"]:::automation
        Roles["Roles & Tasks"]:::automation
        
        AnsibleCore --> Playbooks
        Playbooks --> Roles
    end

    %% Database Cluster Layer
    subgraph DBCluster
        PostgreSQL[(PostgreSQL Primary/Replica)]:::database
        Patroni["Patroni HA Controller"]:::ha
        DCS["DCS (etcd/Consul)"]:::ha
        LoadBalancer["Load Balancer (HAProxy)"]:::network
        PgBouncer["Connection Pooler (PgBouncer)"]:::network
        Netdata["Monitoring (Netdata)"]:::monitoring
        VIPManager["VIP Manager"]:::network
        WAL_G["Backup System (WAL-G)"]:::backup
        
        Patroni --> PostgreSQL
        Patroni --> DCS
        LoadBalancer --> PostgreSQL
        PgBouncer --> PostgreSQL
        Netdata -.-> PostgreSQL
        VIPManager --> LoadBalancer
        WAL_G -.-> PostgreSQL
    end

    %% Inter-layer connections
    Client1 --> LoadBalancer
    Client1 --> UI
    Console --> Automation
    Automation --> DBCluster

    %% Click events for component mapping
    click UI "https://github.com/vitabaks/autobase/tree/master/console/ui/"
    click API "https://github.com/vitabaks/autobase/tree/master/console/service/"
    click ConsoleDB "https://github.com/vitabaks/autobase/tree/master/console/db/"
    click AnsibleCore "https://github.com/vitabaks/autobase/tree/master/automation/"
    click Patroni "https://github.com/vitabaks/autobase/tree/master/automation/roles/patroni/"
    click LoadBalancer "https://github.com/vitabaks/autobase/tree/master/automation/roles/haproxy/"
    click DCS "https://github.com/vitabaks/autobase/tree/master/automation/roles/etcd/"
    click PgBouncer "https://github.com/vitabaks/autobase/tree/master/automation/roles/pgbouncer/"
    click Netdata "https://github.com/vitabaks/autobase/tree/master/automation/roles/netdata/"
    click VIPManager "https://github.com/vitabaks/autobase/tree/master/automation/roles/vip-manager/"
    click Playbooks "https://github.com/vitabaks/autobase/blob/master/automation/deploy_pgcluster.yml"
    click WAL_G "https://github.com/vitabaks/autobase/tree/master/automation/roles/wal-g/"

    %% Styling
    classDef frontend fill:#42A5F5,stroke:#1976D2,color:white
    classDef backend fill:#66BB6A,stroke:#388E3C,color:white
    classDef database fill:#AB47BC,stroke:#7B1FA2,color:white
    classDef infra fill:#78909C,stroke:#455A64,color:white
    classDef automation fill:#26C6DA,stroke:#0097A7,color:white
    classDef ha fill:#FFB74D,stroke:#F57C00,color:white
    classDef network fill:#FF7043,stroke:#E64A19,color:white
    classDef monitoring fill:#9CCC65,stroke:#689F38,color:white
    classDef backup fill:#7E57C2,stroke:#512DA8,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DB[(Database)]:::database
        Infra["Infrastructure"]:::infra
        Auto["Automation"]:::automation
        HA["High Availability"]:::ha
        Net["Network Component"]:::network
        Mon["Monitoring"]:::monitoring
        Backup["Backup System"]:::backup
    end
```
