dbctl

Crates.iodbctl
lib.rsdbctl
version0.1.0
created_at2025-07-19 06:20:05.786364+00
updated_at2025-07-19 06:20:05.786364+00
descriptionA CLI tool to manage Dockerized databases like PostgreSQL, Redis, and MariaDB
homepage
repositoryhttps://github.com/Akshay2642005/dbctl.git
max_upload_size
id1759963
size49,568
Akshay (Akshay2642005)

documentation

README

๐Ÿ› ๏ธ dbctl

A flexible, user-friendly, and type-safe CLI + TUI tool written in Rust to create, run, and manage Dockerized databases (PostgreSQL, Redis, MariaDB, and more).

Built with love for learners and power users alike. ๐Ÿ’–

License Rust Docker

๐ŸŽฏ Overview

dbctl simplifies database development and testing by providing:

  • Fast creation of Docker containers for popular databases

  • Easy management via both CLI and interactive TUI modes

  • Type-safe input collection and validation

  • Powerful insights with stats, logs, and connection details

  • Configuration persistence with JSON-based profiles

Supported Databases

  • ๐Ÿ˜ PostgreSQL - Full-featured, robust relational database

  • ๐Ÿ”„ Redis - In-memory data structure store

  • ๐Ÿฌ MariaDB - Community-developed fork of MySQL

  • โž• Extensible architecture for adding more database types


๐Ÿš€ Quick Start

# Install from crates.io
cargo install dbctl

# Create a PostgreSQL database
dbctl create postgres --name mypg --user admin --password secret --port 5432

# Launch the interactive TUI wizard

dbctl wizard

๐Ÿ“… Development Roadmap

Week Focus Goals
1 โœ… Setup + CLI/TUI Basics Rust, project layout, clap, ratatui
2 ๐Ÿ›ข๏ธ PostgreSQL support Database trait, default configs
3 ๐Ÿณ Docker integration Launch & manage containers
4 โš™๏ธ CLI Command: Create Launch Postgres via CLI
5 ๐ŸŽจ TUI Wizard Select DB & enter info visually

| 6 | ๐Ÿงฉ Add Redis, MariaDB | Implement additional backends |

| 7 | ๐Ÿ“Š Stats & Logging | Show container stats, logs, inspect | | 8 | ๐Ÿงช Error Handling & Polish | thiserror, tracing, UX |


โœ… Feature Checklist

๐Ÿ—๏ธ Core Project Setup

  • Project Initialization with cargo new
  • Modular Folder Structure
  • Logging with tracing
  • Error handling with thiserror

โš™๏ธ CLI Interface (clap)

  • Create database (PostgreSQL)
  • Create database (Redis)
  • Create database (MariaDB)
  • Inspect running containers
  • Show container logs
  • Delete database containers

๐ŸŽจ TUI Wizard (ratatui)

  • Select database type
  • Input config values with validation
  • Preview config before launching
  • Display creation results and info
  • Add theme/colors and improved UX

๐Ÿณ Docker API (bollard)

  • Start Postgres container

  • Start Redis container

  • Start MariaDB container

  • View stats/logs of container

  • Return container ID + connection URL

  • Stop and remove containers

๐Ÿ“„ JSON Config Support

  • Load config from file

  • Save config to file

  • Update config (edit mode)


๐Ÿ“‚ Project Architecture

dbctl/
โ”œโ”€โ”€ Cargo.toml
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs             # Entry point
โ”‚   โ”œโ”€โ”€ cli/                # CLI command handling
โ”‚   โ”‚   โ””โ”€โ”€ mod.rs
โ”‚   โ”œโ”€โ”€ tui/                # Terminal UI components
โ”‚   โ”‚   โ””โ”€โ”€ mod.rs
โ”‚   โ”œโ”€โ”€ db/                 # Database implementations
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”‚   โ”œโ”€โ”€ postgres.rs
โ”‚   โ”‚   โ”œโ”€โ”€ redis.rs
โ”‚   โ”‚   โ””โ”€โ”€ mariadb.rs
โ”‚   โ”œโ”€โ”€ docker/             # Docker interaction

โ”‚   โ”‚   โ””โ”€โ”€ engine.rs

โ”‚   โ”œโ”€โ”€ config/             # Configuration handling
โ”‚   โ”‚   โ””โ”€โ”€ models.rs
โ”‚   โ”œโ”€โ”€ output.rs           # Output formatting
โ”‚   โ”œโ”€โ”€ utils.rs            # Utility functions
โ”‚   โ””โ”€โ”€ error.rs            # Error types


๐Ÿ’ป Usage Examples

Command-Line Interface


# Create a PostgreSQL database
$ dbctl create postgres \
  --name mypg \
  --user admin \

  --password secret \

  --port 5432


โœ… Database 'mypg' started in Docker
๐Ÿ”— URL: postgres://admin:secret@localhost:5432/mypg
๐Ÿ†” Container ID: 17afc8c9d16


# List running database containers
$ dbctl list

# View container logs
$ dbctl logs mypg


# Stop and remove a container
$ dbctl remove mypg

Terminal User Interface

The TUI provides an interactive wizard for configuring and launching databases:

+------------------------------------------+
|    Select a Database to Launch           |
|  > PostgreSQL                            |

|    Redis                                 |
|    MariaDB                               |
+------------------------------------------+

+------------------------------------------+
|  ๐Ÿงพ PostgreSQL Setup                     |

|  Name      : mypg                        |
|  Username  : admin                       |
|  Password  : ******                      |

|  Host      : localhost                   |
|  Port      : 5432                        |
|  SSL?      : [ No ]                      |
+------------------------------------------+
|        [ Create Database ]               |

+------------------------------------------+

โœ… Success! Container Started

๐Ÿ”— URL: postgres://admin:secret@localhost:5432/mypg
๐Ÿ†” Container ID: 17afc8c9d16


๐Ÿ”ง Database Configuration

Configurations can be saved as JSON profiles for reuse:

{
  "type": "postgres",

  "name": "mypg",

  "user": "admin",
  "password": "secret",
  "host": "localhost",

  "port": 5432,
  "db_name": "mypg",
  "ssl": false
}

Load saved configurations:


$ dbctl create --from-file postgres-dev.json


๐Ÿ› ๏ธ Installation

Prerequisites

  • Rust toolchain (stable)

  • Docker installed and running

From Source


# Clone the repository
git clone https://github.com/yourusername/dbctl.git
cd dbctl


# Build and install
cargo install --path .

๐Ÿ“š Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 0

cargo fmt