# ๐ ๏ธ 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. ๐



## ๐ฏ 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
```bash
# 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
| 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 |
| 7 | ๐ Stats & Logging | Show container stats, logs, inspect |
| 8 | ๐งช Error Handling & Polish | `thiserror`, tracing, UX |
---
## โ
Feature Checklist
### ๐๏ธ Core Project Setup
- [x] Project Initialization with `cargo new`
- [x] Modular Folder Structure
- [x] Logging with `tracing`
- [x] Error handling with `thiserror`
### โ๏ธ CLI Interface (`clap`)
- [x] 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`)
- [x] 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
```bash
# 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:
```
+------------------------------------------+
+------------------------------------------+
+------------------------------------------+
| Name : mypg |
| Username : admin |
| Password : ****** |
| 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:
```json
{
"type": "postgres",
"name": "mypg",
"user": "admin",
"password": "secret",
"host": "localhost",
"port": 5432,
"db_name": "mypg",
"ssl": false
}
```
Load saved configurations:
```bash
$ dbctl create --from-file postgres-dev.json
```
---
## ๐ ๏ธ Installation
### Prerequisites
- Rust toolchain (stable)
- Docker installed and running
### From Source
```bash
# 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.