# torodebout/dbvault architecture

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

- Interactive diagram: https://gitdiagram.com/torodebout/dbvault
- Repository: https://github.com/torodebout/dbvault

## Overview

##### Project type and purpose
- This is a command-line database backup and restore tool (“dbVault”) targeting PostgreSQL and MongoDB, with pluggable storage backends (local filesystem and AWS S3) and gzip compression.

##### File structure
- Top-level folders and files:
- config/ holds sample env and YAML config
- scripts/ automates install, setup, cleans, test runs
- src/ contains all runtime code, organized into sub-packages:
– main.py: CLI entrypoint
– config/: ConfigManager
– backup/: BackupManager
– restore/: RestoreManager
– database/: DB adapter base, factory, Postgres and Mongo implementations
– storage/: Storage adapter base, factory, local and S3 implementations
– utils/: compression, logging, validation helpers
- Tests and pytest.ini define unit/integration test suite.
- setup.py and requirements*.txt handle packaging and dependencies.

##### README for additional insights
- Describes supported databases, storage options, gzip compression, typical commands (test, backup, list-backups, restore).

- Clear labels: name each module/class or layer
- Blue rectangles for core components (Managers, Factories)
- Yellow circles for utilities (compression, logging)

##### Detail
- Two main workflows (backup vs. restore) side by side or top/bottom
- Config ingestion, factory branching, and the compression step

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        CLI["CLI Interface"]:::core
    end

    subgraph "Configuration Files"
        Env[".env example"]:::doc
        YAML["config.yaml"]:::doc
    end

    subgraph "Application Layer"
        Config["ConfigManager"]:::config
        Dispatcher["Command Dispatcher"]:::core
        BM["BackupManager"]:::core
        RM["RestoreManager"]:::core
    end

    subgraph "Infrastructure Layer"
        subgraph "Database Adapters"
            DBFactory["Database Adapter Factory"]:::core
            DBBase["Database Adapter Base"]:::core
            PGAdapter["PostgreSQL Adapter"]:::core
            MongoAdapter["MongoDB Adapter"]:::core
        end
        subgraph "Storage Adapters"
            StorageFactory["Storage Adapter Factory"]:::core
            LocalStorage["LocalStorage Adapter"]:::core
            S3Storage["S3Storage Adapter"]:::core
        end
    end

    subgraph "Utils"
        Compress["Compression Utility"]:::utils
        Logging["Logging Utility"]:::utils
        Validate["Validation Utility"]:::utils
    end

    subgraph "External Services"
        Postgres["PostgreSQL DB"]:::db
        MongoDB["MongoDB"]:::db
        LocalFS["Local Filesystem"]:::db
        S3Bucket["AWS S3 Bucket"]:::db
    end

    CLI -->|reads| Config
    CLI -->|dispatch command| Dispatcher
    Config -.->|loads env/yaml| Env
    Config -.->|loads env/yaml| YAML
    Dispatcher -->|backup command| BM
    Dispatcher -->|restore command| RM

    BM -->|selects| DBFactory
    DBFactory --> DBBase
    DBFactory --> PGAdapter
    DBFactory --> MongoAdapter
    BM -->|dumps data| PGAdapter
    BM -->|dumps data| MongoAdapter
    BM --> Compress
    Compress -->|compressed stream| StorageFactory
    StorageFactory --> LocalStorage
    StorageFactory --> S3Storage
    LocalStorage -->|write backup| LocalFS
    S3Storage -->|write backup| S3Bucket

    RM -->|selects| StorageFactory
    StorageFactory --> LocalStorage
    StorageFactory --> S3Storage
    LocalStorage -->|read backup| LocalFS
    S3Storage -->|read backup| S3Bucket
    RM --> Compress
    Compress -->|decompressed stream| DBFactory
    DBFactory --> PGAdapter
    DBFactory --> MongoAdapter
    PGAdapter -->|restore| Postgres
    MongoAdapter -->|restore| MongoDB

    click CLI "https://github.com/torodebout/dbvault/blob/main/src/main.py"
    click Config "https://github.com/torodebout/dbvault/blob/main/src/config/config_manager.py"
    click BM "https://github.com/torodebout/dbvault/blob/main/src/backup/backup_manager.py"
    click RM "https://github.com/torodebout/dbvault/blob/main/src/restore/restore_manager.py"
    click DBBase "https://github.com/torodebout/dbvault/blob/main/src/database/base.py"
    click DBFactory "https://github.com/torodebout/dbvault/blob/main/src/database/factory.py"
    click PGAdapter "https://github.com/torodebout/dbvault/blob/main/src/database/postgresql.py"
    click MongoAdapter "https://github.com/torodebout/dbvault/blob/main/src/database/mongodb.py"
    click StorageFactory "https://github.com/torodebout/dbvault/blob/main/src/storage/factory.py"
    click LocalStorage "https://github.com/torodebout/dbvault/blob/main/src/storage/local.py"
    click S3Storage "https://github.com/torodebout/dbvault/blob/main/src/storage/aws_s3.py"
    click Compress "https://github.com/torodebout/dbvault/blob/main/src/utils/compression.py"
    click Logging "https://github.com/torodebout/dbvault/blob/main/src/utils/logging.py"
    click Validate "https://github.com/torodebout/dbvault/blob/main/src/utils/validators.py"
    click Env "https://github.com/torodebout/dbvault/blob/main/config/.env.example"
    click YAML "https://github.com/torodebout/dbvault/blob/main/config/config.yaml"

    classDef core fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef utils fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef db fill:#90EE90,stroke:#333,stroke-width:1px
    classDef doc fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef config fill:#FFD700,stroke:#333,stroke-width:1px
```
