| Crates.io | dpbook |
| lib.rs | dpbook |
| version | 0.1.7 |
| created_at | 2025-09-19 10:58:28.117298+00 |
| updated_at | 2025-09-19 13:16:10.620623+00 |
| description | CLI based phonebook application |
| homepage | |
| repository | https://github.com/Darshan25503/dpbook.git |
| max_upload_size | |
| id | 1846278 |
| size | 114,554 |
A Rust-based command-line phonebook application built with clean architecture principles and SOLID design patterns.
This application follows Clean Architecture principles with clear separation of concerns:
src/
├── domain/ # Business logic and entities
│ ├── entities/ # Core business entities (Contact)
│ ├── value_objects/# Value objects (PhoneNumber, Email, ContactId)
│ ├── repositories/ # Repository interfaces (abstractions)
│ └── errors.rs # Domain-specific errors
├── application/ # Use cases and business rules
│ ├── use_cases/ # Individual use cases (Add, Find, Update, etc.)
│ ├── services/ # Application services
│ └── validation.rs # Input validation utilities
├── infrastructure/ # External concerns (file storage, etc.)
│ ├── repositories/ # Repository implementations
│ └── persistence/ # File storage implementation
└── presentation/ # User interface (CLI)
└── cli/ # Command-line interface
Download the latest release for your platform from the releases page.
cargo install dpbook
# Pull and run the Docker image
docker pull darshan25503/dpbook:latest
# Run with persistent data
docker run -v $(pwd)/data:/app/data darshan25503/dpbook:latest list
# Clone the repository
git clone https://github.com/Darshan25503/dpbook.git
cd dpbook
# Build the application
cargo build --release
# The binary will be available at target/release/dpbook
# Add a new contact
dpbook add --first-name "John" --last-name "Doe" --phone "555-123-4567" --email "john@example.com"
# List all contacts
dpbook list
# Search for contacts
dpbook search "john"
# Find a specific contact by ID
dpbook find <contact-id>
# Update a contact
dpbook update <contact-id> --first-name "Jane" --add-phone "555-987-6543"
# Delete a contact
dpbook delete <contact-id>
# Show statistics
dpbook stats
# List with pagination and sorting
dpbook list --page 0 --page-size 5 --sort-by last-name --reverse
# Add contact with multiple phone numbers and emails
dpbook add \
--first-name "Alice" \
--last-name "Smith" \
--phone "555-111-2222" \
--phone "555-333-4444" \
--email "alice@work.com" \
--email "alice@personal.com"
# Update contact by adding and removing information
dpbook update <contact-id> \
--add-phone "555-999-8888" \
--remove-email "old@email.com" \
--notes "Updated contact information"
# Use custom data file
dpbook --file /path/to/contacts.json list
Contacts are stored in a JSON file (default: contacts.json in the current directory). The file is created automatically when you add your first contact.
{
"contacts": {
"contact-uuid": {
"id": "contact-uuid",
"first_name": "John",
"last_name": "Doe",
"phone_numbers": [
{
"value": "5551234567"
}
],
"emails": [
{
"value": "john@example.com"
}
],
"notes": null,
"tags": [],
"metadata": {}
}
}
}
# Check code formatting
cargo fmt --check
# Run clippy for linting
cargo clippy
# Check for security vulnerabilities
cargo audit
The codebase follows clean architecture with these layers:
The application uses comprehensive error handling with custom error types for each layer:
git checkout -b feature/amazing-feature)cargo fmt && cargo clippy)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.